babylon.gui.js 720 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-gui", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-gui"] = factory(require("babylonjs"));
  8. else
  9. root["BABYLON"] = root["BABYLON"] || {}, root["BABYLON"]["GUI"] = factory(root["BABYLON"]);
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__) {
  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. !*** C:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __spreadArrays, __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__, "__spreadArrays", function() { return __spreadArrays; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  126. /*! *****************************************************************************
  127. Copyright (c) Microsoft Corporation. All rights reserved.
  128. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  129. this file except in compliance with the License. You may obtain a copy of the
  130. License at http://www.apache.org/licenses/LICENSE-2.0
  131. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  132. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  133. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  134. MERCHANTABLITY OR NON-INFRINGEMENT.
  135. See the Apache Version 2.0 License for specific language governing permissions
  136. and limitations under the License.
  137. ***************************************************************************** */
  138. /* global Reflect, Promise */
  139. var extendStatics = function(d, b) {
  140. extendStatics = Object.setPrototypeOf ||
  141. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  142. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  143. return extendStatics(d, b);
  144. };
  145. function __extends(d, b) {
  146. extendStatics(d, b);
  147. function __() { this.constructor = d; }
  148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  149. }
  150. var __assign = function() {
  151. __assign = Object.assign || function __assign(t) {
  152. for (var s, i = 1, n = arguments.length; i < n; i++) {
  153. s = arguments[i];
  154. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  155. }
  156. return t;
  157. }
  158. return __assign.apply(this, arguments);
  159. }
  160. function __rest(s, e) {
  161. var t = {};
  162. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  163. t[p] = s[p];
  164. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  165. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  166. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  167. t[p[i]] = s[p[i]];
  168. }
  169. return t;
  170. }
  171. function __decorate(decorators, target, key, desc) {
  172. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  173. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  174. 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;
  175. return c > 3 && r && Object.defineProperty(target, key, r), r;
  176. }
  177. function __param(paramIndex, decorator) {
  178. return function (target, key) { decorator(target, key, paramIndex); }
  179. }
  180. function __metadata(metadataKey, metadataValue) {
  181. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  182. }
  183. function __awaiter(thisArg, _arguments, P, generator) {
  184. return new (P || (P = Promise))(function (resolve, reject) {
  185. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  186. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  187. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  188. step((generator = generator.apply(thisArg, _arguments || [])).next());
  189. });
  190. }
  191. function __generator(thisArg, body) {
  192. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  193. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  194. function verb(n) { return function (v) { return step([n, v]); }; }
  195. function step(op) {
  196. if (f) throw new TypeError("Generator is already executing.");
  197. while (_) try {
  198. 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;
  199. if (y = 0, t) op = [op[0] & 2, t.value];
  200. switch (op[0]) {
  201. case 0: case 1: t = op; break;
  202. case 4: _.label++; return { value: op[1], done: false };
  203. case 5: _.label++; y = op[1]; op = [0]; continue;
  204. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  205. default:
  206. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  207. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  208. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  209. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  210. if (t[2]) _.ops.pop();
  211. _.trys.pop(); continue;
  212. }
  213. op = body.call(thisArg, _);
  214. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  215. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  216. }
  217. }
  218. function __exportStar(m, exports) {
  219. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  220. }
  221. function __values(o) {
  222. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  223. if (m) return m.call(o);
  224. return {
  225. next: function () {
  226. if (o && i >= o.length) o = void 0;
  227. return { value: o && o[i++], done: !o };
  228. }
  229. };
  230. }
  231. function __read(o, n) {
  232. var m = typeof Symbol === "function" && o[Symbol.iterator];
  233. if (!m) return o;
  234. var i = m.call(o), r, ar = [], e;
  235. try {
  236. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  237. }
  238. catch (error) { e = { error: error }; }
  239. finally {
  240. try {
  241. if (r && !r.done && (m = i["return"])) m.call(i);
  242. }
  243. finally { if (e) throw e.error; }
  244. }
  245. return ar;
  246. }
  247. function __spread() {
  248. for (var ar = [], i = 0; i < arguments.length; i++)
  249. ar = ar.concat(__read(arguments[i]));
  250. return ar;
  251. }
  252. function __spreadArrays() {
  253. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  254. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  255. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  256. r[k] = a[j];
  257. return r;
  258. };
  259. function __await(v) {
  260. return this instanceof __await ? (this.v = v, this) : new __await(v);
  261. }
  262. function __asyncGenerator(thisArg, _arguments, generator) {
  263. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  264. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  265. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  266. 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); }); }; }
  267. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  268. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  269. function fulfill(value) { resume("next", value); }
  270. function reject(value) { resume("throw", value); }
  271. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  272. }
  273. function __asyncDelegator(o) {
  274. var i, p;
  275. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  276. 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; }
  277. }
  278. function __asyncValues(o) {
  279. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  280. var m = o[Symbol.asyncIterator], i;
  281. 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);
  282. 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); }); }; }
  283. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  284. }
  285. function __makeTemplateObject(cooked, raw) {
  286. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  287. return cooked;
  288. };
  289. function __importStar(mod) {
  290. if (mod && mod.__esModule) return mod;
  291. var result = {};
  292. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  293. result.default = mod;
  294. return result;
  295. }
  296. function __importDefault(mod) {
  297. return (mod && mod.__esModule) ? mod : { default: mod };
  298. }
  299. /***/ }),
  300. /***/ "../../node_modules/webpack/buildin/global.js":
  301. /*!***********************************!*\
  302. !*** (webpack)/buildin/global.js ***!
  303. \***********************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports) {
  306. var g;
  307. // This works in non-strict mode
  308. g = (function() {
  309. return this;
  310. })();
  311. try {
  312. // This works if eval is allowed (see CSP)
  313. g = g || new Function("return this")();
  314. } catch (e) {
  315. // This works if the window reference is available
  316. if (typeof window === "object") g = window;
  317. }
  318. // g can still be undefined, but nothing to do about it...
  319. // We return undefined, instead of nothing here, so it's
  320. // easier to handle this case. if(!global) { ...}
  321. module.exports = g;
  322. /***/ }),
  323. /***/ "./2D/adtInstrumentation.ts":
  324. /*!**********************************!*\
  325. !*** ./2D/adtInstrumentation.ts ***!
  326. \**********************************/
  327. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  329. "use strict";
  330. __webpack_require__.r(__webpack_exports__);
  331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  332. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Misc/perfCounter");
  333. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  334. /**
  335. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  336. */
  337. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  338. /**
  339. * Instantiates a new advanced dynamic texture instrumentation.
  340. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  341. * @param texture Defines the AdvancedDynamicTexture to instrument
  342. */
  343. function AdvancedDynamicTextureInstrumentation(
  344. /**
  345. * Define the instrumented AdvancedDynamicTexture.
  346. */
  347. texture) {
  348. this.texture = texture;
  349. this._captureRenderTime = false;
  350. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  351. this._captureLayoutTime = false;
  352. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  353. // Observers
  354. this._onBeginRenderObserver = null;
  355. this._onEndRenderObserver = null;
  356. this._onBeginLayoutObserver = null;
  357. this._onEndLayoutObserver = null;
  358. }
  359. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  360. // Properties
  361. /**
  362. * Gets the perf counter used to capture render time
  363. */
  364. get: function () {
  365. return this._renderTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  371. /**
  372. * Gets the perf counter used to capture layout time
  373. */
  374. get: function () {
  375. return this._layoutTime;
  376. },
  377. enumerable: true,
  378. configurable: true
  379. });
  380. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  381. /**
  382. * Enable or disable the render time capture
  383. */
  384. get: function () {
  385. return this._captureRenderTime;
  386. },
  387. set: function (value) {
  388. var _this = this;
  389. if (value === this._captureRenderTime) {
  390. return;
  391. }
  392. this._captureRenderTime = value;
  393. if (value) {
  394. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  395. _this._renderTime.beginMonitoring();
  396. });
  397. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  398. _this._renderTime.endMonitoring(true);
  399. });
  400. }
  401. else {
  402. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  403. this._onBeginRenderObserver = null;
  404. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  405. this._onEndRenderObserver = null;
  406. }
  407. },
  408. enumerable: true,
  409. configurable: true
  410. });
  411. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  412. /**
  413. * Enable or disable the layout time capture
  414. */
  415. get: function () {
  416. return this._captureLayoutTime;
  417. },
  418. set: function (value) {
  419. var _this = this;
  420. if (value === this._captureLayoutTime) {
  421. return;
  422. }
  423. this._captureLayoutTime = value;
  424. if (value) {
  425. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  426. _this._layoutTime.beginMonitoring();
  427. });
  428. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  429. _this._layoutTime.endMonitoring(true);
  430. });
  431. }
  432. else {
  433. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  434. this._onBeginLayoutObserver = null;
  435. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  436. this._onEndLayoutObserver = null;
  437. }
  438. },
  439. enumerable: true,
  440. configurable: true
  441. });
  442. /**
  443. * Dispose and release associated resources.
  444. */
  445. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  446. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  447. this._onBeginRenderObserver = null;
  448. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  449. this._onEndRenderObserver = null;
  450. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  451. this._onBeginLayoutObserver = null;
  452. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  453. this._onEndLayoutObserver = null;
  454. this.texture = null;
  455. };
  456. return AdvancedDynamicTextureInstrumentation;
  457. }());
  458. /***/ }),
  459. /***/ "./2D/advancedDynamicTexture.ts":
  460. /*!**************************************!*\
  461. !*** ./2D/advancedDynamicTexture.ts ***!
  462. \**************************************/
  463. /*! exports provided: AdvancedDynamicTexture */
  464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  465. "use strict";
  466. __webpack_require__.r(__webpack_exports__);
  467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  469. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  470. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  471. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  472. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  473. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  474. /**
  475. * Class used to create texture to support 2D GUI elements
  476. * @see http://doc.babylonjs.com/how_to/gui
  477. */
  478. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  479. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AdvancedDynamicTexture, _super);
  480. /**
  481. * Creates a new AdvancedDynamicTexture
  482. * @param name defines the name of the texture
  483. * @param width defines the width of the texture
  484. * @param height defines the height of the texture
  485. * @param scene defines the hosting scene
  486. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  487. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  488. */
  489. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  490. if (width === void 0) { width = 0; }
  491. if (height === void 0) { height = 0; }
  492. if (generateMipMaps === void 0) { generateMipMaps = false; }
  493. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  494. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA) || this;
  495. _this._isDirty = false;
  496. /** @hidden */
  497. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  498. /** @hidden */
  499. _this._lastControlOver = {};
  500. /** @hidden */
  501. _this._lastControlDown = {};
  502. /** @hidden */
  503. _this._capturingControl = {};
  504. /** @hidden */
  505. _this._linkedControls = new Array();
  506. _this._isFullscreen = false;
  507. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  508. _this._idealWidth = 0;
  509. _this._idealHeight = 0;
  510. _this._useSmallestIdeal = false;
  511. _this._renderAtIdealSize = false;
  512. _this._blockNextFocusCheck = false;
  513. _this._renderScale = 1;
  514. _this._cursorChanged = false;
  515. /**
  516. * Define type to string to ensure compatibility across browsers
  517. * Safari doesn't support DataTransfer constructor
  518. */
  519. _this._clipboardData = "";
  520. /**
  521. * Observable event triggered each time an clipboard event is received from the rendering canvas
  522. */
  523. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  524. /**
  525. * Observable event triggered each time a pointer down is intercepted by a control
  526. */
  527. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  528. /**
  529. * Observable event triggered before layout is evaluated
  530. */
  531. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  532. /**
  533. * Observable event triggered after the layout was evaluated
  534. */
  535. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  536. /**
  537. * Observable event triggered before the texture is rendered
  538. */
  539. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  540. /**
  541. * Observable event triggered after the texture was rendered
  542. */
  543. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  544. /**
  545. * Gets or sets a boolean defining if alpha is stored as premultiplied
  546. */
  547. _this.premulAlpha = false;
  548. _this._useInvalidateRectOptimization = true;
  549. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  550. _this._invalidatedRectangle = null;
  551. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  552. /** @hidden */
  553. _this.onClipboardCopy = function (rawEvt) {
  554. var evt = rawEvt;
  555. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  556. _this.onClipboardObservable.notifyObservers(ev);
  557. evt.preventDefault();
  558. };
  559. /** @hidden */
  560. _this.onClipboardCut = function (rawEvt) {
  561. var evt = rawEvt;
  562. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  563. _this.onClipboardObservable.notifyObservers(ev);
  564. evt.preventDefault();
  565. };
  566. /** @hidden */
  567. _this.onClipboardPaste = function (rawEvt) {
  568. var evt = rawEvt;
  569. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  570. _this.onClipboardObservable.notifyObservers(ev);
  571. evt.preventDefault();
  572. };
  573. scene = _this.getScene();
  574. if (!scene || !_this._texture) {
  575. return _this;
  576. }
  577. _this._rootElement = scene.getEngine().getInputElement();
  578. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  579. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  580. if (!_this._focusedControl) {
  581. return;
  582. }
  583. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  584. _this._focusedControl.processKeyboard(info.event);
  585. }
  586. info.skipOnPointerObservable = true;
  587. });
  588. _this._rootContainer._link(_this);
  589. _this.hasAlpha = true;
  590. if (!width || !height) {
  591. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  592. _this._onResize();
  593. }
  594. _this._texture.isReady = true;
  595. return _this;
  596. }
  597. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  598. /**
  599. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  600. * Useful when you want more antialiasing
  601. */
  602. get: function () {
  603. return this._renderScale;
  604. },
  605. set: function (value) {
  606. if (value === this._renderScale) {
  607. return;
  608. }
  609. this._renderScale = value;
  610. this._onResize();
  611. },
  612. enumerable: true,
  613. configurable: true
  614. });
  615. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  616. /** Gets or sets the background color */
  617. get: function () {
  618. return this._background;
  619. },
  620. set: function (value) {
  621. if (this._background === value) {
  622. return;
  623. }
  624. this._background = value;
  625. this.markAsDirty();
  626. },
  627. enumerable: true,
  628. configurable: true
  629. });
  630. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  631. /**
  632. * Gets or sets the ideal width used to design controls.
  633. * The GUI will then rescale everything accordingly
  634. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  635. */
  636. get: function () {
  637. return this._idealWidth;
  638. },
  639. set: function (value) {
  640. if (this._idealWidth === value) {
  641. return;
  642. }
  643. this._idealWidth = value;
  644. this.markAsDirty();
  645. this._rootContainer._markAllAsDirty();
  646. },
  647. enumerable: true,
  648. configurable: true
  649. });
  650. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  651. /**
  652. * Gets or sets the ideal height used to design controls.
  653. * The GUI will then rescale everything accordingly
  654. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  655. */
  656. get: function () {
  657. return this._idealHeight;
  658. },
  659. set: function (value) {
  660. if (this._idealHeight === value) {
  661. return;
  662. }
  663. this._idealHeight = value;
  664. this.markAsDirty();
  665. this._rootContainer._markAllAsDirty();
  666. },
  667. enumerable: true,
  668. configurable: true
  669. });
  670. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  671. /**
  672. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  673. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  674. */
  675. get: function () {
  676. return this._useSmallestIdeal;
  677. },
  678. set: function (value) {
  679. if (this._useSmallestIdeal === value) {
  680. return;
  681. }
  682. this._useSmallestIdeal = value;
  683. this.markAsDirty();
  684. this._rootContainer._markAllAsDirty();
  685. },
  686. enumerable: true,
  687. configurable: true
  688. });
  689. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  690. /**
  691. * Gets or sets a boolean indicating if adaptive scaling must be used
  692. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  693. */
  694. get: function () {
  695. return this._renderAtIdealSize;
  696. },
  697. set: function (value) {
  698. if (this._renderAtIdealSize === value) {
  699. return;
  700. }
  701. this._renderAtIdealSize = value;
  702. this._onResize();
  703. },
  704. enumerable: true,
  705. configurable: true
  706. });
  707. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  708. /**
  709. * Gets the underlying layer used to render the texture when in fullscreen mode
  710. */
  711. get: function () {
  712. return this._layerToDispose;
  713. },
  714. enumerable: true,
  715. configurable: true
  716. });
  717. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  718. /**
  719. * Gets the root container control
  720. */
  721. get: function () {
  722. return this._rootContainer;
  723. },
  724. enumerable: true,
  725. configurable: true
  726. });
  727. /**
  728. * Returns an array containing the root container.
  729. * This is mostly used to let the Inspector introspects the ADT
  730. * @returns an array containing the rootContainer
  731. */
  732. AdvancedDynamicTexture.prototype.getChildren = function () {
  733. return [this._rootContainer];
  734. };
  735. /**
  736. * Will return all controls that are inside this texture
  737. * @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
  738. * @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
  739. * @return all child controls
  740. */
  741. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  742. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  743. };
  744. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  745. /**
  746. * Gets or sets the current focused control
  747. */
  748. get: function () {
  749. return this._focusedControl;
  750. },
  751. set: function (control) {
  752. if (this._focusedControl == control) {
  753. return;
  754. }
  755. if (this._focusedControl) {
  756. this._focusedControl.onBlur();
  757. }
  758. if (control) {
  759. control.onFocus();
  760. }
  761. this._focusedControl = control;
  762. },
  763. enumerable: true,
  764. configurable: true
  765. });
  766. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  767. /**
  768. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  769. */
  770. get: function () {
  771. if (!this.layer) {
  772. return true;
  773. }
  774. return (!this.layer.isBackground);
  775. },
  776. set: function (value) {
  777. if (!this.layer) {
  778. return;
  779. }
  780. if (this.layer.isBackground === !value) {
  781. return;
  782. }
  783. this.layer.isBackground = !value;
  784. },
  785. enumerable: true,
  786. configurable: true
  787. });
  788. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  789. /**
  790. * Gets or set information about clipboardData
  791. */
  792. get: function () {
  793. return this._clipboardData;
  794. },
  795. set: function (value) {
  796. this._clipboardData = value;
  797. },
  798. enumerable: true,
  799. configurable: true
  800. });
  801. /**
  802. * Get the current class name of the texture useful for serialization or dynamic coding.
  803. * @returns "AdvancedDynamicTexture"
  804. */
  805. AdvancedDynamicTexture.prototype.getClassName = function () {
  806. return "AdvancedDynamicTexture";
  807. };
  808. /**
  809. * Function used to execute a function on all controls
  810. * @param func defines the function to execute
  811. * @param container defines the container where controls belong. If null the root container will be used
  812. */
  813. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  814. if (!container) {
  815. container = this._rootContainer;
  816. }
  817. func(container);
  818. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  819. var child = _a[_i];
  820. if (child.children) {
  821. this.executeOnAllControls(func, child);
  822. continue;
  823. }
  824. func(child);
  825. }
  826. };
  827. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  828. /**
  829. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  830. */
  831. get: function () {
  832. return this._useInvalidateRectOptimization;
  833. },
  834. set: function (value) {
  835. this._useInvalidateRectOptimization = value;
  836. },
  837. enumerable: true,
  838. configurable: true
  839. });
  840. /**
  841. * Invalidates a rectangle area on the gui texture
  842. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  843. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  844. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  845. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  846. */
  847. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  848. if (!this._useInvalidateRectOptimization) {
  849. return;
  850. }
  851. if (!this._invalidatedRectangle) {
  852. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  853. }
  854. else {
  855. // Compute intersection
  856. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  857. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  858. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  859. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  860. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  861. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  862. }
  863. };
  864. /**
  865. * Marks the texture as dirty forcing a complete update
  866. */
  867. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  868. this._isDirty = true;
  869. };
  870. /**
  871. * Helper function used to create a new style
  872. * @returns a new style
  873. * @see http://doc.babylonjs.com/how_to/gui#styles
  874. */
  875. AdvancedDynamicTexture.prototype.createStyle = function () {
  876. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  877. };
  878. /**
  879. * Adds a new control to the root container
  880. * @param control defines the control to add
  881. * @returns the current texture
  882. */
  883. AdvancedDynamicTexture.prototype.addControl = function (control) {
  884. this._rootContainer.addControl(control);
  885. return this;
  886. };
  887. /**
  888. * Removes a control from the root container
  889. * @param control defines the control to remove
  890. * @returns the current texture
  891. */
  892. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  893. this._rootContainer.removeControl(control);
  894. return this;
  895. };
  896. /**
  897. * Release all resources
  898. */
  899. AdvancedDynamicTexture.prototype.dispose = function () {
  900. var scene = this.getScene();
  901. if (!scene) {
  902. return;
  903. }
  904. this._rootElement = null;
  905. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  906. if (this._resizeObserver) {
  907. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  908. }
  909. if (this._pointerMoveObserver) {
  910. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  911. }
  912. if (this._pointerObserver) {
  913. scene.onPointerObservable.remove(this._pointerObserver);
  914. }
  915. if (this._preKeyboardObserver) {
  916. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  917. }
  918. if (this._canvasPointerOutObserver) {
  919. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  920. }
  921. if (this._layerToDispose) {
  922. this._layerToDispose.texture = null;
  923. this._layerToDispose.dispose();
  924. this._layerToDispose = null;
  925. }
  926. this._rootContainer.dispose();
  927. this.onClipboardObservable.clear();
  928. this.onControlPickedObservable.clear();
  929. this.onBeginRenderObservable.clear();
  930. this.onEndRenderObservable.clear();
  931. this.onBeginLayoutObservable.clear();
  932. this.onEndLayoutObservable.clear();
  933. _super.prototype.dispose.call(this);
  934. };
  935. AdvancedDynamicTexture.prototype._onResize = function () {
  936. var scene = this.getScene();
  937. if (!scene) {
  938. return;
  939. }
  940. // Check size
  941. var engine = scene.getEngine();
  942. var textureSize = this.getSize();
  943. var renderWidth = engine.getRenderWidth() * this._renderScale;
  944. var renderHeight = engine.getRenderHeight() * this._renderScale;
  945. if (this._renderAtIdealSize) {
  946. if (this._idealWidth) {
  947. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  948. renderWidth = this._idealWidth;
  949. }
  950. else if (this._idealHeight) {
  951. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  952. renderHeight = this._idealHeight;
  953. }
  954. }
  955. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  956. this.scaleTo(renderWidth, renderHeight);
  957. this.markAsDirty();
  958. if (this._idealWidth || this._idealHeight) {
  959. this._rootContainer._markAllAsDirty();
  960. }
  961. }
  962. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  963. };
  964. /** @hidden */
  965. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  966. var engine = scene.getEngine();
  967. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  968. };
  969. /**
  970. * Get screen coordinates for a vector3
  971. * @param position defines the position to project
  972. * @param worldMatrix defines the world matrix to use
  973. * @returns the projected position
  974. */
  975. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  976. var scene = this.getScene();
  977. if (!scene) {
  978. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  979. }
  980. var globalViewport = this._getGlobalViewport(scene);
  981. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  982. projectedPosition.scaleInPlace(this.renderScale);
  983. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  984. };
  985. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  986. if (this._layerToDispose) {
  987. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  988. return;
  989. }
  990. }
  991. if (this._isFullscreen && this._linkedControls.length) {
  992. var scene = this.getScene();
  993. if (!scene) {
  994. return;
  995. }
  996. var globalViewport = this._getGlobalViewport(scene);
  997. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  998. var control = _a[_i];
  999. if (!control.isVisible) {
  1000. continue;
  1001. }
  1002. var mesh = control._linkedMesh;
  1003. if (!mesh || mesh.isDisposed()) {
  1004. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1005. control.linkWithMesh(null);
  1006. });
  1007. continue;
  1008. }
  1009. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1010. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1011. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1012. control.notRenderable = true;
  1013. continue;
  1014. }
  1015. control.notRenderable = false;
  1016. // Account for RenderScale.
  1017. projectedPosition.scaleInPlace(this.renderScale);
  1018. control._moveToProjectedPosition(projectedPosition);
  1019. }
  1020. }
  1021. if (!this._isDirty && !this._rootContainer.isDirty) {
  1022. return;
  1023. }
  1024. this._isDirty = false;
  1025. this._render();
  1026. this.update(true, this.premulAlpha);
  1027. };
  1028. AdvancedDynamicTexture.prototype._render = function () {
  1029. var textureSize = this.getSize();
  1030. var renderWidth = textureSize.width;
  1031. var renderHeight = textureSize.height;
  1032. var context = this.getContext();
  1033. context.font = "18px Arial";
  1034. context.strokeStyle = "white";
  1035. // Layout
  1036. this.onBeginLayoutObservable.notifyObservers(this);
  1037. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1038. this._rootContainer._layout(measure, context);
  1039. this.onEndLayoutObservable.notifyObservers(this);
  1040. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1041. // Clear
  1042. if (this._invalidatedRectangle) {
  1043. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1044. }
  1045. else {
  1046. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1047. }
  1048. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1049. if (this._background) {
  1050. context.save();
  1051. context.fillStyle = this._background;
  1052. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1053. context.restore();
  1054. }
  1055. // Render
  1056. this.onBeginRenderObservable.notifyObservers(this);
  1057. this._rootContainer._render(context, this._invalidatedRectangle);
  1058. this.onEndRenderObservable.notifyObservers(this);
  1059. this._invalidatedRectangle = null;
  1060. };
  1061. /** @hidden */
  1062. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1063. if (this._rootElement) {
  1064. this._rootElement.style.cursor = cursor;
  1065. this._cursorChanged = true;
  1066. }
  1067. };
  1068. /** @hidden */
  1069. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1070. this._lastControlDown[pointerId] = control;
  1071. this.onControlPickedObservable.notifyObservers(control);
  1072. };
  1073. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1074. var scene = this.getScene();
  1075. if (!scene) {
  1076. return;
  1077. }
  1078. var engine = scene.getEngine();
  1079. var textureSize = this.getSize();
  1080. if (this._isFullscreen) {
  1081. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1082. var viewport = camera.viewport;
  1083. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1084. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1085. }
  1086. if (this._capturingControl[pointerId]) {
  1087. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1088. return;
  1089. }
  1090. this._cursorChanged = false;
  1091. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1092. this._changeCursor("");
  1093. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1094. if (this._lastControlOver[pointerId]) {
  1095. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1096. delete this._lastControlOver[pointerId];
  1097. }
  1098. }
  1099. }
  1100. if (!this._cursorChanged) {
  1101. this._changeCursor("");
  1102. }
  1103. this._manageFocus();
  1104. };
  1105. /** @hidden */
  1106. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1107. for (var pointerId in list) {
  1108. if (!list.hasOwnProperty(pointerId)) {
  1109. continue;
  1110. }
  1111. var lastControlOver = list[pointerId];
  1112. if (lastControlOver === control) {
  1113. delete list[pointerId];
  1114. }
  1115. }
  1116. };
  1117. /** @hidden */
  1118. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1119. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1120. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1121. };
  1122. /** Attach to all scene events required to support pointer events */
  1123. AdvancedDynamicTexture.prototype.attach = function () {
  1124. var _this = this;
  1125. var scene = this.getScene();
  1126. if (!scene) {
  1127. return;
  1128. }
  1129. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1130. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1131. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1132. return;
  1133. }
  1134. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1135. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1136. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1137. return;
  1138. }
  1139. if (!scene) {
  1140. return;
  1141. }
  1142. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1143. var engine = scene.getEngine();
  1144. if (!camera) {
  1145. tempViewport.x = 0;
  1146. tempViewport.y = 0;
  1147. tempViewport.width = engine.getRenderWidth();
  1148. tempViewport.height = engine.getRenderHeight();
  1149. }
  1150. else {
  1151. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1152. }
  1153. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1154. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1155. _this._shouldBlockPointer = false;
  1156. // Do picking modifies _shouldBlockPointer
  1157. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1158. // Avoid overwriting a true skipOnPointerObservable to false
  1159. if (_this._shouldBlockPointer) {
  1160. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1161. }
  1162. });
  1163. this._attachToOnPointerOut(scene);
  1164. };
  1165. /**
  1166. * Register the clipboard Events onto the canvas
  1167. */
  1168. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1169. self.addEventListener("copy", this.onClipboardCopy, false);
  1170. self.addEventListener("cut", this.onClipboardCut, false);
  1171. self.addEventListener("paste", this.onClipboardPaste, false);
  1172. };
  1173. /**
  1174. * Unregister the clipboard Events from the canvas
  1175. */
  1176. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1177. self.removeEventListener("copy", this.onClipboardCopy);
  1178. self.removeEventListener("cut", this.onClipboardCut);
  1179. self.removeEventListener("paste", this.onClipboardPaste);
  1180. };
  1181. /**
  1182. * Connect the texture to a hosting mesh to enable interactions
  1183. * @param mesh defines the mesh to attach to
  1184. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1185. */
  1186. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1187. var _this = this;
  1188. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1189. var scene = this.getScene();
  1190. if (!scene) {
  1191. return;
  1192. }
  1193. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1194. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1195. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1196. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1197. return;
  1198. }
  1199. var pointerId = pi.event.pointerId || 0;
  1200. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1201. var uv = pi.pickInfo.getTextureCoordinates();
  1202. if (uv) {
  1203. var size = _this.getSize();
  1204. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1205. }
  1206. }
  1207. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1208. if (_this._lastControlDown[pointerId]) {
  1209. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1210. }
  1211. delete _this._lastControlDown[pointerId];
  1212. if (_this.focusedControl) {
  1213. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1214. var canMoveFocus = true;
  1215. if (friendlyControls) {
  1216. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1217. var control = friendlyControls_1[_i];
  1218. // Same host, no need to keep the focus
  1219. if (_this === control._host) {
  1220. continue;
  1221. }
  1222. // Different hosts
  1223. var otherHost = control._host;
  1224. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1225. canMoveFocus = false;
  1226. break;
  1227. }
  1228. }
  1229. }
  1230. if (canMoveFocus) {
  1231. _this.focusedControl = null;
  1232. }
  1233. }
  1234. }
  1235. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1236. if (_this._lastControlOver[pointerId]) {
  1237. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1238. }
  1239. delete _this._lastControlOver[pointerId];
  1240. }
  1241. });
  1242. mesh.enablePointerMoveEvents = supportPointerMove;
  1243. this._attachToOnPointerOut(scene);
  1244. };
  1245. /**
  1246. * Move the focus to a specific control
  1247. * @param control defines the control which will receive the focus
  1248. */
  1249. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1250. this.focusedControl = control;
  1251. this._lastPickedControl = control;
  1252. this._blockNextFocusCheck = true;
  1253. };
  1254. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1255. if (this._blockNextFocusCheck) {
  1256. this._blockNextFocusCheck = false;
  1257. this._lastPickedControl = this._focusedControl;
  1258. return;
  1259. }
  1260. // Focus management
  1261. if (this._focusedControl) {
  1262. if (this._focusedControl !== this._lastPickedControl) {
  1263. if (this._lastPickedControl.isFocusInvisible) {
  1264. return;
  1265. }
  1266. this.focusedControl = null;
  1267. }
  1268. }
  1269. };
  1270. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1271. var _this = this;
  1272. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1273. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1274. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1275. }
  1276. delete _this._lastControlOver[pointerEvent.pointerId];
  1277. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1278. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1279. delete _this._lastControlDown[pointerEvent.pointerId];
  1280. }
  1281. });
  1282. };
  1283. // Statics
  1284. /**
  1285. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1286. * @param mesh defines the mesh which will receive the texture
  1287. * @param width defines the texture width (1024 by default)
  1288. * @param height defines the texture height (1024 by default)
  1289. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1290. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1291. * @returns a new AdvancedDynamicTexture
  1292. */
  1293. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1294. if (width === void 0) { width = 1024; }
  1295. if (height === void 0) { height = 1024; }
  1296. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1297. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1298. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1299. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1300. material.backFaceCulling = false;
  1301. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1302. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1303. if (onlyAlphaTesting) {
  1304. material.diffuseTexture = result;
  1305. material.emissiveTexture = result;
  1306. result.hasAlpha = true;
  1307. }
  1308. else {
  1309. material.emissiveTexture = result;
  1310. material.opacityTexture = result;
  1311. }
  1312. mesh.material = material;
  1313. result.attachToMesh(mesh, supportPointerMove);
  1314. return result;
  1315. };
  1316. /**
  1317. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1318. * In this mode the texture will rely on a layer for its rendering.
  1319. * This allows it to be treated like any other layer.
  1320. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1321. * LayerMask is set through advancedTexture.layer.layerMask
  1322. * @param name defines name for the texture
  1323. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1324. * @param scene defines the hsoting scene
  1325. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1326. * @returns a new AdvancedDynamicTexture
  1327. */
  1328. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1329. if (foreground === void 0) { foreground = true; }
  1330. if (scene === void 0) { scene = null; }
  1331. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1332. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1333. // Display
  1334. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1335. layer.texture = result;
  1336. result._layerToDispose = layer;
  1337. result._isFullscreen = true;
  1338. // Attach
  1339. result.attach();
  1340. return result;
  1341. };
  1342. return AdvancedDynamicTexture;
  1343. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1344. /***/ }),
  1345. /***/ "./2D/controls/button.ts":
  1346. /*!*******************************!*\
  1347. !*** ./2D/controls/button.ts ***!
  1348. \*******************************/
  1349. /*! exports provided: Button */
  1350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1351. "use strict";
  1352. __webpack_require__.r(__webpack_exports__);
  1353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1354. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1355. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1356. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1357. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1358. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1359. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  1360. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1361. /**
  1362. * Class used to create 2D buttons
  1363. */
  1364. var Button = /** @class */ (function (_super) {
  1365. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1366. /**
  1367. * Creates a new Button
  1368. * @param name defines the name of the button
  1369. */
  1370. function Button(name) {
  1371. var _this = _super.call(this, name) || this;
  1372. _this.name = name;
  1373. /**
  1374. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1375. */
  1376. _this.delegatePickingToChildren = false;
  1377. _this.thickness = 1;
  1378. _this.isPointerBlocker = true;
  1379. var alphaStore = null;
  1380. _this.pointerEnterAnimation = function () {
  1381. alphaStore = _this.alpha;
  1382. _this.alpha -= 0.1;
  1383. };
  1384. _this.pointerOutAnimation = function () {
  1385. if (alphaStore !== null) {
  1386. _this.alpha = alphaStore;
  1387. }
  1388. };
  1389. _this.pointerDownAnimation = function () {
  1390. _this.scaleX -= 0.05;
  1391. _this.scaleY -= 0.05;
  1392. };
  1393. _this.pointerUpAnimation = function () {
  1394. _this.scaleX += 0.05;
  1395. _this.scaleY += 0.05;
  1396. };
  1397. return _this;
  1398. }
  1399. Object.defineProperty(Button.prototype, "image", {
  1400. /**
  1401. * Returns the image part of the button (if any)
  1402. */
  1403. get: function () {
  1404. return this._image;
  1405. },
  1406. enumerable: true,
  1407. configurable: true
  1408. });
  1409. Object.defineProperty(Button.prototype, "textBlock", {
  1410. /**
  1411. * Returns the image part of the button (if any)
  1412. */
  1413. get: function () {
  1414. return this._textBlock;
  1415. },
  1416. enumerable: true,
  1417. configurable: true
  1418. });
  1419. Button.prototype._getTypeName = function () {
  1420. return "Button";
  1421. };
  1422. // While being a container, the button behaves like a control.
  1423. /** @hidden */
  1424. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1425. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1426. return false;
  1427. }
  1428. if (!_super.prototype.contains.call(this, x, y)) {
  1429. return false;
  1430. }
  1431. if (this.delegatePickingToChildren) {
  1432. var contains = false;
  1433. for (var index = this._children.length - 1; index >= 0; index--) {
  1434. var child = this._children[index];
  1435. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1436. contains = true;
  1437. break;
  1438. }
  1439. }
  1440. if (!contains) {
  1441. return false;
  1442. }
  1443. }
  1444. this._processObservables(type, x, y, pointerId, buttonIndex);
  1445. return true;
  1446. };
  1447. /** @hidden */
  1448. Button.prototype._onPointerEnter = function (target) {
  1449. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1450. return false;
  1451. }
  1452. if (this.pointerEnterAnimation) {
  1453. this.pointerEnterAnimation();
  1454. }
  1455. return true;
  1456. };
  1457. /** @hidden */
  1458. Button.prototype._onPointerOut = function (target, force) {
  1459. if (force === void 0) { force = false; }
  1460. if (this.pointerOutAnimation) {
  1461. this.pointerOutAnimation();
  1462. }
  1463. _super.prototype._onPointerOut.call(this, target, force);
  1464. };
  1465. /** @hidden */
  1466. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1467. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1468. return false;
  1469. }
  1470. if (this.pointerDownAnimation) {
  1471. this.pointerDownAnimation();
  1472. }
  1473. return true;
  1474. };
  1475. /** @hidden */
  1476. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1477. if (this.pointerUpAnimation) {
  1478. this.pointerUpAnimation();
  1479. }
  1480. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1481. };
  1482. // Statics
  1483. /**
  1484. * Creates a new button made with an image and a text
  1485. * @param name defines the name of the button
  1486. * @param text defines the text of the button
  1487. * @param imageUrl defines the url of the image
  1488. * @returns a new Button
  1489. */
  1490. Button.CreateImageButton = function (name, text, imageUrl) {
  1491. var result = new Button(name);
  1492. // Adding text
  1493. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1494. textBlock.textWrapping = true;
  1495. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1496. textBlock.paddingLeft = "20%";
  1497. result.addControl(textBlock);
  1498. // Adding image
  1499. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1500. iconImage.width = "20%";
  1501. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1502. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1503. result.addControl(iconImage);
  1504. // Store
  1505. result._image = iconImage;
  1506. result._textBlock = textBlock;
  1507. return result;
  1508. };
  1509. /**
  1510. * Creates a new button made with an image
  1511. * @param name defines the name of the button
  1512. * @param imageUrl defines the url of the image
  1513. * @returns a new Button
  1514. */
  1515. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1516. var result = new Button(name);
  1517. // Adding image
  1518. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1519. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1520. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1521. result.addControl(iconImage);
  1522. // Store
  1523. result._image = iconImage;
  1524. return result;
  1525. };
  1526. /**
  1527. * Creates a new button made with a text
  1528. * @param name defines the name of the button
  1529. * @param text defines the text of the button
  1530. * @returns a new Button
  1531. */
  1532. Button.CreateSimpleButton = function (name, text) {
  1533. var result = new Button(name);
  1534. // Adding text
  1535. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1536. textBlock.textWrapping = true;
  1537. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1538. result.addControl(textBlock);
  1539. // Store
  1540. result._textBlock = textBlock;
  1541. return result;
  1542. };
  1543. /**
  1544. * Creates a new button made with an image and a centered text
  1545. * @param name defines the name of the button
  1546. * @param text defines the text of the button
  1547. * @param imageUrl defines the url of the image
  1548. * @returns a new Button
  1549. */
  1550. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1551. var result = new Button(name);
  1552. // Adding image
  1553. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1554. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1555. result.addControl(iconImage);
  1556. // Adding text
  1557. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1558. textBlock.textWrapping = true;
  1559. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1560. result.addControl(textBlock);
  1561. // Store
  1562. result._image = iconImage;
  1563. result._textBlock = textBlock;
  1564. return result;
  1565. };
  1566. return Button;
  1567. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1568. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1569. /***/ }),
  1570. /***/ "./2D/controls/checkbox.ts":
  1571. /*!*********************************!*\
  1572. !*** ./2D/controls/checkbox.ts ***!
  1573. \*********************************/
  1574. /*! exports provided: Checkbox */
  1575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1576. "use strict";
  1577. __webpack_require__.r(__webpack_exports__);
  1578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1579. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1580. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1581. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1582. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1583. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1584. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1585. /**
  1586. * Class used to represent a 2D checkbox
  1587. */
  1588. var Checkbox = /** @class */ (function (_super) {
  1589. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1590. /**
  1591. * Creates a new CheckBox
  1592. * @param name defines the control name
  1593. */
  1594. function Checkbox(name) {
  1595. var _this = _super.call(this, name) || this;
  1596. _this.name = name;
  1597. _this._isChecked = false;
  1598. _this._background = "black";
  1599. _this._checkSizeRatio = 0.8;
  1600. _this._thickness = 1;
  1601. /**
  1602. * Observable raised when isChecked property changes
  1603. */
  1604. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1605. _this.isPointerBlocker = true;
  1606. return _this;
  1607. }
  1608. Object.defineProperty(Checkbox.prototype, "thickness", {
  1609. /** Gets or sets border thickness */
  1610. get: function () {
  1611. return this._thickness;
  1612. },
  1613. set: function (value) {
  1614. if (this._thickness === value) {
  1615. return;
  1616. }
  1617. this._thickness = value;
  1618. this._markAsDirty();
  1619. },
  1620. enumerable: true,
  1621. configurable: true
  1622. });
  1623. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1624. /** Gets or sets a value indicating the ratio between overall size and check size */
  1625. get: function () {
  1626. return this._checkSizeRatio;
  1627. },
  1628. set: function (value) {
  1629. value = Math.max(Math.min(1, value), 0);
  1630. if (this._checkSizeRatio === value) {
  1631. return;
  1632. }
  1633. this._checkSizeRatio = value;
  1634. this._markAsDirty();
  1635. },
  1636. enumerable: true,
  1637. configurable: true
  1638. });
  1639. Object.defineProperty(Checkbox.prototype, "background", {
  1640. /** Gets or sets background color */
  1641. get: function () {
  1642. return this._background;
  1643. },
  1644. set: function (value) {
  1645. if (this._background === value) {
  1646. return;
  1647. }
  1648. this._background = value;
  1649. this._markAsDirty();
  1650. },
  1651. enumerable: true,
  1652. configurable: true
  1653. });
  1654. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1655. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1656. get: function () {
  1657. return this._isChecked;
  1658. },
  1659. set: function (value) {
  1660. if (this._isChecked === value) {
  1661. return;
  1662. }
  1663. this._isChecked = value;
  1664. this._markAsDirty();
  1665. this.onIsCheckedChangedObservable.notifyObservers(value);
  1666. },
  1667. enumerable: true,
  1668. configurable: true
  1669. });
  1670. Checkbox.prototype._getTypeName = function () {
  1671. return "Checkbox";
  1672. };
  1673. /** @hidden */
  1674. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1675. context.save();
  1676. this._applyStates(context);
  1677. var actualWidth = this._currentMeasure.width - this._thickness;
  1678. var actualHeight = this._currentMeasure.height - this._thickness;
  1679. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1680. context.shadowColor = this.shadowColor;
  1681. context.shadowBlur = this.shadowBlur;
  1682. context.shadowOffsetX = this.shadowOffsetX;
  1683. context.shadowOffsetY = this.shadowOffsetY;
  1684. }
  1685. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1686. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1687. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1688. context.shadowBlur = 0;
  1689. context.shadowOffsetX = 0;
  1690. context.shadowOffsetY = 0;
  1691. }
  1692. if (this._isChecked) {
  1693. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1694. var offsetWidth = actualWidth * this._checkSizeRatio;
  1695. var offseHeight = actualHeight * this._checkSizeRatio;
  1696. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1697. }
  1698. context.strokeStyle = this.color;
  1699. context.lineWidth = this._thickness;
  1700. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1701. context.restore();
  1702. };
  1703. // Events
  1704. /** @hidden */
  1705. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1706. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1707. return false;
  1708. }
  1709. this.isChecked = !this.isChecked;
  1710. return true;
  1711. };
  1712. /**
  1713. * Utility function to easily create a checkbox with a header
  1714. * @param title defines the label to use for the header
  1715. * @param onValueChanged defines the callback to call when value changes
  1716. * @returns a StackPanel containing the checkbox and a textBlock
  1717. */
  1718. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1719. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1720. panel.isVertical = false;
  1721. panel.height = "30px";
  1722. var checkbox = new Checkbox();
  1723. checkbox.width = "20px";
  1724. checkbox.height = "20px";
  1725. checkbox.isChecked = true;
  1726. checkbox.color = "green";
  1727. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1728. panel.addControl(checkbox);
  1729. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1730. header.text = title;
  1731. header.width = "180px";
  1732. header.paddingLeft = "5px";
  1733. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1734. header.color = "white";
  1735. panel.addControl(header);
  1736. return panel;
  1737. };
  1738. return Checkbox;
  1739. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1740. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1741. /***/ }),
  1742. /***/ "./2D/controls/colorpicker.ts":
  1743. /*!************************************!*\
  1744. !*** ./2D/controls/colorpicker.ts ***!
  1745. \************************************/
  1746. /*! exports provided: ColorPicker */
  1747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1748. "use strict";
  1749. __webpack_require__.r(__webpack_exports__);
  1750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1751. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1752. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1753. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1754. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1755. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1756. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1757. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1758. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1759. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1760. /** Class used to create color pickers */
  1761. var ColorPicker = /** @class */ (function (_super) {
  1762. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1763. /**
  1764. * Creates a new ColorPicker
  1765. * @param name defines the control name
  1766. */
  1767. function ColorPicker(name) {
  1768. var _this = _super.call(this, name) || this;
  1769. _this.name = name;
  1770. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1771. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1772. _this._pointerStartedOnSquare = false;
  1773. _this._pointerStartedOnWheel = false;
  1774. _this._squareLeft = 0;
  1775. _this._squareTop = 0;
  1776. _this._squareSize = 0;
  1777. _this._h = 360;
  1778. _this._s = 1;
  1779. _this._v = 1;
  1780. _this._lastPointerDownID = -1;
  1781. /**
  1782. * Observable raised when the value changes
  1783. */
  1784. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1785. // Events
  1786. _this._pointerIsDown = false;
  1787. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1788. _this.size = "200px";
  1789. _this.isPointerBlocker = true;
  1790. return _this;
  1791. }
  1792. Object.defineProperty(ColorPicker.prototype, "value", {
  1793. /** Gets or sets the color of the color picker */
  1794. get: function () {
  1795. return this._value;
  1796. },
  1797. set: function (value) {
  1798. if (this._value.equals(value)) {
  1799. return;
  1800. }
  1801. this._value.copyFrom(value);
  1802. this._value.toHSVToRef(this._tmpColor);
  1803. this._h = this._tmpColor.r;
  1804. this._s = Math.max(this._tmpColor.g, 0.00001);
  1805. this._v = Math.max(this._tmpColor.b, 0.00001);
  1806. this._markAsDirty();
  1807. if (this._value.r <= ColorPicker._Epsilon) {
  1808. this._value.r = 0;
  1809. }
  1810. if (this._value.g <= ColorPicker._Epsilon) {
  1811. this._value.g = 0;
  1812. }
  1813. if (this._value.b <= ColorPicker._Epsilon) {
  1814. this._value.b = 0;
  1815. }
  1816. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1817. this._value.r = 1.0;
  1818. }
  1819. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1820. this._value.g = 1.0;
  1821. }
  1822. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1823. this._value.b = 1.0;
  1824. }
  1825. this.onValueChangedObservable.notifyObservers(this._value);
  1826. },
  1827. enumerable: true,
  1828. configurable: true
  1829. });
  1830. Object.defineProperty(ColorPicker.prototype, "width", {
  1831. /**
  1832. * Gets or sets control width
  1833. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1834. */
  1835. get: function () {
  1836. return this._width.toString(this._host);
  1837. },
  1838. set: function (value) {
  1839. if (this._width.toString(this._host) === value) {
  1840. return;
  1841. }
  1842. if (this._width.fromString(value)) {
  1843. this._height.fromString(value);
  1844. this._markAsDirty();
  1845. }
  1846. },
  1847. enumerable: true,
  1848. configurable: true
  1849. });
  1850. Object.defineProperty(ColorPicker.prototype, "height", {
  1851. /**
  1852. * Gets or sets control height
  1853. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1854. */
  1855. get: function () {
  1856. return this._height.toString(this._host);
  1857. },
  1858. /** Gets or sets control height */
  1859. set: function (value) {
  1860. if (this._height.toString(this._host) === value) {
  1861. return;
  1862. }
  1863. if (this._height.fromString(value)) {
  1864. this._width.fromString(value);
  1865. this._markAsDirty();
  1866. }
  1867. },
  1868. enumerable: true,
  1869. configurable: true
  1870. });
  1871. Object.defineProperty(ColorPicker.prototype, "size", {
  1872. /** Gets or sets control size */
  1873. get: function () {
  1874. return this.width;
  1875. },
  1876. set: function (value) {
  1877. this.width = value;
  1878. },
  1879. enumerable: true,
  1880. configurable: true
  1881. });
  1882. ColorPicker.prototype._getTypeName = function () {
  1883. return "ColorPicker";
  1884. };
  1885. /** @hidden */
  1886. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1887. if (parentMeasure.width < parentMeasure.height) {
  1888. this._currentMeasure.height = parentMeasure.width;
  1889. }
  1890. else {
  1891. this._currentMeasure.width = parentMeasure.height;
  1892. }
  1893. };
  1894. ColorPicker.prototype._updateSquareProps = function () {
  1895. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1896. var wheelThickness = radius * .2;
  1897. var innerDiameter = (radius - wheelThickness) * 2;
  1898. var squareSize = innerDiameter / (Math.sqrt(2));
  1899. var offset = radius - squareSize * .5;
  1900. this._squareLeft = this._currentMeasure.left + offset;
  1901. this._squareTop = this._currentMeasure.top + offset;
  1902. this._squareSize = squareSize;
  1903. };
  1904. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1905. var lgh = context.createLinearGradient(left, top, width + left, top);
  1906. lgh.addColorStop(0, '#fff');
  1907. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1908. context.fillStyle = lgh;
  1909. context.fillRect(left, top, width, height);
  1910. var lgv = context.createLinearGradient(left, top, left, height + top);
  1911. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1912. lgv.addColorStop(1, '#000');
  1913. context.fillStyle = lgv;
  1914. context.fillRect(left, top, width, height);
  1915. };
  1916. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1917. context.beginPath();
  1918. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1919. context.lineWidth = 3;
  1920. context.strokeStyle = '#333333';
  1921. context.stroke();
  1922. context.beginPath();
  1923. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1924. context.lineWidth = 3;
  1925. context.strokeStyle = '#ffffff';
  1926. context.stroke();
  1927. };
  1928. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1929. var canvas = document.createElement("canvas");
  1930. canvas.width = radius * 2;
  1931. canvas.height = radius * 2;
  1932. var context = canvas.getContext("2d");
  1933. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1934. var data = image.data;
  1935. var color = this._tmpColor;
  1936. var maxDistSq = radius * radius;
  1937. var innerRadius = radius - thickness;
  1938. var minDistSq = innerRadius * innerRadius;
  1939. for (var x = -radius; x < radius; x++) {
  1940. for (var y = -radius; y < radius; y++) {
  1941. var distSq = x * x + y * y;
  1942. if (distSq > maxDistSq || distSq < minDistSq) {
  1943. continue;
  1944. }
  1945. var dist = Math.sqrt(distSq);
  1946. var ang = Math.atan2(y, x);
  1947. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1948. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1949. data[index] = color.r * 255;
  1950. data[index + 1] = color.g * 255;
  1951. data[index + 2] = color.b * 255;
  1952. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1953. //apply less alpha to bigger color pickers
  1954. var alphaAmount = .2;
  1955. var maxAlpha = .2;
  1956. var minAlpha = .04;
  1957. var lowerRadius = 50;
  1958. var upperRadius = 150;
  1959. if (radius < lowerRadius) {
  1960. alphaAmount = maxAlpha;
  1961. }
  1962. else if (radius > upperRadius) {
  1963. alphaAmount = minAlpha;
  1964. }
  1965. else {
  1966. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1967. }
  1968. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1969. if (alphaRatio < alphaAmount) {
  1970. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1971. }
  1972. else if (alphaRatio > 1 - alphaAmount) {
  1973. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1974. }
  1975. else {
  1976. data[index + 3] = 255;
  1977. }
  1978. }
  1979. }
  1980. context.putImageData(image, 0, 0);
  1981. return canvas;
  1982. };
  1983. /** @hidden */
  1984. ColorPicker.prototype._draw = function (context) {
  1985. context.save();
  1986. this._applyStates(context);
  1987. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1988. var wheelThickness = radius * .2;
  1989. var left = this._currentMeasure.left;
  1990. var top = this._currentMeasure.top;
  1991. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  1992. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  1993. }
  1994. this._updateSquareProps();
  1995. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1996. context.shadowColor = this.shadowColor;
  1997. context.shadowBlur = this.shadowBlur;
  1998. context.shadowOffsetX = this.shadowOffsetX;
  1999. context.shadowOffsetY = this.shadowOffsetY;
  2000. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2001. }
  2002. context.drawImage(this._colorWheelCanvas, left, top);
  2003. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2004. context.shadowBlur = 0;
  2005. context.shadowOffsetX = 0;
  2006. context.shadowOffsetY = 0;
  2007. }
  2008. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2009. var cx = this._squareLeft + this._squareSize * this._s;
  2010. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2011. this._drawCircle(cx, cy, radius * .04, context);
  2012. var dist = radius - wheelThickness * .5;
  2013. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2014. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2015. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2016. context.restore();
  2017. };
  2018. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2019. if (this._pointerStartedOnWheel) {
  2020. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2021. var centerX = radius + this._currentMeasure.left;
  2022. var centerY = radius + this._currentMeasure.top;
  2023. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2024. }
  2025. else if (this._pointerStartedOnSquare) {
  2026. this._updateSquareProps();
  2027. this._s = (x - this._squareLeft) / this._squareSize;
  2028. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2029. this._s = Math.min(this._s, 1);
  2030. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2031. this._v = Math.min(this._v, 1);
  2032. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2033. }
  2034. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2035. this.value = this._tmpColor;
  2036. };
  2037. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2038. this._updateSquareProps();
  2039. var left = this._squareLeft;
  2040. var top = this._squareTop;
  2041. var size = this._squareSize;
  2042. if (x >= left && x <= left + size &&
  2043. y >= top && y <= top + size) {
  2044. return true;
  2045. }
  2046. return false;
  2047. };
  2048. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2049. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2050. var centerX = radius + this._currentMeasure.left;
  2051. var centerY = radius + this._currentMeasure.top;
  2052. var wheelThickness = radius * .2;
  2053. var innerRadius = radius - wheelThickness;
  2054. var radiusSq = radius * radius;
  2055. var innerRadiusSq = innerRadius * innerRadius;
  2056. var dx = x - centerX;
  2057. var dy = y - centerY;
  2058. var distSq = dx * dx + dy * dy;
  2059. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2060. return true;
  2061. }
  2062. return false;
  2063. };
  2064. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2065. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2066. return false;
  2067. }
  2068. this._pointerIsDown = true;
  2069. this._pointerStartedOnSquare = false;
  2070. this._pointerStartedOnWheel = false;
  2071. // Invert transform
  2072. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2073. var x = this._transformedPosition.x;
  2074. var y = this._transformedPosition.y;
  2075. if (this._isPointOnSquare(x, y)) {
  2076. this._pointerStartedOnSquare = true;
  2077. }
  2078. else if (this._isPointOnWheel(x, y)) {
  2079. this._pointerStartedOnWheel = true;
  2080. }
  2081. this._updateValueFromPointer(x, y);
  2082. this._host._capturingControl[pointerId] = this;
  2083. this._lastPointerDownID = pointerId;
  2084. return true;
  2085. };
  2086. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2087. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2088. if (pointerId != this._lastPointerDownID) {
  2089. return;
  2090. }
  2091. // Invert transform
  2092. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2093. var x = this._transformedPosition.x;
  2094. var y = this._transformedPosition.y;
  2095. if (this._pointerIsDown) {
  2096. this._updateValueFromPointer(x, y);
  2097. }
  2098. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2099. };
  2100. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2101. this._pointerIsDown = false;
  2102. delete this._host._capturingControl[pointerId];
  2103. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2104. };
  2105. /**
  2106. * This function expands the color picker by creating a color picker dialog with manual
  2107. * color value input and the ability to save colors into an array to be used later in
  2108. * subsequent launches of the dialogue.
  2109. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2110. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  2111. * @returns picked color as a hex string and the saved colors array as hex strings.
  2112. */
  2113. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2114. return new Promise(function (resolve, reject) {
  2115. // Default options
  2116. options.pickerWidth = options.pickerWidth || "640px";
  2117. options.pickerHeight = options.pickerHeight || "400px";
  2118. options.headerHeight = options.headerHeight || "35px";
  2119. options.lastColor = options.lastColor || "#000000";
  2120. options.swatchLimit = options.swatchLimit || 20;
  2121. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2122. // Window size settings
  2123. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2124. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2125. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2126. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2127. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2128. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2129. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2130. // Button Colors
  2131. var buttonColor = "#c0c0c0";
  2132. var buttonBackgroundColor = "#535353";
  2133. var buttonBackgroundHoverColor = "#414141";
  2134. var buttonBackgroundClickColor = "515151";
  2135. var buttonDisabledColor = "#555555";
  2136. var buttonDisabledBackgroundColor = "#454545";
  2137. var currentSwatchesOutlineColor = "#404040";
  2138. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2139. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2140. var iconColorDark = "#aaaaaa";
  2141. var iconColorLight = "#ffffff";
  2142. var closeIconColor;
  2143. // Button settings
  2144. var buttonFontSize;
  2145. var butEdit;
  2146. var buttonWidth;
  2147. var buttonHeight;
  2148. // Input Text Colors
  2149. var inputFieldLabels = ["R", "G", "B"];
  2150. var inputTextBackgroundColor = "#454545";
  2151. var inputTextColor = "#f0f0f0";
  2152. // This is the current color as set by either the picker or by entering a value
  2153. var currentColor;
  2154. // This int is used for naming swatches and serves as the index for calling them from the list
  2155. var swatchNumber;
  2156. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2157. var swatchDrawer;
  2158. var editSwatchMode = false;
  2159. // Color InputText fields that will be updated upon value change
  2160. var picker;
  2161. var rValInt;
  2162. var gValInt;
  2163. var bValInt;
  2164. var rValDec;
  2165. var gValDec;
  2166. var bValDec;
  2167. var hexVal;
  2168. var newSwatch;
  2169. var lastVal;
  2170. var activeField;
  2171. /**
  2172. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2173. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2174. * are will receive no update. This is to prevent the input from the user being overwritten.
  2175. */
  2176. function updateValues(value, inputField) {
  2177. activeField = inputField;
  2178. var pickedColor = value.toHexString();
  2179. newSwatch.background = pickedColor;
  2180. if (rValInt.name != activeField) {
  2181. rValInt.text = Math.floor(value.r * 255).toString();
  2182. }
  2183. if (gValInt.name != activeField) {
  2184. gValInt.text = Math.floor(value.g * 255).toString();
  2185. }
  2186. if (bValInt.name != activeField) {
  2187. bValInt.text = Math.floor(value.b * 255).toString();
  2188. }
  2189. if (rValDec.name != activeField) {
  2190. rValDec.text = value.r.toString();
  2191. }
  2192. if (gValDec.name != activeField) {
  2193. gValDec.text = value.g.toString();
  2194. }
  2195. if (bValDec.name != activeField) {
  2196. bValDec.text = value.b.toString();
  2197. }
  2198. if (hexVal.name != activeField) {
  2199. var minusPound = pickedColor.split("#");
  2200. hexVal.text = minusPound[1];
  2201. }
  2202. if (picker.name != activeField) {
  2203. picker.value = value;
  2204. }
  2205. }
  2206. // When the user enters an integer for R, G, or B we check to make sure it is a valid number and replace if not.
  2207. function updateInt(field, channel) {
  2208. var newValue = field.text;
  2209. var checkVal = /[^0-9]/g.test(newValue);
  2210. if (checkVal) {
  2211. field.text = lastVal;
  2212. return;
  2213. }
  2214. else {
  2215. if (newValue != "") {
  2216. if (Math.floor(parseInt(newValue)) < 0) {
  2217. newValue = "0";
  2218. }
  2219. else if (Math.floor(parseInt(newValue)) > 255) {
  2220. newValue = "255";
  2221. }
  2222. else if (isNaN(parseInt(newValue))) {
  2223. newValue = "0";
  2224. }
  2225. }
  2226. if (activeField == field.name) {
  2227. lastVal = newValue;
  2228. }
  2229. }
  2230. if (newValue != "") {
  2231. newValue = parseInt(newValue).toString();
  2232. field.text = newValue;
  2233. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2234. if (activeField == field.name) {
  2235. if (channel == "r") {
  2236. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2237. }
  2238. else if (channel == "g") {
  2239. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2240. }
  2241. else {
  2242. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2243. }
  2244. }
  2245. }
  2246. }
  2247. // When the user enters a float for R, G, or B we check to make sure it is a valid number and replace if not.
  2248. function updateFloat(field, channel) {
  2249. var newValue = field.text;
  2250. var checkVal = /[^0-9\.]/g.test(newValue);
  2251. if (checkVal) {
  2252. field.text = lastVal;
  2253. return;
  2254. }
  2255. else {
  2256. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2257. if (parseFloat(newValue) < 0.0) {
  2258. newValue = "0.0";
  2259. }
  2260. else if (parseFloat(newValue) > 1.0) {
  2261. newValue = "1.0";
  2262. }
  2263. else if (isNaN(parseFloat(newValue))) {
  2264. newValue = "0.0";
  2265. }
  2266. }
  2267. if (activeField == field.name) {
  2268. lastVal = newValue;
  2269. }
  2270. }
  2271. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2272. newValue = parseFloat(newValue).toString();
  2273. field.text = newValue;
  2274. }
  2275. else {
  2276. newValue = "0.0";
  2277. }
  2278. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2279. if (activeField == field.name) {
  2280. if (channel == "r") {
  2281. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2282. }
  2283. else if (channel == "g") {
  2284. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2285. }
  2286. else {
  2287. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2288. }
  2289. }
  2290. }
  2291. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2292. function deleteSwatch(index) {
  2293. if (options.savedColors) {
  2294. options.savedColors.splice(index, 1);
  2295. }
  2296. if (options.savedColors && options.savedColors.length == 0) {
  2297. setEditButtonVisibility(false);
  2298. editSwatchMode = false;
  2299. }
  2300. }
  2301. // Creates and styles an individual swatch when updateSwatches is called.
  2302. function createSwatch() {
  2303. if (options.savedColors && options.savedColors[swatchNumber]) {
  2304. if (editSwatchMode) {
  2305. var icon = "b";
  2306. }
  2307. else {
  2308. var icon = "";
  2309. }
  2310. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2311. swatch.fontFamily = "BabylonJSglyphs";
  2312. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2313. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2314. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2315. if (swatchLuminence > luminanceLimit) {
  2316. swatch.color = iconColorDark;
  2317. }
  2318. else {
  2319. swatch.color = iconColorLight;
  2320. }
  2321. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2322. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2323. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2324. swatch.background = options.savedColors[swatchNumber];
  2325. swatch.thickness = 2;
  2326. var metadata_1 = swatchNumber;
  2327. swatch.pointerDownAnimation = function () {
  2328. swatch.thickness = 4;
  2329. };
  2330. swatch.pointerUpAnimation = function () {
  2331. swatch.thickness = 3;
  2332. };
  2333. swatch.pointerEnterAnimation = function () {
  2334. swatch.thickness = 3;
  2335. };
  2336. swatch.pointerOutAnimation = function () {
  2337. swatch.thickness = 2;
  2338. };
  2339. swatch.onPointerClickObservable.add(function () {
  2340. if (!editSwatchMode) {
  2341. if (options.savedColors) {
  2342. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2343. }
  2344. }
  2345. else {
  2346. deleteSwatch(metadata_1);
  2347. updateSwatches("", butSave);
  2348. }
  2349. });
  2350. return swatch;
  2351. }
  2352. else {
  2353. return null;
  2354. }
  2355. }
  2356. // Mode switch to render button text and close symbols on swatch controls
  2357. function editSwatches(mode) {
  2358. if (mode !== undefined) {
  2359. editSwatchMode = mode;
  2360. }
  2361. if (editSwatchMode) {
  2362. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2363. var thisButton = swatchDrawer.children[i];
  2364. thisButton.textBlock.text = "b";
  2365. }
  2366. if (butEdit !== undefined) {
  2367. butEdit.textBlock.text = "Done";
  2368. }
  2369. }
  2370. else {
  2371. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2372. var thisButton = swatchDrawer.children[i];
  2373. thisButton.textBlock.text = "";
  2374. }
  2375. if (butEdit !== undefined) {
  2376. butEdit.textBlock.text = "Edit";
  2377. }
  2378. }
  2379. }
  2380. /**
  2381. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2382. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2383. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2384. * saved colors there are and how many can be stored per row.
  2385. */
  2386. function updateSwatches(color, button) {
  2387. if (options.savedColors) {
  2388. if (color != "") {
  2389. options.savedColors.push(color);
  2390. }
  2391. swatchNumber = 0;
  2392. swatchDrawer.clearControls();
  2393. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2394. if (rowCount == 0) {
  2395. var gutterCount = 0;
  2396. }
  2397. else {
  2398. var gutterCount = rowCount + 1;
  2399. }
  2400. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2401. var currentRows = swatchDrawer.rowCount;
  2402. for (var i = 0; i < currentRows; i++) {
  2403. swatchDrawer.removeRowDefinition(0);
  2404. }
  2405. for (var i = 0; i < rowCount + gutterCount; i++) {
  2406. if (i % 2) {
  2407. swatchDrawer.addRowDefinition(swatchSize, true);
  2408. }
  2409. else {
  2410. swatchDrawer.addRowDefinition(gutterSize, true);
  2411. }
  2412. }
  2413. }
  2414. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2415. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2416. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2417. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2418. var totalButtonsThisRow = options.numSwatchesPerLine;
  2419. }
  2420. else {
  2421. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2422. }
  2423. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2424. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2425. if (x > options.numSwatchesPerLine) {
  2426. continue;
  2427. }
  2428. var swatch = createSwatch();
  2429. if (swatch != null) {
  2430. swatchDrawer.addControl(swatch, y, w);
  2431. w += 2;
  2432. swatchNumber++;
  2433. }
  2434. else {
  2435. continue;
  2436. }
  2437. }
  2438. }
  2439. if (options.savedColors.length >= options.swatchLimit) {
  2440. disableButton(button, true);
  2441. }
  2442. else {
  2443. disableButton(button, false);
  2444. }
  2445. }
  2446. }
  2447. // Shows or hides edit swatches button depending on if there are saved swatches
  2448. function setEditButtonVisibility(enableButton) {
  2449. if (enableButton) {
  2450. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2451. butEdit.width = buttonWidth;
  2452. butEdit.height = buttonHeight;
  2453. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2454. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2455. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2456. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2457. butEdit.thickness = 2;
  2458. butEdit.color = buttonColor;
  2459. butEdit.fontSize = buttonFontSize;
  2460. butEdit.background = buttonBackgroundColor;
  2461. butEdit.onPointerEnterObservable.add(function () {
  2462. butEdit.background = buttonBackgroundHoverColor;
  2463. });
  2464. butEdit.onPointerOutObservable.add(function () {
  2465. butEdit.background = buttonBackgroundColor;
  2466. });
  2467. butEdit.pointerDownAnimation = function () {
  2468. butEdit.background = buttonBackgroundClickColor;
  2469. };
  2470. butEdit.pointerUpAnimation = function () {
  2471. butEdit.background = buttonBackgroundHoverColor;
  2472. };
  2473. butEdit.onPointerClickObservable.add(function () {
  2474. if (editSwatchMode) {
  2475. editSwatchMode = false;
  2476. }
  2477. else {
  2478. editSwatchMode = true;
  2479. }
  2480. editSwatches();
  2481. });
  2482. pickerGrid.addControl(butEdit, 1, 0);
  2483. }
  2484. else {
  2485. pickerGrid.removeControl(butEdit);
  2486. }
  2487. }
  2488. // Called when the user hits the limit of saved colors in the drawer.
  2489. function disableButton(button, disabled) {
  2490. if (disabled) {
  2491. button.color = buttonDisabledColor;
  2492. button.background = buttonDisabledBackgroundColor;
  2493. }
  2494. else {
  2495. button.color = buttonColor;
  2496. button.background = buttonBackgroundColor;
  2497. }
  2498. }
  2499. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2500. function closePicker(color) {
  2501. if (options.savedColors && options.savedColors.length > 0) {
  2502. resolve({
  2503. savedColors: options.savedColors,
  2504. pickedColor: color
  2505. });
  2506. }
  2507. else {
  2508. resolve({
  2509. pickedColor: color
  2510. });
  2511. }
  2512. advancedTexture.removeControl(dialogContainer);
  2513. }
  2514. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2515. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2516. dialogContainer.name = "Dialog Container";
  2517. dialogContainer.width = options.pickerWidth;
  2518. if (options.savedColors) {
  2519. dialogContainer.height = containerSize;
  2520. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2521. dialogContainer.addRowDefinition(topRow, false);
  2522. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2523. }
  2524. else {
  2525. dialogContainer.height = options.pickerHeight;
  2526. dialogContainer.addRowDefinition(1.0, false);
  2527. }
  2528. advancedTexture.addControl(dialogContainer);
  2529. // Swatch drawer which contains all saved color buttons
  2530. if (options.savedColors) {
  2531. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2532. swatchDrawer.name = "Swatch Drawer";
  2533. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2534. swatchDrawer.background = buttonBackgroundColor;
  2535. swatchDrawer.width = options.pickerWidth;
  2536. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2537. if (initialRows == 0) {
  2538. var gutterCount = 0;
  2539. }
  2540. else {
  2541. var gutterCount = initialRows + 1;
  2542. }
  2543. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2544. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2545. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2546. if (i % 2 != 0) {
  2547. swatchDrawer.addRowDefinition(swatchSize, true);
  2548. }
  2549. else {
  2550. swatchDrawer.addRowDefinition(gutterSize, true);
  2551. }
  2552. }
  2553. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2554. if (i % 2 != 0) {
  2555. swatchDrawer.addColumnDefinition(swatchSize, true);
  2556. }
  2557. else {
  2558. swatchDrawer.addColumnDefinition(gutterSize, true);
  2559. }
  2560. }
  2561. dialogContainer.addControl(swatchDrawer, 1, 0);
  2562. }
  2563. // Picker container
  2564. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2565. pickerPanel.name = "Picker Panel";
  2566. pickerPanel.height = options.pickerHeight;
  2567. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2568. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2569. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2570. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2571. dialogContainer.addControl(pickerPanel, 0, 0);
  2572. // Picker container header
  2573. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2574. header.name = "Dialogue Header Bar";
  2575. header.background = "#cccccc";
  2576. header.thickness = 0;
  2577. pickerPanel.addControl(header, 0, 0);
  2578. // Header close button
  2579. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2580. closeButton.fontFamily = "BabylonJSglyphs";
  2581. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2582. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2583. closeButton.color = closeIconColor.toHexString();
  2584. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2585. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2586. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2587. closeButton.height = closeButton.width = options.headerHeight;
  2588. closeButton.background = header.background;
  2589. closeButton.thickness = 0;
  2590. closeButton.pointerDownAnimation = function () {
  2591. };
  2592. closeButton.pointerUpAnimation = function () {
  2593. closeButton.background = header.background;
  2594. };
  2595. closeButton.pointerEnterAnimation = function () {
  2596. closeButton.color = header.background;
  2597. closeButton.background = "red";
  2598. };
  2599. closeButton.pointerOutAnimation = function () {
  2600. closeButton.color = closeIconColor.toHexString();
  2601. closeButton.background = header.background;
  2602. };
  2603. closeButton.onPointerClickObservable.add(function () {
  2604. closePicker(currentSwatch.background);
  2605. });
  2606. pickerPanel.addControl(closeButton, 0, 0);
  2607. // Dialog container body
  2608. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2609. dialogBody.name = "Dialogue Body";
  2610. dialogBody.background = buttonBackgroundColor;
  2611. var dialogBodyCols = [0.4375, 0.5625];
  2612. dialogBody.addRowDefinition(1.0, false);
  2613. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2614. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2615. pickerPanel.addControl(dialogBody, 1, 0);
  2616. // Picker grid
  2617. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2618. pickerGrid.name = "Picker Grid";
  2619. pickerGrid.addRowDefinition(0.85, false);
  2620. pickerGrid.addRowDefinition(0.15, false);
  2621. dialogBody.addControl(pickerGrid, 0, 0);
  2622. // Picker control
  2623. picker = new ColorPicker();
  2624. picker.name = "GUI Color Picker";
  2625. if (options.pickerHeight < options.pickerWidth) {
  2626. picker.width = 0.89;
  2627. }
  2628. else {
  2629. picker.height = 0.89;
  2630. }
  2631. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2632. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2633. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2634. picker.onPointerDownObservable.add(function () {
  2635. activeField = picker.name;
  2636. lastVal = "";
  2637. editSwatches(false);
  2638. });
  2639. picker.onValueChangedObservable.add(function (value) {
  2640. if (activeField == picker.name) {
  2641. updateValues(value, picker.name);
  2642. }
  2643. });
  2644. pickerGrid.addControl(picker, 0, 0);
  2645. // Picker body right quarant
  2646. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2647. pickerBodyRight.name = "Dialogue Right Half";
  2648. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2649. var pickerBodyRightRows = [0.514, 0.486];
  2650. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2651. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2652. dialogBody.addControl(pickerBodyRight, 1, 1);
  2653. // Picker container swatches and buttons
  2654. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2655. pickerSwatchesButtons.name = "Swatches and Buttons";
  2656. var pickerButtonsCol = [0.417, 0.583];
  2657. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2658. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2659. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2660. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2661. // Picker Swatches quadrant
  2662. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2663. pickerSwatches.name = "New and Current Swatches";
  2664. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2665. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2666. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2667. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2668. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2669. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2670. // Active swatches
  2671. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2672. activeSwatches.name = "Active Swatches";
  2673. activeSwatches.width = 0.67;
  2674. activeSwatches.addRowDefinition(0.5, false);
  2675. activeSwatches.addRowDefinition(0.5, false);
  2676. pickerSwatches.addControl(activeSwatches, 2, 0);
  2677. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2678. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2679. if (options.pickerWidth > options.pickerHeight) {
  2680. var labelTextSize = labelHeight;
  2681. }
  2682. else {
  2683. var labelTextSize = labelWidth;
  2684. }
  2685. // New color swatch and previous color button
  2686. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2687. newText.text = "new";
  2688. newText.name = "New Color Label";
  2689. newText.color = buttonColor;
  2690. newText.fontSize = labelTextSize;
  2691. pickerSwatches.addControl(newText, 1, 0);
  2692. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2693. newSwatch.name = "New Color Swatch";
  2694. newSwatch.background = options.lastColor;
  2695. newSwatch.thickness = 0;
  2696. activeSwatches.addControl(newSwatch, 0, 0);
  2697. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2698. currentSwatch.background = options.lastColor;
  2699. currentSwatch.thickness = 0;
  2700. currentSwatch.onPointerClickObservable.add(function () {
  2701. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2702. updateValues(revertColor, currentSwatch.name);
  2703. editSwatches(false);
  2704. });
  2705. currentSwatch.pointerDownAnimation = function () { };
  2706. currentSwatch.pointerUpAnimation = function () { };
  2707. currentSwatch.pointerEnterAnimation = function () { };
  2708. currentSwatch.pointerOutAnimation = function () { };
  2709. activeSwatches.addControl(currentSwatch, 1, 0);
  2710. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2711. swatchOutline.name = "Swatch Outline";
  2712. swatchOutline.width = 0.67;
  2713. swatchOutline.thickness = 2;
  2714. swatchOutline.color = currentSwatchesOutlineColor;
  2715. swatchOutline.isHitTestVisible = false;
  2716. pickerSwatches.addControl(swatchOutline, 2, 0);
  2717. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2718. currentText.name = "Current Color Label";
  2719. currentText.text = "current";
  2720. currentText.color = buttonColor;
  2721. currentText.fontSize = labelTextSize;
  2722. pickerSwatches.addControl(currentText, 3, 0);
  2723. // Buttons grid
  2724. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2725. buttonGrid.name = "Button Grid";
  2726. buttonGrid.height = 0.8;
  2727. var buttonGridRows = 1 / 3;
  2728. buttonGrid.addRowDefinition(buttonGridRows, false);
  2729. buttonGrid.addRowDefinition(buttonGridRows, false);
  2730. buttonGrid.addRowDefinition(buttonGridRows, false);
  2731. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2732. // Determine pixel width and height for all buttons from overall panel dimensions
  2733. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2734. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2735. // Determine button type size
  2736. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2737. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2738. }
  2739. else {
  2740. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2741. }
  2742. // Panel Buttons
  2743. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2744. butOK.width = buttonWidth;
  2745. butOK.height = buttonHeight;
  2746. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2747. butOK.thickness = 2;
  2748. butOK.color = buttonColor;
  2749. butOK.fontSize = buttonFontSize;
  2750. butOK.background = buttonBackgroundColor;
  2751. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2752. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2753. butOK.pointerDownAnimation = function () {
  2754. butOK.background = buttonBackgroundClickColor;
  2755. };
  2756. butOK.pointerUpAnimation = function () {
  2757. butOK.background = buttonBackgroundHoverColor;
  2758. };
  2759. butOK.onPointerClickObservable.add(function () {
  2760. editSwatches(false);
  2761. closePicker(newSwatch.background);
  2762. });
  2763. buttonGrid.addControl(butOK, 0, 0);
  2764. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2765. butCancel.width = buttonWidth;
  2766. butCancel.height = buttonHeight;
  2767. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2768. butCancel.thickness = 2;
  2769. butCancel.color = buttonColor;
  2770. butCancel.fontSize = buttonFontSize;
  2771. butCancel.background = buttonBackgroundColor;
  2772. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2773. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2774. butCancel.pointerDownAnimation = function () {
  2775. butCancel.background = buttonBackgroundClickColor;
  2776. };
  2777. butCancel.pointerUpAnimation = function () {
  2778. butCancel.background = buttonBackgroundHoverColor;
  2779. };
  2780. butCancel.onPointerClickObservable.add(function () {
  2781. editSwatches(false);
  2782. closePicker(currentSwatch.background);
  2783. });
  2784. buttonGrid.addControl(butCancel, 1, 0);
  2785. if (options.savedColors) {
  2786. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2787. butSave.width = buttonWidth;
  2788. butSave.height = buttonHeight;
  2789. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2790. butSave.thickness = 2;
  2791. butSave.fontSize = buttonFontSize;
  2792. if (options.savedColors.length < options.swatchLimit) {
  2793. butSave.color = buttonColor;
  2794. butSave.background = buttonBackgroundColor;
  2795. }
  2796. else {
  2797. disableButton(butSave, true);
  2798. }
  2799. butSave.onPointerEnterObservable.add(function () {
  2800. if (options.savedColors) {
  2801. if (options.savedColors.length < options.swatchLimit) {
  2802. butSave.background = buttonBackgroundHoverColor;
  2803. }
  2804. }
  2805. });
  2806. butSave.onPointerOutObservable.add(function () {
  2807. if (options.savedColors) {
  2808. if (options.savedColors.length < options.swatchLimit) {
  2809. butSave.background = buttonBackgroundColor;
  2810. }
  2811. }
  2812. });
  2813. butSave.pointerDownAnimation = function () {
  2814. if (options.savedColors) {
  2815. if (options.savedColors.length < options.swatchLimit) {
  2816. butSave.background = buttonBackgroundClickColor;
  2817. }
  2818. }
  2819. };
  2820. butSave.pointerUpAnimation = function () {
  2821. if (options.savedColors) {
  2822. if (options.savedColors.length < options.swatchLimit) {
  2823. butSave.background = buttonBackgroundHoverColor;
  2824. }
  2825. }
  2826. };
  2827. butSave.onPointerClickObservable.add(function () {
  2828. if (options.savedColors) {
  2829. if (options.savedColors.length == 0) {
  2830. setEditButtonVisibility(true);
  2831. }
  2832. if (options.savedColors.length < options.swatchLimit) {
  2833. updateSwatches(newSwatch.background, butSave);
  2834. }
  2835. editSwatches(false);
  2836. }
  2837. });
  2838. if (options.savedColors.length > 0) {
  2839. setEditButtonVisibility(true);
  2840. }
  2841. buttonGrid.addControl(butSave, 2, 0);
  2842. }
  2843. // Picker color values input
  2844. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2845. pickerColorValues.name = "Dialog Lower Right";
  2846. pickerColorValues.addRowDefinition(0.02, false);
  2847. pickerColorValues.addRowDefinition(0.63, false);
  2848. pickerColorValues.addRowDefinition(0.21, false);
  2849. pickerColorValues.addRowDefinition(0.14, false);
  2850. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2851. // RGB values text boxes
  2852. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2853. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2854. rgbValuesQuadrant.name = "RGB Values";
  2855. rgbValuesQuadrant.width = 0.82;
  2856. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2857. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2858. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2859. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2860. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2861. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2862. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2863. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2864. for (var i = 0; i < inputFieldLabels.length; i++) {
  2865. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2866. labelText.text = inputFieldLabels[i];
  2867. labelText.color = buttonColor;
  2868. labelText.fontSize = buttonFontSize;
  2869. rgbValuesQuadrant.addControl(labelText, i, 0);
  2870. }
  2871. // Input fields for RGB values
  2872. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2873. rValInt.width = 0.83;
  2874. rValInt.height = 0.72;
  2875. rValInt.name = "rIntField";
  2876. rValInt.fontSize = buttonFontSize;
  2877. rValInt.text = (currentColor.r * 255).toString();
  2878. rValInt.color = inputTextColor;
  2879. rValInt.background = inputTextBackgroundColor;
  2880. rValInt.onFocusObservable.add(function () {
  2881. activeField = rValInt.name;
  2882. lastVal = rValInt.text;
  2883. editSwatches(false);
  2884. });
  2885. rValInt.onBlurObservable.add(function () {
  2886. if (rValInt.text == "") {
  2887. rValInt.text = "0";
  2888. }
  2889. updateInt(rValInt, "r");
  2890. if (activeField == rValInt.name) {
  2891. activeField = "";
  2892. }
  2893. });
  2894. rValInt.onTextChangedObservable.add(function () {
  2895. if (activeField == rValInt.name) {
  2896. updateInt(rValInt, "r");
  2897. }
  2898. });
  2899. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2900. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2901. gValInt.width = 0.83;
  2902. gValInt.height = 0.72;
  2903. gValInt.name = "gIntField";
  2904. gValInt.fontSize = buttonFontSize;
  2905. gValInt.text = (currentColor.g * 255).toString();
  2906. gValInt.color = inputTextColor;
  2907. gValInt.background = inputTextBackgroundColor;
  2908. gValInt.onFocusObservable.add(function () {
  2909. activeField = gValInt.name;
  2910. lastVal = gValInt.text;
  2911. editSwatches(false);
  2912. });
  2913. gValInt.onBlurObservable.add(function () {
  2914. if (gValInt.text == "") {
  2915. gValInt.text = "0";
  2916. }
  2917. updateInt(gValInt, "g");
  2918. if (activeField == gValInt.name) {
  2919. activeField = "";
  2920. }
  2921. });
  2922. gValInt.onTextChangedObservable.add(function () {
  2923. if (activeField == gValInt.name) {
  2924. updateInt(gValInt, "g");
  2925. }
  2926. });
  2927. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2928. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2929. bValInt.width = 0.83;
  2930. bValInt.height = 0.72;
  2931. bValInt.name = "bIntField";
  2932. bValInt.fontSize = buttonFontSize;
  2933. bValInt.text = (currentColor.b * 255).toString();
  2934. bValInt.color = inputTextColor;
  2935. bValInt.background = inputTextBackgroundColor;
  2936. bValInt.onFocusObservable.add(function () {
  2937. activeField = bValInt.name;
  2938. lastVal = bValInt.text;
  2939. editSwatches(false);
  2940. });
  2941. bValInt.onBlurObservable.add(function () {
  2942. if (bValInt.text == "") {
  2943. bValInt.text = "0";
  2944. }
  2945. updateInt(bValInt, "b");
  2946. if (activeField == bValInt.name) {
  2947. activeField = "";
  2948. }
  2949. });
  2950. bValInt.onTextChangedObservable.add(function () {
  2951. if (activeField == bValInt.name) {
  2952. updateInt(bValInt, "b");
  2953. }
  2954. });
  2955. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2956. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2957. rValDec.width = 0.95;
  2958. rValDec.height = 0.72;
  2959. rValDec.name = "rDecField";
  2960. rValDec.fontSize = buttonFontSize;
  2961. rValDec.text = currentColor.r.toString();
  2962. rValDec.color = inputTextColor;
  2963. rValDec.background = inputTextBackgroundColor;
  2964. rValDec.onFocusObservable.add(function () {
  2965. activeField = rValDec.name;
  2966. lastVal = rValDec.text;
  2967. editSwatches(false);
  2968. });
  2969. rValDec.onBlurObservable.add(function () {
  2970. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2971. rValDec.text = "0";
  2972. updateFloat(rValDec, "r");
  2973. }
  2974. if (activeField == rValDec.name) {
  2975. activeField = "";
  2976. }
  2977. });
  2978. rValDec.onTextChangedObservable.add(function () {
  2979. if (activeField == rValDec.name) {
  2980. updateFloat(rValDec, "r");
  2981. }
  2982. });
  2983. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  2984. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2985. gValDec.width = 0.95;
  2986. gValDec.height = 0.72;
  2987. gValDec.name = "gDecField";
  2988. gValDec.fontSize = buttonFontSize;
  2989. gValDec.text = currentColor.g.toString();
  2990. gValDec.color = inputTextColor;
  2991. gValDec.background = inputTextBackgroundColor;
  2992. gValDec.onFocusObservable.add(function () {
  2993. activeField = gValDec.name;
  2994. lastVal = gValDec.text;
  2995. editSwatches(false);
  2996. });
  2997. gValDec.onBlurObservable.add(function () {
  2998. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  2999. gValDec.text = "0";
  3000. updateFloat(gValDec, "g");
  3001. }
  3002. if (activeField == gValDec.name) {
  3003. activeField = "";
  3004. }
  3005. });
  3006. gValDec.onTextChangedObservable.add(function () {
  3007. if (activeField == gValDec.name) {
  3008. updateFloat(gValDec, "g");
  3009. }
  3010. });
  3011. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3012. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3013. bValDec.width = 0.95;
  3014. bValDec.height = 0.72;
  3015. bValDec.name = "bDecField";
  3016. bValDec.fontSize = buttonFontSize;
  3017. bValDec.text = currentColor.b.toString();
  3018. bValDec.color = inputTextColor;
  3019. bValDec.background = inputTextBackgroundColor;
  3020. bValDec.onFocusObservable.add(function () {
  3021. activeField = bValDec.name;
  3022. lastVal = bValDec.text;
  3023. editSwatches(false);
  3024. });
  3025. bValDec.onBlurObservable.add(function () {
  3026. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3027. bValDec.text = "0";
  3028. updateFloat(bValDec, "b");
  3029. }
  3030. if (activeField == bValDec.name) {
  3031. activeField = "";
  3032. }
  3033. });
  3034. bValDec.onTextChangedObservable.add(function () {
  3035. if (activeField == bValDec.name) {
  3036. updateFloat(bValDec, "b");
  3037. }
  3038. });
  3039. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3040. // Hex value input
  3041. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3042. hexValueQuadrant.name = "Hex Value";
  3043. hexValueQuadrant.width = 0.82;
  3044. hexValueQuadrant.addRowDefinition(1.0, false);
  3045. hexValueQuadrant.addColumnDefinition(0.1, false);
  3046. hexValueQuadrant.addColumnDefinition(0.9, false);
  3047. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3048. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3049. labelText.text = "#";
  3050. labelText.color = buttonColor;
  3051. labelText.fontSize = buttonFontSize;
  3052. hexValueQuadrant.addControl(labelText, 0, 0);
  3053. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3054. hexVal.width = 0.96;
  3055. hexVal.height = 0.72;
  3056. hexVal.name = "hexField";
  3057. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3058. hexVal.fontSize = buttonFontSize;
  3059. var minusPound = options.lastColor.split("#");
  3060. hexVal.text = minusPound[1];
  3061. hexVal.color = inputTextColor;
  3062. hexVal.background = inputTextBackgroundColor;
  3063. hexVal.onFocusObservable.add(function () {
  3064. activeField = hexVal.name;
  3065. lastVal = hexVal.text;
  3066. editSwatches(false);
  3067. });
  3068. hexVal.onBlurObservable.add(function () {
  3069. if (hexVal.text.length == 3) {
  3070. var val = hexVal.text.split("");
  3071. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3072. }
  3073. if (hexVal.text == "") {
  3074. hexVal.text = "000000";
  3075. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3076. }
  3077. if (activeField == hexVal.name) {
  3078. activeField = "";
  3079. }
  3080. });
  3081. hexVal.onTextChangedObservable.add(function () {
  3082. var newHexValue = hexVal.text;
  3083. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3084. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3085. hexVal.text = lastVal;
  3086. }
  3087. else {
  3088. if (hexVal.text.length < 6) {
  3089. var leadingZero = 6 - hexVal.text.length;
  3090. for (var i = 0; i < leadingZero; i++) {
  3091. newHexValue = "0" + newHexValue;
  3092. }
  3093. }
  3094. if (hexVal.text.length == 3) {
  3095. var val = hexVal.text.split("");
  3096. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3097. }
  3098. newHexValue = "#" + newHexValue;
  3099. if (activeField == hexVal.name) {
  3100. lastVal = hexVal.text;
  3101. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3102. }
  3103. }
  3104. });
  3105. hexValueQuadrant.addControl(hexVal, 0, 1);
  3106. if (options.savedColors && options.savedColors.length > 0) {
  3107. updateSwatches("", butSave);
  3108. }
  3109. });
  3110. };
  3111. ColorPicker._Epsilon = 0.000001;
  3112. return ColorPicker;
  3113. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3114. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3115. /***/ }),
  3116. /***/ "./2D/controls/container.ts":
  3117. /*!**********************************!*\
  3118. !*** ./2D/controls/container.ts ***!
  3119. \**********************************/
  3120. /*! exports provided: Container */
  3121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3122. "use strict";
  3123. __webpack_require__.r(__webpack_exports__);
  3124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3125. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3126. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/perfCounter");
  3127. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3128. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3129. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3130. /**
  3131. * Root class for 2D containers
  3132. * @see http://doc.babylonjs.com/how_to/gui#containers
  3133. */
  3134. var Container = /** @class */ (function (_super) {
  3135. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3136. /**
  3137. * Creates a new Container
  3138. * @param name defines the name of the container
  3139. */
  3140. function Container(name) {
  3141. var _this = _super.call(this, name) || this;
  3142. _this.name = name;
  3143. /** @hidden */
  3144. _this._children = new Array();
  3145. /** @hidden */
  3146. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3147. /** @hidden */
  3148. _this._background = "";
  3149. /** @hidden */
  3150. _this._adaptWidthToChildren = false;
  3151. /** @hidden */
  3152. _this._adaptHeightToChildren = false;
  3153. /**
  3154. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3155. */
  3156. _this.logLayoutCycleErrors = false;
  3157. /**
  3158. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3159. */
  3160. _this.maxLayoutCycle = 3;
  3161. return _this;
  3162. }
  3163. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3164. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3165. get: function () {
  3166. return this._adaptHeightToChildren;
  3167. },
  3168. set: function (value) {
  3169. if (this._adaptHeightToChildren === value) {
  3170. return;
  3171. }
  3172. this._adaptHeightToChildren = value;
  3173. if (value) {
  3174. this.height = "100%";
  3175. }
  3176. this._markAsDirty();
  3177. },
  3178. enumerable: true,
  3179. configurable: true
  3180. });
  3181. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3182. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3183. get: function () {
  3184. return this._adaptWidthToChildren;
  3185. },
  3186. set: function (value) {
  3187. if (this._adaptWidthToChildren === value) {
  3188. return;
  3189. }
  3190. this._adaptWidthToChildren = value;
  3191. if (value) {
  3192. this.width = "100%";
  3193. }
  3194. this._markAsDirty();
  3195. },
  3196. enumerable: true,
  3197. configurable: true
  3198. });
  3199. Object.defineProperty(Container.prototype, "background", {
  3200. /** Gets or sets background color */
  3201. get: function () {
  3202. return this._background;
  3203. },
  3204. set: function (value) {
  3205. if (this._background === value) {
  3206. return;
  3207. }
  3208. this._background = value;
  3209. this._markAsDirty();
  3210. },
  3211. enumerable: true,
  3212. configurable: true
  3213. });
  3214. Object.defineProperty(Container.prototype, "children", {
  3215. /** Gets the list of children */
  3216. get: function () {
  3217. return this._children;
  3218. },
  3219. enumerable: true,
  3220. configurable: true
  3221. });
  3222. Container.prototype._getTypeName = function () {
  3223. return "Container";
  3224. };
  3225. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3226. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3227. var child = _a[_i];
  3228. child._markMatrixAsDirty();
  3229. }
  3230. };
  3231. /**
  3232. * Gets a child using its name
  3233. * @param name defines the child name to look for
  3234. * @returns the child control if found
  3235. */
  3236. Container.prototype.getChildByName = function (name) {
  3237. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3238. var child = _a[_i];
  3239. if (child.name === name) {
  3240. return child;
  3241. }
  3242. }
  3243. return null;
  3244. };
  3245. /**
  3246. * Gets a child using its type and its name
  3247. * @param name defines the child name to look for
  3248. * @param type defines the child type to look for
  3249. * @returns the child control if found
  3250. */
  3251. Container.prototype.getChildByType = function (name, type) {
  3252. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3253. var child = _a[_i];
  3254. if (child.typeName === type) {
  3255. return child;
  3256. }
  3257. }
  3258. return null;
  3259. };
  3260. /**
  3261. * Search for a specific control in children
  3262. * @param control defines the control to look for
  3263. * @returns true if the control is in child list
  3264. */
  3265. Container.prototype.containsControl = function (control) {
  3266. return this.children.indexOf(control) !== -1;
  3267. };
  3268. /**
  3269. * Adds a new control to the current container
  3270. * @param control defines the control to add
  3271. * @returns the current container
  3272. */
  3273. Container.prototype.addControl = function (control) {
  3274. if (!control) {
  3275. return this;
  3276. }
  3277. var index = this._children.indexOf(control);
  3278. if (index !== -1) {
  3279. return this;
  3280. }
  3281. control._link(this._host);
  3282. control._markAllAsDirty();
  3283. this._reOrderControl(control);
  3284. this._markAsDirty();
  3285. return this;
  3286. };
  3287. /**
  3288. * Removes all controls from the current container
  3289. * @returns the current container
  3290. */
  3291. Container.prototype.clearControls = function () {
  3292. var children = this.children.slice();
  3293. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3294. var child = children_1[_i];
  3295. this.removeControl(child);
  3296. }
  3297. return this;
  3298. };
  3299. /**
  3300. * Removes a control from the current container
  3301. * @param control defines the control to remove
  3302. * @returns the current container
  3303. */
  3304. Container.prototype.removeControl = function (control) {
  3305. var index = this._children.indexOf(control);
  3306. if (index !== -1) {
  3307. this._children.splice(index, 1);
  3308. control.parent = null;
  3309. }
  3310. control.linkWithMesh(null);
  3311. if (this._host) {
  3312. this._host._cleanControlAfterRemoval(control);
  3313. }
  3314. this._markAsDirty();
  3315. return this;
  3316. };
  3317. /** @hidden */
  3318. Container.prototype._reOrderControl = function (control) {
  3319. this.removeControl(control);
  3320. var wasAdded = false;
  3321. for (var index = 0; index < this._children.length; index++) {
  3322. if (this._children[index].zIndex > control.zIndex) {
  3323. this._children.splice(index, 0, control);
  3324. wasAdded = true;
  3325. break;
  3326. }
  3327. }
  3328. if (!wasAdded) {
  3329. this._children.push(control);
  3330. }
  3331. control.parent = this;
  3332. this._markAsDirty();
  3333. };
  3334. /** @hidden */
  3335. Container.prototype._offsetLeft = function (offset) {
  3336. _super.prototype._offsetLeft.call(this, offset);
  3337. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3338. var child = _a[_i];
  3339. child._offsetLeft(offset);
  3340. }
  3341. };
  3342. /** @hidden */
  3343. Container.prototype._offsetTop = function (offset) {
  3344. _super.prototype._offsetTop.call(this, offset);
  3345. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3346. var child = _a[_i];
  3347. child._offsetTop(offset);
  3348. }
  3349. };
  3350. /** @hidden */
  3351. Container.prototype._markAllAsDirty = function () {
  3352. _super.prototype._markAllAsDirty.call(this);
  3353. for (var index = 0; index < this._children.length; index++) {
  3354. this._children[index]._markAllAsDirty();
  3355. }
  3356. };
  3357. /** @hidden */
  3358. Container.prototype._localDraw = function (context) {
  3359. if (this._background) {
  3360. context.save();
  3361. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3362. context.shadowColor = this.shadowColor;
  3363. context.shadowBlur = this.shadowBlur;
  3364. context.shadowOffsetX = this.shadowOffsetX;
  3365. context.shadowOffsetY = this.shadowOffsetY;
  3366. }
  3367. context.fillStyle = this._background;
  3368. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3369. context.restore();
  3370. }
  3371. };
  3372. /** @hidden */
  3373. Container.prototype._link = function (host) {
  3374. _super.prototype._link.call(this, host);
  3375. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3376. var child = _a[_i];
  3377. child._link(host);
  3378. }
  3379. };
  3380. /** @hidden */
  3381. Container.prototype._beforeLayout = function () {
  3382. // Do nothing
  3383. };
  3384. /** @hidden */
  3385. Container.prototype._processMeasures = function (parentMeasure, context) {
  3386. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3387. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3388. this._evaluateClippingState(parentMeasure);
  3389. }
  3390. };
  3391. /** @hidden */
  3392. Container.prototype._layout = function (parentMeasure, context) {
  3393. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3394. return false;
  3395. }
  3396. if (this._isDirty) {
  3397. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3398. }
  3399. var rebuildCount = 0;
  3400. context.save();
  3401. this._applyStates(context);
  3402. this._beforeLayout();
  3403. do {
  3404. var computedWidth = -1;
  3405. var computedHeight = -1;
  3406. this._rebuildLayout = false;
  3407. this._processMeasures(parentMeasure, context);
  3408. if (!this._isClipped) {
  3409. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3410. var child = _a[_i];
  3411. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3412. if (child._layout(this._measureForChildren, context)) {
  3413. if (this.adaptWidthToChildren && child._width.isPixel) {
  3414. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3415. }
  3416. if (this.adaptHeightToChildren && child._height.isPixel) {
  3417. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3418. }
  3419. }
  3420. }
  3421. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3422. if (this.width !== computedWidth + "px") {
  3423. this.width = computedWidth + "px";
  3424. this._rebuildLayout = true;
  3425. }
  3426. }
  3427. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3428. if (this.height !== computedHeight + "px") {
  3429. this.height = computedHeight + "px";
  3430. this._rebuildLayout = true;
  3431. }
  3432. }
  3433. this._postMeasure();
  3434. }
  3435. rebuildCount++;
  3436. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3437. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3438. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3439. }
  3440. context.restore();
  3441. if (this._isDirty) {
  3442. this.invalidateRect();
  3443. this._isDirty = false;
  3444. }
  3445. return true;
  3446. };
  3447. Container.prototype._postMeasure = function () {
  3448. // Do nothing by default
  3449. };
  3450. /** @hidden */
  3451. Container.prototype._draw = function (context, invalidatedRectangle) {
  3452. this._localDraw(context);
  3453. if (this.clipChildren) {
  3454. this._clipForChildren(context);
  3455. }
  3456. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3457. var child = _a[_i];
  3458. // Only redraw parts of the screen that are invalidated
  3459. if (invalidatedRectangle) {
  3460. if (!child._intersectsRect(invalidatedRectangle)) {
  3461. continue;
  3462. }
  3463. }
  3464. child._render(context, invalidatedRectangle);
  3465. }
  3466. };
  3467. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3468. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3469. if (!this.children) {
  3470. return;
  3471. }
  3472. for (var index = 0; index < this.children.length; index++) {
  3473. var item = this.children[index];
  3474. if (!predicate || predicate(item)) {
  3475. results.push(item);
  3476. }
  3477. if (!directDescendantsOnly) {
  3478. item.getDescendantsToRef(results, false, predicate);
  3479. }
  3480. }
  3481. };
  3482. /** @hidden */
  3483. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3484. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3485. return false;
  3486. }
  3487. if (!_super.prototype.contains.call(this, x, y)) {
  3488. return false;
  3489. }
  3490. // Checking backwards to pick closest first
  3491. for (var index = this._children.length - 1; index >= 0; index--) {
  3492. var child = this._children[index];
  3493. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3494. if (child.hoverCursor) {
  3495. this._host._changeCursor(child.hoverCursor);
  3496. }
  3497. return true;
  3498. }
  3499. }
  3500. if (!this.isHitTestVisible) {
  3501. return false;
  3502. }
  3503. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3504. };
  3505. /** @hidden */
  3506. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3507. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3508. this._measureForChildren.copyFrom(this._currentMeasure);
  3509. };
  3510. /** Releases associated resources */
  3511. Container.prototype.dispose = function () {
  3512. _super.prototype.dispose.call(this);
  3513. for (var index = this.children.length - 1; index >= 0; index--) {
  3514. this.children[index].dispose();
  3515. }
  3516. };
  3517. return Container;
  3518. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3519. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3520. /***/ }),
  3521. /***/ "./2D/controls/control.ts":
  3522. /*!********************************!*\
  3523. !*** ./2D/controls/control.ts ***!
  3524. \********************************/
  3525. /*! exports provided: Control */
  3526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3527. "use strict";
  3528. __webpack_require__.r(__webpack_exports__);
  3529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3530. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  3531. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3532. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3533. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3534. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3535. /**
  3536. * Root class used for all 2D controls
  3537. * @see http://doc.babylonjs.com/how_to/gui#controls
  3538. */
  3539. var Control = /** @class */ (function () {
  3540. // Functions
  3541. /**
  3542. * Creates a new control
  3543. * @param name defines the name of the control
  3544. */
  3545. function Control(
  3546. /** defines the name of the control */
  3547. name) {
  3548. this.name = name;
  3549. this._alpha = 1;
  3550. this._alphaSet = false;
  3551. this._zIndex = 0;
  3552. /** @hidden */
  3553. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3554. this._fontFamily = "Arial";
  3555. this._fontStyle = "";
  3556. this._fontWeight = "";
  3557. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3558. /** @hidden */
  3559. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3560. /** @hidden */
  3561. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3562. this._color = "";
  3563. this._style = null;
  3564. /** @hidden */
  3565. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3566. /** @hidden */
  3567. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3568. /** @hidden */
  3569. this._isDirty = true;
  3570. /** @hidden */
  3571. this._wasDirty = false;
  3572. /** @hidden */
  3573. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3574. /** @hidden */
  3575. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3576. /** @hidden */
  3577. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3578. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3579. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3580. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3581. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3582. /** @hidden */
  3583. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3584. /** @hidden */
  3585. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3586. this._scaleX = 1.0;
  3587. this._scaleY = 1.0;
  3588. this._rotation = 0;
  3589. this._transformCenterX = 0.5;
  3590. this._transformCenterY = 0.5;
  3591. /** @hidden */
  3592. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3593. /** @hidden */
  3594. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3595. /** @hidden */
  3596. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3597. this._isMatrixDirty = true;
  3598. this._isVisible = true;
  3599. this._isHighlighted = false;
  3600. this._fontSet = false;
  3601. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3602. this._downCount = 0;
  3603. this._enterCount = -1;
  3604. this._doNotRender = false;
  3605. this._downPointerIds = {};
  3606. this._isEnabled = true;
  3607. this._disabledColor = "#9a9a9a";
  3608. /** @hidden */
  3609. this._rebuildLayout = false;
  3610. /** @hidden */
  3611. this._isClipped = false;
  3612. /** @hidden */
  3613. this._automaticSize = false;
  3614. /**
  3615. * Gets or sets an object used to store user defined information for the node
  3616. */
  3617. this.metadata = null;
  3618. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3619. this.isHitTestVisible = true;
  3620. /** Gets or sets a boolean indicating if the control can block pointer events */
  3621. this.isPointerBlocker = false;
  3622. /** Gets or sets a boolean indicating if the control can be focusable */
  3623. this.isFocusInvisible = false;
  3624. /**
  3625. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3626. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  3627. */
  3628. this.clipChildren = true;
  3629. /**
  3630. * Gets or sets a boolean indicating that control content must be clipped
  3631. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  3632. */
  3633. this.clipContent = true;
  3634. /**
  3635. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3636. */
  3637. this.useBitmapCache = false;
  3638. this._shadowOffsetX = 0;
  3639. this._shadowOffsetY = 0;
  3640. this._shadowBlur = 0;
  3641. this._shadowColor = 'black';
  3642. /** Gets or sets the cursor to use when the control is hovered */
  3643. this.hoverCursor = "";
  3644. /** @hidden */
  3645. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3646. /** @hidden */
  3647. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3648. /**
  3649. * An event triggered when the pointer move over the control.
  3650. */
  3651. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3652. /**
  3653. * An event triggered when the pointer move out of the control.
  3654. */
  3655. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3656. /**
  3657. * An event triggered when the pointer taps the control
  3658. */
  3659. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3660. /**
  3661. * An event triggered when pointer up
  3662. */
  3663. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3664. /**
  3665. * An event triggered when a control is clicked on
  3666. */
  3667. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3668. /**
  3669. * An event triggered when pointer enters the control
  3670. */
  3671. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3672. /**
  3673. * An event triggered when the control is marked as dirty
  3674. */
  3675. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3676. /**
  3677. * An event triggered before drawing the control
  3678. */
  3679. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3680. /**
  3681. * An event triggered after the control was drawn
  3682. */
  3683. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3684. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3685. }
  3686. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3687. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3688. get: function () {
  3689. return this._shadowOffsetX;
  3690. },
  3691. set: function (value) {
  3692. if (this._shadowOffsetX === value) {
  3693. return;
  3694. }
  3695. this._shadowOffsetX = value;
  3696. this._markAsDirty();
  3697. },
  3698. enumerable: true,
  3699. configurable: true
  3700. });
  3701. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3702. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3703. get: function () {
  3704. return this._shadowOffsetY;
  3705. },
  3706. set: function (value) {
  3707. if (this._shadowOffsetY === value) {
  3708. return;
  3709. }
  3710. this._shadowOffsetY = value;
  3711. this._markAsDirty();
  3712. },
  3713. enumerable: true,
  3714. configurable: true
  3715. });
  3716. Object.defineProperty(Control.prototype, "shadowBlur", {
  3717. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3718. get: function () {
  3719. return this._shadowBlur;
  3720. },
  3721. set: function (value) {
  3722. if (this._shadowBlur === value) {
  3723. return;
  3724. }
  3725. this._shadowBlur = value;
  3726. this._markAsDirty();
  3727. },
  3728. enumerable: true,
  3729. configurable: true
  3730. });
  3731. Object.defineProperty(Control.prototype, "shadowColor", {
  3732. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3733. get: function () {
  3734. return this._shadowColor;
  3735. },
  3736. set: function (value) {
  3737. if (this._shadowColor === value) {
  3738. return;
  3739. }
  3740. this._shadowColor = value;
  3741. this._markAsDirty();
  3742. },
  3743. enumerable: true,
  3744. configurable: true
  3745. });
  3746. Object.defineProperty(Control.prototype, "typeName", {
  3747. // Properties
  3748. /** Gets the control type name */
  3749. get: function () {
  3750. return this._getTypeName();
  3751. },
  3752. enumerable: true,
  3753. configurable: true
  3754. });
  3755. /**
  3756. * Get the current class name of the control.
  3757. * @returns current class name
  3758. */
  3759. Control.prototype.getClassName = function () {
  3760. return this._getTypeName();
  3761. };
  3762. Object.defineProperty(Control.prototype, "host", {
  3763. /**
  3764. * Get the hosting AdvancedDynamicTexture
  3765. */
  3766. get: function () {
  3767. return this._host;
  3768. },
  3769. enumerable: true,
  3770. configurable: true
  3771. });
  3772. Object.defineProperty(Control.prototype, "fontOffset", {
  3773. /** Gets or set information about font offsets (used to render and align text) */
  3774. get: function () {
  3775. return this._fontOffset;
  3776. },
  3777. set: function (offset) {
  3778. this._fontOffset = offset;
  3779. },
  3780. enumerable: true,
  3781. configurable: true
  3782. });
  3783. Object.defineProperty(Control.prototype, "alpha", {
  3784. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3785. get: function () {
  3786. return this._alpha;
  3787. },
  3788. set: function (value) {
  3789. if (this._alpha === value) {
  3790. return;
  3791. }
  3792. this._alphaSet = true;
  3793. this._alpha = value;
  3794. this._markAsDirty();
  3795. },
  3796. enumerable: true,
  3797. configurable: true
  3798. });
  3799. Object.defineProperty(Control.prototype, "isHighlighted", {
  3800. /**
  3801. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3802. */
  3803. get: function () {
  3804. return this._isHighlighted;
  3805. },
  3806. set: function (value) {
  3807. if (this._isHighlighted === value) {
  3808. return;
  3809. }
  3810. this._isHighlighted = value;
  3811. this._markAsDirty();
  3812. },
  3813. enumerable: true,
  3814. configurable: true
  3815. });
  3816. Object.defineProperty(Control.prototype, "scaleX", {
  3817. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3818. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3819. */
  3820. get: function () {
  3821. return this._scaleX;
  3822. },
  3823. set: function (value) {
  3824. if (this._scaleX === value) {
  3825. return;
  3826. }
  3827. this._scaleX = value;
  3828. this._markAsDirty();
  3829. this._markMatrixAsDirty();
  3830. },
  3831. enumerable: true,
  3832. configurable: true
  3833. });
  3834. Object.defineProperty(Control.prototype, "scaleY", {
  3835. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3836. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3837. */
  3838. get: function () {
  3839. return this._scaleY;
  3840. },
  3841. set: function (value) {
  3842. if (this._scaleY === value) {
  3843. return;
  3844. }
  3845. this._scaleY = value;
  3846. this._markAsDirty();
  3847. this._markMatrixAsDirty();
  3848. },
  3849. enumerable: true,
  3850. configurable: true
  3851. });
  3852. Object.defineProperty(Control.prototype, "rotation", {
  3853. /** Gets or sets the rotation angle (0 by default)
  3854. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3855. */
  3856. get: function () {
  3857. return this._rotation;
  3858. },
  3859. set: function (value) {
  3860. if (this._rotation === value) {
  3861. return;
  3862. }
  3863. this._rotation = value;
  3864. this._markAsDirty();
  3865. this._markMatrixAsDirty();
  3866. },
  3867. enumerable: true,
  3868. configurable: true
  3869. });
  3870. Object.defineProperty(Control.prototype, "transformCenterY", {
  3871. /** Gets or sets the transformation center on Y axis (0 by default)
  3872. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3873. */
  3874. get: function () {
  3875. return this._transformCenterY;
  3876. },
  3877. set: function (value) {
  3878. if (this._transformCenterY === value) {
  3879. return;
  3880. }
  3881. this._transformCenterY = value;
  3882. this._markAsDirty();
  3883. this._markMatrixAsDirty();
  3884. },
  3885. enumerable: true,
  3886. configurable: true
  3887. });
  3888. Object.defineProperty(Control.prototype, "transformCenterX", {
  3889. /** Gets or sets the transformation center on X axis (0 by default)
  3890. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3891. */
  3892. get: function () {
  3893. return this._transformCenterX;
  3894. },
  3895. set: function (value) {
  3896. if (this._transformCenterX === value) {
  3897. return;
  3898. }
  3899. this._transformCenterX = value;
  3900. this._markAsDirty();
  3901. this._markMatrixAsDirty();
  3902. },
  3903. enumerable: true,
  3904. configurable: true
  3905. });
  3906. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3907. /**
  3908. * Gets or sets the horizontal alignment
  3909. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3910. */
  3911. get: function () {
  3912. return this._horizontalAlignment;
  3913. },
  3914. set: function (value) {
  3915. if (this._horizontalAlignment === value) {
  3916. return;
  3917. }
  3918. this._horizontalAlignment = value;
  3919. this._markAsDirty();
  3920. },
  3921. enumerable: true,
  3922. configurable: true
  3923. });
  3924. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3925. /**
  3926. * Gets or sets the vertical alignment
  3927. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3928. */
  3929. get: function () {
  3930. return this._verticalAlignment;
  3931. },
  3932. set: function (value) {
  3933. if (this._verticalAlignment === value) {
  3934. return;
  3935. }
  3936. this._verticalAlignment = value;
  3937. this._markAsDirty();
  3938. },
  3939. enumerable: true,
  3940. configurable: true
  3941. });
  3942. Object.defineProperty(Control.prototype, "width", {
  3943. /**
  3944. * Gets or sets control width
  3945. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3946. */
  3947. get: function () {
  3948. return this._width.toString(this._host);
  3949. },
  3950. set: function (value) {
  3951. if (this._width.toString(this._host) === value) {
  3952. return;
  3953. }
  3954. if (this._width.fromString(value)) {
  3955. this._markAsDirty();
  3956. }
  3957. },
  3958. enumerable: true,
  3959. configurable: true
  3960. });
  3961. Object.defineProperty(Control.prototype, "widthInPixels", {
  3962. /**
  3963. * Gets or sets the control width in pixel
  3964. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3965. */
  3966. get: function () {
  3967. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3968. },
  3969. set: function (value) {
  3970. if (isNaN(value)) {
  3971. return;
  3972. }
  3973. this.width = value + "px";
  3974. },
  3975. enumerable: true,
  3976. configurable: true
  3977. });
  3978. Object.defineProperty(Control.prototype, "height", {
  3979. /**
  3980. * Gets or sets control height
  3981. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3982. */
  3983. get: function () {
  3984. return this._height.toString(this._host);
  3985. },
  3986. set: function (value) {
  3987. if (this._height.toString(this._host) === value) {
  3988. return;
  3989. }
  3990. if (this._height.fromString(value)) {
  3991. this._markAsDirty();
  3992. }
  3993. },
  3994. enumerable: true,
  3995. configurable: true
  3996. });
  3997. Object.defineProperty(Control.prototype, "heightInPixels", {
  3998. /**
  3999. * Gets or sets control height in pixel
  4000. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4001. */
  4002. get: function () {
  4003. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4004. },
  4005. set: function (value) {
  4006. if (isNaN(value)) {
  4007. return;
  4008. }
  4009. this.height = value + "px";
  4010. },
  4011. enumerable: true,
  4012. configurable: true
  4013. });
  4014. Object.defineProperty(Control.prototype, "fontFamily", {
  4015. /** Gets or set font family */
  4016. get: function () {
  4017. if (!this._fontSet) {
  4018. return "";
  4019. }
  4020. return this._fontFamily;
  4021. },
  4022. set: function (value) {
  4023. if (this._fontFamily === value) {
  4024. return;
  4025. }
  4026. this._fontFamily = value;
  4027. this._resetFontCache();
  4028. },
  4029. enumerable: true,
  4030. configurable: true
  4031. });
  4032. Object.defineProperty(Control.prototype, "fontStyle", {
  4033. /** Gets or sets font style */
  4034. get: function () {
  4035. return this._fontStyle;
  4036. },
  4037. set: function (value) {
  4038. if (this._fontStyle === value) {
  4039. return;
  4040. }
  4041. this._fontStyle = value;
  4042. this._resetFontCache();
  4043. },
  4044. enumerable: true,
  4045. configurable: true
  4046. });
  4047. Object.defineProperty(Control.prototype, "fontWeight", {
  4048. /** Gets or sets font weight */
  4049. get: function () {
  4050. return this._fontWeight;
  4051. },
  4052. set: function (value) {
  4053. if (this._fontWeight === value) {
  4054. return;
  4055. }
  4056. this._fontWeight = value;
  4057. this._resetFontCache();
  4058. },
  4059. enumerable: true,
  4060. configurable: true
  4061. });
  4062. Object.defineProperty(Control.prototype, "style", {
  4063. /**
  4064. * Gets or sets style
  4065. * @see http://doc.babylonjs.com/how_to/gui#styles
  4066. */
  4067. get: function () {
  4068. return this._style;
  4069. },
  4070. set: function (value) {
  4071. var _this = this;
  4072. if (this._style) {
  4073. this._style.onChangedObservable.remove(this._styleObserver);
  4074. this._styleObserver = null;
  4075. }
  4076. this._style = value;
  4077. if (this._style) {
  4078. this._styleObserver = this._style.onChangedObservable.add(function () {
  4079. _this._markAsDirty();
  4080. _this._resetFontCache();
  4081. });
  4082. }
  4083. this._markAsDirty();
  4084. this._resetFontCache();
  4085. },
  4086. enumerable: true,
  4087. configurable: true
  4088. });
  4089. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4090. /** @hidden */
  4091. get: function () {
  4092. return this._fontSize.isPercentage;
  4093. },
  4094. enumerable: true,
  4095. configurable: true
  4096. });
  4097. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4098. /** Gets or sets font size in pixels */
  4099. get: function () {
  4100. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4101. if (fontSizeToUse.isPixel) {
  4102. return fontSizeToUse.getValue(this._host);
  4103. }
  4104. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4105. },
  4106. set: function (value) {
  4107. if (isNaN(value)) {
  4108. return;
  4109. }
  4110. this.fontSize = value + "px";
  4111. },
  4112. enumerable: true,
  4113. configurable: true
  4114. });
  4115. Object.defineProperty(Control.prototype, "fontSize", {
  4116. /** Gets or sets font size */
  4117. get: function () {
  4118. return this._fontSize.toString(this._host);
  4119. },
  4120. set: function (value) {
  4121. if (this._fontSize.toString(this._host) === value) {
  4122. return;
  4123. }
  4124. if (this._fontSize.fromString(value)) {
  4125. this._markAsDirty();
  4126. this._resetFontCache();
  4127. }
  4128. },
  4129. enumerable: true,
  4130. configurable: true
  4131. });
  4132. Object.defineProperty(Control.prototype, "color", {
  4133. /** Gets or sets foreground color */
  4134. get: function () {
  4135. return this._color;
  4136. },
  4137. set: function (value) {
  4138. if (this._color === value) {
  4139. return;
  4140. }
  4141. this._color = value;
  4142. this._markAsDirty();
  4143. },
  4144. enumerable: true,
  4145. configurable: true
  4146. });
  4147. Object.defineProperty(Control.prototype, "zIndex", {
  4148. /** Gets or sets z index which is used to reorder controls on the z axis */
  4149. get: function () {
  4150. return this._zIndex;
  4151. },
  4152. set: function (value) {
  4153. if (this.zIndex === value) {
  4154. return;
  4155. }
  4156. this._zIndex = value;
  4157. if (this.parent) {
  4158. this.parent._reOrderControl(this);
  4159. }
  4160. },
  4161. enumerable: true,
  4162. configurable: true
  4163. });
  4164. Object.defineProperty(Control.prototype, "notRenderable", {
  4165. /** Gets or sets a boolean indicating if the control can be rendered */
  4166. get: function () {
  4167. return this._doNotRender;
  4168. },
  4169. set: function (value) {
  4170. if (this._doNotRender === value) {
  4171. return;
  4172. }
  4173. this._doNotRender = value;
  4174. this._markAsDirty();
  4175. },
  4176. enumerable: true,
  4177. configurable: true
  4178. });
  4179. Object.defineProperty(Control.prototype, "isVisible", {
  4180. /** Gets or sets a boolean indicating if the control is visible */
  4181. get: function () {
  4182. return this._isVisible;
  4183. },
  4184. set: function (value) {
  4185. if (this._isVisible === value) {
  4186. return;
  4187. }
  4188. this._isVisible = value;
  4189. this._markAsDirty(true);
  4190. },
  4191. enumerable: true,
  4192. configurable: true
  4193. });
  4194. Object.defineProperty(Control.prototype, "isDirty", {
  4195. /** Gets a boolean indicating that the control needs to update its rendering */
  4196. get: function () {
  4197. return this._isDirty;
  4198. },
  4199. enumerable: true,
  4200. configurable: true
  4201. });
  4202. Object.defineProperty(Control.prototype, "linkedMesh", {
  4203. /**
  4204. * Gets the current linked mesh (or null if none)
  4205. */
  4206. get: function () {
  4207. return this._linkedMesh;
  4208. },
  4209. enumerable: true,
  4210. configurable: true
  4211. });
  4212. Object.defineProperty(Control.prototype, "paddingLeft", {
  4213. /**
  4214. * Gets or sets a value indicating the padding to use on the left of the control
  4215. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4216. */
  4217. get: function () {
  4218. return this._paddingLeft.toString(this._host);
  4219. },
  4220. set: function (value) {
  4221. if (this._paddingLeft.fromString(value)) {
  4222. this._markAsDirty();
  4223. }
  4224. },
  4225. enumerable: true,
  4226. configurable: true
  4227. });
  4228. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4229. /**
  4230. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4231. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4232. */
  4233. get: function () {
  4234. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4235. },
  4236. set: function (value) {
  4237. if (isNaN(value)) {
  4238. return;
  4239. }
  4240. this.paddingLeft = value + "px";
  4241. },
  4242. enumerable: true,
  4243. configurable: true
  4244. });
  4245. Object.defineProperty(Control.prototype, "paddingRight", {
  4246. /**
  4247. * Gets or sets a value indicating the padding to use on the right of the control
  4248. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4249. */
  4250. get: function () {
  4251. return this._paddingRight.toString(this._host);
  4252. },
  4253. set: function (value) {
  4254. if (this._paddingRight.fromString(value)) {
  4255. this._markAsDirty();
  4256. }
  4257. },
  4258. enumerable: true,
  4259. configurable: true
  4260. });
  4261. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4262. /**
  4263. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4264. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4265. */
  4266. get: function () {
  4267. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4268. },
  4269. set: function (value) {
  4270. if (isNaN(value)) {
  4271. return;
  4272. }
  4273. this.paddingRight = value + "px";
  4274. },
  4275. enumerable: true,
  4276. configurable: true
  4277. });
  4278. Object.defineProperty(Control.prototype, "paddingTop", {
  4279. /**
  4280. * Gets or sets a value indicating the padding to use on the top of the control
  4281. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4282. */
  4283. get: function () {
  4284. return this._paddingTop.toString(this._host);
  4285. },
  4286. set: function (value) {
  4287. if (this._paddingTop.fromString(value)) {
  4288. this._markAsDirty();
  4289. }
  4290. },
  4291. enumerable: true,
  4292. configurable: true
  4293. });
  4294. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4295. /**
  4296. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4297. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4298. */
  4299. get: function () {
  4300. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4301. },
  4302. set: function (value) {
  4303. if (isNaN(value)) {
  4304. return;
  4305. }
  4306. this.paddingTop = value + "px";
  4307. },
  4308. enumerable: true,
  4309. configurable: true
  4310. });
  4311. Object.defineProperty(Control.prototype, "paddingBottom", {
  4312. /**
  4313. * Gets or sets a value indicating the padding to use on the bottom of the control
  4314. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4315. */
  4316. get: function () {
  4317. return this._paddingBottom.toString(this._host);
  4318. },
  4319. set: function (value) {
  4320. if (this._paddingBottom.fromString(value)) {
  4321. this._markAsDirty();
  4322. }
  4323. },
  4324. enumerable: true,
  4325. configurable: true
  4326. });
  4327. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4328. /**
  4329. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4330. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4331. */
  4332. get: function () {
  4333. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4334. },
  4335. set: function (value) {
  4336. if (isNaN(value)) {
  4337. return;
  4338. }
  4339. this.paddingBottom = value + "px";
  4340. },
  4341. enumerable: true,
  4342. configurable: true
  4343. });
  4344. Object.defineProperty(Control.prototype, "left", {
  4345. /**
  4346. * Gets or sets a value indicating the left coordinate of the control
  4347. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4348. */
  4349. get: function () {
  4350. return this._left.toString(this._host);
  4351. },
  4352. set: function (value) {
  4353. if (this._left.fromString(value)) {
  4354. this._markAsDirty();
  4355. }
  4356. },
  4357. enumerable: true,
  4358. configurable: true
  4359. });
  4360. Object.defineProperty(Control.prototype, "leftInPixels", {
  4361. /**
  4362. * Gets or sets a value indicating the left coordinate in pixels of the control
  4363. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4364. */
  4365. get: function () {
  4366. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4367. },
  4368. set: function (value) {
  4369. if (isNaN(value)) {
  4370. return;
  4371. }
  4372. this.left = value + "px";
  4373. },
  4374. enumerable: true,
  4375. configurable: true
  4376. });
  4377. Object.defineProperty(Control.prototype, "top", {
  4378. /**
  4379. * Gets or sets a value indicating the top coordinate of the control
  4380. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4381. */
  4382. get: function () {
  4383. return this._top.toString(this._host);
  4384. },
  4385. set: function (value) {
  4386. if (this._top.fromString(value)) {
  4387. this._markAsDirty();
  4388. }
  4389. },
  4390. enumerable: true,
  4391. configurable: true
  4392. });
  4393. Object.defineProperty(Control.prototype, "topInPixels", {
  4394. /**
  4395. * Gets or sets a value indicating the top coordinate in pixels of the control
  4396. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4397. */
  4398. get: function () {
  4399. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4400. },
  4401. set: function (value) {
  4402. if (isNaN(value)) {
  4403. return;
  4404. }
  4405. this.top = value + "px";
  4406. },
  4407. enumerable: true,
  4408. configurable: true
  4409. });
  4410. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4411. /**
  4412. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4413. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4414. */
  4415. get: function () {
  4416. return this._linkOffsetX.toString(this._host);
  4417. },
  4418. set: function (value) {
  4419. if (this._linkOffsetX.fromString(value)) {
  4420. this._markAsDirty();
  4421. }
  4422. },
  4423. enumerable: true,
  4424. configurable: true
  4425. });
  4426. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4427. /**
  4428. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4429. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4430. */
  4431. get: function () {
  4432. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4433. },
  4434. set: function (value) {
  4435. if (isNaN(value)) {
  4436. return;
  4437. }
  4438. this.linkOffsetX = value + "px";
  4439. },
  4440. enumerable: true,
  4441. configurable: true
  4442. });
  4443. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4444. /**
  4445. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4446. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4447. */
  4448. get: function () {
  4449. return this._linkOffsetY.toString(this._host);
  4450. },
  4451. set: function (value) {
  4452. if (this._linkOffsetY.fromString(value)) {
  4453. this._markAsDirty();
  4454. }
  4455. },
  4456. enumerable: true,
  4457. configurable: true
  4458. });
  4459. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4460. /**
  4461. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4462. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4463. */
  4464. get: function () {
  4465. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4466. },
  4467. set: function (value) {
  4468. if (isNaN(value)) {
  4469. return;
  4470. }
  4471. this.linkOffsetY = value + "px";
  4472. },
  4473. enumerable: true,
  4474. configurable: true
  4475. });
  4476. Object.defineProperty(Control.prototype, "centerX", {
  4477. /** Gets the center coordinate on X axis */
  4478. get: function () {
  4479. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4480. },
  4481. enumerable: true,
  4482. configurable: true
  4483. });
  4484. Object.defineProperty(Control.prototype, "centerY", {
  4485. /** Gets the center coordinate on Y axis */
  4486. get: function () {
  4487. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4488. },
  4489. enumerable: true,
  4490. configurable: true
  4491. });
  4492. Object.defineProperty(Control.prototype, "isEnabled", {
  4493. /** Gets or sets if control is Enabled*/
  4494. get: function () {
  4495. return this._isEnabled;
  4496. },
  4497. set: function (value) {
  4498. if (this._isEnabled === value) {
  4499. return;
  4500. }
  4501. this._isEnabled = value;
  4502. this._markAsDirty();
  4503. },
  4504. enumerable: true,
  4505. configurable: true
  4506. });
  4507. Object.defineProperty(Control.prototype, "disabledColor", {
  4508. /** Gets or sets background color of control if it's disabled*/
  4509. get: function () {
  4510. return this._disabledColor;
  4511. },
  4512. set: function (value) {
  4513. if (this._disabledColor === value) {
  4514. return;
  4515. }
  4516. this._disabledColor = value;
  4517. this._markAsDirty();
  4518. },
  4519. enumerable: true,
  4520. configurable: true
  4521. });
  4522. /** @hidden */
  4523. Control.prototype._getTypeName = function () {
  4524. return "Control";
  4525. };
  4526. /**
  4527. * Gets the first ascendant in the hierarchy of the given type
  4528. * @param className defines the required type
  4529. * @returns the ascendant or null if not found
  4530. */
  4531. Control.prototype.getAscendantOfClass = function (className) {
  4532. if (!this.parent) {
  4533. return null;
  4534. }
  4535. if (this.parent.getClassName() === className) {
  4536. return this.parent;
  4537. }
  4538. return this.parent.getAscendantOfClass(className);
  4539. };
  4540. /** @hidden */
  4541. Control.prototype._resetFontCache = function () {
  4542. this._fontSet = true;
  4543. this._markAsDirty();
  4544. };
  4545. /**
  4546. * Determines if a container is an ascendant of the current control
  4547. * @param container defines the container to look for
  4548. * @returns true if the container is one of the ascendant of the control
  4549. */
  4550. Control.prototype.isAscendant = function (container) {
  4551. if (!this.parent) {
  4552. return false;
  4553. }
  4554. if (this.parent === container) {
  4555. return true;
  4556. }
  4557. return this.parent.isAscendant(container);
  4558. };
  4559. /**
  4560. * Gets coordinates in local control space
  4561. * @param globalCoordinates defines the coordinates to transform
  4562. * @returns the new coordinates in local space
  4563. */
  4564. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4565. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4566. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4567. return result;
  4568. };
  4569. /**
  4570. * Gets coordinates in local control space
  4571. * @param globalCoordinates defines the coordinates to transform
  4572. * @param result defines the target vector2 where to store the result
  4573. * @returns the current control
  4574. */
  4575. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4576. result.x = globalCoordinates.x - this._currentMeasure.left;
  4577. result.y = globalCoordinates.y - this._currentMeasure.top;
  4578. return this;
  4579. };
  4580. /**
  4581. * Gets coordinates in parent local control space
  4582. * @param globalCoordinates defines the coordinates to transform
  4583. * @returns the new coordinates in parent local space
  4584. */
  4585. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4586. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4587. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4588. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4589. return result;
  4590. };
  4591. /**
  4592. * Move the current control to a vector3 position projected onto the screen.
  4593. * @param position defines the target position
  4594. * @param scene defines the hosting scene
  4595. */
  4596. Control.prototype.moveToVector3 = function (position, scene) {
  4597. if (!this._host || this.parent !== this._host._rootContainer) {
  4598. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4599. return;
  4600. }
  4601. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4602. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4603. var globalViewport = this._host._getGlobalViewport(scene);
  4604. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4605. this._moveToProjectedPosition(projectedPosition);
  4606. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4607. this.notRenderable = true;
  4608. return;
  4609. }
  4610. this.notRenderable = false;
  4611. };
  4612. /**
  4613. * Will store all controls that have this control as ascendant in a given array
  4614. * @param results defines the array where to store the descendants
  4615. * @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
  4616. * @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
  4617. */
  4618. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4619. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4620. // Do nothing by default
  4621. };
  4622. /**
  4623. * Will return all controls that have this control as ascendant
  4624. * @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
  4625. * @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
  4626. * @return all child controls
  4627. */
  4628. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4629. var results = new Array();
  4630. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4631. return results;
  4632. };
  4633. /**
  4634. * Link current control with a target mesh
  4635. * @param mesh defines the mesh to link with
  4636. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4637. */
  4638. Control.prototype.linkWithMesh = function (mesh) {
  4639. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4640. if (mesh) {
  4641. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4642. }
  4643. return;
  4644. }
  4645. var index = this._host._linkedControls.indexOf(this);
  4646. if (index !== -1) {
  4647. this._linkedMesh = mesh;
  4648. if (!mesh) {
  4649. this._host._linkedControls.splice(index, 1);
  4650. }
  4651. return;
  4652. }
  4653. else if (!mesh) {
  4654. return;
  4655. }
  4656. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4657. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4658. this._linkedMesh = mesh;
  4659. this._host._linkedControls.push(this);
  4660. };
  4661. /** @hidden */
  4662. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4663. var oldLeft = this._left.getValue(this._host);
  4664. var oldTop = this._top.getValue(this._host);
  4665. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4666. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4667. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4668. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4669. newLeft = oldLeft;
  4670. }
  4671. if (Math.abs(newTop - oldTop) < 0.5) {
  4672. newTop = oldTop;
  4673. }
  4674. }
  4675. this.left = newLeft + "px";
  4676. this.top = newTop + "px";
  4677. this._left.ignoreAdaptiveScaling = true;
  4678. this._top.ignoreAdaptiveScaling = true;
  4679. this._markAsDirty();
  4680. };
  4681. /** @hidden */
  4682. Control.prototype._offsetLeft = function (offset) {
  4683. this._isDirty = true;
  4684. this._currentMeasure.left += offset;
  4685. };
  4686. /** @hidden */
  4687. Control.prototype._offsetTop = function (offset) {
  4688. this._isDirty = true;
  4689. this._currentMeasure.top += offset;
  4690. };
  4691. /** @hidden */
  4692. Control.prototype._markMatrixAsDirty = function () {
  4693. this._isMatrixDirty = true;
  4694. this._flagDescendantsAsMatrixDirty();
  4695. };
  4696. /** @hidden */
  4697. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4698. // No child
  4699. };
  4700. /** @hidden */
  4701. Control.prototype._intersectsRect = function (rect) {
  4702. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4703. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4704. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4705. return false;
  4706. }
  4707. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4708. return false;
  4709. }
  4710. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4711. return false;
  4712. }
  4713. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4714. return false;
  4715. }
  4716. return true;
  4717. };
  4718. /** @hidden */
  4719. Control.prototype.invalidateRect = function () {
  4720. this._transform();
  4721. if (this.host && this.host.useInvalidateRectOptimization) {
  4722. // Rotate by transform to get the measure transformed to global space
  4723. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4724. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4725. // the previous measure is used to properly clear a control that is scaled down
  4726. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4727. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4728. // Expand rect based on shadows
  4729. var shadowOffsetX = this.shadowOffsetX;
  4730. var shadowOffsetY = this.shadowOffsetY;
  4731. var shadowBlur = this.shadowBlur;
  4732. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4733. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4734. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4735. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4736. this.host.invalidateRect(Math.floor(this._tmpMeasureA.left + leftShadowOffset), Math.floor(this._tmpMeasureA.top + topShadowOffset), Math.ceil(this._tmpMeasureA.left + this._tmpMeasureA.width + rightShadowOffset), Math.ceil(this._tmpMeasureA.top + this._tmpMeasureA.height + bottomShadowOffset));
  4737. }
  4738. else {
  4739. this.host.invalidateRect(Math.floor(this._tmpMeasureA.left), Math.floor(this._tmpMeasureA.top), Math.ceil(this._tmpMeasureA.left + this._tmpMeasureA.width), Math.ceil(this._tmpMeasureA.top + this._tmpMeasureA.height));
  4740. }
  4741. }
  4742. };
  4743. /** @hidden */
  4744. Control.prototype._markAsDirty = function (force) {
  4745. if (force === void 0) { force = false; }
  4746. if (!this._isVisible && !force) {
  4747. return;
  4748. }
  4749. this._isDirty = true;
  4750. // Redraw only this rectangle
  4751. if (this._host) {
  4752. this._host.markAsDirty();
  4753. }
  4754. };
  4755. /** @hidden */
  4756. Control.prototype._markAllAsDirty = function () {
  4757. this._markAsDirty();
  4758. if (this._font) {
  4759. this._prepareFont();
  4760. }
  4761. };
  4762. /** @hidden */
  4763. Control.prototype._link = function (host) {
  4764. this._host = host;
  4765. if (this._host) {
  4766. this.uniqueId = this._host.getScene().getUniqueId();
  4767. }
  4768. };
  4769. /** @hidden */
  4770. Control.prototype._transform = function (context) {
  4771. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4772. return;
  4773. }
  4774. // postTranslate
  4775. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4776. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4777. if (context) {
  4778. context.translate(offsetX, offsetY);
  4779. // rotate
  4780. context.rotate(this._rotation);
  4781. // scale
  4782. context.scale(this._scaleX, this._scaleY);
  4783. // preTranslate
  4784. context.translate(-offsetX, -offsetY);
  4785. }
  4786. // Need to update matrices?
  4787. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4788. this._cachedOffsetX = offsetX;
  4789. this._cachedOffsetY = offsetY;
  4790. this._isMatrixDirty = false;
  4791. this._flagDescendantsAsMatrixDirty();
  4792. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4793. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4794. }
  4795. };
  4796. /** @hidden */
  4797. Control.prototype._renderHighlight = function (context) {
  4798. if (!this.isHighlighted) {
  4799. return;
  4800. }
  4801. context.save();
  4802. context.strokeStyle = "#4affff";
  4803. context.lineWidth = 2;
  4804. this._renderHighlightSpecific(context);
  4805. context.restore();
  4806. };
  4807. /** @hidden */
  4808. Control.prototype._renderHighlightSpecific = function (context) {
  4809. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4810. };
  4811. /** @hidden */
  4812. Control.prototype._applyStates = function (context) {
  4813. if (this._isFontSizeInPercentage) {
  4814. this._fontSet = true;
  4815. }
  4816. if (this._fontSet) {
  4817. this._prepareFont();
  4818. this._fontSet = false;
  4819. }
  4820. if (this._font) {
  4821. context.font = this._font;
  4822. }
  4823. if (this._color) {
  4824. context.fillStyle = this._color;
  4825. }
  4826. if (Control.AllowAlphaInheritance) {
  4827. context.globalAlpha *= this._alpha;
  4828. }
  4829. else if (this._alphaSet) {
  4830. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4831. }
  4832. };
  4833. /** @hidden */
  4834. Control.prototype._layout = function (parentMeasure, context) {
  4835. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4836. return false;
  4837. }
  4838. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4839. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4840. context.save();
  4841. this._applyStates(context);
  4842. var rebuildCount = 0;
  4843. do {
  4844. this._rebuildLayout = false;
  4845. this._processMeasures(parentMeasure, context);
  4846. rebuildCount++;
  4847. } while (this._rebuildLayout && rebuildCount < 3);
  4848. if (rebuildCount >= 3) {
  4849. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4850. }
  4851. context.restore();
  4852. this.invalidateRect();
  4853. this._evaluateClippingState(parentMeasure);
  4854. }
  4855. this._wasDirty = this._isDirty;
  4856. this._isDirty = false;
  4857. return true;
  4858. };
  4859. /** @hidden */
  4860. Control.prototype._processMeasures = function (parentMeasure, context) {
  4861. this._currentMeasure.copyFrom(parentMeasure);
  4862. // Let children take some pre-measurement actions
  4863. this._preMeasure(parentMeasure, context);
  4864. this._measure();
  4865. this._computeAlignment(parentMeasure, context);
  4866. // Convert to int values
  4867. this._currentMeasure.left = this._currentMeasure.left | 0;
  4868. this._currentMeasure.top = this._currentMeasure.top | 0;
  4869. this._currentMeasure.width = this._currentMeasure.width | 0;
  4870. this._currentMeasure.height = this._currentMeasure.height | 0;
  4871. // Let children add more features
  4872. this._additionalProcessing(parentMeasure, context);
  4873. this._cachedParentMeasure.copyFrom(parentMeasure);
  4874. if (this.onDirtyObservable.hasObservers()) {
  4875. this.onDirtyObservable.notifyObservers(this);
  4876. }
  4877. };
  4878. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4879. if (this.parent && this.parent.clipChildren) {
  4880. // Early clip
  4881. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4882. this._isClipped = true;
  4883. return;
  4884. }
  4885. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4886. this._isClipped = true;
  4887. return;
  4888. }
  4889. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4890. this._isClipped = true;
  4891. return;
  4892. }
  4893. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4894. this._isClipped = true;
  4895. return;
  4896. }
  4897. }
  4898. this._isClipped = false;
  4899. };
  4900. /** @hidden */
  4901. Control.prototype._measure = function () {
  4902. // Width / Height
  4903. if (this._width.isPixel) {
  4904. this._currentMeasure.width = this._width.getValue(this._host);
  4905. }
  4906. else {
  4907. this._currentMeasure.width *= this._width.getValue(this._host);
  4908. }
  4909. if (this._height.isPixel) {
  4910. this._currentMeasure.height = this._height.getValue(this._host);
  4911. }
  4912. else {
  4913. this._currentMeasure.height *= this._height.getValue(this._host);
  4914. }
  4915. };
  4916. /** @hidden */
  4917. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4918. var width = this._currentMeasure.width;
  4919. var height = this._currentMeasure.height;
  4920. var parentWidth = parentMeasure.width;
  4921. var parentHeight = parentMeasure.height;
  4922. // Left / top
  4923. var x = 0;
  4924. var y = 0;
  4925. switch (this.horizontalAlignment) {
  4926. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4927. x = 0;
  4928. break;
  4929. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4930. x = parentWidth - width;
  4931. break;
  4932. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4933. x = (parentWidth - width) / 2;
  4934. break;
  4935. }
  4936. switch (this.verticalAlignment) {
  4937. case Control.VERTICAL_ALIGNMENT_TOP:
  4938. y = 0;
  4939. break;
  4940. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4941. y = parentHeight - height;
  4942. break;
  4943. case Control.VERTICAL_ALIGNMENT_CENTER:
  4944. y = (parentHeight - height) / 2;
  4945. break;
  4946. }
  4947. if (this._paddingLeft.isPixel) {
  4948. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4949. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4950. }
  4951. else {
  4952. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4953. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4954. }
  4955. if (this._paddingRight.isPixel) {
  4956. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4957. }
  4958. else {
  4959. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4960. }
  4961. if (this._paddingTop.isPixel) {
  4962. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4963. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4964. }
  4965. else {
  4966. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4967. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4968. }
  4969. if (this._paddingBottom.isPixel) {
  4970. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4971. }
  4972. else {
  4973. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4974. }
  4975. if (this._left.isPixel) {
  4976. this._currentMeasure.left += this._left.getValue(this._host);
  4977. }
  4978. else {
  4979. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4980. }
  4981. if (this._top.isPixel) {
  4982. this._currentMeasure.top += this._top.getValue(this._host);
  4983. }
  4984. else {
  4985. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4986. }
  4987. this._currentMeasure.left += x;
  4988. this._currentMeasure.top += y;
  4989. };
  4990. /** @hidden */
  4991. Control.prototype._preMeasure = function (parentMeasure, context) {
  4992. // Do nothing
  4993. };
  4994. /** @hidden */
  4995. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4996. // Do nothing
  4997. };
  4998. /** @hidden */
  4999. Control.prototype._clipForChildren = function (context) {
  5000. // DO nothing
  5001. };
  5002. Control.prototype._clip = function (context, invalidatedRectangle) {
  5003. context.beginPath();
  5004. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5005. if (invalidatedRectangle) {
  5006. // Rotate the invalidated rect into the control's space
  5007. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5008. // Get the intersection of the rect in context space and the current context
  5009. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5010. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5011. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5012. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5013. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5014. Control._ClipMeasure.copyFrom(intersection);
  5015. }
  5016. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5017. var shadowOffsetX = this.shadowOffsetX;
  5018. var shadowOffsetY = this.shadowOffsetY;
  5019. var shadowBlur = this.shadowBlur;
  5020. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5021. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5022. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5023. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5024. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5025. }
  5026. else {
  5027. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5028. }
  5029. context.clip();
  5030. };
  5031. /** @hidden */
  5032. Control.prototype._render = function (context, invalidatedRectangle) {
  5033. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5034. this._isDirty = false;
  5035. return false;
  5036. }
  5037. context.save();
  5038. this._applyStates(context);
  5039. // Transform
  5040. this._transform(context);
  5041. // Clip
  5042. if (this.clipContent) {
  5043. this._clip(context, invalidatedRectangle);
  5044. }
  5045. if (this.onBeforeDrawObservable.hasObservers()) {
  5046. this.onBeforeDrawObservable.notifyObservers(this);
  5047. }
  5048. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5049. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5050. }
  5051. else {
  5052. this._draw(context, invalidatedRectangle);
  5053. }
  5054. if (this.useBitmapCache && this._wasDirty) {
  5055. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5056. }
  5057. this._renderHighlight(context);
  5058. if (this.onAfterDrawObservable.hasObservers()) {
  5059. this.onAfterDrawObservable.notifyObservers(this);
  5060. }
  5061. context.restore();
  5062. return true;
  5063. };
  5064. /** @hidden */
  5065. Control.prototype._draw = function (context, invalidatedRectangle) {
  5066. // Do nothing
  5067. };
  5068. /**
  5069. * Tests if a given coordinates belong to the current control
  5070. * @param x defines x coordinate to test
  5071. * @param y defines y coordinate to test
  5072. * @returns true if the coordinates are inside the control
  5073. */
  5074. Control.prototype.contains = function (x, y) {
  5075. // Invert transform
  5076. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5077. x = this._transformedPosition.x;
  5078. y = this._transformedPosition.y;
  5079. // Check
  5080. if (x < this._currentMeasure.left) {
  5081. return false;
  5082. }
  5083. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5084. return false;
  5085. }
  5086. if (y < this._currentMeasure.top) {
  5087. return false;
  5088. }
  5089. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5090. return false;
  5091. }
  5092. if (this.isPointerBlocker) {
  5093. this._host._shouldBlockPointer = true;
  5094. }
  5095. return true;
  5096. };
  5097. /** @hidden */
  5098. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5099. if (!this._isEnabled) {
  5100. return false;
  5101. }
  5102. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5103. return false;
  5104. }
  5105. if (!this.contains(x, y)) {
  5106. return false;
  5107. }
  5108. this._processObservables(type, x, y, pointerId, buttonIndex);
  5109. return true;
  5110. };
  5111. /** @hidden */
  5112. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5113. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5114. if (canNotify && this.parent != null) {
  5115. this.parent._onPointerMove(target, coordinates, pointerId);
  5116. }
  5117. };
  5118. /** @hidden */
  5119. Control.prototype._onPointerEnter = function (target) {
  5120. if (!this._isEnabled) {
  5121. return false;
  5122. }
  5123. if (this._enterCount > 0) {
  5124. return false;
  5125. }
  5126. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5127. this._enterCount = 0;
  5128. }
  5129. this._enterCount++;
  5130. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5131. if (canNotify && this.parent != null) {
  5132. this.parent._onPointerEnter(target);
  5133. }
  5134. return true;
  5135. };
  5136. /** @hidden */
  5137. Control.prototype._onPointerOut = function (target, force) {
  5138. if (force === void 0) { force = false; }
  5139. if (!force && (!this._isEnabled || target === this)) {
  5140. return;
  5141. }
  5142. this._enterCount = 0;
  5143. var canNotify = true;
  5144. if (!target.isAscendant(this)) {
  5145. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5146. }
  5147. if (canNotify && this.parent != null) {
  5148. this.parent._onPointerOut(target, force);
  5149. }
  5150. };
  5151. /** @hidden */
  5152. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5153. // Prevent pointerout to lose control context.
  5154. // Event redundancy is checked inside the function.
  5155. this._onPointerEnter(this);
  5156. if (this._downCount !== 0) {
  5157. return false;
  5158. }
  5159. this._downCount++;
  5160. this._downPointerIds[pointerId] = true;
  5161. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5162. if (canNotify && this.parent != null) {
  5163. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5164. }
  5165. return true;
  5166. };
  5167. /** @hidden */
  5168. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5169. if (!this._isEnabled) {
  5170. return;
  5171. }
  5172. this._downCount = 0;
  5173. delete this._downPointerIds[pointerId];
  5174. var canNotifyClick = notifyClick;
  5175. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5176. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5177. }
  5178. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5179. if (canNotify && this.parent != null) {
  5180. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5181. }
  5182. };
  5183. /** @hidden */
  5184. Control.prototype._forcePointerUp = function (pointerId) {
  5185. if (pointerId === void 0) { pointerId = null; }
  5186. if (pointerId !== null) {
  5187. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5188. }
  5189. else {
  5190. for (var key in this._downPointerIds) {
  5191. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5192. }
  5193. }
  5194. };
  5195. /** @hidden */
  5196. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5197. if (!this._isEnabled) {
  5198. return false;
  5199. }
  5200. this._dummyVector2.copyFromFloats(x, y);
  5201. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5202. this._onPointerMove(this, this._dummyVector2, pointerId);
  5203. var previousControlOver = this._host._lastControlOver[pointerId];
  5204. if (previousControlOver && previousControlOver !== this) {
  5205. previousControlOver._onPointerOut(this);
  5206. }
  5207. if (previousControlOver !== this) {
  5208. this._onPointerEnter(this);
  5209. }
  5210. this._host._lastControlOver[pointerId] = this;
  5211. return true;
  5212. }
  5213. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5214. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5215. this._host._registerLastControlDown(this, pointerId);
  5216. this._host._lastPickedControl = this;
  5217. return true;
  5218. }
  5219. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5220. if (this._host._lastControlDown[pointerId]) {
  5221. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5222. }
  5223. delete this._host._lastControlDown[pointerId];
  5224. return true;
  5225. }
  5226. return false;
  5227. };
  5228. Control.prototype._prepareFont = function () {
  5229. if (!this._font && !this._fontSet) {
  5230. return;
  5231. }
  5232. if (this._style) {
  5233. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5234. }
  5235. else {
  5236. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5237. }
  5238. this._fontOffset = Control._GetFontOffset(this._font);
  5239. };
  5240. /** Releases associated resources */
  5241. Control.prototype.dispose = function () {
  5242. this.onDirtyObservable.clear();
  5243. this.onBeforeDrawObservable.clear();
  5244. this.onAfterDrawObservable.clear();
  5245. this.onPointerDownObservable.clear();
  5246. this.onPointerEnterObservable.clear();
  5247. this.onPointerMoveObservable.clear();
  5248. this.onPointerOutObservable.clear();
  5249. this.onPointerUpObservable.clear();
  5250. this.onPointerClickObservable.clear();
  5251. if (this._styleObserver && this._style) {
  5252. this._style.onChangedObservable.remove(this._styleObserver);
  5253. this._styleObserver = null;
  5254. }
  5255. if (this.parent) {
  5256. this.parent.removeControl(this);
  5257. this.parent = null;
  5258. }
  5259. if (this._host) {
  5260. var index = this._host._linkedControls.indexOf(this);
  5261. if (index > -1) {
  5262. this.linkWithMesh(null);
  5263. }
  5264. }
  5265. };
  5266. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5267. /** HORIZONTAL_ALIGNMENT_LEFT */
  5268. get: function () {
  5269. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5270. },
  5271. enumerable: true,
  5272. configurable: true
  5273. });
  5274. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5275. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5276. get: function () {
  5277. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5278. },
  5279. enumerable: true,
  5280. configurable: true
  5281. });
  5282. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5283. /** HORIZONTAL_ALIGNMENT_CENTER */
  5284. get: function () {
  5285. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5286. },
  5287. enumerable: true,
  5288. configurable: true
  5289. });
  5290. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5291. /** VERTICAL_ALIGNMENT_TOP */
  5292. get: function () {
  5293. return Control._VERTICAL_ALIGNMENT_TOP;
  5294. },
  5295. enumerable: true,
  5296. configurable: true
  5297. });
  5298. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5299. /** VERTICAL_ALIGNMENT_BOTTOM */
  5300. get: function () {
  5301. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5302. },
  5303. enumerable: true,
  5304. configurable: true
  5305. });
  5306. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5307. /** VERTICAL_ALIGNMENT_CENTER */
  5308. get: function () {
  5309. return Control._VERTICAL_ALIGNMENT_CENTER;
  5310. },
  5311. enumerable: true,
  5312. configurable: true
  5313. });
  5314. /** @hidden */
  5315. Control._GetFontOffset = function (font) {
  5316. if (Control._FontHeightSizes[font]) {
  5317. return Control._FontHeightSizes[font];
  5318. }
  5319. var text = document.createElement("span");
  5320. text.innerHTML = "Hg";
  5321. text.style.font = font;
  5322. var block = document.createElement("div");
  5323. block.style.display = "inline-block";
  5324. block.style.width = "1px";
  5325. block.style.height = "0px";
  5326. block.style.verticalAlign = "bottom";
  5327. var div = document.createElement("div");
  5328. div.appendChild(text);
  5329. div.appendChild(block);
  5330. document.body.appendChild(div);
  5331. var fontAscent = 0;
  5332. var fontHeight = 0;
  5333. try {
  5334. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5335. block.style.verticalAlign = "baseline";
  5336. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5337. }
  5338. finally {
  5339. document.body.removeChild(div);
  5340. }
  5341. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5342. Control._FontHeightSizes[font] = result;
  5343. return result;
  5344. };
  5345. /** @hidden */
  5346. Control.drawEllipse = function (x, y, width, height, context) {
  5347. context.translate(x, y);
  5348. context.scale(width, height);
  5349. context.beginPath();
  5350. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5351. context.closePath();
  5352. context.scale(1 / width, 1 / height);
  5353. context.translate(-x, -y);
  5354. };
  5355. /**
  5356. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5357. */
  5358. Control.AllowAlphaInheritance = false;
  5359. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5360. // Statics
  5361. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5362. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5363. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5364. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5365. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5366. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5367. Control._FontHeightSizes = {};
  5368. /**
  5369. * Creates a stack panel that can be used to render headers
  5370. * @param control defines the control to associate with the header
  5371. * @param text defines the text of the header
  5372. * @param size defines the size of the header
  5373. * @param options defines options used to configure the header
  5374. * @returns a new StackPanel
  5375. * @ignore
  5376. * @hidden
  5377. */
  5378. Control.AddHeader = function () { };
  5379. return Control;
  5380. }());
  5381. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5382. /***/ }),
  5383. /***/ "./2D/controls/displayGrid.ts":
  5384. /*!************************************!*\
  5385. !*** ./2D/controls/displayGrid.ts ***!
  5386. \************************************/
  5387. /*! exports provided: DisplayGrid */
  5388. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5389. "use strict";
  5390. __webpack_require__.r(__webpack_exports__);
  5391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5392. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5393. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5394. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5395. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5396. /** Class used to render a grid */
  5397. var DisplayGrid = /** @class */ (function (_super) {
  5398. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5399. /**
  5400. * Creates a new GridDisplayRectangle
  5401. * @param name defines the control name
  5402. */
  5403. function DisplayGrid(name) {
  5404. var _this = _super.call(this, name) || this;
  5405. _this.name = name;
  5406. _this._cellWidth = 20;
  5407. _this._cellHeight = 20;
  5408. _this._minorLineTickness = 1;
  5409. _this._minorLineColor = "DarkGray";
  5410. _this._majorLineTickness = 2;
  5411. _this._majorLineColor = "White";
  5412. _this._majorLineFrequency = 5;
  5413. _this._background = "Black";
  5414. _this._displayMajorLines = true;
  5415. _this._displayMinorLines = true;
  5416. return _this;
  5417. }
  5418. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5419. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5420. get: function () {
  5421. return this._displayMinorLines;
  5422. },
  5423. set: function (value) {
  5424. if (this._displayMinorLines === value) {
  5425. return;
  5426. }
  5427. this._displayMinorLines = value;
  5428. this._markAsDirty();
  5429. },
  5430. enumerable: true,
  5431. configurable: true
  5432. });
  5433. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5434. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5435. get: function () {
  5436. return this._displayMajorLines;
  5437. },
  5438. set: function (value) {
  5439. if (this._displayMajorLines === value) {
  5440. return;
  5441. }
  5442. this._displayMajorLines = value;
  5443. this._markAsDirty();
  5444. },
  5445. enumerable: true,
  5446. configurable: true
  5447. });
  5448. Object.defineProperty(DisplayGrid.prototype, "background", {
  5449. /** Gets or sets background color (Black by default) */
  5450. get: function () {
  5451. return this._background;
  5452. },
  5453. set: function (value) {
  5454. if (this._background === value) {
  5455. return;
  5456. }
  5457. this._background = value;
  5458. this._markAsDirty();
  5459. },
  5460. enumerable: true,
  5461. configurable: true
  5462. });
  5463. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5464. /** Gets or sets the width of each cell (20 by default) */
  5465. get: function () {
  5466. return this._cellWidth;
  5467. },
  5468. set: function (value) {
  5469. this._cellWidth = value;
  5470. this._markAsDirty();
  5471. },
  5472. enumerable: true,
  5473. configurable: true
  5474. });
  5475. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5476. /** Gets or sets the height of each cell (20 by default) */
  5477. get: function () {
  5478. return this._cellHeight;
  5479. },
  5480. set: function (value) {
  5481. this._cellHeight = value;
  5482. this._markAsDirty();
  5483. },
  5484. enumerable: true,
  5485. configurable: true
  5486. });
  5487. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5488. /** Gets or sets the tickness of minor lines (1 by default) */
  5489. get: function () {
  5490. return this._minorLineTickness;
  5491. },
  5492. set: function (value) {
  5493. this._minorLineTickness = value;
  5494. this._markAsDirty();
  5495. },
  5496. enumerable: true,
  5497. configurable: true
  5498. });
  5499. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5500. /** Gets or sets the color of minor lines (DarkGray by default) */
  5501. get: function () {
  5502. return this._minorLineColor;
  5503. },
  5504. set: function (value) {
  5505. this._minorLineColor = value;
  5506. this._markAsDirty();
  5507. },
  5508. enumerable: true,
  5509. configurable: true
  5510. });
  5511. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5512. /** Gets or sets the tickness of major lines (2 by default) */
  5513. get: function () {
  5514. return this._majorLineTickness;
  5515. },
  5516. set: function (value) {
  5517. this._majorLineTickness = value;
  5518. this._markAsDirty();
  5519. },
  5520. enumerable: true,
  5521. configurable: true
  5522. });
  5523. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5524. /** Gets or sets the color of major lines (White by default) */
  5525. get: function () {
  5526. return this._majorLineColor;
  5527. },
  5528. set: function (value) {
  5529. this._majorLineColor = value;
  5530. this._markAsDirty();
  5531. },
  5532. enumerable: true,
  5533. configurable: true
  5534. });
  5535. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5536. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5537. get: function () {
  5538. return this._majorLineFrequency;
  5539. },
  5540. set: function (value) {
  5541. this._majorLineFrequency = value;
  5542. this._markAsDirty();
  5543. },
  5544. enumerable: true,
  5545. configurable: true
  5546. });
  5547. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5548. context.save();
  5549. this._applyStates(context);
  5550. if (this._isEnabled) {
  5551. if (this._background) {
  5552. context.fillStyle = this._background;
  5553. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5554. }
  5555. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5556. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5557. // Minor lines
  5558. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5559. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5560. if (this._displayMinorLines) {
  5561. context.strokeStyle = this._minorLineColor;
  5562. context.lineWidth = this._minorLineTickness;
  5563. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5564. var cellX = left + x * this.cellWidth;
  5565. context.beginPath();
  5566. context.moveTo(cellX, this._currentMeasure.top);
  5567. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5568. context.stroke();
  5569. }
  5570. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5571. var cellY = top_1 + y * this.cellHeight;
  5572. context.beginPath();
  5573. context.moveTo(this._currentMeasure.left, cellY);
  5574. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5575. context.stroke();
  5576. }
  5577. }
  5578. // Major lines
  5579. if (this._displayMajorLines) {
  5580. context.strokeStyle = this._majorLineColor;
  5581. context.lineWidth = this._majorLineTickness;
  5582. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5583. var cellX = left + x * this.cellWidth;
  5584. context.beginPath();
  5585. context.moveTo(cellX, this._currentMeasure.top);
  5586. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5587. context.stroke();
  5588. }
  5589. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5590. var cellY = top_1 + y * this.cellHeight;
  5591. context.moveTo(this._currentMeasure.left, cellY);
  5592. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5593. context.closePath();
  5594. context.stroke();
  5595. }
  5596. }
  5597. }
  5598. context.restore();
  5599. };
  5600. DisplayGrid.prototype._getTypeName = function () {
  5601. return "DisplayGrid";
  5602. };
  5603. return DisplayGrid;
  5604. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5605. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5606. /***/ }),
  5607. /***/ "./2D/controls/ellipse.ts":
  5608. /*!********************************!*\
  5609. !*** ./2D/controls/ellipse.ts ***!
  5610. \********************************/
  5611. /*! exports provided: Ellipse */
  5612. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5613. "use strict";
  5614. __webpack_require__.r(__webpack_exports__);
  5615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5616. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5617. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5618. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5619. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5620. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5621. /** Class used to create 2D ellipse containers */
  5622. var Ellipse = /** @class */ (function (_super) {
  5623. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5624. /**
  5625. * Creates a new Ellipse
  5626. * @param name defines the control name
  5627. */
  5628. function Ellipse(name) {
  5629. var _this = _super.call(this, name) || this;
  5630. _this.name = name;
  5631. _this._thickness = 1;
  5632. return _this;
  5633. }
  5634. Object.defineProperty(Ellipse.prototype, "thickness", {
  5635. /** Gets or sets border thickness */
  5636. get: function () {
  5637. return this._thickness;
  5638. },
  5639. set: function (value) {
  5640. if (this._thickness === value) {
  5641. return;
  5642. }
  5643. this._thickness = value;
  5644. this._markAsDirty();
  5645. },
  5646. enumerable: true,
  5647. configurable: true
  5648. });
  5649. Ellipse.prototype._getTypeName = function () {
  5650. return "Ellipse";
  5651. };
  5652. Ellipse.prototype._localDraw = function (context) {
  5653. context.save();
  5654. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5655. context.shadowColor = this.shadowColor;
  5656. context.shadowBlur = this.shadowBlur;
  5657. context.shadowOffsetX = this.shadowOffsetX;
  5658. context.shadowOffsetY = this.shadowOffsetY;
  5659. }
  5660. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2 - this._thickness / 2, this._currentMeasure.height / 2 - this._thickness / 2, context);
  5661. if (this._background) {
  5662. context.fillStyle = this._background;
  5663. context.fill();
  5664. }
  5665. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5666. context.shadowBlur = 0;
  5667. context.shadowOffsetX = 0;
  5668. context.shadowOffsetY = 0;
  5669. }
  5670. if (this._thickness) {
  5671. if (this.color) {
  5672. context.strokeStyle = this.color;
  5673. }
  5674. context.lineWidth = this._thickness;
  5675. context.stroke();
  5676. }
  5677. context.restore();
  5678. };
  5679. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5680. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5681. this._measureForChildren.width -= 2 * this._thickness;
  5682. this._measureForChildren.height -= 2 * this._thickness;
  5683. this._measureForChildren.left += this._thickness;
  5684. this._measureForChildren.top += this._thickness;
  5685. };
  5686. Ellipse.prototype._clipForChildren = function (context) {
  5687. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2, this._currentMeasure.height / 2, context);
  5688. context.clip();
  5689. };
  5690. return Ellipse;
  5691. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5692. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5693. /***/ }),
  5694. /***/ "./2D/controls/grid.ts":
  5695. /*!*****************************!*\
  5696. !*** ./2D/controls/grid.ts ***!
  5697. \*****************************/
  5698. /*! exports provided: Grid */
  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__, "Grid", function() { return Grid; });
  5703. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5704. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5705. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5706. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5707. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  5708. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5709. /**
  5710. * Class used to create a 2D grid container
  5711. */
  5712. var Grid = /** @class */ (function (_super) {
  5713. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5714. /**
  5715. * Creates a new Grid
  5716. * @param name defines control name
  5717. */
  5718. function Grid(name) {
  5719. var _this = _super.call(this, name) || this;
  5720. _this.name = name;
  5721. _this._rowDefinitions = new Array();
  5722. _this._columnDefinitions = new Array();
  5723. _this._cells = {};
  5724. _this._childControls = new Array();
  5725. return _this;
  5726. }
  5727. Object.defineProperty(Grid.prototype, "columnCount", {
  5728. /**
  5729. * Gets the number of columns
  5730. */
  5731. get: function () {
  5732. return this._columnDefinitions.length;
  5733. },
  5734. enumerable: true,
  5735. configurable: true
  5736. });
  5737. Object.defineProperty(Grid.prototype, "rowCount", {
  5738. /**
  5739. * Gets the number of rows
  5740. */
  5741. get: function () {
  5742. return this._rowDefinitions.length;
  5743. },
  5744. enumerable: true,
  5745. configurable: true
  5746. });
  5747. Object.defineProperty(Grid.prototype, "children", {
  5748. /** Gets the list of children */
  5749. get: function () {
  5750. return this._childControls;
  5751. },
  5752. enumerable: true,
  5753. configurable: true
  5754. });
  5755. Object.defineProperty(Grid.prototype, "cells", {
  5756. /** Gets the list of cells (e.g. the containers) */
  5757. get: function () {
  5758. return this._cells;
  5759. },
  5760. enumerable: true,
  5761. configurable: true
  5762. });
  5763. /**
  5764. * Gets the definition of a specific row
  5765. * @param index defines the index of the row
  5766. * @returns the row definition
  5767. */
  5768. Grid.prototype.getRowDefinition = function (index) {
  5769. if (index < 0 || index >= this._rowDefinitions.length) {
  5770. return null;
  5771. }
  5772. return this._rowDefinitions[index];
  5773. };
  5774. /**
  5775. * Gets the definition of a specific column
  5776. * @param index defines the index of the column
  5777. * @returns the column definition
  5778. */
  5779. Grid.prototype.getColumnDefinition = function (index) {
  5780. if (index < 0 || index >= this._columnDefinitions.length) {
  5781. return null;
  5782. }
  5783. return this._columnDefinitions[index];
  5784. };
  5785. /**
  5786. * Adds a new row to the grid
  5787. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5788. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5789. * @returns the current grid
  5790. */
  5791. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5792. if (isPixel === void 0) { isPixel = false; }
  5793. this._rowDefinitions.push(new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](height, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE));
  5794. this._markAsDirty();
  5795. return this;
  5796. };
  5797. /**
  5798. * Adds a new column to the grid
  5799. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5800. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5801. * @returns the current grid
  5802. */
  5803. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5804. if (isPixel === void 0) { isPixel = false; }
  5805. this._columnDefinitions.push(new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](width, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE));
  5806. this._markAsDirty();
  5807. return this;
  5808. };
  5809. /**
  5810. * Update a row definition
  5811. * @param index defines the index of the row to update
  5812. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5813. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5814. * @returns the current grid
  5815. */
  5816. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5817. if (isPixel === void 0) { isPixel = false; }
  5818. if (index < 0 || index >= this._rowDefinitions.length) {
  5819. return this;
  5820. }
  5821. var current = this._rowDefinitions[index];
  5822. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5823. return this;
  5824. }
  5825. this._rowDefinitions[index] = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](height, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE);
  5826. this._markAsDirty();
  5827. return this;
  5828. };
  5829. /**
  5830. * Update a column definition
  5831. * @param index defines the index of the column to update
  5832. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5833. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5834. * @returns the current grid
  5835. */
  5836. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5837. if (isPixel === void 0) { isPixel = false; }
  5838. if (index < 0 || index >= this._columnDefinitions.length) {
  5839. return this;
  5840. }
  5841. var current = this._columnDefinitions[index];
  5842. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5843. return this;
  5844. }
  5845. this._columnDefinitions[index] = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](width, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE);
  5846. this._markAsDirty();
  5847. return this;
  5848. };
  5849. /**
  5850. * Gets the list of children stored in a specific cell
  5851. * @param row defines the row to check
  5852. * @param column defines the column to check
  5853. * @returns the list of controls
  5854. */
  5855. Grid.prototype.getChildrenAt = function (row, column) {
  5856. var cell = this._cells[row + ":" + column];
  5857. if (!cell) {
  5858. return null;
  5859. }
  5860. return cell.children;
  5861. };
  5862. /**
  5863. * Gets a string representing the child cell info (row x column)
  5864. * @param child defines the control to get info from
  5865. * @returns a string containing the child cell info (row x column)
  5866. */
  5867. Grid.prototype.getChildCellInfo = function (child) {
  5868. return child._tag;
  5869. };
  5870. Grid.prototype._removeCell = function (cell, key) {
  5871. if (!cell) {
  5872. return;
  5873. }
  5874. _super.prototype.removeControl.call(this, cell);
  5875. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5876. var control = _a[_i];
  5877. var childIndex = this._childControls.indexOf(control);
  5878. if (childIndex !== -1) {
  5879. this._childControls.splice(childIndex, 1);
  5880. }
  5881. }
  5882. delete this._cells[key];
  5883. };
  5884. Grid.prototype._offsetCell = function (previousKey, key) {
  5885. if (!this._cells[key]) {
  5886. return;
  5887. }
  5888. this._cells[previousKey] = this._cells[key];
  5889. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5890. var control = _a[_i];
  5891. control._tag = previousKey;
  5892. }
  5893. delete this._cells[key];
  5894. };
  5895. /**
  5896. * Remove a column definition at specified index
  5897. * @param index defines the index of the column to remove
  5898. * @returns the current grid
  5899. */
  5900. Grid.prototype.removeColumnDefinition = function (index) {
  5901. if (index < 0 || index >= this._columnDefinitions.length) {
  5902. return this;
  5903. }
  5904. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5905. var key = x + ":" + index;
  5906. var cell = this._cells[key];
  5907. this._removeCell(cell, key);
  5908. }
  5909. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5910. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5911. var previousKey = x + ":" + (y - 1);
  5912. var key = x + ":" + y;
  5913. this._offsetCell(previousKey, key);
  5914. }
  5915. }
  5916. this._columnDefinitions.splice(index, 1);
  5917. this._markAsDirty();
  5918. return this;
  5919. };
  5920. /**
  5921. * Remove a row definition at specified index
  5922. * @param index defines the index of the row to remove
  5923. * @returns the current grid
  5924. */
  5925. Grid.prototype.removeRowDefinition = function (index) {
  5926. if (index < 0 || index >= this._rowDefinitions.length) {
  5927. return this;
  5928. }
  5929. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5930. var key = index + ":" + y;
  5931. var cell = this._cells[key];
  5932. this._removeCell(cell, key);
  5933. }
  5934. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5935. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5936. var previousKey = x - 1 + ":" + y;
  5937. var key = x + ":" + y;
  5938. this._offsetCell(previousKey, key);
  5939. }
  5940. }
  5941. this._rowDefinitions.splice(index, 1);
  5942. this._markAsDirty();
  5943. return this;
  5944. };
  5945. /**
  5946. * Adds a new control to the current grid
  5947. * @param control defines the control to add
  5948. * @param row defines the row where to add the control (0 by default)
  5949. * @param column defines the column where to add the control (0 by default)
  5950. * @returns the current grid
  5951. */
  5952. Grid.prototype.addControl = function (control, row, column) {
  5953. if (row === void 0) { row = 0; }
  5954. if (column === void 0) { column = 0; }
  5955. if (this._rowDefinitions.length === 0) {
  5956. // Add default row definition
  5957. this.addRowDefinition(1, false);
  5958. }
  5959. if (this._columnDefinitions.length === 0) {
  5960. // Add default column definition
  5961. this.addColumnDefinition(1, false);
  5962. }
  5963. if (this._childControls.indexOf(control) !== -1) {
  5964. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].Warn("Control (Name:" + control.name + ", UniqueId:" + control.uniqueId + ") is already associated with this grid. You must remove it before reattaching it");
  5965. return this;
  5966. }
  5967. var x = Math.min(row, this._rowDefinitions.length - 1);
  5968. var y = Math.min(column, this._columnDefinitions.length - 1);
  5969. var key = x + ":" + y;
  5970. var goodContainer = this._cells[key];
  5971. if (!goodContainer) {
  5972. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5973. this._cells[key] = goodContainer;
  5974. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5975. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5976. _super.prototype.addControl.call(this, goodContainer);
  5977. }
  5978. goodContainer.addControl(control);
  5979. this._childControls.push(control);
  5980. control._tag = key;
  5981. control.parent = this;
  5982. this._markAsDirty();
  5983. return this;
  5984. };
  5985. /**
  5986. * Removes a control from the current container
  5987. * @param control defines the control to remove
  5988. * @returns the current container
  5989. */
  5990. Grid.prototype.removeControl = function (control) {
  5991. var index = this._childControls.indexOf(control);
  5992. if (index !== -1) {
  5993. this._childControls.splice(index, 1);
  5994. }
  5995. var cell = this._cells[control._tag];
  5996. if (cell) {
  5997. cell.removeControl(control);
  5998. control._tag = null;
  5999. }
  6000. this._markAsDirty();
  6001. return this;
  6002. };
  6003. Grid.prototype._getTypeName = function () {
  6004. return "Grid";
  6005. };
  6006. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6007. var widths = [];
  6008. var heights = [];
  6009. var lefts = [];
  6010. var tops = [];
  6011. var availableWidth = this._currentMeasure.width;
  6012. var globalWidthPercentage = 0;
  6013. var availableHeight = this._currentMeasure.height;
  6014. var globalHeightPercentage = 0;
  6015. // Heights
  6016. var index = 0;
  6017. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6018. var value = _a[_i];
  6019. if (value.isPixel) {
  6020. var height = value.getValue(this._host);
  6021. availableHeight -= height;
  6022. heights[index] = height;
  6023. }
  6024. else {
  6025. globalHeightPercentage += value.internalValue;
  6026. }
  6027. index++;
  6028. }
  6029. var top = 0;
  6030. index = 0;
  6031. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6032. var value = _c[_b];
  6033. tops.push(top);
  6034. if (!value.isPixel) {
  6035. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6036. top += height;
  6037. heights[index] = height;
  6038. }
  6039. else {
  6040. top += value.getValue(this._host);
  6041. }
  6042. index++;
  6043. }
  6044. // Widths
  6045. index = 0;
  6046. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6047. var value = _e[_d];
  6048. if (value.isPixel) {
  6049. var width = value.getValue(this._host);
  6050. availableWidth -= width;
  6051. widths[index] = width;
  6052. }
  6053. else {
  6054. globalWidthPercentage += value.internalValue;
  6055. }
  6056. index++;
  6057. }
  6058. var left = 0;
  6059. index = 0;
  6060. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6061. var value = _g[_f];
  6062. lefts.push(left);
  6063. if (!value.isPixel) {
  6064. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6065. left += width;
  6066. widths[index] = width;
  6067. }
  6068. else {
  6069. left += value.getValue(this._host);
  6070. }
  6071. index++;
  6072. }
  6073. definitionCallback(lefts, tops, widths, heights);
  6074. };
  6075. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6076. var _this = this;
  6077. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6078. // Setting child sizes
  6079. for (var key in _this._cells) {
  6080. if (!_this._cells.hasOwnProperty(key)) {
  6081. continue;
  6082. }
  6083. var split = key.split(":");
  6084. var x = parseInt(split[0]);
  6085. var y = parseInt(split[1]);
  6086. var cell = _this._cells[key];
  6087. cell.left = lefts[y] + "px";
  6088. cell.top = tops[x] + "px";
  6089. cell.width = widths[y] + "px";
  6090. cell.height = heights[x] + "px";
  6091. cell._left.ignoreAdaptiveScaling = true;
  6092. cell._top.ignoreAdaptiveScaling = true;
  6093. cell._width.ignoreAdaptiveScaling = true;
  6094. cell._height.ignoreAdaptiveScaling = true;
  6095. }
  6096. });
  6097. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6098. };
  6099. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6100. for (var key in this._cells) {
  6101. if (!this._cells.hasOwnProperty(key)) {
  6102. continue;
  6103. }
  6104. var child = this._cells[key];
  6105. child._markMatrixAsDirty();
  6106. }
  6107. };
  6108. Grid.prototype._renderHighlightSpecific = function (context) {
  6109. var _this = this;
  6110. _super.prototype._renderHighlightSpecific.call(this, context);
  6111. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6112. // Columns
  6113. for (var index = 0; index < lefts.length; index++) {
  6114. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6115. context.beginPath();
  6116. context.moveTo(left, _this._currentMeasure.top);
  6117. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6118. context.stroke();
  6119. }
  6120. // Rows
  6121. for (var index = 0; index < tops.length; index++) {
  6122. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6123. context.beginPath();
  6124. context.moveTo(_this._currentMeasure.left, top_1);
  6125. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6126. context.stroke();
  6127. }
  6128. });
  6129. context.restore();
  6130. };
  6131. /** Releases associated resources */
  6132. Grid.prototype.dispose = function () {
  6133. _super.prototype.dispose.call(this);
  6134. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6135. var control = _a[_i];
  6136. control.dispose();
  6137. }
  6138. this._childControls = [];
  6139. };
  6140. return Grid;
  6141. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6142. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6143. /***/ }),
  6144. /***/ "./2D/controls/image.ts":
  6145. /*!******************************!*\
  6146. !*** ./2D/controls/image.ts ***!
  6147. \******************************/
  6148. /*! exports provided: Image */
  6149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6150. "use strict";
  6151. __webpack_require__.r(__webpack_exports__);
  6152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6153. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6154. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6155. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6156. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6157. /**
  6158. * Class used to create 2D images
  6159. */
  6160. var Image = /** @class */ (function (_super) {
  6161. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6162. /**
  6163. * Creates a new Image
  6164. * @param name defines the control name
  6165. * @param url defines the image url
  6166. */
  6167. function Image(name, url) {
  6168. if (url === void 0) { url = null; }
  6169. var _this = _super.call(this, name) || this;
  6170. _this.name = name;
  6171. _this._workingCanvas = null;
  6172. _this._loaded = false;
  6173. _this._stretch = Image.STRETCH_FILL;
  6174. _this._autoScale = false;
  6175. _this._sourceLeft = 0;
  6176. _this._sourceTop = 0;
  6177. _this._sourceWidth = 0;
  6178. _this._sourceHeight = 0;
  6179. _this._cellWidth = 0;
  6180. _this._cellHeight = 0;
  6181. _this._cellId = -1;
  6182. _this._populateNinePatchSlicesFromImage = false;
  6183. /**
  6184. * Observable notified when the content is loaded
  6185. */
  6186. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6187. /**
  6188. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6189. */
  6190. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6191. _this.source = url;
  6192. return _this;
  6193. }
  6194. Object.defineProperty(Image.prototype, "isLoaded", {
  6195. /**
  6196. * Gets a boolean indicating that the content is loaded
  6197. */
  6198. get: function () {
  6199. return this._loaded;
  6200. },
  6201. enumerable: true,
  6202. configurable: true
  6203. });
  6204. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6205. /**
  6206. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6207. */
  6208. get: function () {
  6209. return this._populateNinePatchSlicesFromImage;
  6210. },
  6211. set: function (value) {
  6212. if (this._populateNinePatchSlicesFromImage === value) {
  6213. return;
  6214. }
  6215. this._populateNinePatchSlicesFromImage = value;
  6216. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6217. this._extractNinePatchSliceDataFromImage();
  6218. }
  6219. },
  6220. enumerable: true,
  6221. configurable: true
  6222. });
  6223. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6224. /**
  6225. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6226. * Beware using this as this will comsume more memory as the image has to be stored twice
  6227. */
  6228. get: function () {
  6229. return this._detectPointerOnOpaqueOnly;
  6230. },
  6231. set: function (value) {
  6232. if (this._detectPointerOnOpaqueOnly === value) {
  6233. return;
  6234. }
  6235. this._detectPointerOnOpaqueOnly = value;
  6236. },
  6237. enumerable: true,
  6238. configurable: true
  6239. });
  6240. Object.defineProperty(Image.prototype, "sliceLeft", {
  6241. /**
  6242. * Gets or sets the left value for slicing (9-patch)
  6243. */
  6244. get: function () {
  6245. return this._sliceLeft;
  6246. },
  6247. set: function (value) {
  6248. if (this._sliceLeft === value) {
  6249. return;
  6250. }
  6251. this._sliceLeft = value;
  6252. this._markAsDirty();
  6253. },
  6254. enumerable: true,
  6255. configurable: true
  6256. });
  6257. Object.defineProperty(Image.prototype, "sliceRight", {
  6258. /**
  6259. * Gets or sets the right value for slicing (9-patch)
  6260. */
  6261. get: function () {
  6262. return this._sliceRight;
  6263. },
  6264. set: function (value) {
  6265. if (this._sliceRight === value) {
  6266. return;
  6267. }
  6268. this._sliceRight = value;
  6269. this._markAsDirty();
  6270. },
  6271. enumerable: true,
  6272. configurable: true
  6273. });
  6274. Object.defineProperty(Image.prototype, "sliceTop", {
  6275. /**
  6276. * Gets or sets the top value for slicing (9-patch)
  6277. */
  6278. get: function () {
  6279. return this._sliceTop;
  6280. },
  6281. set: function (value) {
  6282. if (this._sliceTop === value) {
  6283. return;
  6284. }
  6285. this._sliceTop = value;
  6286. this._markAsDirty();
  6287. },
  6288. enumerable: true,
  6289. configurable: true
  6290. });
  6291. Object.defineProperty(Image.prototype, "sliceBottom", {
  6292. /**
  6293. * Gets or sets the bottom value for slicing (9-patch)
  6294. */
  6295. get: function () {
  6296. return this._sliceBottom;
  6297. },
  6298. set: function (value) {
  6299. if (this._sliceBottom === value) {
  6300. return;
  6301. }
  6302. this._sliceBottom = value;
  6303. this._markAsDirty();
  6304. },
  6305. enumerable: true,
  6306. configurable: true
  6307. });
  6308. Object.defineProperty(Image.prototype, "sourceLeft", {
  6309. /**
  6310. * Gets or sets the left coordinate in the source image
  6311. */
  6312. get: function () {
  6313. return this._sourceLeft;
  6314. },
  6315. set: function (value) {
  6316. if (this._sourceLeft === value) {
  6317. return;
  6318. }
  6319. this._sourceLeft = value;
  6320. this._markAsDirty();
  6321. },
  6322. enumerable: true,
  6323. configurable: true
  6324. });
  6325. Object.defineProperty(Image.prototype, "sourceTop", {
  6326. /**
  6327. * Gets or sets the top coordinate in the source image
  6328. */
  6329. get: function () {
  6330. return this._sourceTop;
  6331. },
  6332. set: function (value) {
  6333. if (this._sourceTop === value) {
  6334. return;
  6335. }
  6336. this._sourceTop = value;
  6337. this._markAsDirty();
  6338. },
  6339. enumerable: true,
  6340. configurable: true
  6341. });
  6342. Object.defineProperty(Image.prototype, "sourceWidth", {
  6343. /**
  6344. * Gets or sets the width to capture in the source image
  6345. */
  6346. get: function () {
  6347. return this._sourceWidth;
  6348. },
  6349. set: function (value) {
  6350. if (this._sourceWidth === value) {
  6351. return;
  6352. }
  6353. this._sourceWidth = value;
  6354. this._markAsDirty();
  6355. },
  6356. enumerable: true,
  6357. configurable: true
  6358. });
  6359. Object.defineProperty(Image.prototype, "sourceHeight", {
  6360. /**
  6361. * Gets or sets the height to capture in the source image
  6362. */
  6363. get: function () {
  6364. return this._sourceHeight;
  6365. },
  6366. set: function (value) {
  6367. if (this._sourceHeight === value) {
  6368. return;
  6369. }
  6370. this._sourceHeight = value;
  6371. this._markAsDirty();
  6372. },
  6373. enumerable: true,
  6374. configurable: true
  6375. });
  6376. Object.defineProperty(Image.prototype, "autoScale", {
  6377. /**
  6378. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6379. * @see http://doc.babylonjs.com/how_to/gui#image
  6380. */
  6381. get: function () {
  6382. return this._autoScale;
  6383. },
  6384. set: function (value) {
  6385. if (this._autoScale === value) {
  6386. return;
  6387. }
  6388. this._autoScale = value;
  6389. if (value && this._loaded) {
  6390. this.synchronizeSizeWithContent();
  6391. }
  6392. },
  6393. enumerable: true,
  6394. configurable: true
  6395. });
  6396. Object.defineProperty(Image.prototype, "stretch", {
  6397. /** Gets or sets the streching mode used by the image */
  6398. get: function () {
  6399. return this._stretch;
  6400. },
  6401. set: function (value) {
  6402. if (this._stretch === value) {
  6403. return;
  6404. }
  6405. this._stretch = value;
  6406. this._markAsDirty();
  6407. },
  6408. enumerable: true,
  6409. configurable: true
  6410. });
  6411. Object.defineProperty(Image.prototype, "domImage", {
  6412. get: function () {
  6413. return this._domImage;
  6414. },
  6415. /**
  6416. * Gets or sets the internal DOM image used to render the control
  6417. */
  6418. set: function (value) {
  6419. var _this = this;
  6420. this._domImage = value;
  6421. this._loaded = false;
  6422. if (this._domImage.width) {
  6423. this._onImageLoaded();
  6424. }
  6425. else {
  6426. this._domImage.onload = function () {
  6427. _this._onImageLoaded();
  6428. };
  6429. }
  6430. },
  6431. enumerable: true,
  6432. configurable: true
  6433. });
  6434. Image.prototype._onImageLoaded = function () {
  6435. this._imageWidth = this._domImage.width;
  6436. this._imageHeight = this._domImage.height;
  6437. this._loaded = true;
  6438. if (this._populateNinePatchSlicesFromImage) {
  6439. this._extractNinePatchSliceDataFromImage();
  6440. }
  6441. if (this._autoScale) {
  6442. this.synchronizeSizeWithContent();
  6443. }
  6444. this.onImageLoadedObservable.notifyObservers(this);
  6445. this._markAsDirty();
  6446. };
  6447. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6448. if (!this._workingCanvas) {
  6449. this._workingCanvas = document.createElement('canvas');
  6450. }
  6451. var canvas = this._workingCanvas;
  6452. var context = canvas.getContext('2d');
  6453. var width = this._domImage.width;
  6454. var height = this._domImage.height;
  6455. canvas.width = width;
  6456. canvas.height = height;
  6457. context.drawImage(this._domImage, 0, 0, width, height);
  6458. var imageData = context.getImageData(0, 0, width, height);
  6459. // Left and right
  6460. this._sliceLeft = -1;
  6461. this._sliceRight = -1;
  6462. for (var x = 0; x < width; x++) {
  6463. var alpha = imageData.data[x * 4 + 3];
  6464. if (alpha > 127 && this._sliceLeft === -1) {
  6465. this._sliceLeft = x;
  6466. continue;
  6467. }
  6468. if (alpha < 127 && this._sliceLeft > -1) {
  6469. this._sliceRight = x;
  6470. break;
  6471. }
  6472. }
  6473. // top and bottom
  6474. this._sliceTop = -1;
  6475. this._sliceBottom = -1;
  6476. for (var y = 0; y < height; y++) {
  6477. var alpha = imageData.data[y * width * 4 + 3];
  6478. if (alpha > 127 && this._sliceTop === -1) {
  6479. this._sliceTop = y;
  6480. continue;
  6481. }
  6482. if (alpha < 127 && this._sliceTop > -1) {
  6483. this._sliceBottom = y;
  6484. break;
  6485. }
  6486. }
  6487. };
  6488. Object.defineProperty(Image.prototype, "source", {
  6489. /**
  6490. * Gets or sets image source url
  6491. */
  6492. set: function (value) {
  6493. var _this = this;
  6494. if (this._source === value) {
  6495. return;
  6496. }
  6497. this._loaded = false;
  6498. this._source = value;
  6499. if (value) {
  6500. value = this._svgCheck(value);
  6501. }
  6502. this._domImage = document.createElement("img");
  6503. this._domImage.onload = function () {
  6504. _this._onImageLoaded();
  6505. };
  6506. if (value) {
  6507. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6508. this._domImage.src = value;
  6509. }
  6510. },
  6511. enumerable: true,
  6512. configurable: true
  6513. });
  6514. /**
  6515. * Checks for svg document with icon id present
  6516. */
  6517. Image.prototype._svgCheck = function (value) {
  6518. var _this = this;
  6519. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6520. var svgsrc = value.split('#')[0];
  6521. var elemid = value.split('#')[1];
  6522. // check if object alr exist in document
  6523. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6524. if (svgExist) {
  6525. // wait for object to load
  6526. svgExist.addEventListener("load", function () {
  6527. _this._getSVGAttribs(svgExist, elemid);
  6528. });
  6529. }
  6530. else {
  6531. // create document object
  6532. var svgImage = document.createElement("object");
  6533. svgImage.data = svgsrc;
  6534. svgImage.type = "image/svg+xml";
  6535. svgImage.width = "0%";
  6536. svgImage.height = "0%";
  6537. document.body.appendChild(svgImage);
  6538. // when the object has loaded, get the element attribs
  6539. svgImage.onload = function () {
  6540. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6541. if (svgobj) {
  6542. _this._getSVGAttribs(svgobj, elemid);
  6543. }
  6544. };
  6545. }
  6546. return svgsrc;
  6547. }
  6548. else {
  6549. return value;
  6550. }
  6551. };
  6552. /**
  6553. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6554. * given external svg file and icon id
  6555. */
  6556. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6557. var svgDoc = svgsrc.contentDocument;
  6558. // get viewbox width and height, get svg document width and height in px
  6559. if (svgDoc && svgDoc.documentElement) {
  6560. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6561. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6562. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6563. // get element bbox and matrix transform
  6564. var elem = svgDoc.getElementById(elemid);
  6565. if (vb && docwidth && docheight) {
  6566. var vb_width = Number(vb.split(" ")[2]);
  6567. var vb_height = Number(vb.split(" ")[3]);
  6568. var elem_bbox = elem.getBBox();
  6569. var elem_matrix_a = 1;
  6570. var elem_matrix_d = 1;
  6571. var elem_matrix_e = 0;
  6572. var elem_matrix_f = 0;
  6573. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6574. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6575. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6576. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6577. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6578. }
  6579. // compute source coordinates and dimensions
  6580. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6581. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6582. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6583. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6584. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6585. }
  6586. }
  6587. };
  6588. Object.defineProperty(Image.prototype, "cellWidth", {
  6589. /**
  6590. * Gets or sets the cell width to use when animation sheet is enabled
  6591. * @see http://doc.babylonjs.com/how_to/gui#image
  6592. */
  6593. get: function () {
  6594. return this._cellWidth;
  6595. },
  6596. set: function (value) {
  6597. if (this._cellWidth === value) {
  6598. return;
  6599. }
  6600. this._cellWidth = value;
  6601. this._markAsDirty();
  6602. },
  6603. enumerable: true,
  6604. configurable: true
  6605. });
  6606. Object.defineProperty(Image.prototype, "cellHeight", {
  6607. /**
  6608. * Gets or sets the cell height to use when animation sheet is enabled
  6609. * @see http://doc.babylonjs.com/how_to/gui#image
  6610. */
  6611. get: function () {
  6612. return this._cellHeight;
  6613. },
  6614. set: function (value) {
  6615. if (this._cellHeight === value) {
  6616. return;
  6617. }
  6618. this._cellHeight = value;
  6619. this._markAsDirty();
  6620. },
  6621. enumerable: true,
  6622. configurable: true
  6623. });
  6624. Object.defineProperty(Image.prototype, "cellId", {
  6625. /**
  6626. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6627. * @see http://doc.babylonjs.com/how_to/gui#image
  6628. */
  6629. get: function () {
  6630. return this._cellId;
  6631. },
  6632. set: function (value) {
  6633. if (this._cellId === value) {
  6634. return;
  6635. }
  6636. this._cellId = value;
  6637. this._markAsDirty();
  6638. },
  6639. enumerable: true,
  6640. configurable: true
  6641. });
  6642. /**
  6643. * Tests if a given coordinates belong to the current control
  6644. * @param x defines x coordinate to test
  6645. * @param y defines y coordinate to test
  6646. * @returns true if the coordinates are inside the control
  6647. */
  6648. Image.prototype.contains = function (x, y) {
  6649. if (!_super.prototype.contains.call(this, x, y)) {
  6650. return false;
  6651. }
  6652. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6653. return true;
  6654. }
  6655. var canvas = this._workingCanvas;
  6656. var context = canvas.getContext("2d");
  6657. var width = this._currentMeasure.width | 0;
  6658. var height = this._currentMeasure.height | 0;
  6659. var imageData = context.getImageData(0, 0, width, height).data;
  6660. x = (x - this._currentMeasure.left) | 0;
  6661. y = (y - this._currentMeasure.top) | 0;
  6662. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6663. return pickedPixel > 0;
  6664. };
  6665. Image.prototype._getTypeName = function () {
  6666. return "Image";
  6667. };
  6668. /** Force the control to synchronize with its content */
  6669. Image.prototype.synchronizeSizeWithContent = function () {
  6670. if (!this._loaded) {
  6671. return;
  6672. }
  6673. this.width = this._domImage.width + "px";
  6674. this.height = this._domImage.height + "px";
  6675. };
  6676. Image.prototype._processMeasures = function (parentMeasure, context) {
  6677. if (this._loaded) {
  6678. switch (this._stretch) {
  6679. case Image.STRETCH_NONE:
  6680. break;
  6681. case Image.STRETCH_FILL:
  6682. break;
  6683. case Image.STRETCH_UNIFORM:
  6684. break;
  6685. case Image.STRETCH_NINE_PATCH:
  6686. break;
  6687. case Image.STRETCH_EXTEND:
  6688. if (this._autoScale) {
  6689. this.synchronizeSizeWithContent();
  6690. }
  6691. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6692. this.parent.adaptWidthToChildren = true;
  6693. this.parent.adaptHeightToChildren = true;
  6694. }
  6695. break;
  6696. }
  6697. }
  6698. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6699. };
  6700. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6701. if (!this._detectPointerOnOpaqueOnly) {
  6702. return;
  6703. }
  6704. if (!this._workingCanvas) {
  6705. this._workingCanvas = document.createElement('canvas');
  6706. }
  6707. var canvas = this._workingCanvas;
  6708. var width = this._currentMeasure.width;
  6709. var height = this._currentMeasure.height;
  6710. var context = canvas.getContext("2d");
  6711. canvas.width = width;
  6712. canvas.height = height;
  6713. context.clearRect(0, 0, width, height);
  6714. };
  6715. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6716. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6717. if (!this._detectPointerOnOpaqueOnly) {
  6718. return;
  6719. }
  6720. var canvas = this._workingCanvas;
  6721. context = canvas.getContext("2d");
  6722. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6723. };
  6724. Image.prototype._draw = function (context) {
  6725. context.save();
  6726. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6727. context.shadowColor = this.shadowColor;
  6728. context.shadowBlur = this.shadowBlur;
  6729. context.shadowOffsetX = this.shadowOffsetX;
  6730. context.shadowOffsetY = this.shadowOffsetY;
  6731. }
  6732. var x, y, width, height;
  6733. if (this.cellId == -1) {
  6734. x = this._sourceLeft;
  6735. y = this._sourceTop;
  6736. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6737. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6738. }
  6739. else {
  6740. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6741. var column = (this.cellId / rowCount) >> 0;
  6742. var row = this.cellId % rowCount;
  6743. x = this.cellWidth * row;
  6744. y = this.cellHeight * column;
  6745. width = this.cellWidth;
  6746. height = this.cellHeight;
  6747. }
  6748. this._prepareWorkingCanvasForOpaqueDetection();
  6749. this._applyStates(context);
  6750. if (this._loaded) {
  6751. switch (this._stretch) {
  6752. case Image.STRETCH_NONE:
  6753. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6754. break;
  6755. case Image.STRETCH_FILL:
  6756. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6757. break;
  6758. case Image.STRETCH_UNIFORM:
  6759. var hRatio = this._currentMeasure.width / width;
  6760. var vRatio = this._currentMeasure.height / height;
  6761. var ratio = Math.min(hRatio, vRatio);
  6762. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6763. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6764. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6765. break;
  6766. case Image.STRETCH_EXTEND:
  6767. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6768. break;
  6769. case Image.STRETCH_NINE_PATCH:
  6770. this._renderNinePatch(context);
  6771. break;
  6772. }
  6773. }
  6774. context.restore();
  6775. };
  6776. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6777. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6778. };
  6779. Image.prototype._renderNinePatch = function (context) {
  6780. var height = this._imageHeight;
  6781. var leftWidth = this._sliceLeft;
  6782. var topHeight = this._sliceTop;
  6783. var bottomHeight = this._imageHeight - this._sliceBottom;
  6784. var rightWidth = this._imageWidth - this._sliceRight;
  6785. var left = 0;
  6786. var top = 0;
  6787. if (this._populateNinePatchSlicesFromImage) {
  6788. left = 1;
  6789. top = 1;
  6790. height -= 2;
  6791. leftWidth -= 1;
  6792. topHeight -= 1;
  6793. bottomHeight -= 1;
  6794. rightWidth -= 1;
  6795. }
  6796. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6797. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6798. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6799. // Corners
  6800. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6801. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6802. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6803. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6804. // Center
  6805. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop + 1, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight + 1);
  6806. // Borders
  6807. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6808. this._drawImage(context, this._sliceRight, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + this._currentMeasure.width - rightWidth, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6809. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6810. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6811. };
  6812. Image.prototype.dispose = function () {
  6813. _super.prototype.dispose.call(this);
  6814. this.onImageLoadedObservable.clear();
  6815. this.onSVGAttributesComputedObservable.clear();
  6816. };
  6817. // Static
  6818. /** STRETCH_NONE */
  6819. Image.STRETCH_NONE = 0;
  6820. /** STRETCH_FILL */
  6821. Image.STRETCH_FILL = 1;
  6822. /** STRETCH_UNIFORM */
  6823. Image.STRETCH_UNIFORM = 2;
  6824. /** STRETCH_EXTEND */
  6825. Image.STRETCH_EXTEND = 3;
  6826. /** NINE_PATCH */
  6827. Image.STRETCH_NINE_PATCH = 4;
  6828. return Image;
  6829. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6830. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  6831. /***/ }),
  6832. /***/ "./2D/controls/index.ts":
  6833. /*!******************************!*\
  6834. !*** ./2D/controls/index.ts ***!
  6835. \******************************/
  6836. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  6837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6838. "use strict";
  6839. __webpack_require__.r(__webpack_exports__);
  6840. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6842. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6844. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6846. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6848. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6850. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6852. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6854. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6856. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6858. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6860. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6862. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6864. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6866. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6868. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6874. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6876. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6879. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6882. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6884. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6886. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6888. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6890. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6892. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6894. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  6895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__["ImageScrollBar"]; });
  6896. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_25__["name"]; });
  6898. /***/ }),
  6899. /***/ "./2D/controls/inputPassword.ts":
  6900. /*!**************************************!*\
  6901. !*** ./2D/controls/inputPassword.ts ***!
  6902. \**************************************/
  6903. /*! exports provided: InputPassword */
  6904. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6905. "use strict";
  6906. __webpack_require__.r(__webpack_exports__);
  6907. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6908. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6909. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6910. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  6911. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  6912. /**
  6913. * Class used to create a password control
  6914. */
  6915. var InputPassword = /** @class */ (function (_super) {
  6916. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  6917. function InputPassword() {
  6918. return _super !== null && _super.apply(this, arguments) || this;
  6919. }
  6920. InputPassword.prototype._beforeRenderText = function (text) {
  6921. var txt = "";
  6922. for (var i = 0; i < text.length; i++) {
  6923. txt += "\u2022";
  6924. }
  6925. return txt;
  6926. };
  6927. return InputPassword;
  6928. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6929. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  6930. /***/ }),
  6931. /***/ "./2D/controls/inputText.ts":
  6932. /*!**********************************!*\
  6933. !*** ./2D/controls/inputText.ts ***!
  6934. \**********************************/
  6935. /*! exports provided: InputText */
  6936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6937. "use strict";
  6938. __webpack_require__.r(__webpack_exports__);
  6939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6940. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6941. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6942. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6943. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6944. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6945. /**
  6946. * Class used to create input text control
  6947. */
  6948. var InputText = /** @class */ (function (_super) {
  6949. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  6950. /**
  6951. * Creates a new InputText
  6952. * @param name defines the control name
  6953. * @param text defines the text of the control
  6954. */
  6955. function InputText(name, text) {
  6956. if (text === void 0) { text = ""; }
  6957. var _this = _super.call(this, name) || this;
  6958. _this.name = name;
  6959. _this._text = "";
  6960. _this._placeholderText = "";
  6961. _this._background = "#222222";
  6962. _this._focusedBackground = "#000000";
  6963. _this._focusedColor = "white";
  6964. _this._placeholderColor = "gray";
  6965. _this._thickness = 1;
  6966. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6967. _this._autoStretchWidth = true;
  6968. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6969. _this._isFocused = false;
  6970. _this._blinkIsEven = false;
  6971. _this._cursorOffset = 0;
  6972. _this._deadKey = false;
  6973. _this._addKey = true;
  6974. _this._currentKey = "";
  6975. _this._isTextHighlightOn = false;
  6976. _this._textHighlightColor = "#d5e0ff";
  6977. _this._highligherOpacity = 0.4;
  6978. _this._highlightedText = "";
  6979. _this._startHighlightIndex = 0;
  6980. _this._endHighlightIndex = 0;
  6981. _this._cursorIndex = -1;
  6982. _this._onFocusSelectAll = false;
  6983. _this._isPointerDown = false;
  6984. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6985. _this.promptMessage = "Please enter text:";
  6986. /** Force disable prompt on mobile device */
  6987. _this.disableMobilePrompt = false;
  6988. /** Observable raised when the text changes */
  6989. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6990. /** Observable raised just before an entered character is to be added */
  6991. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6992. /** Observable raised when the control gets the focus */
  6993. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6994. /** Observable raised when the control loses the focus */
  6995. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6996. /**Observable raised when the text is highlighted */
  6997. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6998. /**Observable raised when copy event is triggered */
  6999. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7000. /** Observable raised when cut event is triggered */
  7001. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7002. /** Observable raised when paste event is triggered */
  7003. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7004. /** Observable raised when a key event was processed */
  7005. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7006. _this.text = text;
  7007. _this.isPointerBlocker = true;
  7008. return _this;
  7009. }
  7010. Object.defineProperty(InputText.prototype, "maxWidth", {
  7011. /** Gets or sets the maximum width allowed by the control */
  7012. get: function () {
  7013. return this._maxWidth.toString(this._host);
  7014. },
  7015. set: function (value) {
  7016. if (this._maxWidth.toString(this._host) === value) {
  7017. return;
  7018. }
  7019. if (this._maxWidth.fromString(value)) {
  7020. this._markAsDirty();
  7021. }
  7022. },
  7023. enumerable: true,
  7024. configurable: true
  7025. });
  7026. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7027. /** Gets the maximum width allowed by the control in pixels */
  7028. get: function () {
  7029. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7030. },
  7031. enumerable: true,
  7032. configurable: true
  7033. });
  7034. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7035. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7036. get: function () {
  7037. return this._highligherOpacity;
  7038. },
  7039. set: function (value) {
  7040. if (this._highligherOpacity === value) {
  7041. return;
  7042. }
  7043. this._highligherOpacity = value;
  7044. this._markAsDirty();
  7045. },
  7046. enumerable: true,
  7047. configurable: true
  7048. });
  7049. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7050. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7051. get: function () {
  7052. return this._onFocusSelectAll;
  7053. },
  7054. set: function (value) {
  7055. if (this._onFocusSelectAll === value) {
  7056. return;
  7057. }
  7058. this._onFocusSelectAll = value;
  7059. this._markAsDirty();
  7060. },
  7061. enumerable: true,
  7062. configurable: true
  7063. });
  7064. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7065. /** Gets or sets the text hightlight color */
  7066. get: function () {
  7067. return this._textHighlightColor;
  7068. },
  7069. set: function (value) {
  7070. if (this._textHighlightColor === value) {
  7071. return;
  7072. }
  7073. this._textHighlightColor = value;
  7074. this._markAsDirty();
  7075. },
  7076. enumerable: true,
  7077. configurable: true
  7078. });
  7079. Object.defineProperty(InputText.prototype, "margin", {
  7080. /** Gets or sets control margin */
  7081. get: function () {
  7082. return this._margin.toString(this._host);
  7083. },
  7084. set: function (value) {
  7085. if (this._margin.toString(this._host) === value) {
  7086. return;
  7087. }
  7088. if (this._margin.fromString(value)) {
  7089. this._markAsDirty();
  7090. }
  7091. },
  7092. enumerable: true,
  7093. configurable: true
  7094. });
  7095. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7096. /** Gets control margin in pixels */
  7097. get: function () {
  7098. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7099. },
  7100. enumerable: true,
  7101. configurable: true
  7102. });
  7103. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7104. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7105. get: function () {
  7106. return this._autoStretchWidth;
  7107. },
  7108. set: function (value) {
  7109. if (this._autoStretchWidth === value) {
  7110. return;
  7111. }
  7112. this._autoStretchWidth = value;
  7113. this._markAsDirty();
  7114. },
  7115. enumerable: true,
  7116. configurable: true
  7117. });
  7118. Object.defineProperty(InputText.prototype, "thickness", {
  7119. /** Gets or sets border thickness */
  7120. get: function () {
  7121. return this._thickness;
  7122. },
  7123. set: function (value) {
  7124. if (this._thickness === value) {
  7125. return;
  7126. }
  7127. this._thickness = value;
  7128. this._markAsDirty();
  7129. },
  7130. enumerable: true,
  7131. configurable: true
  7132. });
  7133. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7134. /** Gets or sets the background color when focused */
  7135. get: function () {
  7136. return this._focusedBackground;
  7137. },
  7138. set: function (value) {
  7139. if (this._focusedBackground === value) {
  7140. return;
  7141. }
  7142. this._focusedBackground = value;
  7143. this._markAsDirty();
  7144. },
  7145. enumerable: true,
  7146. configurable: true
  7147. });
  7148. Object.defineProperty(InputText.prototype, "focusedColor", {
  7149. /** Gets or sets the background color when focused */
  7150. get: function () {
  7151. return this._focusedColor;
  7152. },
  7153. set: function (value) {
  7154. if (this._focusedColor === value) {
  7155. return;
  7156. }
  7157. this._focusedColor = value;
  7158. this._markAsDirty();
  7159. },
  7160. enumerable: true,
  7161. configurable: true
  7162. });
  7163. Object.defineProperty(InputText.prototype, "background", {
  7164. /** Gets or sets the background color */
  7165. get: function () {
  7166. return this._background;
  7167. },
  7168. set: function (value) {
  7169. if (this._background === value) {
  7170. return;
  7171. }
  7172. this._background = value;
  7173. this._markAsDirty();
  7174. },
  7175. enumerable: true,
  7176. configurable: true
  7177. });
  7178. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7179. /** Gets or sets the placeholder color */
  7180. get: function () {
  7181. return this._placeholderColor;
  7182. },
  7183. set: function (value) {
  7184. if (this._placeholderColor === value) {
  7185. return;
  7186. }
  7187. this._placeholderColor = value;
  7188. this._markAsDirty();
  7189. },
  7190. enumerable: true,
  7191. configurable: true
  7192. });
  7193. Object.defineProperty(InputText.prototype, "placeholderText", {
  7194. /** Gets or sets the text displayed when the control is empty */
  7195. get: function () {
  7196. return this._placeholderText;
  7197. },
  7198. set: function (value) {
  7199. if (this._placeholderText === value) {
  7200. return;
  7201. }
  7202. this._placeholderText = value;
  7203. this._markAsDirty();
  7204. },
  7205. enumerable: true,
  7206. configurable: true
  7207. });
  7208. Object.defineProperty(InputText.prototype, "deadKey", {
  7209. /** Gets or sets the dead key flag */
  7210. get: function () {
  7211. return this._deadKey;
  7212. },
  7213. set: function (flag) {
  7214. this._deadKey = flag;
  7215. },
  7216. enumerable: true,
  7217. configurable: true
  7218. });
  7219. Object.defineProperty(InputText.prototype, "highlightedText", {
  7220. /** Gets or sets the highlight text */
  7221. get: function () {
  7222. return this._highlightedText;
  7223. },
  7224. set: function (text) {
  7225. if (this._highlightedText === text) {
  7226. return;
  7227. }
  7228. this._highlightedText = text;
  7229. this._markAsDirty();
  7230. },
  7231. enumerable: true,
  7232. configurable: true
  7233. });
  7234. Object.defineProperty(InputText.prototype, "addKey", {
  7235. /** Gets or sets if the current key should be added */
  7236. get: function () {
  7237. return this._addKey;
  7238. },
  7239. set: function (flag) {
  7240. this._addKey = flag;
  7241. },
  7242. enumerable: true,
  7243. configurable: true
  7244. });
  7245. Object.defineProperty(InputText.prototype, "currentKey", {
  7246. /** Gets or sets the value of the current key being entered */
  7247. get: function () {
  7248. return this._currentKey;
  7249. },
  7250. set: function (key) {
  7251. this._currentKey = key;
  7252. },
  7253. enumerable: true,
  7254. configurable: true
  7255. });
  7256. Object.defineProperty(InputText.prototype, "text", {
  7257. /** Gets or sets the text displayed in the control */
  7258. get: function () {
  7259. return this._text;
  7260. },
  7261. set: function (value) {
  7262. var valueAsString = value.toString(); // Forcing convertion
  7263. if (this._text === valueAsString) {
  7264. return;
  7265. }
  7266. this._text = valueAsString;
  7267. this._markAsDirty();
  7268. this.onTextChangedObservable.notifyObservers(this);
  7269. },
  7270. enumerable: true,
  7271. configurable: true
  7272. });
  7273. Object.defineProperty(InputText.prototype, "width", {
  7274. /** Gets or sets control width */
  7275. get: function () {
  7276. return this._width.toString(this._host);
  7277. },
  7278. set: function (value) {
  7279. if (this._width.toString(this._host) === value) {
  7280. return;
  7281. }
  7282. if (this._width.fromString(value)) {
  7283. this._markAsDirty();
  7284. }
  7285. this.autoStretchWidth = false;
  7286. },
  7287. enumerable: true,
  7288. configurable: true
  7289. });
  7290. /** @hidden */
  7291. InputText.prototype.onBlur = function () {
  7292. this._isFocused = false;
  7293. this._scrollLeft = null;
  7294. this._cursorOffset = 0;
  7295. clearTimeout(this._blinkTimeout);
  7296. this._markAsDirty();
  7297. this.onBlurObservable.notifyObservers(this);
  7298. this._host.unRegisterClipboardEvents();
  7299. if (this._onClipboardObserver) {
  7300. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7301. }
  7302. var scene = this._host.getScene();
  7303. if (this._onPointerDblTapObserver && scene) {
  7304. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7305. }
  7306. };
  7307. /** @hidden */
  7308. InputText.prototype.onFocus = function () {
  7309. var _this = this;
  7310. if (!this._isEnabled) {
  7311. return;
  7312. }
  7313. this._scrollLeft = null;
  7314. this._isFocused = true;
  7315. this._blinkIsEven = false;
  7316. this._cursorOffset = 0;
  7317. this._markAsDirty();
  7318. this.onFocusObservable.notifyObservers(this);
  7319. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7320. var value = prompt(this.promptMessage);
  7321. if (value !== null) {
  7322. this.text = value;
  7323. }
  7324. this._host.focusedControl = null;
  7325. return;
  7326. }
  7327. this._host.registerClipboardEvents();
  7328. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7329. // process clipboard event, can be configured.
  7330. switch (clipboardInfo.type) {
  7331. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7332. _this._onCopyText(clipboardInfo.event);
  7333. _this.onTextCopyObservable.notifyObservers(_this);
  7334. break;
  7335. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7336. _this._onCutText(clipboardInfo.event);
  7337. _this.onTextCutObservable.notifyObservers(_this);
  7338. break;
  7339. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7340. _this._onPasteText(clipboardInfo.event);
  7341. _this.onTextPasteObservable.notifyObservers(_this);
  7342. break;
  7343. default: return;
  7344. }
  7345. });
  7346. var scene = this._host.getScene();
  7347. if (scene) {
  7348. //register the pointer double tap event
  7349. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7350. if (!_this._isFocused) {
  7351. return;
  7352. }
  7353. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7354. _this._processDblClick(pointerInfo);
  7355. }
  7356. });
  7357. }
  7358. if (this._onFocusSelectAll) {
  7359. this._selectAllText();
  7360. }
  7361. };
  7362. InputText.prototype._getTypeName = function () {
  7363. return "InputText";
  7364. };
  7365. /**
  7366. * Function called to get the list of controls that should not steal the focus from this control
  7367. * @returns an array of controls
  7368. */
  7369. InputText.prototype.keepsFocusWith = function () {
  7370. if (!this._connectedVirtualKeyboard) {
  7371. return null;
  7372. }
  7373. return [this._connectedVirtualKeyboard];
  7374. };
  7375. /** @hidden */
  7376. InputText.prototype.processKey = function (keyCode, key, evt) {
  7377. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7378. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7379. return;
  7380. }
  7381. //select all
  7382. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7383. this._selectAllText();
  7384. evt.preventDefault();
  7385. return;
  7386. }
  7387. // Specific cases
  7388. switch (keyCode) {
  7389. case 32: //SPACE
  7390. key = " "; //ie11 key for space is "Spacebar"
  7391. break;
  7392. case 191: //SLASH
  7393. if (evt) {
  7394. evt.preventDefault();
  7395. }
  7396. break;
  7397. case 8: // BACKSPACE
  7398. if (this._text && this._text.length > 0) {
  7399. //delete the highlighted text
  7400. if (this._isTextHighlightOn) {
  7401. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7402. this._isTextHighlightOn = false;
  7403. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7404. this._blinkIsEven = false;
  7405. if (evt) {
  7406. evt.preventDefault();
  7407. }
  7408. return;
  7409. }
  7410. //delete single character
  7411. if (this._cursorOffset === 0) {
  7412. this.text = this._text.substr(0, this._text.length - 1);
  7413. }
  7414. else {
  7415. var deletePosition = this._text.length - this._cursorOffset;
  7416. if (deletePosition > 0) {
  7417. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7418. }
  7419. }
  7420. }
  7421. if (evt) {
  7422. evt.preventDefault();
  7423. }
  7424. return;
  7425. case 46: // DELETE
  7426. if (this._isTextHighlightOn) {
  7427. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7428. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7429. while (decrementor > 0 && this._cursorOffset > 0) {
  7430. this._cursorOffset--;
  7431. }
  7432. this._isTextHighlightOn = false;
  7433. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7434. if (evt) {
  7435. evt.preventDefault();
  7436. }
  7437. return;
  7438. }
  7439. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7440. var deletePosition = this._text.length - this._cursorOffset;
  7441. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7442. this._cursorOffset--;
  7443. }
  7444. if (evt) {
  7445. evt.preventDefault();
  7446. }
  7447. return;
  7448. case 13: // RETURN
  7449. this._host.focusedControl = null;
  7450. this._isTextHighlightOn = false;
  7451. return;
  7452. case 35: // END
  7453. this._cursorOffset = 0;
  7454. this._blinkIsEven = false;
  7455. this._isTextHighlightOn = false;
  7456. this._markAsDirty();
  7457. return;
  7458. case 36: // HOME
  7459. this._cursorOffset = this._text.length;
  7460. this._blinkIsEven = false;
  7461. this._isTextHighlightOn = false;
  7462. this._markAsDirty();
  7463. return;
  7464. case 37: // LEFT
  7465. this._cursorOffset++;
  7466. if (this._cursorOffset > this._text.length) {
  7467. this._cursorOffset = this._text.length;
  7468. }
  7469. if (evt && evt.shiftKey) {
  7470. // update the cursor
  7471. this._blinkIsEven = false;
  7472. // shift + ctrl/cmd + <-
  7473. if (evt.ctrlKey || evt.metaKey) {
  7474. if (!this._isTextHighlightOn) {
  7475. if (this._text.length === this._cursorOffset) {
  7476. return;
  7477. }
  7478. else {
  7479. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7480. }
  7481. }
  7482. this._startHighlightIndex = 0;
  7483. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7484. this._cursorOffset = this._text.length;
  7485. this._isTextHighlightOn = true;
  7486. this._markAsDirty();
  7487. return;
  7488. }
  7489. //store the starting point
  7490. if (!this._isTextHighlightOn) {
  7491. this._isTextHighlightOn = true;
  7492. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7493. }
  7494. //if text is already highlighted
  7495. else if (this._cursorIndex === -1) {
  7496. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7497. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7498. }
  7499. //set the highlight indexes
  7500. if (this._cursorIndex < this._cursorOffset) {
  7501. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7502. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7503. }
  7504. else if (this._cursorIndex > this._cursorOffset) {
  7505. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7506. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7507. }
  7508. else {
  7509. this._isTextHighlightOn = false;
  7510. }
  7511. this._markAsDirty();
  7512. return;
  7513. }
  7514. if (this._isTextHighlightOn) {
  7515. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7516. this._isTextHighlightOn = false;
  7517. }
  7518. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7519. this._cursorOffset = this.text.length;
  7520. evt.preventDefault();
  7521. }
  7522. this._blinkIsEven = false;
  7523. this._isTextHighlightOn = false;
  7524. this._cursorIndex = -1;
  7525. this._markAsDirty();
  7526. return;
  7527. case 39: // RIGHT
  7528. this._cursorOffset--;
  7529. if (this._cursorOffset < 0) {
  7530. this._cursorOffset = 0;
  7531. }
  7532. if (evt && evt.shiftKey) {
  7533. //update the cursor
  7534. this._blinkIsEven = false;
  7535. //shift + ctrl/cmd + ->
  7536. if (evt.ctrlKey || evt.metaKey) {
  7537. if (!this._isTextHighlightOn) {
  7538. if (this._cursorOffset === 0) {
  7539. return;
  7540. }
  7541. else {
  7542. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7543. }
  7544. }
  7545. this._endHighlightIndex = this._text.length;
  7546. this._isTextHighlightOn = true;
  7547. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7548. this._cursorOffset = 0;
  7549. this._markAsDirty();
  7550. return;
  7551. }
  7552. if (!this._isTextHighlightOn) {
  7553. this._isTextHighlightOn = true;
  7554. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7555. }
  7556. //if text is already highlighted
  7557. else if (this._cursorIndex === -1) {
  7558. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7559. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7560. }
  7561. //set the highlight indexes
  7562. if (this._cursorIndex < this._cursorOffset) {
  7563. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7564. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7565. }
  7566. else if (this._cursorIndex > this._cursorOffset) {
  7567. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7568. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7569. }
  7570. else {
  7571. this._isTextHighlightOn = false;
  7572. }
  7573. this._markAsDirty();
  7574. return;
  7575. }
  7576. if (this._isTextHighlightOn) {
  7577. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7578. this._isTextHighlightOn = false;
  7579. }
  7580. //ctr + ->
  7581. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7582. this._cursorOffset = 0;
  7583. evt.preventDefault();
  7584. }
  7585. this._blinkIsEven = false;
  7586. this._isTextHighlightOn = false;
  7587. this._cursorIndex = -1;
  7588. this._markAsDirty();
  7589. return;
  7590. case 222: // Dead
  7591. if (evt) {
  7592. evt.preventDefault();
  7593. }
  7594. this._cursorIndex = -1;
  7595. this.deadKey = true;
  7596. break;
  7597. }
  7598. // Printable characters
  7599. if (key &&
  7600. ((keyCode === -1) || // Direct access
  7601. (keyCode === 32) || // Space
  7602. (keyCode > 47 && keyCode < 64) || // Numbers
  7603. (keyCode > 64 && keyCode < 91) || // Letters
  7604. (keyCode > 159 && keyCode < 193) || // Special characters
  7605. (keyCode > 218 && keyCode < 223) || // Special characters
  7606. (keyCode > 95 && keyCode < 112))) { // Numpad
  7607. this._currentKey = key;
  7608. this.onBeforeKeyAddObservable.notifyObservers(this);
  7609. key = this._currentKey;
  7610. if (this._addKey) {
  7611. if (this._isTextHighlightOn) {
  7612. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7613. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7614. this._isTextHighlightOn = false;
  7615. this._blinkIsEven = false;
  7616. this._markAsDirty();
  7617. }
  7618. else if (this._cursorOffset === 0) {
  7619. this.text += key;
  7620. }
  7621. else {
  7622. var insertPosition = this._text.length - this._cursorOffset;
  7623. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7624. }
  7625. }
  7626. }
  7627. };
  7628. /** @hidden */
  7629. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7630. //update the cursor
  7631. this._blinkIsEven = false;
  7632. if (this._cursorIndex === -1) {
  7633. this._cursorIndex = offset;
  7634. }
  7635. else {
  7636. if (this._cursorIndex < this._cursorOffset) {
  7637. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7638. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7639. }
  7640. else if (this._cursorIndex > this._cursorOffset) {
  7641. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7642. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7643. }
  7644. else {
  7645. this._isTextHighlightOn = false;
  7646. this._markAsDirty();
  7647. return;
  7648. }
  7649. }
  7650. this._isTextHighlightOn = true;
  7651. this._markAsDirty();
  7652. };
  7653. /** @hidden */
  7654. InputText.prototype._processDblClick = function (evt) {
  7655. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7656. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7657. this._endHighlightIndex = this._startHighlightIndex;
  7658. var rWord = /\w+/g, moveLeft, moveRight;
  7659. do {
  7660. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7661. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7662. } while (moveLeft || moveRight);
  7663. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7664. this.onTextHighlightObservable.notifyObservers(this);
  7665. this._isTextHighlightOn = true;
  7666. this._clickedCoordinate = null;
  7667. this._blinkIsEven = true;
  7668. this._cursorIndex = -1;
  7669. this._markAsDirty();
  7670. };
  7671. /** @hidden */
  7672. InputText.prototype._selectAllText = function () {
  7673. this._blinkIsEven = true;
  7674. this._isTextHighlightOn = true;
  7675. this._startHighlightIndex = 0;
  7676. this._endHighlightIndex = this._text.length;
  7677. this._cursorOffset = this._text.length;
  7678. this._cursorIndex = -1;
  7679. this._markAsDirty();
  7680. };
  7681. /**
  7682. * Handles the keyboard event
  7683. * @param evt Defines the KeyboardEvent
  7684. */
  7685. InputText.prototype.processKeyboard = function (evt) {
  7686. // process pressed key
  7687. this.processKey(evt.keyCode, evt.key, evt);
  7688. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7689. };
  7690. /** @hidden */
  7691. InputText.prototype._onCopyText = function (ev) {
  7692. this._isTextHighlightOn = false;
  7693. //when write permission to clipbaord data is denied
  7694. try {
  7695. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7696. }
  7697. catch (_a) { } //pass
  7698. this._host.clipboardData = this._highlightedText;
  7699. };
  7700. /** @hidden */
  7701. InputText.prototype._onCutText = function (ev) {
  7702. if (!this._highlightedText) {
  7703. return;
  7704. }
  7705. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7706. this._isTextHighlightOn = false;
  7707. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7708. //when write permission to clipbaord data is denied
  7709. try {
  7710. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7711. }
  7712. catch (_a) { } //pass
  7713. this._host.clipboardData = this._highlightedText;
  7714. this._highlightedText = "";
  7715. };
  7716. /** @hidden */
  7717. InputText.prototype._onPasteText = function (ev) {
  7718. var data = "";
  7719. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7720. data = ev.clipboardData.getData("text/plain");
  7721. }
  7722. else {
  7723. //get the cached data; returns blank string by default
  7724. data = this._host.clipboardData;
  7725. }
  7726. var insertPosition = this._text.length - this._cursorOffset;
  7727. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7728. };
  7729. InputText.prototype._draw = function (context, invalidatedRectangle) {
  7730. var _this = this;
  7731. context.save();
  7732. this._applyStates(context);
  7733. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7734. context.shadowColor = this.shadowColor;
  7735. context.shadowBlur = this.shadowBlur;
  7736. context.shadowOffsetX = this.shadowOffsetX;
  7737. context.shadowOffsetY = this.shadowOffsetY;
  7738. }
  7739. // Background
  7740. if (this._isFocused) {
  7741. if (this._focusedBackground) {
  7742. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7743. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7744. }
  7745. }
  7746. else if (this._background) {
  7747. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7748. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7749. }
  7750. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7751. context.shadowBlur = 0;
  7752. context.shadowOffsetX = 0;
  7753. context.shadowOffsetY = 0;
  7754. }
  7755. if (!this._fontOffset) {
  7756. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7757. }
  7758. // Text
  7759. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7760. if (this.color) {
  7761. context.fillStyle = this.color;
  7762. }
  7763. var text = this._beforeRenderText(this._text);
  7764. if (!this._isFocused && !this._text && this._placeholderText) {
  7765. text = this._placeholderText;
  7766. if (this._placeholderColor) {
  7767. context.fillStyle = this._placeholderColor;
  7768. }
  7769. }
  7770. this._textWidth = context.measureText(text).width;
  7771. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7772. if (this._autoStretchWidth) {
  7773. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7774. }
  7775. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7776. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7777. context.save();
  7778. context.beginPath();
  7779. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7780. context.clip();
  7781. if (this._isFocused && this._textWidth > availableWidth) {
  7782. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7783. if (!this._scrollLeft) {
  7784. this._scrollLeft = textLeft;
  7785. }
  7786. }
  7787. else {
  7788. this._scrollLeft = clipTextLeft;
  7789. }
  7790. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7791. // Cursor
  7792. if (this._isFocused) {
  7793. // Need to move cursor
  7794. if (this._clickedCoordinate) {
  7795. var rightPosition = this._scrollLeft + this._textWidth;
  7796. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7797. var currentSize = 0;
  7798. this._cursorOffset = 0;
  7799. var previousDist = 0;
  7800. do {
  7801. if (this._cursorOffset) {
  7802. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7803. }
  7804. this._cursorOffset++;
  7805. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7806. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7807. // Find closest move
  7808. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7809. this._cursorOffset--;
  7810. }
  7811. this._blinkIsEven = false;
  7812. this._clickedCoordinate = null;
  7813. }
  7814. // Render cursor
  7815. if (!this._blinkIsEven) {
  7816. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7817. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7818. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7819. if (cursorLeft < clipTextLeft) {
  7820. this._scrollLeft += (clipTextLeft - cursorLeft);
  7821. cursorLeft = clipTextLeft;
  7822. this._markAsDirty();
  7823. }
  7824. else if (cursorLeft > clipTextLeft + availableWidth) {
  7825. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7826. cursorLeft = clipTextLeft + availableWidth;
  7827. this._markAsDirty();
  7828. }
  7829. if (!this._isTextHighlightOn) {
  7830. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7831. }
  7832. }
  7833. clearTimeout(this._blinkTimeout);
  7834. this._blinkTimeout = setTimeout(function () {
  7835. _this._blinkIsEven = !_this._blinkIsEven;
  7836. _this._markAsDirty();
  7837. }, 500);
  7838. //show the highlighted text
  7839. if (this._isTextHighlightOn) {
  7840. clearTimeout(this._blinkTimeout);
  7841. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7842. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7843. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7844. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7845. if (highlightCursorLeft < clipTextLeft) {
  7846. width = width - (clipTextLeft - highlightCursorLeft);
  7847. if (!width) {
  7848. // when using left arrow on text.length > availableWidth;
  7849. // assigns the width of the first letter after clipTextLeft
  7850. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7851. }
  7852. highlightCursorLeft = clipTextLeft;
  7853. }
  7854. //for transparancy
  7855. context.globalAlpha = this._highligherOpacity;
  7856. context.fillStyle = this._textHighlightColor;
  7857. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7858. context.globalAlpha = 1.0;
  7859. }
  7860. }
  7861. context.restore();
  7862. // Border
  7863. if (this._thickness) {
  7864. if (this._isFocused) {
  7865. if (this.focusedColor) {
  7866. context.strokeStyle = this.focusedColor;
  7867. }
  7868. }
  7869. else {
  7870. if (this.color) {
  7871. context.strokeStyle = this.color;
  7872. }
  7873. }
  7874. context.lineWidth = this._thickness;
  7875. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7876. }
  7877. context.restore();
  7878. };
  7879. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7880. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7881. return false;
  7882. }
  7883. this._clickedCoordinate = coordinates.x;
  7884. this._isTextHighlightOn = false;
  7885. this._highlightedText = "";
  7886. this._cursorIndex = -1;
  7887. this._isPointerDown = true;
  7888. this._host._capturingControl[pointerId] = this;
  7889. if (this._host.focusedControl === this) {
  7890. // Move cursor
  7891. clearTimeout(this._blinkTimeout);
  7892. this._markAsDirty();
  7893. return true;
  7894. }
  7895. if (!this._isEnabled) {
  7896. return false;
  7897. }
  7898. this._host.focusedControl = this;
  7899. return true;
  7900. };
  7901. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7902. if (this._host.focusedControl === this && this._isPointerDown) {
  7903. this._clickedCoordinate = coordinates.x;
  7904. this._markAsDirty();
  7905. this._updateValueFromCursorIndex(this._cursorOffset);
  7906. }
  7907. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7908. };
  7909. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7910. this._isPointerDown = false;
  7911. delete this._host._capturingControl[pointerId];
  7912. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7913. };
  7914. InputText.prototype._beforeRenderText = function (text) {
  7915. return text;
  7916. };
  7917. InputText.prototype.dispose = function () {
  7918. _super.prototype.dispose.call(this);
  7919. this.onBlurObservable.clear();
  7920. this.onFocusObservable.clear();
  7921. this.onTextChangedObservable.clear();
  7922. this.onTextCopyObservable.clear();
  7923. this.onTextCutObservable.clear();
  7924. this.onTextPasteObservable.clear();
  7925. this.onTextHighlightObservable.clear();
  7926. this.onKeyboardEventProcessedObservable.clear();
  7927. };
  7928. return InputText;
  7929. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7930. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  7931. /***/ }),
  7932. /***/ "./2D/controls/line.ts":
  7933. /*!*****************************!*\
  7934. !*** ./2D/controls/line.ts ***!
  7935. \*****************************/
  7936. /*! exports provided: Line */
  7937. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7938. "use strict";
  7939. __webpack_require__.r(__webpack_exports__);
  7940. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7941. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7942. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  7943. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7944. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7945. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7946. /** Class used to render 2D lines */
  7947. var Line = /** @class */ (function (_super) {
  7948. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  7949. /**
  7950. * Creates a new Line
  7951. * @param name defines the control name
  7952. */
  7953. function Line(name) {
  7954. var _this = _super.call(this, name) || this;
  7955. _this.name = name;
  7956. _this._lineWidth = 1;
  7957. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7958. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7959. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7960. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7961. _this._dash = new Array();
  7962. _this._automaticSize = true;
  7963. _this.isHitTestVisible = false;
  7964. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7965. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7966. return _this;
  7967. }
  7968. Object.defineProperty(Line.prototype, "dash", {
  7969. /** Gets or sets the dash pattern */
  7970. get: function () {
  7971. return this._dash;
  7972. },
  7973. set: function (value) {
  7974. if (this._dash === value) {
  7975. return;
  7976. }
  7977. this._dash = value;
  7978. this._markAsDirty();
  7979. },
  7980. enumerable: true,
  7981. configurable: true
  7982. });
  7983. Object.defineProperty(Line.prototype, "connectedControl", {
  7984. /** Gets or sets the control connected with the line end */
  7985. get: function () {
  7986. return this._connectedControl;
  7987. },
  7988. set: function (value) {
  7989. var _this = this;
  7990. if (this._connectedControl === value) {
  7991. return;
  7992. }
  7993. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7994. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7995. this._connectedControlDirtyObserver = null;
  7996. }
  7997. if (value) {
  7998. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7999. }
  8000. this._connectedControl = value;
  8001. this._markAsDirty();
  8002. },
  8003. enumerable: true,
  8004. configurable: true
  8005. });
  8006. Object.defineProperty(Line.prototype, "x1", {
  8007. /** Gets or sets start coordinates on X axis */
  8008. get: function () {
  8009. return this._x1.toString(this._host);
  8010. },
  8011. set: function (value) {
  8012. if (this._x1.toString(this._host) === value) {
  8013. return;
  8014. }
  8015. if (this._x1.fromString(value)) {
  8016. this._markAsDirty();
  8017. }
  8018. },
  8019. enumerable: true,
  8020. configurable: true
  8021. });
  8022. Object.defineProperty(Line.prototype, "y1", {
  8023. /** Gets or sets start coordinates on Y axis */
  8024. get: function () {
  8025. return this._y1.toString(this._host);
  8026. },
  8027. set: function (value) {
  8028. if (this._y1.toString(this._host) === value) {
  8029. return;
  8030. }
  8031. if (this._y1.fromString(value)) {
  8032. this._markAsDirty();
  8033. }
  8034. },
  8035. enumerable: true,
  8036. configurable: true
  8037. });
  8038. Object.defineProperty(Line.prototype, "x2", {
  8039. /** Gets or sets end coordinates on X axis */
  8040. get: function () {
  8041. return this._x2.toString(this._host);
  8042. },
  8043. set: function (value) {
  8044. if (this._x2.toString(this._host) === value) {
  8045. return;
  8046. }
  8047. if (this._x2.fromString(value)) {
  8048. this._markAsDirty();
  8049. }
  8050. },
  8051. enumerable: true,
  8052. configurable: true
  8053. });
  8054. Object.defineProperty(Line.prototype, "y2", {
  8055. /** Gets or sets end coordinates on Y axis */
  8056. get: function () {
  8057. return this._y2.toString(this._host);
  8058. },
  8059. set: function (value) {
  8060. if (this._y2.toString(this._host) === value) {
  8061. return;
  8062. }
  8063. if (this._y2.fromString(value)) {
  8064. this._markAsDirty();
  8065. }
  8066. },
  8067. enumerable: true,
  8068. configurable: true
  8069. });
  8070. Object.defineProperty(Line.prototype, "lineWidth", {
  8071. /** Gets or sets line width */
  8072. get: function () {
  8073. return this._lineWidth;
  8074. },
  8075. set: function (value) {
  8076. if (this._lineWidth === value) {
  8077. return;
  8078. }
  8079. this._lineWidth = value;
  8080. this._markAsDirty();
  8081. },
  8082. enumerable: true,
  8083. configurable: true
  8084. });
  8085. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8086. /** Gets or sets horizontal alignment */
  8087. set: function (value) {
  8088. return;
  8089. },
  8090. enumerable: true,
  8091. configurable: true
  8092. });
  8093. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8094. /** Gets or sets vertical alignment */
  8095. set: function (value) {
  8096. return;
  8097. },
  8098. enumerable: true,
  8099. configurable: true
  8100. });
  8101. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8102. get: function () {
  8103. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8104. },
  8105. enumerable: true,
  8106. configurable: true
  8107. });
  8108. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8109. get: function () {
  8110. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8111. },
  8112. enumerable: true,
  8113. configurable: true
  8114. });
  8115. Line.prototype._getTypeName = function () {
  8116. return "Line";
  8117. };
  8118. Line.prototype._draw = function (context) {
  8119. context.save();
  8120. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8121. context.shadowColor = this.shadowColor;
  8122. context.shadowBlur = this.shadowBlur;
  8123. context.shadowOffsetX = this.shadowOffsetX;
  8124. context.shadowOffsetY = this.shadowOffsetY;
  8125. }
  8126. this._applyStates(context);
  8127. context.strokeStyle = this.color;
  8128. context.lineWidth = this._lineWidth;
  8129. context.setLineDash(this._dash);
  8130. context.beginPath();
  8131. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8132. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8133. context.stroke();
  8134. context.restore();
  8135. };
  8136. Line.prototype._measure = function () {
  8137. // Width / Height
  8138. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8139. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8140. };
  8141. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8142. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8143. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8144. };
  8145. /**
  8146. * Move one end of the line given 3D cartesian coordinates.
  8147. * @param position Targeted world position
  8148. * @param scene Scene
  8149. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8150. */
  8151. Line.prototype.moveToVector3 = function (position, scene, end) {
  8152. if (end === void 0) { end = false; }
  8153. if (!this._host || this.parent !== this._host._rootContainer) {
  8154. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8155. return;
  8156. }
  8157. var globalViewport = this._host._getGlobalViewport(scene);
  8158. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8159. this._moveToProjectedPosition(projectedPosition, end);
  8160. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8161. this.notRenderable = true;
  8162. return;
  8163. }
  8164. this.notRenderable = false;
  8165. };
  8166. /**
  8167. * Move one end of the line to a position in screen absolute space.
  8168. * @param projectedPosition Position in screen absolute space (X, Y)
  8169. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8170. */
  8171. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8172. if (end === void 0) { end = false; }
  8173. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8174. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8175. if (end) {
  8176. this.x2 = x;
  8177. this.y2 = y;
  8178. this._x2.ignoreAdaptiveScaling = true;
  8179. this._y2.ignoreAdaptiveScaling = true;
  8180. }
  8181. else {
  8182. this.x1 = x;
  8183. this.y1 = y;
  8184. this._x1.ignoreAdaptiveScaling = true;
  8185. this._y1.ignoreAdaptiveScaling = true;
  8186. }
  8187. };
  8188. return Line;
  8189. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8190. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8191. /***/ }),
  8192. /***/ "./2D/controls/multiLine.ts":
  8193. /*!**********************************!*\
  8194. !*** ./2D/controls/multiLine.ts ***!
  8195. \**********************************/
  8196. /*! exports provided: MultiLine */
  8197. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8198. "use strict";
  8199. __webpack_require__.r(__webpack_exports__);
  8200. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8201. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8202. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/perfCounter");
  8203. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8204. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8205. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8206. /**
  8207. * Class used to create multi line control
  8208. */
  8209. var MultiLine = /** @class */ (function (_super) {
  8210. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8211. /**
  8212. * Creates a new MultiLine
  8213. * @param name defines the control name
  8214. */
  8215. function MultiLine(name) {
  8216. var _this = _super.call(this, name) || this;
  8217. _this.name = name;
  8218. _this._lineWidth = 1;
  8219. /** Function called when a point is updated */
  8220. _this.onPointUpdate = function () {
  8221. _this._markAsDirty();
  8222. };
  8223. _this._automaticSize = true;
  8224. _this.isHitTestVisible = false;
  8225. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8226. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8227. _this._dash = [];
  8228. _this._points = [];
  8229. return _this;
  8230. }
  8231. Object.defineProperty(MultiLine.prototype, "dash", {
  8232. /** Gets or sets dash pattern */
  8233. get: function () {
  8234. return this._dash;
  8235. },
  8236. set: function (value) {
  8237. if (this._dash === value) {
  8238. return;
  8239. }
  8240. this._dash = value;
  8241. this._markAsDirty();
  8242. },
  8243. enumerable: true,
  8244. configurable: true
  8245. });
  8246. /**
  8247. * Gets point stored at specified index
  8248. * @param index defines the index to look for
  8249. * @returns the requested point if found
  8250. */
  8251. MultiLine.prototype.getAt = function (index) {
  8252. if (!this._points[index]) {
  8253. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8254. }
  8255. return this._points[index];
  8256. };
  8257. /**
  8258. * Adds new points to the point collection
  8259. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8260. * @returns the list of created MultiLinePoint
  8261. */
  8262. MultiLine.prototype.add = function () {
  8263. var _this = this;
  8264. var items = [];
  8265. for (var _i = 0; _i < arguments.length; _i++) {
  8266. items[_i] = arguments[_i];
  8267. }
  8268. return items.map(function (item) { return _this.push(item); });
  8269. };
  8270. /**
  8271. * Adds a new point to the point collection
  8272. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8273. * @returns the created MultiLinePoint
  8274. */
  8275. MultiLine.prototype.push = function (item) {
  8276. var point = this.getAt(this._points.length);
  8277. if (item == null) {
  8278. return point;
  8279. }
  8280. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8281. point.mesh = item;
  8282. }
  8283. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8284. point.control = item;
  8285. }
  8286. else if (item.x != null && item.y != null) {
  8287. point.x = item.x;
  8288. point.y = item.y;
  8289. }
  8290. return point;
  8291. };
  8292. /**
  8293. * Remove a specific value or point from the active point collection
  8294. * @param value defines the value or point to remove
  8295. */
  8296. MultiLine.prototype.remove = function (value) {
  8297. var index;
  8298. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8299. index = this._points.indexOf(value);
  8300. if (index === -1) {
  8301. return;
  8302. }
  8303. }
  8304. else {
  8305. index = value;
  8306. }
  8307. var point = this._points[index];
  8308. if (!point) {
  8309. return;
  8310. }
  8311. point.dispose();
  8312. this._points.splice(index, 1);
  8313. };
  8314. /**
  8315. * Resets this object to initial state (no point)
  8316. */
  8317. MultiLine.prototype.reset = function () {
  8318. while (this._points.length > 0) {
  8319. this.remove(this._points.length - 1);
  8320. }
  8321. };
  8322. /**
  8323. * Resets all links
  8324. */
  8325. MultiLine.prototype.resetLinks = function () {
  8326. this._points.forEach(function (point) {
  8327. if (point != null) {
  8328. point.resetLinks();
  8329. }
  8330. });
  8331. };
  8332. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8333. /** Gets or sets line width */
  8334. get: function () {
  8335. return this._lineWidth;
  8336. },
  8337. set: function (value) {
  8338. if (this._lineWidth === value) {
  8339. return;
  8340. }
  8341. this._lineWidth = value;
  8342. this._markAsDirty();
  8343. },
  8344. enumerable: true,
  8345. configurable: true
  8346. });
  8347. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8348. set: function (value) {
  8349. return;
  8350. },
  8351. enumerable: true,
  8352. configurable: true
  8353. });
  8354. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8355. set: function (value) {
  8356. return;
  8357. },
  8358. enumerable: true,
  8359. configurable: true
  8360. });
  8361. MultiLine.prototype._getTypeName = function () {
  8362. return "MultiLine";
  8363. };
  8364. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8365. context.save();
  8366. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8367. context.shadowColor = this.shadowColor;
  8368. context.shadowBlur = this.shadowBlur;
  8369. context.shadowOffsetX = this.shadowOffsetX;
  8370. context.shadowOffsetY = this.shadowOffsetY;
  8371. }
  8372. this._applyStates(context);
  8373. context.strokeStyle = this.color;
  8374. context.lineWidth = this._lineWidth;
  8375. context.setLineDash(this._dash);
  8376. context.beginPath();
  8377. var first = true; //first index is not necessarily 0
  8378. this._points.forEach(function (point) {
  8379. if (!point) {
  8380. return;
  8381. }
  8382. if (first) {
  8383. context.moveTo(point._point.x, point._point.y);
  8384. first = false;
  8385. }
  8386. else {
  8387. context.lineTo(point._point.x, point._point.y);
  8388. }
  8389. });
  8390. context.stroke();
  8391. context.restore();
  8392. };
  8393. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8394. var _this = this;
  8395. this._minX = null;
  8396. this._minY = null;
  8397. this._maxX = null;
  8398. this._maxY = null;
  8399. this._points.forEach(function (point, index) {
  8400. if (!point) {
  8401. return;
  8402. }
  8403. point.translate();
  8404. if (_this._minX == null || point._point.x < _this._minX) {
  8405. _this._minX = point._point.x;
  8406. }
  8407. if (_this._minY == null || point._point.y < _this._minY) {
  8408. _this._minY = point._point.y;
  8409. }
  8410. if (_this._maxX == null || point._point.x > _this._maxX) {
  8411. _this._maxX = point._point.x;
  8412. }
  8413. if (_this._maxY == null || point._point.y > _this._maxY) {
  8414. _this._maxY = point._point.y;
  8415. }
  8416. });
  8417. if (this._minX == null) {
  8418. this._minX = 0;
  8419. }
  8420. if (this._minY == null) {
  8421. this._minY = 0;
  8422. }
  8423. if (this._maxX == null) {
  8424. this._maxX = 0;
  8425. }
  8426. if (this._maxY == null) {
  8427. this._maxY = 0;
  8428. }
  8429. };
  8430. MultiLine.prototype._measure = function () {
  8431. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8432. return;
  8433. }
  8434. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8435. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8436. };
  8437. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8438. if (this._minX == null || this._minY == null) {
  8439. return;
  8440. }
  8441. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8442. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8443. };
  8444. MultiLine.prototype.dispose = function () {
  8445. this.reset();
  8446. _super.prototype.dispose.call(this);
  8447. };
  8448. return MultiLine;
  8449. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8450. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8451. /***/ }),
  8452. /***/ "./2D/controls/radioButton.ts":
  8453. /*!************************************!*\
  8454. !*** ./2D/controls/radioButton.ts ***!
  8455. \************************************/
  8456. /*! exports provided: RadioButton */
  8457. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8458. "use strict";
  8459. __webpack_require__.r(__webpack_exports__);
  8460. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8461. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8462. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  8463. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8464. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8465. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8466. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8467. /**
  8468. * Class used to create radio button controls
  8469. */
  8470. var RadioButton = /** @class */ (function (_super) {
  8471. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8472. /**
  8473. * Creates a new RadioButton
  8474. * @param name defines the control name
  8475. */
  8476. function RadioButton(name) {
  8477. var _this = _super.call(this, name) || this;
  8478. _this.name = name;
  8479. _this._isChecked = false;
  8480. _this._background = "black";
  8481. _this._checkSizeRatio = 0.8;
  8482. _this._thickness = 1;
  8483. /** Gets or sets group name */
  8484. _this.group = "";
  8485. /** Observable raised when isChecked is changed */
  8486. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8487. _this.isPointerBlocker = true;
  8488. return _this;
  8489. }
  8490. Object.defineProperty(RadioButton.prototype, "thickness", {
  8491. /** Gets or sets border thickness */
  8492. get: function () {
  8493. return this._thickness;
  8494. },
  8495. set: function (value) {
  8496. if (this._thickness === value) {
  8497. return;
  8498. }
  8499. this._thickness = value;
  8500. this._markAsDirty();
  8501. },
  8502. enumerable: true,
  8503. configurable: true
  8504. });
  8505. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8506. /** Gets or sets a value indicating the ratio between overall size and check size */
  8507. get: function () {
  8508. return this._checkSizeRatio;
  8509. },
  8510. set: function (value) {
  8511. value = Math.max(Math.min(1, value), 0);
  8512. if (this._checkSizeRatio === value) {
  8513. return;
  8514. }
  8515. this._checkSizeRatio = value;
  8516. this._markAsDirty();
  8517. },
  8518. enumerable: true,
  8519. configurable: true
  8520. });
  8521. Object.defineProperty(RadioButton.prototype, "background", {
  8522. /** Gets or sets background color */
  8523. get: function () {
  8524. return this._background;
  8525. },
  8526. set: function (value) {
  8527. if (this._background === value) {
  8528. return;
  8529. }
  8530. this._background = value;
  8531. this._markAsDirty();
  8532. },
  8533. enumerable: true,
  8534. configurable: true
  8535. });
  8536. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8537. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8538. get: function () {
  8539. return this._isChecked;
  8540. },
  8541. set: function (value) {
  8542. var _this = this;
  8543. if (this._isChecked === value) {
  8544. return;
  8545. }
  8546. this._isChecked = value;
  8547. this._markAsDirty();
  8548. this.onIsCheckedChangedObservable.notifyObservers(value);
  8549. if (this._isChecked && this._host) {
  8550. // Update all controls from same group
  8551. this._host.executeOnAllControls(function (control) {
  8552. if (control === _this) {
  8553. return;
  8554. }
  8555. if (control.group === undefined) {
  8556. return;
  8557. }
  8558. var childRadio = control;
  8559. if (childRadio.group === _this.group) {
  8560. childRadio.isChecked = false;
  8561. }
  8562. });
  8563. }
  8564. },
  8565. enumerable: true,
  8566. configurable: true
  8567. });
  8568. RadioButton.prototype._getTypeName = function () {
  8569. return "RadioButton";
  8570. };
  8571. RadioButton.prototype._draw = function (context) {
  8572. context.save();
  8573. this._applyStates(context);
  8574. var actualWidth = this._currentMeasure.width - this._thickness;
  8575. var actualHeight = this._currentMeasure.height - this._thickness;
  8576. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8577. context.shadowColor = this.shadowColor;
  8578. context.shadowBlur = this.shadowBlur;
  8579. context.shadowOffsetX = this.shadowOffsetX;
  8580. context.shadowOffsetY = this.shadowOffsetY;
  8581. }
  8582. // Outer
  8583. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2 - this._thickness / 2, this._currentMeasure.height / 2 - this._thickness / 2, context);
  8584. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8585. context.fill();
  8586. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8587. context.shadowBlur = 0;
  8588. context.shadowOffsetX = 0;
  8589. context.shadowOffsetY = 0;
  8590. }
  8591. context.strokeStyle = this.color;
  8592. context.lineWidth = this._thickness;
  8593. context.stroke();
  8594. // Inner
  8595. if (this._isChecked) {
  8596. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8597. var offsetWidth = actualWidth * this._checkSizeRatio;
  8598. var offseHeight = actualHeight * this._checkSizeRatio;
  8599. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, offsetWidth / 2 - this._thickness / 2, offseHeight / 2 - this._thickness / 2, context);
  8600. context.fill();
  8601. }
  8602. context.restore();
  8603. };
  8604. // Events
  8605. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8606. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8607. return false;
  8608. }
  8609. if (!this.isChecked) {
  8610. this.isChecked = true;
  8611. }
  8612. return true;
  8613. };
  8614. /**
  8615. * Utility function to easily create a radio button with a header
  8616. * @param title defines the label to use for the header
  8617. * @param group defines the group to use for the radio button
  8618. * @param isChecked defines the initial state of the radio button
  8619. * @param onValueChanged defines the callback to call when value changes
  8620. * @returns a StackPanel containing the radio button and a textBlock
  8621. */
  8622. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8623. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8624. panel.isVertical = false;
  8625. panel.height = "30px";
  8626. var radio = new RadioButton();
  8627. radio.width = "20px";
  8628. radio.height = "20px";
  8629. radio.isChecked = isChecked;
  8630. radio.color = "green";
  8631. radio.group = group;
  8632. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8633. panel.addControl(radio);
  8634. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8635. header.text = title;
  8636. header.width = "180px";
  8637. header.paddingLeft = "5px";
  8638. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8639. header.color = "white";
  8640. panel.addControl(header);
  8641. return panel;
  8642. };
  8643. return RadioButton;
  8644. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8645. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8646. /***/ }),
  8647. /***/ "./2D/controls/rectangle.ts":
  8648. /*!**********************************!*\
  8649. !*** ./2D/controls/rectangle.ts ***!
  8650. \**********************************/
  8651. /*! exports provided: Rectangle */
  8652. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8653. "use strict";
  8654. __webpack_require__.r(__webpack_exports__);
  8655. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8656. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8657. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8658. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  8659. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8660. /** Class used to create rectangle container */
  8661. var Rectangle = /** @class */ (function (_super) {
  8662. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8663. /**
  8664. * Creates a new Rectangle
  8665. * @param name defines the control name
  8666. */
  8667. function Rectangle(name) {
  8668. var _this = _super.call(this, name) || this;
  8669. _this.name = name;
  8670. _this._thickness = 1;
  8671. _this._cornerRadius = 0;
  8672. return _this;
  8673. }
  8674. Object.defineProperty(Rectangle.prototype, "thickness", {
  8675. /** Gets or sets border thickness */
  8676. get: function () {
  8677. return this._thickness;
  8678. },
  8679. set: function (value) {
  8680. if (this._thickness === value) {
  8681. return;
  8682. }
  8683. this._thickness = value;
  8684. this._markAsDirty();
  8685. },
  8686. enumerable: true,
  8687. configurable: true
  8688. });
  8689. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8690. /** Gets or sets the corner radius angle */
  8691. get: function () {
  8692. return this._cornerRadius;
  8693. },
  8694. set: function (value) {
  8695. if (value < 0) {
  8696. value = 0;
  8697. }
  8698. if (this._cornerRadius === value) {
  8699. return;
  8700. }
  8701. this._cornerRadius = value;
  8702. this._markAsDirty();
  8703. },
  8704. enumerable: true,
  8705. configurable: true
  8706. });
  8707. Rectangle.prototype._getTypeName = function () {
  8708. return "Rectangle";
  8709. };
  8710. Rectangle.prototype._localDraw = function (context) {
  8711. context.save();
  8712. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8713. context.shadowColor = this.shadowColor;
  8714. context.shadowBlur = this.shadowBlur;
  8715. context.shadowOffsetX = this.shadowOffsetX;
  8716. context.shadowOffsetY = this.shadowOffsetY;
  8717. }
  8718. if (this._background) {
  8719. context.fillStyle = this._background;
  8720. if (this._cornerRadius) {
  8721. this._drawRoundedRect(context, this._thickness / 2);
  8722. context.fill();
  8723. }
  8724. else {
  8725. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8726. }
  8727. }
  8728. if (this._thickness) {
  8729. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8730. context.shadowBlur = 0;
  8731. context.shadowOffsetX = 0;
  8732. context.shadowOffsetY = 0;
  8733. }
  8734. if (this.color) {
  8735. context.strokeStyle = this.color;
  8736. }
  8737. context.lineWidth = this._thickness;
  8738. if (this._cornerRadius) {
  8739. this._drawRoundedRect(context, this._thickness / 2);
  8740. context.stroke();
  8741. }
  8742. else {
  8743. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8744. }
  8745. }
  8746. context.restore();
  8747. };
  8748. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8749. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8750. this._measureForChildren.width -= 2 * this._thickness;
  8751. this._measureForChildren.height -= 2 * this._thickness;
  8752. this._measureForChildren.left += this._thickness;
  8753. this._measureForChildren.top += this._thickness;
  8754. };
  8755. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8756. if (offset === void 0) { offset = 0; }
  8757. var x = this._currentMeasure.left + offset;
  8758. var y = this._currentMeasure.top + offset;
  8759. var width = this._currentMeasure.width - offset * 2;
  8760. var height = this._currentMeasure.height - offset * 2;
  8761. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8762. context.beginPath();
  8763. context.moveTo(x + radius, y);
  8764. context.lineTo(x + width - radius, y);
  8765. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8766. context.lineTo(x + width, y + height - radius);
  8767. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8768. context.lineTo(x + radius, y + height);
  8769. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8770. context.lineTo(x, y + radius);
  8771. context.quadraticCurveTo(x, y, x + radius, y);
  8772. context.closePath();
  8773. };
  8774. Rectangle.prototype._clipForChildren = function (context) {
  8775. if (this._cornerRadius) {
  8776. this._drawRoundedRect(context, this._thickness);
  8777. context.clip();
  8778. }
  8779. };
  8780. return Rectangle;
  8781. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8782. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  8783. /***/ }),
  8784. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8785. /*!***************************************************!*\
  8786. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8787. \***************************************************/
  8788. /*! exports provided: ScrollViewer */
  8789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8790. "use strict";
  8791. __webpack_require__.r(__webpack_exports__);
  8792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8793. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8794. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/perfCounter");
  8795. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8796. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8797. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8798. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8799. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8800. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8801. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  8802. /**
  8803. * Class used to hold a viewer window and sliders in a grid
  8804. */
  8805. var ScrollViewer = /** @class */ (function (_super) {
  8806. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  8807. /**
  8808. * Creates a new ScrollViewer
  8809. * @param name of ScrollViewer
  8810. */
  8811. function ScrollViewer(name, isImageBased) {
  8812. var _this = _super.call(this, name) || this;
  8813. _this._barSize = 20;
  8814. _this._pointerIsOver = false;
  8815. _this._wheelPrecision = 0.05;
  8816. _this._thumbLength = 0.5;
  8817. _this._thumbHeight = 1;
  8818. _this._barImageHeight = 1;
  8819. _this._useImageBar = isImageBased ? isImageBased : false;
  8820. _this.onDirtyObservable.add(function () {
  8821. _this._horizontalBarSpace.color = _this.color;
  8822. _this._verticalBarSpace.color = _this.color;
  8823. _this._dragSpace.color = _this.color;
  8824. });
  8825. _this.onPointerEnterObservable.add(function () {
  8826. _this._pointerIsOver = true;
  8827. });
  8828. _this.onPointerOutObservable.add(function () {
  8829. _this._pointerIsOver = false;
  8830. });
  8831. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8832. if (_this._useImageBar) {
  8833. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__["ImageScrollBar"]();
  8834. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__["ImageScrollBar"]();
  8835. }
  8836. else {
  8837. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8838. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8839. }
  8840. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8841. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8842. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8843. _this._grid.addColumnDefinition(1);
  8844. _this._grid.addColumnDefinition(0, true);
  8845. _this._grid.addRowDefinition(1);
  8846. _this._grid.addRowDefinition(0, true);
  8847. _super.prototype.addControl.call(_this, _this._grid);
  8848. _this._grid.addControl(_this._window, 0, 0);
  8849. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8850. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8851. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8852. _this._verticalBarSpace.thickness = 1;
  8853. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8854. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  8855. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8856. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8857. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8858. _this._horizontalBarSpace.thickness = 1;
  8859. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8860. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  8861. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8862. _this._dragSpace.thickness = 1;
  8863. _this._grid.addControl(_this._dragSpace, 1, 1);
  8864. // Colors
  8865. if (!_this._useImageBar) {
  8866. _this.barColor = "grey";
  8867. _this.barBackground = "transparent";
  8868. }
  8869. return _this;
  8870. }
  8871. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8872. /**
  8873. * Gets the horizontal scrollbar
  8874. */
  8875. get: function () {
  8876. return this._horizontalBar;
  8877. },
  8878. enumerable: true,
  8879. configurable: true
  8880. });
  8881. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8882. /**
  8883. * Gets the vertical scrollbar
  8884. */
  8885. get: function () {
  8886. return this._verticalBar;
  8887. },
  8888. enumerable: true,
  8889. configurable: true
  8890. });
  8891. /**
  8892. * Adds a new control to the current container
  8893. * @param control defines the control to add
  8894. * @returns the current container
  8895. */
  8896. ScrollViewer.prototype.addControl = function (control) {
  8897. if (!control) {
  8898. return this;
  8899. }
  8900. this._window.addControl(control);
  8901. return this;
  8902. };
  8903. /**
  8904. * Removes a control from the current container
  8905. * @param control defines the control to remove
  8906. * @returns the current container
  8907. */
  8908. ScrollViewer.prototype.removeControl = function (control) {
  8909. this._window.removeControl(control);
  8910. return this;
  8911. };
  8912. Object.defineProperty(ScrollViewer.prototype, "children", {
  8913. /** Gets the list of children */
  8914. get: function () {
  8915. return this._window.children;
  8916. },
  8917. enumerable: true,
  8918. configurable: true
  8919. });
  8920. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8921. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8922. var child = _a[_i];
  8923. child._markMatrixAsDirty();
  8924. }
  8925. };
  8926. /** Reset the scroll viewer window to initial size */
  8927. ScrollViewer.prototype.resetWindow = function () {
  8928. this._window.width = "100%";
  8929. this._window.height = "100%";
  8930. };
  8931. ScrollViewer.prototype._getTypeName = function () {
  8932. return "ScrollViewer";
  8933. };
  8934. ScrollViewer.prototype._buildClientSizes = function () {
  8935. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8936. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8937. this._clientWidth = this._window.parentClientWidth;
  8938. this._clientHeight = this._window.parentClientHeight;
  8939. };
  8940. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8941. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8942. this._buildClientSizes();
  8943. };
  8944. ScrollViewer.prototype._postMeasure = function () {
  8945. _super.prototype._postMeasure.call(this);
  8946. this._updateScroller();
  8947. };
  8948. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8949. /**
  8950. * Gets or sets the mouse wheel precision
  8951. * from 0 to 1 with a default value of 0.05
  8952. * */
  8953. get: function () {
  8954. return this._wheelPrecision;
  8955. },
  8956. set: function (value) {
  8957. if (this._wheelPrecision === value) {
  8958. return;
  8959. }
  8960. if (value < 0) {
  8961. value = 0;
  8962. }
  8963. if (value > 1) {
  8964. value = 1;
  8965. }
  8966. this._wheelPrecision = value;
  8967. },
  8968. enumerable: true,
  8969. configurable: true
  8970. });
  8971. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  8972. /** Gets or sets the scroll bar container background color */
  8973. get: function () {
  8974. return this._horizontalBarSpace.background;
  8975. },
  8976. set: function (color) {
  8977. if (this._horizontalBarSpace.background === color) {
  8978. return;
  8979. }
  8980. this._horizontalBarSpace.background = color;
  8981. this._verticalBarSpace.background = color;
  8982. },
  8983. enumerable: true,
  8984. configurable: true
  8985. });
  8986. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8987. /** Gets or sets the bar color */
  8988. get: function () {
  8989. return this._barColor;
  8990. },
  8991. set: function (color) {
  8992. if (this._barColor === color) {
  8993. return;
  8994. }
  8995. this._barColor = color;
  8996. this._horizontalBar.color = color;
  8997. this._verticalBar.color = color;
  8998. },
  8999. enumerable: true,
  9000. configurable: true
  9001. });
  9002. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9003. /** Gets or sets the bar image */
  9004. get: function () {
  9005. return this._barImage;
  9006. },
  9007. set: function (value) {
  9008. if (this._barImage === value) {
  9009. return;
  9010. }
  9011. this._barImage = value;
  9012. var hb = this._horizontalBar;
  9013. var vb = this._verticalBar;
  9014. hb.thumbImage = value;
  9015. vb.thumbImage = value;
  9016. },
  9017. enumerable: true,
  9018. configurable: true
  9019. });
  9020. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9021. /** Gets or sets the size of the bar */
  9022. get: function () {
  9023. return this._barSize;
  9024. },
  9025. set: function (value) {
  9026. if (this._barSize === value) {
  9027. return;
  9028. }
  9029. this._barSize = value;
  9030. this._markAsDirty();
  9031. if (this._horizontalBar.isVisible) {
  9032. this._grid.setRowDefinition(1, this._barSize, true);
  9033. }
  9034. if (this._verticalBar.isVisible) {
  9035. this._grid.setColumnDefinition(1, this._barSize, true);
  9036. }
  9037. },
  9038. enumerable: true,
  9039. configurable: true
  9040. });
  9041. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9042. /** Gets or sets the length of the thumb */
  9043. get: function () {
  9044. return this._thumbLength;
  9045. },
  9046. set: function (value) {
  9047. if (this._thumbLength === value) {
  9048. return;
  9049. }
  9050. if (value <= 0) {
  9051. value = 0.1;
  9052. }
  9053. if (value > 1) {
  9054. value = 1;
  9055. }
  9056. this._thumbLength = value;
  9057. var hb = this._horizontalBar;
  9058. var vb = this._verticalBar;
  9059. hb.thumbLength = value;
  9060. vb.thumbLength = value;
  9061. this._markAsDirty();
  9062. },
  9063. enumerable: true,
  9064. configurable: true
  9065. });
  9066. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9067. /** Gets or sets the height of the thumb */
  9068. get: function () {
  9069. return this._thumbHeight;
  9070. },
  9071. set: function (value) {
  9072. if (this._thumbHeight === value) {
  9073. return;
  9074. }
  9075. if (value <= 0) {
  9076. value = 0.1;
  9077. }
  9078. if (value > 1) {
  9079. value = 1;
  9080. }
  9081. this._thumbHeight = value;
  9082. var hb = this._horizontalBar;
  9083. var vb = this._verticalBar;
  9084. hb.thumbHeight = value;
  9085. vb.thumbHeight = value;
  9086. this._markAsDirty();
  9087. },
  9088. enumerable: true,
  9089. configurable: true
  9090. });
  9091. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9092. /** Gets or sets the height of the bar image */
  9093. get: function () {
  9094. return this._barImageHeight;
  9095. },
  9096. set: function (value) {
  9097. if (this._barImageHeight === value) {
  9098. return;
  9099. }
  9100. if (value <= 0) {
  9101. value = 0.1;
  9102. }
  9103. if (value > 1) {
  9104. value = 1;
  9105. }
  9106. this._barImageHeight = value;
  9107. var hb = this._horizontalBar;
  9108. var vb = this._verticalBar;
  9109. hb.barImageHeight = value;
  9110. vb.barImageHeight = value;
  9111. this._markAsDirty();
  9112. },
  9113. enumerable: true,
  9114. configurable: true
  9115. });
  9116. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9117. /** Gets or sets the bar background */
  9118. get: function () {
  9119. return this._barBackground;
  9120. },
  9121. set: function (color) {
  9122. if (this._barBackground === color) {
  9123. return;
  9124. }
  9125. this._barBackground = color;
  9126. var hb = this._horizontalBar;
  9127. var vb = this._verticalBar;
  9128. hb.background = color;
  9129. vb.background = color;
  9130. this._dragSpace.background = color;
  9131. },
  9132. enumerable: true,
  9133. configurable: true
  9134. });
  9135. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9136. /** Gets or sets the bar background image */
  9137. get: function () {
  9138. return this._barBackgroundImage;
  9139. },
  9140. set: function (value) {
  9141. if (this._barBackgroundImage === value) {
  9142. }
  9143. this._barBackgroundImage = value;
  9144. var hb = this._horizontalBar;
  9145. var vb = this._verticalBar;
  9146. hb.backgroundImage = value;
  9147. vb.backgroundImage = value;
  9148. },
  9149. enumerable: true,
  9150. configurable: true
  9151. });
  9152. /** @hidden */
  9153. ScrollViewer.prototype._updateScroller = function () {
  9154. var windowContentsWidth = this._window._currentMeasure.width;
  9155. var windowContentsHeight = this._window._currentMeasure.height;
  9156. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  9157. this._grid.setRowDefinition(1, 0, true);
  9158. this._horizontalBar.isVisible = false;
  9159. this._horizontalBar.value = 0;
  9160. this._rebuildLayout = true;
  9161. }
  9162. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  9163. this._grid.setRowDefinition(1, this._barSize, true);
  9164. this._horizontalBar.isVisible = true;
  9165. this._rebuildLayout = true;
  9166. }
  9167. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  9168. this._grid.setColumnDefinition(1, 0, true);
  9169. this._verticalBar.isVisible = false;
  9170. this._verticalBar.value = 0;
  9171. this._rebuildLayout = true;
  9172. }
  9173. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  9174. this._grid.setColumnDefinition(1, this._barSize, true);
  9175. this._verticalBar.isVisible = true;
  9176. this._rebuildLayout = true;
  9177. }
  9178. this._buildClientSizes();
  9179. this._endLeft = this._clientWidth - windowContentsWidth;
  9180. this._endTop = this._clientHeight - windowContentsHeight;
  9181. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  9182. var newTop = this._verticalBar.value * this._endTop + "px";
  9183. if (newLeft !== this._window.left) {
  9184. this._window.left = newLeft;
  9185. this._rebuildLayout = true;
  9186. }
  9187. if (newTop !== this._window.top) {
  9188. this._window.top = newTop;
  9189. this._rebuildLayout = true;
  9190. }
  9191. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * this._clientWidth + "px";
  9192. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * this._clientHeight + "px";
  9193. };
  9194. ScrollViewer.prototype._link = function (host) {
  9195. _super.prototype._link.call(this, host);
  9196. this._attachWheel();
  9197. };
  9198. /** @hidden */
  9199. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9200. var _this = this;
  9201. barControl.paddingLeft = 0;
  9202. barControl.width = "100%";
  9203. barControl.height = "100%";
  9204. barControl.barOffset = 0;
  9205. barControl.value = 0;
  9206. barControl.maximum = 1;
  9207. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9208. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9209. barControl.isVertical = isVertical;
  9210. barControl.rotation = rotation;
  9211. barControl.isVisible = false;
  9212. barContainer.addControl(barControl);
  9213. barControl.onValueChangedObservable.add(function (value) {
  9214. if (rotation > 0) {
  9215. _this._window.top = value * _this._endTop + "px";
  9216. }
  9217. else {
  9218. _this._window.left = value * _this._endLeft + "px";
  9219. }
  9220. });
  9221. };
  9222. /** @hidden */
  9223. ScrollViewer.prototype._attachWheel = function () {
  9224. var _this = this;
  9225. if (!this._host || this._onPointerObserver) {
  9226. return;
  9227. }
  9228. var scene = this._host.getScene();
  9229. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  9230. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  9231. return;
  9232. }
  9233. if (_this._verticalBar.isVisible == true) {
  9234. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  9235. _this._verticalBar.value -= _this._wheelPrecision;
  9236. }
  9237. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9238. _this._verticalBar.value += _this._wheelPrecision;
  9239. }
  9240. }
  9241. if (_this._horizontalBar.isVisible == true) {
  9242. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9243. _this._horizontalBar.value += _this._wheelPrecision;
  9244. }
  9245. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  9246. _this._horizontalBar.value -= _this._wheelPrecision;
  9247. }
  9248. }
  9249. });
  9250. };
  9251. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9252. if (!this.isHighlighted) {
  9253. return;
  9254. }
  9255. _super.prototype._renderHighlightSpecific.call(this, context);
  9256. this._grid._renderHighlightSpecific(context);
  9257. context.restore();
  9258. };
  9259. /** Releases associated resources */
  9260. ScrollViewer.prototype.dispose = function () {
  9261. var scene = this._host.getScene();
  9262. if (scene && this._onPointerObserver) {
  9263. scene.onPointerObservable.remove(this._onPointerObserver);
  9264. this._onPointerObserver = null;
  9265. }
  9266. _super.prototype.dispose.call(this);
  9267. };
  9268. return ScrollViewer;
  9269. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  9270. babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9271. /***/ }),
  9272. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9273. /*!*********************************************************!*\
  9274. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9275. \*********************************************************/
  9276. /*! exports provided: _ScrollViewerWindow */
  9277. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9278. "use strict";
  9279. __webpack_require__.r(__webpack_exports__);
  9280. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9281. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9282. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9283. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9284. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9285. /**
  9286. * Class used to hold a the container for ScrollViewer
  9287. * @hidden
  9288. */
  9289. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9290. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9291. /**
  9292. * Creates a new ScrollViewerWindow
  9293. * @param name of ScrollViewerWindow
  9294. */
  9295. function _ScrollViewerWindow(name) {
  9296. return _super.call(this, name) || this;
  9297. }
  9298. _ScrollViewerWindow.prototype._getTypeName = function () {
  9299. return "ScrollViewerWindow";
  9300. };
  9301. /** @hidden */
  9302. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9303. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9304. this._measureForChildren.left = this._currentMeasure.left;
  9305. this._measureForChildren.top = this._currentMeasure.top;
  9306. this._measureForChildren.width = parentMeasure.width;
  9307. this._measureForChildren.height = parentMeasure.height;
  9308. };
  9309. _ScrollViewerWindow.prototype._postMeasure = function () {
  9310. var maxWidth = this.parentClientWidth;
  9311. var maxHeight = this.parentClientHeight;
  9312. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9313. var child = _a[_i];
  9314. if (!child.isVisible || child.notRenderable) {
  9315. continue;
  9316. }
  9317. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9318. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9319. }
  9320. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9321. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9322. }
  9323. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9324. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9325. }
  9326. if (this._currentMeasure.width !== maxWidth) {
  9327. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9328. this._currentMeasure.width = maxWidth;
  9329. this._rebuildLayout = true;
  9330. this._isDirty = true;
  9331. }
  9332. if (this._currentMeasure.height !== maxHeight) {
  9333. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9334. this._currentMeasure.height = maxHeight;
  9335. this._rebuildLayout = true;
  9336. this._isDirty = true;
  9337. }
  9338. _super.prototype._postMeasure.call(this);
  9339. };
  9340. return _ScrollViewerWindow;
  9341. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9342. /***/ }),
  9343. /***/ "./2D/controls/selector.ts":
  9344. /*!*********************************!*\
  9345. !*** ./2D/controls/selector.ts ***!
  9346. \*********************************/
  9347. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9348. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9349. "use strict";
  9350. __webpack_require__.r(__webpack_exports__);
  9351. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9352. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9354. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9356. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9357. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9358. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9359. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9360. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9361. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9362. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9363. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9364. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9365. /** Class used to create a RadioGroup
  9366. * which contains groups of radio buttons
  9367. */
  9368. var SelectorGroup = /** @class */ (function () {
  9369. /**
  9370. * Creates a new SelectorGroup
  9371. * @param name of group, used as a group heading
  9372. */
  9373. function SelectorGroup(
  9374. /** name of SelectorGroup */
  9375. name) {
  9376. this.name = name;
  9377. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9378. this._selectors = new Array();
  9379. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9380. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9381. this._groupHeader = this._addGroupHeader(name);
  9382. }
  9383. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9384. /** Gets the groupPanel of the SelectorGroup */
  9385. get: function () {
  9386. return this._groupPanel;
  9387. },
  9388. enumerable: true,
  9389. configurable: true
  9390. });
  9391. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9392. /** Gets the selectors array */
  9393. get: function () {
  9394. return this._selectors;
  9395. },
  9396. enumerable: true,
  9397. configurable: true
  9398. });
  9399. Object.defineProperty(SelectorGroup.prototype, "header", {
  9400. /** Gets and sets the group header */
  9401. get: function () {
  9402. return this._groupHeader.text;
  9403. },
  9404. set: function (label) {
  9405. if (this._groupHeader.text === "label") {
  9406. return;
  9407. }
  9408. this._groupHeader.text = label;
  9409. },
  9410. enumerable: true,
  9411. configurable: true
  9412. });
  9413. /** @hidden */
  9414. SelectorGroup.prototype._addGroupHeader = function (text) {
  9415. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9416. groupHeading.width = 0.9;
  9417. groupHeading.height = "30px";
  9418. groupHeading.textWrapping = true;
  9419. groupHeading.color = "black";
  9420. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9421. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9422. groupHeading.left = "2px";
  9423. this._groupPanel.addControl(groupHeading);
  9424. return groupHeading;
  9425. };
  9426. /** @hidden*/
  9427. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9428. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9429. return;
  9430. }
  9431. return this._selectors[selectorNb];
  9432. };
  9433. /** Removes the selector at the given position
  9434. * @param selectorNb the position of the selector within the group
  9435. */
  9436. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9437. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9438. return;
  9439. }
  9440. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9441. this._selectors.splice(selectorNb, 1);
  9442. };
  9443. return SelectorGroup;
  9444. }());
  9445. /** Class used to create a CheckboxGroup
  9446. * which contains groups of checkbox buttons
  9447. */
  9448. var CheckboxGroup = /** @class */ (function (_super) {
  9449. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  9450. function CheckboxGroup() {
  9451. return _super !== null && _super.apply(this, arguments) || this;
  9452. }
  9453. /** Adds a checkbox as a control
  9454. * @param text is the label for the selector
  9455. * @param func is the function called when the Selector is checked
  9456. * @param checked is true when Selector is checked
  9457. */
  9458. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9459. if (func === void 0) { func = function (s) { }; }
  9460. if (checked === void 0) { checked = false; }
  9461. var checked = checked || false;
  9462. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9463. button.width = "20px";
  9464. button.height = "20px";
  9465. button.color = "#364249";
  9466. button.background = "#CCCCCC";
  9467. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9468. button.onIsCheckedChangedObservable.add(function (state) {
  9469. func(state);
  9470. });
  9471. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9472. _selector.height = "30px";
  9473. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9474. _selector.left = "4px";
  9475. this.groupPanel.addControl(_selector);
  9476. this.selectors.push(_selector);
  9477. button.isChecked = checked;
  9478. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9479. button.color = this.groupPanel.parent.parent.buttonColor;
  9480. button.background = this.groupPanel.parent.parent.buttonBackground;
  9481. }
  9482. };
  9483. /** @hidden */
  9484. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9485. this.selectors[selectorNb].children[1].text = label;
  9486. };
  9487. /** @hidden */
  9488. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9489. this.selectors[selectorNb].children[1].color = color;
  9490. };
  9491. /** @hidden */
  9492. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9493. this.selectors[selectorNb].children[0].color = color;
  9494. };
  9495. /** @hidden */
  9496. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9497. this.selectors[selectorNb].children[0].background = color;
  9498. };
  9499. return CheckboxGroup;
  9500. }(SelectorGroup));
  9501. /** Class used to create a RadioGroup
  9502. * which contains groups of radio buttons
  9503. */
  9504. var RadioGroup = /** @class */ (function (_super) {
  9505. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  9506. function RadioGroup() {
  9507. var _this = _super !== null && _super.apply(this, arguments) || this;
  9508. _this._selectNb = 0;
  9509. return _this;
  9510. }
  9511. /** Adds a radio button as a control
  9512. * @param label is the label for the selector
  9513. * @param func is the function called when the Selector is checked
  9514. * @param checked is true when Selector is checked
  9515. */
  9516. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9517. if (func === void 0) { func = function (n) { }; }
  9518. if (checked === void 0) { checked = false; }
  9519. var nb = this._selectNb++;
  9520. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9521. button.name = label;
  9522. button.width = "20px";
  9523. button.height = "20px";
  9524. button.color = "#364249";
  9525. button.background = "#CCCCCC";
  9526. button.group = this.name;
  9527. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9528. button.onIsCheckedChangedObservable.add(function (state) {
  9529. if (state) {
  9530. func(nb);
  9531. }
  9532. });
  9533. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9534. _selector.height = "30px";
  9535. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9536. _selector.left = "4px";
  9537. this.groupPanel.addControl(_selector);
  9538. this.selectors.push(_selector);
  9539. button.isChecked = checked;
  9540. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9541. button.color = this.groupPanel.parent.parent.buttonColor;
  9542. button.background = this.groupPanel.parent.parent.buttonBackground;
  9543. }
  9544. };
  9545. /** @hidden */
  9546. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9547. this.selectors[selectorNb].children[1].text = label;
  9548. };
  9549. /** @hidden */
  9550. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9551. this.selectors[selectorNb].children[1].color = color;
  9552. };
  9553. /** @hidden */
  9554. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9555. this.selectors[selectorNb].children[0].color = color;
  9556. };
  9557. /** @hidden */
  9558. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9559. this.selectors[selectorNb].children[0].background = color;
  9560. };
  9561. return RadioGroup;
  9562. }(SelectorGroup));
  9563. /** Class used to create a SliderGroup
  9564. * which contains groups of slider buttons
  9565. */
  9566. var SliderGroup = /** @class */ (function (_super) {
  9567. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  9568. function SliderGroup() {
  9569. return _super !== null && _super.apply(this, arguments) || this;
  9570. }
  9571. /**
  9572. * Adds a slider to the SelectorGroup
  9573. * @param label is the label for the SliderBar
  9574. * @param func is the function called when the Slider moves
  9575. * @param unit is a string describing the units used, eg degrees or metres
  9576. * @param min is the minimum value for the Slider
  9577. * @param max is the maximum value for the Slider
  9578. * @param value is the start value for the Slider between min and max
  9579. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9580. */
  9581. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9582. if (func === void 0) { func = function (v) { }; }
  9583. if (unit === void 0) { unit = "Units"; }
  9584. if (min === void 0) { min = 0; }
  9585. if (max === void 0) { max = 0; }
  9586. if (value === void 0) { value = 0; }
  9587. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9588. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9589. button.name = unit;
  9590. button.value = value;
  9591. button.minimum = min;
  9592. button.maximum = max;
  9593. button.width = 0.9;
  9594. button.height = "20px";
  9595. button.color = "#364249";
  9596. button.background = "#CCCCCC";
  9597. button.borderColor = "black";
  9598. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9599. button.left = "4px";
  9600. button.paddingBottom = "4px";
  9601. button.onValueChangedObservable.add(function (value) {
  9602. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9603. func(value);
  9604. });
  9605. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9606. _selector.height = "60px";
  9607. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9608. _selector.left = "4px";
  9609. _selector.children[0].name = label;
  9610. this.groupPanel.addControl(_selector);
  9611. this.selectors.push(_selector);
  9612. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9613. button.color = this.groupPanel.parent.parent.buttonColor;
  9614. button.background = this.groupPanel.parent.parent.buttonBackground;
  9615. }
  9616. };
  9617. /** @hidden */
  9618. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9619. this.selectors[selectorNb].children[0].name = label;
  9620. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9621. };
  9622. /** @hidden */
  9623. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9624. this.selectors[selectorNb].children[0].color = color;
  9625. };
  9626. /** @hidden */
  9627. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9628. this.selectors[selectorNb].children[1].color = color;
  9629. };
  9630. /** @hidden */
  9631. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9632. this.selectors[selectorNb].children[1].background = color;
  9633. };
  9634. return SliderGroup;
  9635. }(SelectorGroup));
  9636. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9637. * @see http://doc.babylonjs.com/how_to/selector
  9638. */
  9639. var SelectionPanel = /** @class */ (function (_super) {
  9640. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  9641. /**
  9642. * Creates a new SelectionPanel
  9643. * @param name of SelectionPanel
  9644. * @param groups is an array of SelectionGroups
  9645. */
  9646. function SelectionPanel(
  9647. /** name of SelectionPanel */
  9648. name,
  9649. /** an array of SelectionGroups */
  9650. groups) {
  9651. if (groups === void 0) { groups = []; }
  9652. var _this = _super.call(this, name) || this;
  9653. _this.name = name;
  9654. _this.groups = groups;
  9655. _this._buttonColor = "#364249";
  9656. _this._buttonBackground = "#CCCCCC";
  9657. _this._headerColor = "black";
  9658. _this._barColor = "white";
  9659. _this._barHeight = "2px";
  9660. _this._spacerHeight = "20px";
  9661. _this._bars = new Array();
  9662. _this._groups = groups;
  9663. _this.thickness = 2;
  9664. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9665. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9666. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9667. _this._panel.top = 5;
  9668. _this._panel.left = 5;
  9669. _this._panel.width = 0.95;
  9670. if (groups.length > 0) {
  9671. for (var i = 0; i < groups.length - 1; i++) {
  9672. _this._panel.addControl(groups[i].groupPanel);
  9673. _this._addSpacer();
  9674. }
  9675. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9676. }
  9677. _this.addControl(_this._panel);
  9678. return _this;
  9679. }
  9680. SelectionPanel.prototype._getTypeName = function () {
  9681. return "SelectionPanel";
  9682. };
  9683. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9684. /** Gets or sets the headerColor */
  9685. get: function () {
  9686. return this._headerColor;
  9687. },
  9688. set: function (color) {
  9689. if (this._headerColor === color) {
  9690. return;
  9691. }
  9692. this._headerColor = color;
  9693. this._setHeaderColor();
  9694. },
  9695. enumerable: true,
  9696. configurable: true
  9697. });
  9698. SelectionPanel.prototype._setHeaderColor = function () {
  9699. for (var i = 0; i < this._groups.length; i++) {
  9700. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9701. }
  9702. };
  9703. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9704. /** Gets or sets the button color */
  9705. get: function () {
  9706. return this._buttonColor;
  9707. },
  9708. set: function (color) {
  9709. if (this._buttonColor === color) {
  9710. return;
  9711. }
  9712. this._buttonColor = color;
  9713. this._setbuttonColor();
  9714. },
  9715. enumerable: true,
  9716. configurable: true
  9717. });
  9718. SelectionPanel.prototype._setbuttonColor = function () {
  9719. for (var i = 0; i < this._groups.length; i++) {
  9720. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9721. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9722. }
  9723. }
  9724. };
  9725. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9726. /** Gets or sets the label color */
  9727. get: function () {
  9728. return this._labelColor;
  9729. },
  9730. set: function (color) {
  9731. if (this._labelColor === color) {
  9732. return;
  9733. }
  9734. this._labelColor = color;
  9735. this._setLabelColor();
  9736. },
  9737. enumerable: true,
  9738. configurable: true
  9739. });
  9740. SelectionPanel.prototype._setLabelColor = function () {
  9741. for (var i = 0; i < this._groups.length; i++) {
  9742. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9743. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9744. }
  9745. }
  9746. };
  9747. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9748. /** Gets or sets the button background */
  9749. get: function () {
  9750. return this._buttonBackground;
  9751. },
  9752. set: function (color) {
  9753. if (this._buttonBackground === color) {
  9754. return;
  9755. }
  9756. this._buttonBackground = color;
  9757. this._setButtonBackground();
  9758. },
  9759. enumerable: true,
  9760. configurable: true
  9761. });
  9762. SelectionPanel.prototype._setButtonBackground = function () {
  9763. for (var i = 0; i < this._groups.length; i++) {
  9764. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9765. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9766. }
  9767. }
  9768. };
  9769. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9770. /** Gets or sets the color of separator bar */
  9771. get: function () {
  9772. return this._barColor;
  9773. },
  9774. set: function (color) {
  9775. if (this._barColor === color) {
  9776. return;
  9777. }
  9778. this._barColor = color;
  9779. this._setBarColor();
  9780. },
  9781. enumerable: true,
  9782. configurable: true
  9783. });
  9784. SelectionPanel.prototype._setBarColor = function () {
  9785. for (var i = 0; i < this._bars.length; i++) {
  9786. this._bars[i].children[0].background = this._barColor;
  9787. }
  9788. };
  9789. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9790. /** Gets or sets the height of separator bar */
  9791. get: function () {
  9792. return this._barHeight;
  9793. },
  9794. set: function (value) {
  9795. if (this._barHeight === value) {
  9796. return;
  9797. }
  9798. this._barHeight = value;
  9799. this._setBarHeight();
  9800. },
  9801. enumerable: true,
  9802. configurable: true
  9803. });
  9804. SelectionPanel.prototype._setBarHeight = function () {
  9805. for (var i = 0; i < this._bars.length; i++) {
  9806. this._bars[i].children[0].height = this._barHeight;
  9807. }
  9808. };
  9809. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9810. /** Gets or sets the height of spacers*/
  9811. get: function () {
  9812. return this._spacerHeight;
  9813. },
  9814. set: function (value) {
  9815. if (this._spacerHeight === value) {
  9816. return;
  9817. }
  9818. this._spacerHeight = value;
  9819. this._setSpacerHeight();
  9820. },
  9821. enumerable: true,
  9822. configurable: true
  9823. });
  9824. SelectionPanel.prototype._setSpacerHeight = function () {
  9825. for (var i = 0; i < this._bars.length; i++) {
  9826. this._bars[i].height = this._spacerHeight;
  9827. }
  9828. };
  9829. /** Adds a bar between groups */
  9830. SelectionPanel.prototype._addSpacer = function () {
  9831. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9832. separator.width = 1;
  9833. separator.height = this._spacerHeight;
  9834. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9835. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9836. bar.width = 1;
  9837. bar.height = this._barHeight;
  9838. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9839. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9840. bar.background = this._barColor;
  9841. bar.color = "transparent";
  9842. separator.addControl(bar);
  9843. this._panel.addControl(separator);
  9844. this._bars.push(separator);
  9845. };
  9846. /** Add a group to the selection panel
  9847. * @param group is the selector group to add
  9848. */
  9849. SelectionPanel.prototype.addGroup = function (group) {
  9850. if (this._groups.length > 0) {
  9851. this._addSpacer();
  9852. }
  9853. this._panel.addControl(group.groupPanel);
  9854. this._groups.push(group);
  9855. group.groupPanel.children[0].color = this._headerColor;
  9856. for (var j = 0; j < group.selectors.length; j++) {
  9857. group._setSelectorButtonColor(j, this._buttonColor);
  9858. group._setSelectorButtonBackground(j, this._buttonBackground);
  9859. }
  9860. };
  9861. /** Remove the group from the given position
  9862. * @param groupNb is the position of the group in the list
  9863. */
  9864. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9865. if (groupNb < 0 || groupNb >= this._groups.length) {
  9866. return;
  9867. }
  9868. var group = this._groups[groupNb];
  9869. this._panel.removeControl(group.groupPanel);
  9870. this._groups.splice(groupNb, 1);
  9871. if (groupNb < this._bars.length) {
  9872. this._panel.removeControl(this._bars[groupNb]);
  9873. this._bars.splice(groupNb, 1);
  9874. }
  9875. };
  9876. /** Change a group header label
  9877. * @param label is the new group header label
  9878. * @param groupNb is the number of the group to relabel
  9879. * */
  9880. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9881. if (groupNb < 0 || groupNb >= this._groups.length) {
  9882. return;
  9883. }
  9884. var group = this._groups[groupNb];
  9885. group.groupPanel.children[0].text = label;
  9886. };
  9887. /** Change selector label to the one given
  9888. * @param label is the new selector label
  9889. * @param groupNb is the number of the groupcontaining the selector
  9890. * @param selectorNb is the number of the selector within a group to relabel
  9891. * */
  9892. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9893. if (groupNb < 0 || groupNb >= this._groups.length) {
  9894. return;
  9895. }
  9896. var group = this._groups[groupNb];
  9897. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9898. return;
  9899. }
  9900. group._setSelectorLabel(selectorNb, label);
  9901. };
  9902. /** For a given group position remove the selector at the given position
  9903. * @param groupNb is the number of the group to remove the selector from
  9904. * @param selectorNb is the number of the selector within the group
  9905. */
  9906. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9907. if (groupNb < 0 || groupNb >= this._groups.length) {
  9908. return;
  9909. }
  9910. var group = this._groups[groupNb];
  9911. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9912. return;
  9913. }
  9914. group.removeSelector(selectorNb);
  9915. };
  9916. /** For a given group position of correct type add a checkbox button
  9917. * @param groupNb is the number of the group to remove the selector from
  9918. * @param label is the label for the selector
  9919. * @param func is the function called when the Selector is checked
  9920. * @param checked is true when Selector is checked
  9921. */
  9922. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9923. if (func === void 0) { func = function () { }; }
  9924. if (checked === void 0) { checked = false; }
  9925. if (groupNb < 0 || groupNb >= this._groups.length) {
  9926. return;
  9927. }
  9928. var group = this._groups[groupNb];
  9929. group.addCheckbox(label, func, checked);
  9930. };
  9931. /** For a given group position of correct type add a radio button
  9932. * @param groupNb is the number of the group to remove the selector from
  9933. * @param label is the label for the selector
  9934. * @param func is the function called when the Selector is checked
  9935. * @param checked is true when Selector is checked
  9936. */
  9937. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9938. if (func === void 0) { func = function () { }; }
  9939. if (checked === void 0) { checked = false; }
  9940. if (groupNb < 0 || groupNb >= this._groups.length) {
  9941. return;
  9942. }
  9943. var group = this._groups[groupNb];
  9944. group.addRadio(label, func, checked);
  9945. };
  9946. /**
  9947. * For a given slider group add a slider
  9948. * @param groupNb is the number of the group to add the slider to
  9949. * @param label is the label for the Slider
  9950. * @param func is the function called when the Slider moves
  9951. * @param unit is a string describing the units used, eg degrees or metres
  9952. * @param min is the minimum value for the Slider
  9953. * @param max is the maximum value for the Slider
  9954. * @param value is the start value for the Slider between min and max
  9955. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9956. */
  9957. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9958. if (func === void 0) { func = function () { }; }
  9959. if (unit === void 0) { unit = "Units"; }
  9960. if (min === void 0) { min = 0; }
  9961. if (max === void 0) { max = 0; }
  9962. if (value === void 0) { value = 0; }
  9963. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9964. if (groupNb < 0 || groupNb >= this._groups.length) {
  9965. return;
  9966. }
  9967. var group = this._groups[groupNb];
  9968. group.addSlider(label, func, unit, min, max, value, onVal);
  9969. };
  9970. return SelectionPanel;
  9971. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9972. /***/ }),
  9973. /***/ "./2D/controls/sliders/baseSlider.ts":
  9974. /*!*******************************************!*\
  9975. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9976. \*******************************************/
  9977. /*! exports provided: BaseSlider */
  9978. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9979. "use strict";
  9980. __webpack_require__.r(__webpack_exports__);
  9981. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9982. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9983. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  9984. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9985. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9986. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9987. /**
  9988. * Class used to create slider controls
  9989. */
  9990. var BaseSlider = /** @class */ (function (_super) {
  9991. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  9992. /**
  9993. * Creates a new BaseSlider
  9994. * @param name defines the control name
  9995. */
  9996. function BaseSlider(name) {
  9997. var _this = _super.call(this, name) || this;
  9998. _this.name = name;
  9999. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10000. _this._minimum = 0;
  10001. _this._maximum = 100;
  10002. _this._value = 50;
  10003. _this._isVertical = false;
  10004. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10005. _this._isThumbClamped = false;
  10006. _this._displayThumb = true;
  10007. _this._step = 0;
  10008. _this._lastPointerDownID = -1;
  10009. // Shared rendering info
  10010. _this._effectiveBarOffset = 0;
  10011. /** Observable raised when the sldier value changes */
  10012. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10013. // Events
  10014. _this._pointerIsDown = false;
  10015. _this.isPointerBlocker = true;
  10016. return _this;
  10017. }
  10018. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10019. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10020. get: function () {
  10021. return this._displayThumb;
  10022. },
  10023. set: function (value) {
  10024. if (this._displayThumb === value) {
  10025. return;
  10026. }
  10027. this._displayThumb = value;
  10028. this._markAsDirty();
  10029. },
  10030. enumerable: true,
  10031. configurable: true
  10032. });
  10033. Object.defineProperty(BaseSlider.prototype, "step", {
  10034. /** Gets or sets a step to apply to values (0 by default) */
  10035. get: function () {
  10036. return this._step;
  10037. },
  10038. set: function (value) {
  10039. if (this._step === value) {
  10040. return;
  10041. }
  10042. this._step = value;
  10043. this._markAsDirty();
  10044. },
  10045. enumerable: true,
  10046. configurable: true
  10047. });
  10048. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10049. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10050. get: function () {
  10051. return this._barOffset.toString(this._host);
  10052. },
  10053. set: function (value) {
  10054. if (this._barOffset.toString(this._host) === value) {
  10055. return;
  10056. }
  10057. if (this._barOffset.fromString(value)) {
  10058. this._markAsDirty();
  10059. }
  10060. },
  10061. enumerable: true,
  10062. configurable: true
  10063. });
  10064. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10065. /** Gets main bar offset in pixels*/
  10066. get: function () {
  10067. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10068. },
  10069. enumerable: true,
  10070. configurable: true
  10071. });
  10072. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10073. /** Gets or sets thumb width */
  10074. get: function () {
  10075. return this._thumbWidth.toString(this._host);
  10076. },
  10077. set: function (value) {
  10078. if (this._thumbWidth.toString(this._host) === value) {
  10079. return;
  10080. }
  10081. if (this._thumbWidth.fromString(value)) {
  10082. this._markAsDirty();
  10083. }
  10084. },
  10085. enumerable: true,
  10086. configurable: true
  10087. });
  10088. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10089. /** Gets thumb width in pixels */
  10090. get: function () {
  10091. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10092. },
  10093. enumerable: true,
  10094. configurable: true
  10095. });
  10096. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10097. /** Gets or sets minimum value */
  10098. get: function () {
  10099. return this._minimum;
  10100. },
  10101. set: function (value) {
  10102. if (this._minimum === value) {
  10103. return;
  10104. }
  10105. this._minimum = value;
  10106. this._markAsDirty();
  10107. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10108. },
  10109. enumerable: true,
  10110. configurable: true
  10111. });
  10112. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10113. /** Gets or sets maximum value */
  10114. get: function () {
  10115. return this._maximum;
  10116. },
  10117. set: function (value) {
  10118. if (this._maximum === value) {
  10119. return;
  10120. }
  10121. this._maximum = value;
  10122. this._markAsDirty();
  10123. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10124. },
  10125. enumerable: true,
  10126. configurable: true
  10127. });
  10128. Object.defineProperty(BaseSlider.prototype, "value", {
  10129. /** Gets or sets current value */
  10130. get: function () {
  10131. return this._value;
  10132. },
  10133. set: function (value) {
  10134. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10135. if (this._value === value) {
  10136. return;
  10137. }
  10138. this._value = value;
  10139. this._markAsDirty();
  10140. this.onValueChangedObservable.notifyObservers(this._value);
  10141. },
  10142. enumerable: true,
  10143. configurable: true
  10144. });
  10145. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10146. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10147. get: function () {
  10148. return this._isVertical;
  10149. },
  10150. set: function (value) {
  10151. if (this._isVertical === value) {
  10152. return;
  10153. }
  10154. this._isVertical = value;
  10155. this._markAsDirty();
  10156. },
  10157. enumerable: true,
  10158. configurable: true
  10159. });
  10160. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10161. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10162. get: function () {
  10163. return this._isThumbClamped;
  10164. },
  10165. set: function (value) {
  10166. if (this._isThumbClamped === value) {
  10167. return;
  10168. }
  10169. this._isThumbClamped = value;
  10170. this._markAsDirty();
  10171. },
  10172. enumerable: true,
  10173. configurable: true
  10174. });
  10175. BaseSlider.prototype._getTypeName = function () {
  10176. return "BaseSlider";
  10177. };
  10178. BaseSlider.prototype._getThumbPosition = function () {
  10179. if (this.isVertical) {
  10180. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10181. }
  10182. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10183. };
  10184. BaseSlider.prototype._getThumbThickness = function (type) {
  10185. var thumbThickness = 0;
  10186. switch (type) {
  10187. case "circle":
  10188. if (this._thumbWidth.isPixel) {
  10189. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10190. }
  10191. else {
  10192. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10193. }
  10194. break;
  10195. case "rectangle":
  10196. if (this._thumbWidth.isPixel) {
  10197. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10198. }
  10199. else {
  10200. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10201. }
  10202. }
  10203. return thumbThickness;
  10204. };
  10205. BaseSlider.prototype._prepareRenderingData = function (type) {
  10206. // Main bar
  10207. this._effectiveBarOffset = 0;
  10208. this._renderLeft = this._currentMeasure.left;
  10209. this._renderTop = this._currentMeasure.top;
  10210. this._renderWidth = this._currentMeasure.width;
  10211. this._renderHeight = this._currentMeasure.height;
  10212. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10213. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10214. this._effectiveThumbThickness = this._getThumbThickness(type);
  10215. if (this.displayThumb) {
  10216. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10217. }
  10218. //throw error when height is less than width for vertical slider
  10219. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10220. console.error("Height should be greater than width");
  10221. return;
  10222. }
  10223. if (this._barOffset.isPixel) {
  10224. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10225. }
  10226. else {
  10227. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10228. }
  10229. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10230. if (this.isVertical) {
  10231. this._renderLeft += this._effectiveBarOffset;
  10232. if (!this.isThumbClamped && this.displayThumb) {
  10233. this._renderTop += (this._effectiveThumbThickness / 2);
  10234. }
  10235. this._renderHeight = this._backgroundBoxLength;
  10236. this._renderWidth = this._backgroundBoxThickness;
  10237. }
  10238. else {
  10239. this._renderTop += this._effectiveBarOffset;
  10240. if (!this.isThumbClamped && this.displayThumb) {
  10241. this._renderLeft += (this._effectiveThumbThickness / 2);
  10242. }
  10243. this._renderHeight = this._backgroundBoxThickness;
  10244. this._renderWidth = this._backgroundBoxLength;
  10245. }
  10246. };
  10247. /** @hidden */
  10248. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10249. if (this.rotation != 0) {
  10250. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10251. x = this._transformedPosition.x;
  10252. y = this._transformedPosition.y;
  10253. }
  10254. var value;
  10255. if (this._isVertical) {
  10256. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10257. }
  10258. else {
  10259. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10260. }
  10261. var mult = (1 / this._step) | 0;
  10262. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10263. };
  10264. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10265. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10266. return false;
  10267. }
  10268. this._pointerIsDown = true;
  10269. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10270. this._host._capturingControl[pointerId] = this;
  10271. this._lastPointerDownID = pointerId;
  10272. return true;
  10273. };
  10274. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10275. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10276. if (pointerId != this._lastPointerDownID) {
  10277. return;
  10278. }
  10279. if (this._pointerIsDown) {
  10280. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10281. }
  10282. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10283. };
  10284. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10285. this._pointerIsDown = false;
  10286. delete this._host._capturingControl[pointerId];
  10287. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10288. };
  10289. return BaseSlider;
  10290. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10291. /***/ }),
  10292. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10293. /*!*************************************************!*\
  10294. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10295. \*************************************************/
  10296. /*! exports provided: ImageBasedSlider */
  10297. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10298. "use strict";
  10299. __webpack_require__.r(__webpack_exports__);
  10300. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10301. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10302. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10303. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10304. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  10305. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10306. /**
  10307. * Class used to create slider controls based on images
  10308. */
  10309. var ImageBasedSlider = /** @class */ (function (_super) {
  10310. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  10311. /**
  10312. * Creates a new ImageBasedSlider
  10313. * @param name defines the control name
  10314. */
  10315. function ImageBasedSlider(name) {
  10316. var _this = _super.call(this, name) || this;
  10317. _this.name = name;
  10318. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10319. return _this;
  10320. }
  10321. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10322. get: function () {
  10323. return this._displayThumb && this.thumbImage != null;
  10324. },
  10325. set: function (value) {
  10326. if (this._displayThumb === value) {
  10327. return;
  10328. }
  10329. this._displayThumb = value;
  10330. this._markAsDirty();
  10331. },
  10332. enumerable: true,
  10333. configurable: true
  10334. });
  10335. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10336. /**
  10337. * Gets or sets the image used to render the background
  10338. */
  10339. get: function () {
  10340. return this._backgroundImage;
  10341. },
  10342. set: function (value) {
  10343. var _this = this;
  10344. if (this._backgroundImage === value) {
  10345. return;
  10346. }
  10347. this._backgroundImage = value;
  10348. if (value && !value.isLoaded) {
  10349. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10350. }
  10351. this._markAsDirty();
  10352. },
  10353. enumerable: true,
  10354. configurable: true
  10355. });
  10356. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10357. /**
  10358. * Gets or sets the image used to render the value bar
  10359. */
  10360. get: function () {
  10361. return this._valueBarImage;
  10362. },
  10363. set: function (value) {
  10364. var _this = this;
  10365. if (this._valueBarImage === value) {
  10366. return;
  10367. }
  10368. this._valueBarImage = value;
  10369. if (value && !value.isLoaded) {
  10370. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10371. }
  10372. this._markAsDirty();
  10373. },
  10374. enumerable: true,
  10375. configurable: true
  10376. });
  10377. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10378. /**
  10379. * Gets or sets the image used to render the thumb
  10380. */
  10381. get: function () {
  10382. return this._thumbImage;
  10383. },
  10384. set: function (value) {
  10385. var _this = this;
  10386. if (this._thumbImage === value) {
  10387. return;
  10388. }
  10389. this._thumbImage = value;
  10390. if (value && !value.isLoaded) {
  10391. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10392. }
  10393. this._markAsDirty();
  10394. },
  10395. enumerable: true,
  10396. configurable: true
  10397. });
  10398. ImageBasedSlider.prototype._getTypeName = function () {
  10399. return "ImageBasedSlider";
  10400. };
  10401. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  10402. context.save();
  10403. this._applyStates(context);
  10404. this._prepareRenderingData("rectangle");
  10405. var thumbPosition = this._getThumbPosition();
  10406. var left = this._renderLeft;
  10407. var top = this._renderTop;
  10408. var width = this._renderWidth;
  10409. var height = this._renderHeight;
  10410. // Background
  10411. if (this._backgroundImage) {
  10412. this._tempMeasure.copyFromFloats(left, top, width, height);
  10413. if (this.isThumbClamped && this.displayThumb) {
  10414. if (this.isVertical) {
  10415. this._tempMeasure.height += this._effectiveThumbThickness;
  10416. }
  10417. else {
  10418. this._tempMeasure.width += this._effectiveThumbThickness;
  10419. }
  10420. }
  10421. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10422. this._backgroundImage._draw(context);
  10423. }
  10424. // Bar
  10425. if (this._valueBarImage) {
  10426. if (this.isVertical) {
  10427. if (this.isThumbClamped && this.displayThumb) {
  10428. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10429. }
  10430. else {
  10431. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10432. }
  10433. }
  10434. else {
  10435. if (this.isThumbClamped && this.displayThumb) {
  10436. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10437. }
  10438. else {
  10439. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10440. }
  10441. }
  10442. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10443. this._valueBarImage._draw(context);
  10444. }
  10445. // Thumb
  10446. if (this.displayThumb) {
  10447. if (this.isVertical) {
  10448. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10449. }
  10450. else {
  10451. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10452. }
  10453. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10454. this._thumbImage._draw(context);
  10455. }
  10456. context.restore();
  10457. };
  10458. return ImageBasedSlider;
  10459. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10460. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  10461. /***/ }),
  10462. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  10463. /*!***********************************************!*\
  10464. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  10465. \***********************************************/
  10466. /*! exports provided: ImageScrollBar */
  10467. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10468. "use strict";
  10469. __webpack_require__.r(__webpack_exports__);
  10470. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  10471. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10472. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10473. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10474. /**
  10475. * Class used to create slider controls
  10476. */
  10477. var ImageScrollBar = /** @class */ (function (_super) {
  10478. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  10479. /**
  10480. * Creates a new ImageScrollBar
  10481. * @param name defines the control name
  10482. */
  10483. function ImageScrollBar(name) {
  10484. var _this = _super.call(this, name) || this;
  10485. _this.name = name;
  10486. _this._thumbLength = 0.5;
  10487. _this._thumbHeight = 1;
  10488. _this._barImageHeight = 1;
  10489. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10490. return _this;
  10491. }
  10492. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  10493. /**
  10494. * Gets or sets the image used to render the background
  10495. */
  10496. get: function () {
  10497. return this._backgroundImage;
  10498. },
  10499. set: function (value) {
  10500. var _this = this;
  10501. if (this._backgroundImage === value) {
  10502. return;
  10503. }
  10504. this._backgroundImage = value;
  10505. if (value && !value.isLoaded) {
  10506. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10507. }
  10508. this._markAsDirty();
  10509. },
  10510. enumerable: true,
  10511. configurable: true
  10512. });
  10513. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  10514. /**
  10515. * Gets or sets the image used to render the thumb
  10516. */
  10517. get: function () {
  10518. return this._thumbImage;
  10519. },
  10520. set: function (value) {
  10521. var _this = this;
  10522. if (this._thumbImage === value) {
  10523. return;
  10524. }
  10525. this._thumbImage = value;
  10526. if (value && !value.isLoaded) {
  10527. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10528. }
  10529. this._markAsDirty();
  10530. },
  10531. enumerable: true,
  10532. configurable: true
  10533. });
  10534. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  10535. /**
  10536. * Gets or sets the length of the thumb
  10537. */
  10538. get: function () {
  10539. return this._thumbLength;
  10540. },
  10541. set: function (value) {
  10542. if (this._thumbLength === value) {
  10543. return;
  10544. }
  10545. this._thumbLength = value;
  10546. this._markAsDirty();
  10547. },
  10548. enumerable: true,
  10549. configurable: true
  10550. });
  10551. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  10552. /**
  10553. * Gets or sets the height of the thumb
  10554. */
  10555. get: function () {
  10556. return this._thumbHeight;
  10557. },
  10558. set: function (value) {
  10559. if (this._thumbLength === value) {
  10560. return;
  10561. }
  10562. this._thumbHeight = value;
  10563. this._markAsDirty();
  10564. },
  10565. enumerable: true,
  10566. configurable: true
  10567. });
  10568. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  10569. /**
  10570. * Gets or sets the height of the bar image
  10571. */
  10572. get: function () {
  10573. return this._barImageHeight;
  10574. },
  10575. set: function (value) {
  10576. if (this._barImageHeight === value) {
  10577. return;
  10578. }
  10579. this._barImageHeight = value;
  10580. this._markAsDirty();
  10581. },
  10582. enumerable: true,
  10583. configurable: true
  10584. });
  10585. ImageScrollBar.prototype._getTypeName = function () {
  10586. return "ImageScrollBar";
  10587. };
  10588. ImageScrollBar.prototype._getThumbThickness = function () {
  10589. var thumbThickness = 0;
  10590. if (this._thumbWidth.isPixel) {
  10591. thumbThickness = this._thumbWidth.getValue(this._host);
  10592. }
  10593. else {
  10594. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10595. }
  10596. return thumbThickness;
  10597. };
  10598. ImageScrollBar.prototype._draw = function (context) {
  10599. context.save();
  10600. this._applyStates(context);
  10601. this._prepareRenderingData("rectangle");
  10602. var thumbPosition = this._getThumbPosition();
  10603. var left = this._renderLeft;
  10604. var top = this._renderTop;
  10605. var width = this._renderWidth;
  10606. var height = this._renderHeight;
  10607. // Background
  10608. if (this._backgroundImage) {
  10609. this._tempMeasure.copyFromFloats(left, top, width, height);
  10610. if (this.isVertical) {
  10611. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  10612. this._tempMeasure.height += this._effectiveThumbThickness;
  10613. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10614. }
  10615. else {
  10616. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  10617. this._tempMeasure.width += this._effectiveThumbThickness;
  10618. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10619. }
  10620. this._backgroundImage._draw(context);
  10621. }
  10622. // Thumb
  10623. if (this.isVertical) {
  10624. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset + this._currentMeasure.width * (1 - this._thumbHeight) * 0.5, this._currentMeasure.top + thumbPosition, this._currentMeasure.width * this._thumbHeight, this._effectiveThumbThickness);
  10625. }
  10626. else {
  10627. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top + this._currentMeasure.height * (1 - this._thumbHeight) * 0.5, this._effectiveThumbThickness, this._currentMeasure.height * this._thumbHeight);
  10628. }
  10629. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10630. this._thumbImage._draw(context);
  10631. context.restore();
  10632. };
  10633. /** @hidden */
  10634. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10635. if (this.rotation != 0) {
  10636. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10637. x = this._transformedPosition.x;
  10638. y = this._transformedPosition.y;
  10639. }
  10640. if (this._first) {
  10641. this._first = false;
  10642. this._originX = x;
  10643. this._originY = y;
  10644. // Check if move is required
  10645. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  10646. if (this.isVertical) {
  10647. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10648. }
  10649. else {
  10650. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10651. }
  10652. }
  10653. }
  10654. // Delta mode
  10655. var delta = 0;
  10656. if (this.isVertical) {
  10657. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10658. }
  10659. else {
  10660. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10661. }
  10662. this.value += delta * (this.maximum - this.minimum);
  10663. this._originX = x;
  10664. this._originY = y;
  10665. };
  10666. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10667. this._first = true;
  10668. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10669. };
  10670. return ImageScrollBar;
  10671. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10672. /***/ }),
  10673. /***/ "./2D/controls/sliders/scrollBar.ts":
  10674. /*!******************************************!*\
  10675. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10676. \******************************************/
  10677. /*! exports provided: ScrollBar */
  10678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10679. "use strict";
  10680. __webpack_require__.r(__webpack_exports__);
  10681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10682. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10683. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10684. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10685. /**
  10686. * Class used to create slider controls
  10687. */
  10688. var ScrollBar = /** @class */ (function (_super) {
  10689. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  10690. /**
  10691. * Creates a new Slider
  10692. * @param name defines the control name
  10693. */
  10694. function ScrollBar(name) {
  10695. var _this = _super.call(this, name) || this;
  10696. _this.name = name;
  10697. _this._background = "black";
  10698. _this._borderColor = "white";
  10699. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10700. return _this;
  10701. }
  10702. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10703. /** Gets or sets border color */
  10704. get: function () {
  10705. return this._borderColor;
  10706. },
  10707. set: function (value) {
  10708. if (this._borderColor === value) {
  10709. return;
  10710. }
  10711. this._borderColor = value;
  10712. this._markAsDirty();
  10713. },
  10714. enumerable: true,
  10715. configurable: true
  10716. });
  10717. Object.defineProperty(ScrollBar.prototype, "background", {
  10718. /** Gets or sets background color */
  10719. get: function () {
  10720. return this._background;
  10721. },
  10722. set: function (value) {
  10723. if (this._background === value) {
  10724. return;
  10725. }
  10726. this._background = value;
  10727. this._markAsDirty();
  10728. },
  10729. enumerable: true,
  10730. configurable: true
  10731. });
  10732. ScrollBar.prototype._getTypeName = function () {
  10733. return "Scrollbar";
  10734. };
  10735. ScrollBar.prototype._getThumbThickness = function () {
  10736. var thumbThickness = 0;
  10737. if (this._thumbWidth.isPixel) {
  10738. thumbThickness = this._thumbWidth.getValue(this._host);
  10739. }
  10740. else {
  10741. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10742. }
  10743. return thumbThickness;
  10744. };
  10745. ScrollBar.prototype._draw = function (context) {
  10746. context.save();
  10747. this._applyStates(context);
  10748. this._prepareRenderingData("rectangle");
  10749. var left = this._renderLeft;
  10750. var thumbPosition = this._getThumbPosition();
  10751. context.fillStyle = this._background;
  10752. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10753. // Value bar
  10754. context.fillStyle = this.color;
  10755. // Thumb
  10756. if (this.isVertical) {
  10757. this._tempMeasure.left = left - this._effectiveBarOffset;
  10758. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  10759. this._tempMeasure.width = this._currentMeasure.width;
  10760. this._tempMeasure.height = this._effectiveThumbThickness;
  10761. }
  10762. else {
  10763. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  10764. this._tempMeasure.top = this._currentMeasure.top;
  10765. this._tempMeasure.width = this._effectiveThumbThickness;
  10766. this._tempMeasure.height = this._currentMeasure.height;
  10767. }
  10768. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  10769. context.restore();
  10770. };
  10771. /** @hidden */
  10772. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10773. if (this.rotation != 0) {
  10774. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10775. x = this._transformedPosition.x;
  10776. y = this._transformedPosition.y;
  10777. }
  10778. if (this._first) {
  10779. this._first = false;
  10780. this._originX = x;
  10781. this._originY = y;
  10782. // Check if move is required
  10783. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  10784. if (this.isVertical) {
  10785. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10786. }
  10787. else {
  10788. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10789. }
  10790. }
  10791. }
  10792. // Delta mode
  10793. var delta = 0;
  10794. if (this.isVertical) {
  10795. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10796. }
  10797. else {
  10798. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10799. }
  10800. this.value += delta * (this.maximum - this.minimum);
  10801. this._originX = x;
  10802. this._originY = y;
  10803. };
  10804. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10805. this._first = true;
  10806. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10807. };
  10808. return ScrollBar;
  10809. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10810. /***/ }),
  10811. /***/ "./2D/controls/sliders/slider.ts":
  10812. /*!***************************************!*\
  10813. !*** ./2D/controls/sliders/slider.ts ***!
  10814. \***************************************/
  10815. /*! exports provided: Slider */
  10816. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10817. "use strict";
  10818. __webpack_require__.r(__webpack_exports__);
  10819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10820. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10821. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10822. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  10823. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  10824. /**
  10825. * Class used to create slider controls
  10826. */
  10827. var Slider = /** @class */ (function (_super) {
  10828. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  10829. /**
  10830. * Creates a new Slider
  10831. * @param name defines the control name
  10832. */
  10833. function Slider(name) {
  10834. var _this = _super.call(this, name) || this;
  10835. _this.name = name;
  10836. _this._background = "black";
  10837. _this._borderColor = "white";
  10838. _this._isThumbCircle = false;
  10839. _this._displayValueBar = true;
  10840. return _this;
  10841. }
  10842. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10843. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10844. get: function () {
  10845. return this._displayValueBar;
  10846. },
  10847. set: function (value) {
  10848. if (this._displayValueBar === value) {
  10849. return;
  10850. }
  10851. this._displayValueBar = value;
  10852. this._markAsDirty();
  10853. },
  10854. enumerable: true,
  10855. configurable: true
  10856. });
  10857. Object.defineProperty(Slider.prototype, "borderColor", {
  10858. /** Gets or sets border color */
  10859. get: function () {
  10860. return this._borderColor;
  10861. },
  10862. set: function (value) {
  10863. if (this._borderColor === value) {
  10864. return;
  10865. }
  10866. this._borderColor = value;
  10867. this._markAsDirty();
  10868. },
  10869. enumerable: true,
  10870. configurable: true
  10871. });
  10872. Object.defineProperty(Slider.prototype, "background", {
  10873. /** Gets or sets background color */
  10874. get: function () {
  10875. return this._background;
  10876. },
  10877. set: function (value) {
  10878. if (this._background === value) {
  10879. return;
  10880. }
  10881. this._background = value;
  10882. this._markAsDirty();
  10883. },
  10884. enumerable: true,
  10885. configurable: true
  10886. });
  10887. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10888. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10889. get: function () {
  10890. return this._isThumbCircle;
  10891. },
  10892. set: function (value) {
  10893. if (this._isThumbCircle === value) {
  10894. return;
  10895. }
  10896. this._isThumbCircle = value;
  10897. this._markAsDirty();
  10898. },
  10899. enumerable: true,
  10900. configurable: true
  10901. });
  10902. Slider.prototype._getTypeName = function () {
  10903. return "Slider";
  10904. };
  10905. Slider.prototype._draw = function (context, invalidatedRectangle) {
  10906. context.save();
  10907. this._applyStates(context);
  10908. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10909. var left = this._renderLeft;
  10910. var top = this._renderTop;
  10911. var width = this._renderWidth;
  10912. var height = this._renderHeight;
  10913. var radius = 0;
  10914. if (this.isThumbClamped && this.isThumbCircle) {
  10915. if (this.isVertical) {
  10916. top += (this._effectiveThumbThickness / 2);
  10917. }
  10918. else {
  10919. left += (this._effectiveThumbThickness / 2);
  10920. }
  10921. radius = this._backgroundBoxThickness / 2;
  10922. }
  10923. else {
  10924. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10925. }
  10926. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10927. context.shadowColor = this.shadowColor;
  10928. context.shadowBlur = this.shadowBlur;
  10929. context.shadowOffsetX = this.shadowOffsetX;
  10930. context.shadowOffsetY = this.shadowOffsetY;
  10931. }
  10932. var thumbPosition = this._getThumbPosition();
  10933. context.fillStyle = this._background;
  10934. if (this.isVertical) {
  10935. if (this.isThumbClamped) {
  10936. if (this.isThumbCircle) {
  10937. context.beginPath();
  10938. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10939. context.fill();
  10940. context.fillRect(left, top, width, height);
  10941. }
  10942. else {
  10943. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10944. }
  10945. }
  10946. else {
  10947. context.fillRect(left, top, width, height);
  10948. }
  10949. }
  10950. else {
  10951. if (this.isThumbClamped) {
  10952. if (this.isThumbCircle) {
  10953. context.beginPath();
  10954. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10955. context.fill();
  10956. context.fillRect(left, top, width, height);
  10957. }
  10958. else {
  10959. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10960. }
  10961. }
  10962. else {
  10963. context.fillRect(left, top, width, height);
  10964. }
  10965. }
  10966. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10967. context.shadowBlur = 0;
  10968. context.shadowOffsetX = 0;
  10969. context.shadowOffsetY = 0;
  10970. }
  10971. // Value bar
  10972. context.fillStyle = this.color;
  10973. if (this._displayValueBar) {
  10974. if (this.isVertical) {
  10975. if (this.isThumbClamped) {
  10976. if (this.isThumbCircle) {
  10977. context.beginPath();
  10978. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10979. context.fill();
  10980. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10981. }
  10982. else {
  10983. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10984. }
  10985. }
  10986. else {
  10987. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10988. }
  10989. }
  10990. else {
  10991. if (this.isThumbClamped) {
  10992. if (this.isThumbCircle) {
  10993. context.beginPath();
  10994. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10995. context.fill();
  10996. context.fillRect(left, top, thumbPosition, height);
  10997. }
  10998. else {
  10999. context.fillRect(left, top, thumbPosition, height);
  11000. }
  11001. }
  11002. else {
  11003. context.fillRect(left, top, thumbPosition, height);
  11004. }
  11005. }
  11006. }
  11007. // Thumb
  11008. if (this.displayThumb) {
  11009. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11010. context.shadowColor = this.shadowColor;
  11011. context.shadowBlur = this.shadowBlur;
  11012. context.shadowOffsetX = this.shadowOffsetX;
  11013. context.shadowOffsetY = this.shadowOffsetY;
  11014. }
  11015. if (this._isThumbCircle) {
  11016. context.beginPath();
  11017. if (this.isVertical) {
  11018. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11019. }
  11020. else {
  11021. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11022. }
  11023. context.fill();
  11024. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11025. context.shadowBlur = 0;
  11026. context.shadowOffsetX = 0;
  11027. context.shadowOffsetY = 0;
  11028. }
  11029. context.strokeStyle = this._borderColor;
  11030. context.stroke();
  11031. }
  11032. else {
  11033. if (this.isVertical) {
  11034. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11035. }
  11036. else {
  11037. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11038. }
  11039. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11040. context.shadowBlur = 0;
  11041. context.shadowOffsetX = 0;
  11042. context.shadowOffsetY = 0;
  11043. }
  11044. context.strokeStyle = this._borderColor;
  11045. if (this.isVertical) {
  11046. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11047. }
  11048. else {
  11049. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11050. }
  11051. }
  11052. }
  11053. context.restore();
  11054. };
  11055. return Slider;
  11056. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11057. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11058. /***/ }),
  11059. /***/ "./2D/controls/stackPanel.ts":
  11060. /*!***********************************!*\
  11061. !*** ./2D/controls/stackPanel.ts ***!
  11062. \***********************************/
  11063. /*! exports provided: StackPanel */
  11064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11065. "use strict";
  11066. __webpack_require__.r(__webpack_exports__);
  11067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11068. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11069. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  11070. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11071. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11072. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11073. /**
  11074. * Class used to create a 2D stack panel container
  11075. */
  11076. var StackPanel = /** @class */ (function (_super) {
  11077. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11078. /**
  11079. * Creates a new StackPanel
  11080. * @param name defines control name
  11081. */
  11082. function StackPanel(name) {
  11083. var _this = _super.call(this, name) || this;
  11084. _this.name = name;
  11085. _this._isVertical = true;
  11086. _this._manualWidth = false;
  11087. _this._manualHeight = false;
  11088. _this._doNotTrackManualChanges = false;
  11089. /**
  11090. * Gets or sets a boolean indicating that layou warnings should be ignored
  11091. */
  11092. _this.ignoreLayoutWarnings = false;
  11093. return _this;
  11094. }
  11095. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11096. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11097. get: function () {
  11098. return this._isVertical;
  11099. },
  11100. set: function (value) {
  11101. if (this._isVertical === value) {
  11102. return;
  11103. }
  11104. this._isVertical = value;
  11105. this._markAsDirty();
  11106. },
  11107. enumerable: true,
  11108. configurable: true
  11109. });
  11110. Object.defineProperty(StackPanel.prototype, "width", {
  11111. get: function () {
  11112. return this._width.toString(this._host);
  11113. },
  11114. /**
  11115. * Gets or sets panel width.
  11116. * This value should not be set when in horizontal mode as it will be computed automatically
  11117. */
  11118. set: function (value) {
  11119. if (!this._doNotTrackManualChanges) {
  11120. this._manualWidth = true;
  11121. }
  11122. if (this._width.toString(this._host) === value) {
  11123. return;
  11124. }
  11125. if (this._width.fromString(value)) {
  11126. this._markAsDirty();
  11127. }
  11128. },
  11129. enumerable: true,
  11130. configurable: true
  11131. });
  11132. Object.defineProperty(StackPanel.prototype, "height", {
  11133. get: function () {
  11134. return this._height.toString(this._host);
  11135. },
  11136. /**
  11137. * Gets or sets panel height.
  11138. * This value should not be set when in vertical mode as it will be computed automatically
  11139. */
  11140. set: function (value) {
  11141. if (!this._doNotTrackManualChanges) {
  11142. this._manualHeight = true;
  11143. }
  11144. if (this._height.toString(this._host) === value) {
  11145. return;
  11146. }
  11147. if (this._height.fromString(value)) {
  11148. this._markAsDirty();
  11149. }
  11150. },
  11151. enumerable: true,
  11152. configurable: true
  11153. });
  11154. StackPanel.prototype._getTypeName = function () {
  11155. return "StackPanel";
  11156. };
  11157. /** @hidden */
  11158. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11159. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11160. var child = _a[_i];
  11161. if (this._isVertical) {
  11162. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11163. }
  11164. else {
  11165. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11166. }
  11167. }
  11168. _super.prototype._preMeasure.call(this, parentMeasure, context);
  11169. };
  11170. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  11171. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  11172. this._measureForChildren.copyFrom(parentMeasure);
  11173. this._measureForChildren.left = this._currentMeasure.left;
  11174. this._measureForChildren.top = this._currentMeasure.top;
  11175. if (!this.isVertical || this._manualWidth) {
  11176. this._measureForChildren.width = this._currentMeasure.width;
  11177. }
  11178. if (this.isVertical || this._manualHeight) {
  11179. this._measureForChildren.height = this._currentMeasure.height;
  11180. }
  11181. };
  11182. StackPanel.prototype._postMeasure = function () {
  11183. var stackWidth = 0;
  11184. var stackHeight = 0;
  11185. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11186. var child = _a[_i];
  11187. if (!child.isVisible || child.notRenderable) {
  11188. continue;
  11189. }
  11190. if (this._isVertical) {
  11191. if (child.top !== stackHeight + "px") {
  11192. child.top = stackHeight + "px";
  11193. this._rebuildLayout = true;
  11194. child._top.ignoreAdaptiveScaling = true;
  11195. }
  11196. if (child._height.isPercentage && !child._automaticSize) {
  11197. if (!this.ignoreLayoutWarnings) {
  11198. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Warn("Control (Name:" + child.name + ", UniqueId:" + child.uniqueId + ") is using height in percentage mode inside a vertical StackPanel");
  11199. }
  11200. }
  11201. else {
  11202. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  11203. }
  11204. }
  11205. else {
  11206. if (child.left !== stackWidth + "px") {
  11207. child.left = stackWidth + "px";
  11208. this._rebuildLayout = true;
  11209. child._left.ignoreAdaptiveScaling = true;
  11210. }
  11211. if (child._width.isPercentage && !child._automaticSize) {
  11212. if (!this.ignoreLayoutWarnings) {
  11213. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Warn("Control (Name:" + child.name + ", UniqueId:" + child.uniqueId + ") is using width in percentage mode inside a horizontal StackPanel");
  11214. }
  11215. }
  11216. else {
  11217. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  11218. }
  11219. }
  11220. }
  11221. this._doNotTrackManualChanges = true;
  11222. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  11223. // User can now define their own height and width for stack panel.
  11224. var panelWidthChanged = false;
  11225. var panelHeightChanged = false;
  11226. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  11227. var previousHeight = this.height;
  11228. this.height = stackHeight + "px";
  11229. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  11230. }
  11231. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  11232. var previousWidth = this.width;
  11233. this.width = stackWidth + "px";
  11234. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  11235. }
  11236. if (panelHeightChanged) {
  11237. this._height.ignoreAdaptiveScaling = true;
  11238. }
  11239. if (panelWidthChanged) {
  11240. this._width.ignoreAdaptiveScaling = true;
  11241. }
  11242. this._doNotTrackManualChanges = false;
  11243. if (panelWidthChanged || panelHeightChanged) {
  11244. this._rebuildLayout = true;
  11245. }
  11246. _super.prototype._postMeasure.call(this);
  11247. };
  11248. return StackPanel;
  11249. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  11250. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  11251. /***/ }),
  11252. /***/ "./2D/controls/statics.ts":
  11253. /*!********************************!*\
  11254. !*** ./2D/controls/statics.ts ***!
  11255. \********************************/
  11256. /*! exports provided: name */
  11257. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11258. "use strict";
  11259. __webpack_require__.r(__webpack_exports__);
  11260. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  11261. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11262. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11263. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  11264. /**
  11265. * Forcing an export so that this code will execute
  11266. * @hidden
  11267. */
  11268. var name = "Statics";
  11269. /**
  11270. * Creates a stack panel that can be used to render headers
  11271. * @param control defines the control to associate with the header
  11272. * @param text defines the text of the header
  11273. * @param size defines the size of the header
  11274. * @param options defines options used to configure the header
  11275. * @returns a new StackPanel
  11276. */
  11277. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  11278. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  11279. var isHorizontal = options ? options.isHorizontal : true;
  11280. var controlFirst = options ? options.controlFirst : true;
  11281. panel.isVertical = !isHorizontal;
  11282. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  11283. header.text = text;
  11284. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11285. if (isHorizontal) {
  11286. header.width = size;
  11287. }
  11288. else {
  11289. header.height = size;
  11290. }
  11291. if (controlFirst) {
  11292. panel.addControl(control);
  11293. panel.addControl(header);
  11294. header.paddingLeft = "5px";
  11295. }
  11296. else {
  11297. panel.addControl(header);
  11298. panel.addControl(control);
  11299. header.paddingRight = "5px";
  11300. }
  11301. header.shadowBlur = control.shadowBlur;
  11302. header.shadowColor = control.shadowColor;
  11303. header.shadowOffsetX = control.shadowOffsetX;
  11304. header.shadowOffsetY = control.shadowOffsetY;
  11305. return panel;
  11306. };
  11307. /***/ }),
  11308. /***/ "./2D/controls/textBlock.ts":
  11309. /*!**********************************!*\
  11310. !*** ./2D/controls/textBlock.ts ***!
  11311. \**********************************/
  11312. /*! exports provided: TextWrapping, TextBlock */
  11313. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11314. "use strict";
  11315. __webpack_require__.r(__webpack_exports__);
  11316. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  11317. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  11318. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11319. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  11320. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11321. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  11322. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11323. /**
  11324. * Enum that determines the text-wrapping mode to use.
  11325. */
  11326. var TextWrapping;
  11327. (function (TextWrapping) {
  11328. /**
  11329. * Clip the text when it's larger than Control.width; this is the default mode.
  11330. */
  11331. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  11332. /**
  11333. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  11334. */
  11335. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  11336. /**
  11337. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  11338. */
  11339. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  11340. })(TextWrapping || (TextWrapping = {}));
  11341. /**
  11342. * Class used to create text block control
  11343. */
  11344. var TextBlock = /** @class */ (function (_super) {
  11345. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  11346. /**
  11347. * Creates a new TextBlock object
  11348. * @param name defines the name of the control
  11349. * @param text defines the text to display (emptry string by default)
  11350. */
  11351. function TextBlock(
  11352. /**
  11353. * Defines the name of the control
  11354. */
  11355. name, text) {
  11356. if (text === void 0) { text = ""; }
  11357. var _this = _super.call(this, name) || this;
  11358. _this.name = name;
  11359. _this._text = "";
  11360. _this._textWrapping = TextWrapping.Clip;
  11361. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  11362. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  11363. _this._resizeToFit = false;
  11364. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  11365. _this._outlineWidth = 0;
  11366. _this._outlineColor = "white";
  11367. /**
  11368. * An event triggered after the text is changed
  11369. */
  11370. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11371. /**
  11372. * An event triggered after the text was broken up into lines
  11373. */
  11374. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11375. _this.text = text;
  11376. return _this;
  11377. }
  11378. Object.defineProperty(TextBlock.prototype, "lines", {
  11379. /**
  11380. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  11381. */
  11382. get: function () {
  11383. return this._lines;
  11384. },
  11385. enumerable: true,
  11386. configurable: true
  11387. });
  11388. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  11389. /**
  11390. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11391. */
  11392. get: function () {
  11393. return this._resizeToFit;
  11394. },
  11395. /**
  11396. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11397. */
  11398. set: function (value) {
  11399. if (this._resizeToFit === value) {
  11400. return;
  11401. }
  11402. this._resizeToFit = value;
  11403. if (this._resizeToFit) {
  11404. this._width.ignoreAdaptiveScaling = true;
  11405. this._height.ignoreAdaptiveScaling = true;
  11406. }
  11407. this._markAsDirty();
  11408. },
  11409. enumerable: true,
  11410. configurable: true
  11411. });
  11412. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  11413. /**
  11414. * Gets or sets a boolean indicating if text must be wrapped
  11415. */
  11416. get: function () {
  11417. return this._textWrapping;
  11418. },
  11419. /**
  11420. * Gets or sets a boolean indicating if text must be wrapped
  11421. */
  11422. set: function (value) {
  11423. if (this._textWrapping === value) {
  11424. return;
  11425. }
  11426. this._textWrapping = +value;
  11427. this._markAsDirty();
  11428. },
  11429. enumerable: true,
  11430. configurable: true
  11431. });
  11432. Object.defineProperty(TextBlock.prototype, "text", {
  11433. /**
  11434. * Gets or sets text to display
  11435. */
  11436. get: function () {
  11437. return this._text;
  11438. },
  11439. /**
  11440. * Gets or sets text to display
  11441. */
  11442. set: function (value) {
  11443. if (this._text === value) {
  11444. return;
  11445. }
  11446. this._text = value;
  11447. this._markAsDirty();
  11448. this.onTextChangedObservable.notifyObservers(this);
  11449. },
  11450. enumerable: true,
  11451. configurable: true
  11452. });
  11453. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  11454. /**
  11455. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11456. */
  11457. get: function () {
  11458. return this._textHorizontalAlignment;
  11459. },
  11460. /**
  11461. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11462. */
  11463. set: function (value) {
  11464. if (this._textHorizontalAlignment === value) {
  11465. return;
  11466. }
  11467. this._textHorizontalAlignment = value;
  11468. this._markAsDirty();
  11469. },
  11470. enumerable: true,
  11471. configurable: true
  11472. });
  11473. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  11474. /**
  11475. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11476. */
  11477. get: function () {
  11478. return this._textVerticalAlignment;
  11479. },
  11480. /**
  11481. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11482. */
  11483. set: function (value) {
  11484. if (this._textVerticalAlignment === value) {
  11485. return;
  11486. }
  11487. this._textVerticalAlignment = value;
  11488. this._markAsDirty();
  11489. },
  11490. enumerable: true,
  11491. configurable: true
  11492. });
  11493. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  11494. /**
  11495. * Gets or sets line spacing value
  11496. */
  11497. get: function () {
  11498. return this._lineSpacing.toString(this._host);
  11499. },
  11500. /**
  11501. * Gets or sets line spacing value
  11502. */
  11503. set: function (value) {
  11504. if (this._lineSpacing.fromString(value)) {
  11505. this._markAsDirty();
  11506. }
  11507. },
  11508. enumerable: true,
  11509. configurable: true
  11510. });
  11511. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  11512. /**
  11513. * Gets or sets outlineWidth of the text to display
  11514. */
  11515. get: function () {
  11516. return this._outlineWidth;
  11517. },
  11518. /**
  11519. * Gets or sets outlineWidth of the text to display
  11520. */
  11521. set: function (value) {
  11522. if (this._outlineWidth === value) {
  11523. return;
  11524. }
  11525. this._outlineWidth = value;
  11526. this._markAsDirty();
  11527. },
  11528. enumerable: true,
  11529. configurable: true
  11530. });
  11531. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  11532. /**
  11533. * Gets or sets outlineColor of the text to display
  11534. */
  11535. get: function () {
  11536. return this._outlineColor;
  11537. },
  11538. /**
  11539. * Gets or sets outlineColor of the text to display
  11540. */
  11541. set: function (value) {
  11542. if (this._outlineColor === value) {
  11543. return;
  11544. }
  11545. this._outlineColor = value;
  11546. this._markAsDirty();
  11547. },
  11548. enumerable: true,
  11549. configurable: true
  11550. });
  11551. TextBlock.prototype._getTypeName = function () {
  11552. return "TextBlock";
  11553. };
  11554. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11555. if (!this._fontOffset) {
  11556. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11557. }
  11558. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11559. // Prepare lines
  11560. this._lines = this._breakLines(this._currentMeasure.width, context);
  11561. this.onLinesReadyObservable.notifyObservers(this);
  11562. var maxLineWidth = 0;
  11563. for (var i = 0; i < this._lines.length; i++) {
  11564. var line = this._lines[i];
  11565. if (line.width > maxLineWidth) {
  11566. maxLineWidth = line.width;
  11567. }
  11568. }
  11569. if (this._resizeToFit) {
  11570. if (this._textWrapping === TextWrapping.Clip) {
  11571. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11572. if (newWidth !== this._width.internalValue) {
  11573. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11574. this._rebuildLayout = true;
  11575. }
  11576. }
  11577. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11578. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11579. var lineSpacing = 0;
  11580. if (this._lineSpacing.isPixel) {
  11581. lineSpacing = this._lineSpacing.getValue(this._host);
  11582. }
  11583. else {
  11584. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11585. }
  11586. newHeight += (this._lines.length - 1) * lineSpacing;
  11587. }
  11588. if (newHeight !== this._height.internalValue) {
  11589. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11590. this._rebuildLayout = true;
  11591. }
  11592. }
  11593. };
  11594. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11595. var width = this._currentMeasure.width;
  11596. var x = 0;
  11597. switch (this._textHorizontalAlignment) {
  11598. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11599. x = 0;
  11600. break;
  11601. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11602. x = width - textWidth;
  11603. break;
  11604. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11605. x = (width - textWidth) / 2;
  11606. break;
  11607. }
  11608. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11609. context.shadowColor = this.shadowColor;
  11610. context.shadowBlur = this.shadowBlur;
  11611. context.shadowOffsetX = this.shadowOffsetX;
  11612. context.shadowOffsetY = this.shadowOffsetY;
  11613. }
  11614. if (this.outlineWidth) {
  11615. context.strokeText(text, this._currentMeasure.left + x, y);
  11616. }
  11617. context.fillText(text, this._currentMeasure.left + x, y);
  11618. };
  11619. /** @hidden */
  11620. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  11621. context.save();
  11622. this._applyStates(context);
  11623. // Render lines
  11624. this._renderLines(context);
  11625. context.restore();
  11626. };
  11627. TextBlock.prototype._applyStates = function (context) {
  11628. _super.prototype._applyStates.call(this, context);
  11629. if (this.outlineWidth) {
  11630. context.lineWidth = this.outlineWidth;
  11631. context.strokeStyle = this.outlineColor;
  11632. }
  11633. };
  11634. TextBlock.prototype._breakLines = function (refWidth, context) {
  11635. var lines = [];
  11636. var _lines = this.text.split("\n");
  11637. if (this._textWrapping === TextWrapping.Ellipsis) {
  11638. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11639. var _line = _lines_1[_i];
  11640. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11641. }
  11642. }
  11643. else if (this._textWrapping === TextWrapping.WordWrap) {
  11644. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11645. var _line = _lines_2[_a];
  11646. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11647. }
  11648. }
  11649. else {
  11650. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11651. var _line = _lines_3[_b];
  11652. lines.push(this._parseLine(_line, context));
  11653. }
  11654. }
  11655. return lines;
  11656. };
  11657. TextBlock.prototype._parseLine = function (line, context) {
  11658. if (line === void 0) { line = ''; }
  11659. return { text: line, width: context.measureText(line).width };
  11660. };
  11661. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11662. if (line === void 0) { line = ''; }
  11663. var lineWidth = context.measureText(line).width;
  11664. if (lineWidth > width) {
  11665. line += '…';
  11666. }
  11667. while (line.length > 2 && lineWidth > width) {
  11668. line = line.slice(0, -2) + '…';
  11669. lineWidth = context.measureText(line).width;
  11670. }
  11671. return { text: line, width: lineWidth };
  11672. };
  11673. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11674. if (line === void 0) { line = ''; }
  11675. var lines = [];
  11676. var words = line.split(' ');
  11677. var lineWidth = 0;
  11678. for (var n = 0; n < words.length; n++) {
  11679. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11680. var metrics = context.measureText(testLine);
  11681. var testWidth = metrics.width;
  11682. if (testWidth > width && n > 0) {
  11683. lines.push({ text: line, width: lineWidth });
  11684. line = words[n];
  11685. lineWidth = context.measureText(line).width;
  11686. }
  11687. else {
  11688. lineWidth = testWidth;
  11689. line = testLine;
  11690. }
  11691. }
  11692. lines.push({ text: line, width: lineWidth });
  11693. return lines;
  11694. };
  11695. TextBlock.prototype._renderLines = function (context) {
  11696. var height = this._currentMeasure.height;
  11697. var rootY = 0;
  11698. switch (this._textVerticalAlignment) {
  11699. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11700. rootY = this._fontOffset.ascent;
  11701. break;
  11702. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11703. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11704. break;
  11705. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11706. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11707. break;
  11708. }
  11709. rootY += this._currentMeasure.top;
  11710. for (var i = 0; i < this._lines.length; i++) {
  11711. var line = this._lines[i];
  11712. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11713. if (this._lineSpacing.isPixel) {
  11714. rootY += this._lineSpacing.getValue(this._host);
  11715. }
  11716. else {
  11717. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11718. }
  11719. }
  11720. this._drawText(line.text, line.width, rootY, context);
  11721. rootY += this._fontOffset.height;
  11722. }
  11723. };
  11724. /**
  11725. * Given a width constraint applied on the text block, find the expected height
  11726. * @returns expected height
  11727. */
  11728. TextBlock.prototype.computeExpectedHeight = function () {
  11729. if (this.text && this.widthInPixels) {
  11730. var context_1 = document.createElement('canvas').getContext('2d');
  11731. if (context_1) {
  11732. this._applyStates(context_1);
  11733. if (!this._fontOffset) {
  11734. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11735. }
  11736. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11737. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11738. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11739. var lineSpacing = 0;
  11740. if (this._lineSpacing.isPixel) {
  11741. lineSpacing = this._lineSpacing.getValue(this._host);
  11742. }
  11743. else {
  11744. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11745. }
  11746. newHeight += (lines.length - 1) * lineSpacing;
  11747. }
  11748. return newHeight;
  11749. }
  11750. }
  11751. return 0;
  11752. };
  11753. TextBlock.prototype.dispose = function () {
  11754. _super.prototype.dispose.call(this);
  11755. this.onTextChangedObservable.clear();
  11756. };
  11757. return TextBlock;
  11758. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11759. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  11760. /***/ }),
  11761. /***/ "./2D/controls/virtualKeyboard.ts":
  11762. /*!****************************************!*\
  11763. !*** ./2D/controls/virtualKeyboard.ts ***!
  11764. \****************************************/
  11765. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11767. "use strict";
  11768. __webpack_require__.r(__webpack_exports__);
  11769. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11770. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11771. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11772. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  11773. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11774. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11775. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11776. /**
  11777. * Class used to store key control properties
  11778. */
  11779. var KeyPropertySet = /** @class */ (function () {
  11780. function KeyPropertySet() {
  11781. }
  11782. return KeyPropertySet;
  11783. }());
  11784. /**
  11785. * Class used to create virtual keyboard
  11786. */
  11787. var VirtualKeyboard = /** @class */ (function (_super) {
  11788. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  11789. function VirtualKeyboard() {
  11790. var _this = _super !== null && _super.apply(this, arguments) || this;
  11791. /** Observable raised when a key is pressed */
  11792. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11793. /** Gets or sets default key button width */
  11794. _this.defaultButtonWidth = "40px";
  11795. /** Gets or sets default key button height */
  11796. _this.defaultButtonHeight = "40px";
  11797. /** Gets or sets default key button left padding */
  11798. _this.defaultButtonPaddingLeft = "2px";
  11799. /** Gets or sets default key button right padding */
  11800. _this.defaultButtonPaddingRight = "2px";
  11801. /** Gets or sets default key button top padding */
  11802. _this.defaultButtonPaddingTop = "2px";
  11803. /** Gets or sets default key button bottom padding */
  11804. _this.defaultButtonPaddingBottom = "2px";
  11805. /** Gets or sets default key button foreground color */
  11806. _this.defaultButtonColor = "#DDD";
  11807. /** Gets or sets default key button background color */
  11808. _this.defaultButtonBackground = "#070707";
  11809. /** Gets or sets shift button foreground color */
  11810. _this.shiftButtonColor = "#7799FF";
  11811. /** Gets or sets shift button thickness*/
  11812. _this.selectedShiftThickness = 1;
  11813. /** Gets shift key state */
  11814. _this.shiftState = 0;
  11815. _this._currentlyConnectedInputText = null;
  11816. _this._connectedInputTexts = [];
  11817. _this._onKeyPressObserver = null;
  11818. return _this;
  11819. }
  11820. VirtualKeyboard.prototype._getTypeName = function () {
  11821. return "VirtualKeyboard";
  11822. };
  11823. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11824. var _this = this;
  11825. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11826. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11827. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11828. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11829. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11830. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11831. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11832. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11833. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11834. button.thickness = 0;
  11835. button.isFocusInvisible = true;
  11836. button.shadowColor = this.shadowColor;
  11837. button.shadowBlur = this.shadowBlur;
  11838. button.shadowOffsetX = this.shadowOffsetX;
  11839. button.shadowOffsetY = this.shadowOffsetY;
  11840. button.onPointerUpObservable.add(function () {
  11841. _this.onKeyPressObservable.notifyObservers(key);
  11842. });
  11843. return button;
  11844. };
  11845. /**
  11846. * Adds a new row of keys
  11847. * @param keys defines the list of keys to add
  11848. * @param propertySets defines the associated property sets
  11849. */
  11850. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11851. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11852. panel.isVertical = false;
  11853. panel.isFocusInvisible = true;
  11854. var maxKey = null;
  11855. for (var i = 0; i < keys.length; i++) {
  11856. var properties = null;
  11857. if (propertySets && propertySets.length === keys.length) {
  11858. properties = propertySets[i];
  11859. }
  11860. var key = this._createKey(keys[i], properties);
  11861. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  11862. maxKey = key;
  11863. }
  11864. panel.addControl(key);
  11865. }
  11866. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  11867. this.addControl(panel);
  11868. };
  11869. /**
  11870. * Set the shift key to a specific state
  11871. * @param shiftState defines the new shift state
  11872. */
  11873. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11874. if (!this.children) {
  11875. return;
  11876. }
  11877. for (var i = 0; i < this.children.length; i++) {
  11878. var row = this.children[i];
  11879. if (!row || !row.children) {
  11880. continue;
  11881. }
  11882. var rowContainer = row;
  11883. for (var j = 0; j < rowContainer.children.length; j++) {
  11884. var button = rowContainer.children[j];
  11885. if (!button || !button.children[0]) {
  11886. continue;
  11887. }
  11888. var button_tblock = button.children[0];
  11889. if (button_tblock.text === "\u21E7") {
  11890. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11891. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11892. }
  11893. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11894. }
  11895. }
  11896. };
  11897. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11898. /** Gets the input text control currently attached to the keyboard */
  11899. get: function () {
  11900. return this._currentlyConnectedInputText;
  11901. },
  11902. enumerable: true,
  11903. configurable: true
  11904. });
  11905. /**
  11906. * Connects the keyboard with an input text control
  11907. *
  11908. * @param input defines the target control
  11909. */
  11910. VirtualKeyboard.prototype.connect = function (input) {
  11911. var _this = this;
  11912. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11913. if (inputTextAlreadyConnected) {
  11914. return;
  11915. }
  11916. if (this._onKeyPressObserver === null) {
  11917. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11918. if (!_this._currentlyConnectedInputText) {
  11919. return;
  11920. }
  11921. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11922. switch (key) {
  11923. case "\u21E7":
  11924. _this.shiftState++;
  11925. if (_this.shiftState > 2) {
  11926. _this.shiftState = 0;
  11927. }
  11928. _this.applyShiftState(_this.shiftState);
  11929. return;
  11930. case "\u2190":
  11931. _this._currentlyConnectedInputText.processKey(8);
  11932. return;
  11933. case "\u21B5":
  11934. _this._currentlyConnectedInputText.processKey(13);
  11935. return;
  11936. }
  11937. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11938. if (_this.shiftState === 1) {
  11939. _this.shiftState = 0;
  11940. _this.applyShiftState(_this.shiftState);
  11941. }
  11942. });
  11943. }
  11944. this.isVisible = false;
  11945. this._currentlyConnectedInputText = input;
  11946. input._connectedVirtualKeyboard = this;
  11947. // Events hooking
  11948. var onFocusObserver = input.onFocusObservable.add(function () {
  11949. _this._currentlyConnectedInputText = input;
  11950. input._connectedVirtualKeyboard = _this;
  11951. _this.isVisible = true;
  11952. });
  11953. var onBlurObserver = input.onBlurObservable.add(function () {
  11954. input._connectedVirtualKeyboard = null;
  11955. _this._currentlyConnectedInputText = null;
  11956. _this.isVisible = false;
  11957. });
  11958. this._connectedInputTexts.push({
  11959. input: input,
  11960. onBlurObserver: onBlurObserver,
  11961. onFocusObserver: onFocusObserver
  11962. });
  11963. };
  11964. /**
  11965. * Disconnects the keyboard from connected InputText controls
  11966. *
  11967. * @param input optionally defines a target control, otherwise all are disconnected
  11968. */
  11969. VirtualKeyboard.prototype.disconnect = function (input) {
  11970. var _this = this;
  11971. if (input) {
  11972. // .find not available on IE
  11973. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11974. if (filtered.length === 1) {
  11975. this._removeConnectedInputObservables(filtered[0]);
  11976. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11977. if (this._currentlyConnectedInputText === input) {
  11978. this._currentlyConnectedInputText = null;
  11979. }
  11980. }
  11981. }
  11982. else {
  11983. this._connectedInputTexts.forEach(function (connectedInputText) {
  11984. _this._removeConnectedInputObservables(connectedInputText);
  11985. });
  11986. this._connectedInputTexts = [];
  11987. }
  11988. if (this._connectedInputTexts.length === 0) {
  11989. this._currentlyConnectedInputText = null;
  11990. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11991. this._onKeyPressObserver = null;
  11992. }
  11993. };
  11994. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11995. connectedInputText.input._connectedVirtualKeyboard = null;
  11996. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11997. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11998. };
  11999. /**
  12000. * Release all resources
  12001. */
  12002. VirtualKeyboard.prototype.dispose = function () {
  12003. _super.prototype.dispose.call(this);
  12004. this.disconnect();
  12005. };
  12006. // Statics
  12007. /**
  12008. * Creates a new keyboard using a default layout
  12009. *
  12010. * @param name defines control name
  12011. * @returns a new VirtualKeyboard
  12012. */
  12013. VirtualKeyboard.CreateDefaultLayout = function (name) {
  12014. var returnValue = new VirtualKeyboard(name);
  12015. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  12016. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  12017. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  12018. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  12019. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  12020. return returnValue;
  12021. };
  12022. return VirtualKeyboard;
  12023. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  12024. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  12025. /***/ }),
  12026. /***/ "./2D/index.ts":
  12027. /*!*********************!*\
  12028. !*** ./2D/index.ts ***!
  12029. \*********************/
  12030. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  12031. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12032. "use strict";
  12033. __webpack_require__.r(__webpack_exports__);
  12034. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  12035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  12036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  12037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  12038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  12039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  12040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  12041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  12042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  12043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  12044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  12045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  12046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  12047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  12048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  12049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  12050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  12051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  12052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  12053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  12054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  12055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  12056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  12057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  12058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  12059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  12060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  12061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  12062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  12063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  12064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  12065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  12066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  12067. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  12069. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  12070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  12071. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  12072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  12073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  12074. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  12075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  12076. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  12077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  12078. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  12079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  12080. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  12082. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  12083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  12084. /***/ }),
  12085. /***/ "./2D/math2D.ts":
  12086. /*!**********************!*\
  12087. !*** ./2D/math2D.ts ***!
  12088. \**********************/
  12089. /*! exports provided: Vector2WithInfo, Matrix2D */
  12090. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12091. "use strict";
  12092. __webpack_require__.r(__webpack_exports__);
  12093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  12094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  12095. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12096. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12097. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12098. /**
  12099. * Class used to transport Vector2 information for pointer events
  12100. */
  12101. var Vector2WithInfo = /** @class */ (function (_super) {
  12102. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  12103. /**
  12104. * Creates a new Vector2WithInfo
  12105. * @param source defines the vector2 data to transport
  12106. * @param buttonIndex defines the current mouse button index
  12107. */
  12108. function Vector2WithInfo(source,
  12109. /** defines the current mouse button index */
  12110. buttonIndex) {
  12111. if (buttonIndex === void 0) { buttonIndex = 0; }
  12112. var _this = _super.call(this, source.x, source.y) || this;
  12113. _this.buttonIndex = buttonIndex;
  12114. return _this;
  12115. }
  12116. return Vector2WithInfo;
  12117. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  12118. /** Class used to provide 2D matrix features */
  12119. var Matrix2D = /** @class */ (function () {
  12120. /**
  12121. * Creates a new matrix
  12122. * @param m00 defines value for (0, 0)
  12123. * @param m01 defines value for (0, 1)
  12124. * @param m10 defines value for (1, 0)
  12125. * @param m11 defines value for (1, 1)
  12126. * @param m20 defines value for (2, 0)
  12127. * @param m21 defines value for (2, 1)
  12128. */
  12129. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  12130. /** Gets the internal array of 6 floats used to store matrix data */
  12131. this.m = new Float32Array(6);
  12132. this.fromValues(m00, m01, m10, m11, m20, m21);
  12133. }
  12134. /**
  12135. * Fills the matrix from direct values
  12136. * @param m00 defines value for (0, 0)
  12137. * @param m01 defines value for (0, 1)
  12138. * @param m10 defines value for (1, 0)
  12139. * @param m11 defines value for (1, 1)
  12140. * @param m20 defines value for (2, 0)
  12141. * @param m21 defines value for (2, 1)
  12142. * @returns the current modified matrix
  12143. */
  12144. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  12145. this.m[0] = m00;
  12146. this.m[1] = m01;
  12147. this.m[2] = m10;
  12148. this.m[3] = m11;
  12149. this.m[4] = m20;
  12150. this.m[5] = m21;
  12151. return this;
  12152. };
  12153. /**
  12154. * Gets matrix determinant
  12155. * @returns the determinant
  12156. */
  12157. Matrix2D.prototype.determinant = function () {
  12158. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  12159. };
  12160. /**
  12161. * Inverses the matrix and stores it in a target matrix
  12162. * @param result defines the target matrix
  12163. * @returns the current matrix
  12164. */
  12165. Matrix2D.prototype.invertToRef = function (result) {
  12166. var l0 = this.m[0];
  12167. var l1 = this.m[1];
  12168. var l2 = this.m[2];
  12169. var l3 = this.m[3];
  12170. var l4 = this.m[4];
  12171. var l5 = this.m[5];
  12172. var det = this.determinant();
  12173. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  12174. result.m[0] = 0;
  12175. result.m[1] = 0;
  12176. result.m[2] = 0;
  12177. result.m[3] = 0;
  12178. result.m[4] = 0;
  12179. result.m[5] = 0;
  12180. return this;
  12181. }
  12182. var detDiv = 1 / det;
  12183. var det4 = l2 * l5 - l3 * l4;
  12184. var det5 = l1 * l4 - l0 * l5;
  12185. result.m[0] = l3 * detDiv;
  12186. result.m[1] = -l1 * detDiv;
  12187. result.m[2] = -l2 * detDiv;
  12188. result.m[3] = l0 * detDiv;
  12189. result.m[4] = det4 * detDiv;
  12190. result.m[5] = det5 * detDiv;
  12191. return this;
  12192. };
  12193. /**
  12194. * Multiplies the current matrix with another one
  12195. * @param other defines the second operand
  12196. * @param result defines the target matrix
  12197. * @returns the current matrix
  12198. */
  12199. Matrix2D.prototype.multiplyToRef = function (other, result) {
  12200. var l0 = this.m[0];
  12201. var l1 = this.m[1];
  12202. var l2 = this.m[2];
  12203. var l3 = this.m[3];
  12204. var l4 = this.m[4];
  12205. var l5 = this.m[5];
  12206. var r0 = other.m[0];
  12207. var r1 = other.m[1];
  12208. var r2 = other.m[2];
  12209. var r3 = other.m[3];
  12210. var r4 = other.m[4];
  12211. var r5 = other.m[5];
  12212. result.m[0] = l0 * r0 + l1 * r2;
  12213. result.m[1] = l0 * r1 + l1 * r3;
  12214. result.m[2] = l2 * r0 + l3 * r2;
  12215. result.m[3] = l2 * r1 + l3 * r3;
  12216. result.m[4] = l4 * r0 + l5 * r2 + r4;
  12217. result.m[5] = l4 * r1 + l5 * r3 + r5;
  12218. return this;
  12219. };
  12220. /**
  12221. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  12222. * @param x defines the x coordinate to transform
  12223. * @param y defines the x coordinate to transform
  12224. * @param result defines the target vector2
  12225. * @returns the current matrix
  12226. */
  12227. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  12228. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  12229. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  12230. return this;
  12231. };
  12232. // Statics
  12233. /**
  12234. * Creates an identity matrix
  12235. * @returns a new matrix
  12236. */
  12237. Matrix2D.Identity = function () {
  12238. return new Matrix2D(1, 0, 0, 1, 0, 0);
  12239. };
  12240. /**
  12241. * Creates a translation matrix and stores it in a target matrix
  12242. * @param x defines the x coordinate of the translation
  12243. * @param y defines the y coordinate of the translation
  12244. * @param result defines the target matrix
  12245. */
  12246. Matrix2D.TranslationToRef = function (x, y, result) {
  12247. result.fromValues(1, 0, 0, 1, x, y);
  12248. };
  12249. /**
  12250. * Creates a scaling matrix and stores it in a target matrix
  12251. * @param x defines the x coordinate of the scaling
  12252. * @param y defines the y coordinate of the scaling
  12253. * @param result defines the target matrix
  12254. */
  12255. Matrix2D.ScalingToRef = function (x, y, result) {
  12256. result.fromValues(x, 0, 0, y, 0, 0);
  12257. };
  12258. /**
  12259. * Creates a rotation matrix and stores it in a target matrix
  12260. * @param angle defines the rotation angle
  12261. * @param result defines the target matrix
  12262. */
  12263. Matrix2D.RotationToRef = function (angle, result) {
  12264. var s = Math.sin(angle);
  12265. var c = Math.cos(angle);
  12266. result.fromValues(c, s, -s, c, 0, 0);
  12267. };
  12268. /**
  12269. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  12270. * @param tx defines the x coordinate of the translation
  12271. * @param ty defines the y coordinate of the translation
  12272. * @param angle defines the rotation angle
  12273. * @param scaleX defines the x coordinate of the scaling
  12274. * @param scaleY defines the y coordinate of the scaling
  12275. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  12276. * @param result defines the target matrix
  12277. */
  12278. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  12279. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  12280. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  12281. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  12282. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  12283. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  12284. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  12285. if (parentMatrix) {
  12286. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  12287. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  12288. }
  12289. else {
  12290. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  12291. }
  12292. };
  12293. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  12294. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  12295. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  12296. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  12297. Matrix2D._TempCompose0 = Matrix2D.Identity();
  12298. Matrix2D._TempCompose1 = Matrix2D.Identity();
  12299. Matrix2D._TempCompose2 = Matrix2D.Identity();
  12300. return Matrix2D;
  12301. }());
  12302. /***/ }),
  12303. /***/ "./2D/measure.ts":
  12304. /*!***********************!*\
  12305. !*** ./2D/measure.ts ***!
  12306. \***********************/
  12307. /*! exports provided: Measure */
  12308. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12309. "use strict";
  12310. __webpack_require__.r(__webpack_exports__);
  12311. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  12312. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12313. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12314. /**
  12315. * Class used to store 2D control sizes
  12316. */
  12317. var Measure = /** @class */ (function () {
  12318. /**
  12319. * Creates a new measure
  12320. * @param left defines left coordinate
  12321. * @param top defines top coordinate
  12322. * @param width defines width dimension
  12323. * @param height defines height dimension
  12324. */
  12325. function Measure(
  12326. /** defines left coordinate */
  12327. left,
  12328. /** defines top coordinate */
  12329. top,
  12330. /** defines width dimension */
  12331. width,
  12332. /** defines height dimension */
  12333. height) {
  12334. this.left = left;
  12335. this.top = top;
  12336. this.width = width;
  12337. this.height = height;
  12338. }
  12339. /**
  12340. * Copy from another measure
  12341. * @param other defines the other measure to copy from
  12342. */
  12343. Measure.prototype.copyFrom = function (other) {
  12344. this.left = other.left;
  12345. this.top = other.top;
  12346. this.width = other.width;
  12347. this.height = other.height;
  12348. };
  12349. /**
  12350. * Copy from a group of 4 floats
  12351. * @param left defines left coordinate
  12352. * @param top defines top coordinate
  12353. * @param width defines width dimension
  12354. * @param height defines height dimension
  12355. */
  12356. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  12357. this.left = left;
  12358. this.top = top;
  12359. this.width = width;
  12360. this.height = height;
  12361. };
  12362. /**
  12363. * Computes the axis aligned bounding box measure for two given measures
  12364. * @param a Input measure
  12365. * @param b Input measure
  12366. * @param result the resulting bounding measure
  12367. */
  12368. Measure.CombineToRef = function (a, b, result) {
  12369. var left = Math.min(a.left, b.left);
  12370. var top = Math.min(a.top, b.top);
  12371. var right = Math.max(a.left + a.width, b.left + b.width);
  12372. var bottom = Math.max(a.top + a.height, b.top + b.height);
  12373. result.left = left;
  12374. result.top = top;
  12375. result.width = right - left;
  12376. result.height = bottom - top;
  12377. };
  12378. /**
  12379. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  12380. * @param transform the matrix to transform the measure before computing the AABB
  12381. * @param result the resulting AABB
  12382. */
  12383. Measure.prototype.transformToRef = function (transform, result) {
  12384. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  12385. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  12386. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12387. for (var i = 0; i < 4; i++) {
  12388. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  12389. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  12390. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  12391. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  12392. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  12393. }
  12394. result.left = min.x;
  12395. result.top = min.y;
  12396. result.width = max.x - min.x;
  12397. result.height = max.y - min.y;
  12398. };
  12399. /**
  12400. * Check equality between this measure and another one
  12401. * @param other defines the other measures
  12402. * @returns true if both measures are equals
  12403. */
  12404. Measure.prototype.isEqualsTo = function (other) {
  12405. if (this.left !== other.left) {
  12406. return false;
  12407. }
  12408. if (this.top !== other.top) {
  12409. return false;
  12410. }
  12411. if (this.width !== other.width) {
  12412. return false;
  12413. }
  12414. if (this.height !== other.height) {
  12415. return false;
  12416. }
  12417. return true;
  12418. };
  12419. /**
  12420. * Creates an empty measure
  12421. * @returns a new measure
  12422. */
  12423. Measure.Empty = function () {
  12424. return new Measure(0, 0, 0, 0);
  12425. };
  12426. return Measure;
  12427. }());
  12428. /***/ }),
  12429. /***/ "./2D/multiLinePoint.ts":
  12430. /*!******************************!*\
  12431. !*** ./2D/multiLinePoint.ts ***!
  12432. \******************************/
  12433. /*! exports provided: MultiLinePoint */
  12434. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12435. "use strict";
  12436. __webpack_require__.r(__webpack_exports__);
  12437. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  12438. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12439. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12440. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12441. /**
  12442. * Class used to store a point for a MultiLine object.
  12443. * The point can be pure 2D coordinates, a mesh or a control
  12444. */
  12445. var MultiLinePoint = /** @class */ (function () {
  12446. /**
  12447. * Creates a new MultiLinePoint
  12448. * @param multiLine defines the source MultiLine object
  12449. */
  12450. function MultiLinePoint(multiLine) {
  12451. this._multiLine = multiLine;
  12452. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12453. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12454. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12455. }
  12456. Object.defineProperty(MultiLinePoint.prototype, "x", {
  12457. /** Gets or sets x coordinate */
  12458. get: function () {
  12459. return this._x.toString(this._multiLine._host);
  12460. },
  12461. set: function (value) {
  12462. if (this._x.toString(this._multiLine._host) === value) {
  12463. return;
  12464. }
  12465. if (this._x.fromString(value)) {
  12466. this._multiLine._markAsDirty();
  12467. }
  12468. },
  12469. enumerable: true,
  12470. configurable: true
  12471. });
  12472. Object.defineProperty(MultiLinePoint.prototype, "y", {
  12473. /** Gets or sets y coordinate */
  12474. get: function () {
  12475. return this._y.toString(this._multiLine._host);
  12476. },
  12477. set: function (value) {
  12478. if (this._y.toString(this._multiLine._host) === value) {
  12479. return;
  12480. }
  12481. if (this._y.fromString(value)) {
  12482. this._multiLine._markAsDirty();
  12483. }
  12484. },
  12485. enumerable: true,
  12486. configurable: true
  12487. });
  12488. Object.defineProperty(MultiLinePoint.prototype, "control", {
  12489. /** Gets or sets the control associated with this point */
  12490. get: function () {
  12491. return this._control;
  12492. },
  12493. set: function (value) {
  12494. if (this._control === value) {
  12495. return;
  12496. }
  12497. if (this._control && this._controlObserver) {
  12498. this._control.onDirtyObservable.remove(this._controlObserver);
  12499. this._controlObserver = null;
  12500. }
  12501. this._control = value;
  12502. if (this._control) {
  12503. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  12504. }
  12505. this._multiLine._markAsDirty();
  12506. },
  12507. enumerable: true,
  12508. configurable: true
  12509. });
  12510. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  12511. /** Gets or sets the mesh associated with this point */
  12512. get: function () {
  12513. return this._mesh;
  12514. },
  12515. set: function (value) {
  12516. if (this._mesh === value) {
  12517. return;
  12518. }
  12519. if (this._mesh && this._meshObserver) {
  12520. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  12521. }
  12522. this._mesh = value;
  12523. if (this._mesh) {
  12524. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  12525. }
  12526. this._multiLine._markAsDirty();
  12527. },
  12528. enumerable: true,
  12529. configurable: true
  12530. });
  12531. /** Resets links */
  12532. MultiLinePoint.prototype.resetLinks = function () {
  12533. this.control = null;
  12534. this.mesh = null;
  12535. };
  12536. /**
  12537. * Gets a translation vector
  12538. * @returns the translation vector
  12539. */
  12540. MultiLinePoint.prototype.translate = function () {
  12541. this._point = this._translatePoint();
  12542. return this._point;
  12543. };
  12544. MultiLinePoint.prototype._translatePoint = function () {
  12545. if (this._mesh != null) {
  12546. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  12547. }
  12548. else if (this._control != null) {
  12549. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  12550. }
  12551. else {
  12552. var host = this._multiLine._host;
  12553. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  12554. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  12555. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  12556. }
  12557. };
  12558. /** Release associated resources */
  12559. MultiLinePoint.prototype.dispose = function () {
  12560. this.resetLinks();
  12561. };
  12562. return MultiLinePoint;
  12563. }());
  12564. /***/ }),
  12565. /***/ "./2D/style.ts":
  12566. /*!*********************!*\
  12567. !*** ./2D/style.ts ***!
  12568. \*********************/
  12569. /*! exports provided: Style */
  12570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12571. "use strict";
  12572. __webpack_require__.r(__webpack_exports__);
  12573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  12574. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12575. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12576. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12577. /**
  12578. * Define a style used by control to automatically setup properties based on a template.
  12579. * Only support font related properties so far
  12580. */
  12581. var Style = /** @class */ (function () {
  12582. /**
  12583. * Creates a new style object
  12584. * @param host defines the AdvancedDynamicTexture which hosts this style
  12585. */
  12586. function Style(host) {
  12587. this._fontFamily = "Arial";
  12588. this._fontStyle = "";
  12589. this._fontWeight = "";
  12590. /** @hidden */
  12591. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12592. /**
  12593. * Observable raised when the style values are changed
  12594. */
  12595. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12596. this._host = host;
  12597. }
  12598. Object.defineProperty(Style.prototype, "fontSize", {
  12599. /**
  12600. * Gets or sets the font size
  12601. */
  12602. get: function () {
  12603. return this._fontSize.toString(this._host);
  12604. },
  12605. set: function (value) {
  12606. if (this._fontSize.toString(this._host) === value) {
  12607. return;
  12608. }
  12609. if (this._fontSize.fromString(value)) {
  12610. this.onChangedObservable.notifyObservers(this);
  12611. }
  12612. },
  12613. enumerable: true,
  12614. configurable: true
  12615. });
  12616. Object.defineProperty(Style.prototype, "fontFamily", {
  12617. /**
  12618. * Gets or sets the font family
  12619. */
  12620. get: function () {
  12621. return this._fontFamily;
  12622. },
  12623. set: function (value) {
  12624. if (this._fontFamily === value) {
  12625. return;
  12626. }
  12627. this._fontFamily = value;
  12628. this.onChangedObservable.notifyObservers(this);
  12629. },
  12630. enumerable: true,
  12631. configurable: true
  12632. });
  12633. Object.defineProperty(Style.prototype, "fontStyle", {
  12634. /**
  12635. * Gets or sets the font style
  12636. */
  12637. get: function () {
  12638. return this._fontStyle;
  12639. },
  12640. set: function (value) {
  12641. if (this._fontStyle === value) {
  12642. return;
  12643. }
  12644. this._fontStyle = value;
  12645. this.onChangedObservable.notifyObservers(this);
  12646. },
  12647. enumerable: true,
  12648. configurable: true
  12649. });
  12650. Object.defineProperty(Style.prototype, "fontWeight", {
  12651. /** Gets or sets font weight */
  12652. get: function () {
  12653. return this._fontWeight;
  12654. },
  12655. set: function (value) {
  12656. if (this._fontWeight === value) {
  12657. return;
  12658. }
  12659. this._fontWeight = value;
  12660. this.onChangedObservable.notifyObservers(this);
  12661. },
  12662. enumerable: true,
  12663. configurable: true
  12664. });
  12665. /** Dispose all associated resources */
  12666. Style.prototype.dispose = function () {
  12667. this.onChangedObservable.clear();
  12668. };
  12669. return Style;
  12670. }());
  12671. /***/ }),
  12672. /***/ "./2D/valueAndUnit.ts":
  12673. /*!****************************!*\
  12674. !*** ./2D/valueAndUnit.ts ***!
  12675. \****************************/
  12676. /*! exports provided: ValueAndUnit */
  12677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12678. "use strict";
  12679. __webpack_require__.r(__webpack_exports__);
  12680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12681. /**
  12682. * Class used to specific a value and its associated unit
  12683. */
  12684. var ValueAndUnit = /** @class */ (function () {
  12685. /**
  12686. * Creates a new ValueAndUnit
  12687. * @param value defines the value to store
  12688. * @param unit defines the unit to store
  12689. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12690. */
  12691. function ValueAndUnit(value,
  12692. /** defines the unit to store */
  12693. unit,
  12694. /** defines a boolean indicating if the value can be negative */
  12695. negativeValueAllowed) {
  12696. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12697. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12698. this.unit = unit;
  12699. this.negativeValueAllowed = negativeValueAllowed;
  12700. this._value = 1;
  12701. /**
  12702. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12703. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12704. */
  12705. this.ignoreAdaptiveScaling = false;
  12706. this._value = value;
  12707. this._originalUnit = unit;
  12708. }
  12709. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12710. /** Gets a boolean indicating if the value is a percentage */
  12711. get: function () {
  12712. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12713. },
  12714. enumerable: true,
  12715. configurable: true
  12716. });
  12717. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12718. /** Gets a boolean indicating if the value is store as pixel */
  12719. get: function () {
  12720. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12721. },
  12722. enumerable: true,
  12723. configurable: true
  12724. });
  12725. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12726. /** Gets direct internal value */
  12727. get: function () {
  12728. return this._value;
  12729. },
  12730. enumerable: true,
  12731. configurable: true
  12732. });
  12733. /**
  12734. * Gets value as pixel
  12735. * @param host defines the root host
  12736. * @param refValue defines the reference value for percentages
  12737. * @returns the value as pixel
  12738. */
  12739. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12740. if (this.isPixel) {
  12741. return this.getValue(host);
  12742. }
  12743. return this.getValue(host) * refValue;
  12744. };
  12745. /**
  12746. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12747. * @param value defines the value to store
  12748. * @param unit defines the unit to store
  12749. * @returns the current ValueAndUnit
  12750. */
  12751. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12752. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12753. this._value = value;
  12754. this.unit = unit;
  12755. return this;
  12756. };
  12757. /**
  12758. * Gets the value accordingly to its unit
  12759. * @param host defines the root host
  12760. * @returns the value
  12761. */
  12762. ValueAndUnit.prototype.getValue = function (host) {
  12763. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12764. var width = 0;
  12765. var height = 0;
  12766. if (host.idealWidth) {
  12767. width = (this._value * host.getSize().width) / host.idealWidth;
  12768. }
  12769. if (host.idealHeight) {
  12770. height = (this._value * host.getSize().height) / host.idealHeight;
  12771. }
  12772. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12773. return window.innerWidth < window.innerHeight ? width : height;
  12774. }
  12775. if (host.idealWidth) { // horizontal
  12776. return width;
  12777. }
  12778. if (host.idealHeight) { // vertical
  12779. return height;
  12780. }
  12781. }
  12782. return this._value;
  12783. };
  12784. /**
  12785. * Gets a string representation of the value
  12786. * @param host defines the root host
  12787. * @param decimals defines an optional number of decimals to display
  12788. * @returns a string
  12789. */
  12790. ValueAndUnit.prototype.toString = function (host, decimals) {
  12791. switch (this.unit) {
  12792. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12793. var percentage = this.getValue(host) * 100;
  12794. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  12795. case ValueAndUnit.UNITMODE_PIXEL:
  12796. var pixels = this.getValue(host);
  12797. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  12798. }
  12799. return this.unit.toString();
  12800. };
  12801. /**
  12802. * Store a value parsed from a string
  12803. * @param source defines the source string
  12804. * @returns true if the value was successfully parsed
  12805. */
  12806. ValueAndUnit.prototype.fromString = function (source) {
  12807. var match = ValueAndUnit._Regex.exec(source.toString());
  12808. if (!match || match.length === 0) {
  12809. return false;
  12810. }
  12811. var sourceValue = parseFloat(match[1]);
  12812. var sourceUnit = this._originalUnit;
  12813. if (!this.negativeValueAllowed) {
  12814. if (sourceValue < 0) {
  12815. sourceValue = 0;
  12816. }
  12817. }
  12818. if (match.length === 4) {
  12819. switch (match[3]) {
  12820. case "px":
  12821. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12822. break;
  12823. case "%":
  12824. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12825. sourceValue /= 100.0;
  12826. break;
  12827. }
  12828. }
  12829. if (sourceValue === this._value && sourceUnit === this.unit) {
  12830. return false;
  12831. }
  12832. this._value = sourceValue;
  12833. this.unit = sourceUnit;
  12834. return true;
  12835. };
  12836. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12837. /** UNITMODE_PERCENTAGE */
  12838. get: function () {
  12839. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12840. },
  12841. enumerable: true,
  12842. configurable: true
  12843. });
  12844. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12845. /** UNITMODE_PIXEL */
  12846. get: function () {
  12847. return ValueAndUnit._UNITMODE_PIXEL;
  12848. },
  12849. enumerable: true,
  12850. configurable: true
  12851. });
  12852. // Static
  12853. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12854. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12855. ValueAndUnit._UNITMODE_PIXEL = 1;
  12856. return ValueAndUnit;
  12857. }());
  12858. /***/ }),
  12859. /***/ "./2D/xmlLoader.ts":
  12860. /*!*************************!*\
  12861. !*** ./2D/xmlLoader.ts ***!
  12862. \*************************/
  12863. /*! exports provided: XmlLoader */
  12864. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12865. "use strict";
  12866. __webpack_require__.r(__webpack_exports__);
  12867. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  12868. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  12869. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  12870. /**
  12871. * Class used to load GUI via XML.
  12872. */
  12873. var XmlLoader = /** @class */ (function () {
  12874. /**
  12875. * Create a new xml loader
  12876. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  12877. */
  12878. function XmlLoader(parentClass) {
  12879. if (parentClass === void 0) { parentClass = null; }
  12880. this._nodes = {};
  12881. this._nodeTypes = {
  12882. element: 1,
  12883. attribute: 2,
  12884. text: 3
  12885. };
  12886. this._isLoaded = false;
  12887. this._objectAttributes = {
  12888. "textHorizontalAlignment": 1,
  12889. "textVerticalAlignment": 2,
  12890. "horizontalAlignment": 3,
  12891. "verticalAlignment": 4,
  12892. "stretch": 5,
  12893. };
  12894. if (parentClass) {
  12895. this._parentClass = parentClass;
  12896. }
  12897. }
  12898. XmlLoader.prototype._getChainElement = function (attributeValue) {
  12899. var element = window;
  12900. if (this._parentClass) {
  12901. element = this._parentClass;
  12902. }
  12903. var value = attributeValue;
  12904. value = value.split(".");
  12905. for (var i = 0; i < value.length; i++) {
  12906. element = element[value[i]];
  12907. }
  12908. return element;
  12909. };
  12910. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  12911. var attribute = attributeName.split(".");
  12912. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  12913. return className[attribute[1]];
  12914. };
  12915. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  12916. if (linkParent === void 0) { linkParent = true; }
  12917. try {
  12918. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  12919. var guiNode = new className();
  12920. if (parent && linkParent) {
  12921. parent.addControl(guiNode);
  12922. }
  12923. for (var i = 0; i < node.attributes.length; i++) {
  12924. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  12925. continue;
  12926. }
  12927. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  12928. var element = this._getChainElement(node.attributes[i].value);
  12929. guiNode[node.attributes[i].name].add(element);
  12930. continue;
  12931. }
  12932. else if (node.attributes[i].name == "linkWithMesh") {
  12933. if (this._parentClass) {
  12934. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  12935. }
  12936. else {
  12937. guiNode.linkWithMesh(window[node.attributes[i].value]);
  12938. }
  12939. }
  12940. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  12941. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  12942. guiNode[node.attributes[i].name] = element;
  12943. }
  12944. else if (!this._objectAttributes[node.attributes[i].name]) {
  12945. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  12946. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  12947. }
  12948. else {
  12949. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  12950. }
  12951. }
  12952. else {
  12953. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  12954. }
  12955. }
  12956. if (!node.attributes.getNamedItem("id")) {
  12957. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  12958. return guiNode;
  12959. }
  12960. if (!this._nodes[node.attributes.getNamedItem("id").nodeValue]) {
  12961. this._nodes[node.attributes.getNamedItem("id").nodeValue] = guiNode;
  12962. }
  12963. else {
  12964. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  12965. }
  12966. return guiNode;
  12967. }
  12968. catch (e) {
  12969. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  12970. }
  12971. };
  12972. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  12973. var width;
  12974. var height;
  12975. var columns;
  12976. var rows = node.children;
  12977. var cells;
  12978. var isPixel = false;
  12979. var cellNode;
  12980. var rowNumber = -1;
  12981. var columnNumber = -1;
  12982. var totalColumnsNumber = 0;
  12983. for (var i = 0; i < rows.length; i++) {
  12984. if (rows[i].nodeType != this._nodeTypes.element) {
  12985. continue;
  12986. }
  12987. if (rows[i].nodeName != "Row") {
  12988. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  12989. }
  12990. rowNumber += 1;
  12991. columns = rows[i].children;
  12992. if (!rows[i].attributes.getNamedItem("height")) {
  12993. throw "XmlLoader Exception : Height must be defined for grid rows";
  12994. }
  12995. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  12996. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  12997. guiNode.addRowDefinition(height, isPixel);
  12998. for (var j = 0; j < columns.length; j++) {
  12999. if (columns[j].nodeType != this._nodeTypes.element) {
  13000. continue;
  13001. }
  13002. if (columns[j].nodeName != "Column") {
  13003. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  13004. }
  13005. columnNumber += 1;
  13006. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  13007. throw "XmlLoader Exception : In the Grid element, the number of columns is defined in the first row, do not add more columns in the subsequent rows.";
  13008. }
  13009. if (rowNumber == 0) {
  13010. if (!columns[j].attributes.getNamedItem("width")) {
  13011. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  13012. }
  13013. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  13014. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  13015. guiNode.addColumnDefinition(width, isPixel);
  13016. }
  13017. cells = columns[j].children;
  13018. for (var k = 0; k < cells.length; k++) {
  13019. if (cells[k].nodeType != this._nodeTypes.element) {
  13020. continue;
  13021. }
  13022. cellNode = this._createGuiElement(cells[k], guiNode, false);
  13023. guiNode.addControl(cellNode, rowNumber, columnNumber);
  13024. if (cells[k].firstChild) {
  13025. this._parseXml(cells[k].firstChild, cellNode);
  13026. }
  13027. }
  13028. }
  13029. if (rowNumber == 0) {
  13030. totalColumnsNumber = columnNumber;
  13031. }
  13032. columnNumber = -1;
  13033. }
  13034. if (node.nextSibling) {
  13035. this._parseXml(node.nextSibling, parent);
  13036. }
  13037. };
  13038. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  13039. if (node.firstChild) {
  13040. this._parseXml(node.firstChild, guiNode);
  13041. }
  13042. if (node.nextSibling) {
  13043. this._parseXml(node.nextSibling, parent);
  13044. }
  13045. };
  13046. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  13047. if (this._parentClass) {
  13048. this._parentClass[variable] = source[iterator];
  13049. }
  13050. else {
  13051. window[variable] = source[iterator];
  13052. }
  13053. if (node.firstChild) {
  13054. this._parseXml(node.firstChild, guiNode, true);
  13055. }
  13056. };
  13057. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  13058. var dataSource = node.attributes.getNamedItem("dataSource").value;
  13059. if (!dataSource.includes(" in ")) {
  13060. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  13061. }
  13062. else {
  13063. var isArray = true;
  13064. var splittedSource = dataSource.split(" in ");
  13065. if (splittedSource.length < 2) {
  13066. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  13067. }
  13068. var source = splittedSource[1];
  13069. if (source.startsWith("{") && source.endsWith("}")) {
  13070. isArray = false;
  13071. }
  13072. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  13073. source = source.substring(1, source.length - 1);
  13074. }
  13075. if (this._parentClass) {
  13076. source = this._parentClass[source];
  13077. }
  13078. else {
  13079. source = window[source];
  13080. }
  13081. if (isArray) {
  13082. for (var i = 0; i < source.length; i++) {
  13083. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13084. }
  13085. }
  13086. else {
  13087. for (var i in source) {
  13088. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13089. }
  13090. }
  13091. if (node.nextSibling) {
  13092. this._parseXml(node.nextSibling, parent);
  13093. }
  13094. }
  13095. };
  13096. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  13097. if (generated === void 0) { generated = false; }
  13098. if (node.nodeType != this._nodeTypes.element) {
  13099. if (node.nextSibling) {
  13100. this._parseXml(node.nextSibling, parent, generated);
  13101. }
  13102. return;
  13103. }
  13104. if (generated) {
  13105. node.setAttribute("id", parent.id + parent._children.length + 1);
  13106. }
  13107. var guiNode = this._createGuiElement(node, parent);
  13108. if (node.nodeName == "Grid") {
  13109. this._parseGrid(node, guiNode, parent);
  13110. }
  13111. else if (!node.attributes.getNamedItem("dataSource")) {
  13112. this._parseElement(node, guiNode, parent);
  13113. }
  13114. else {
  13115. this._parseElementsFromSource(node, guiNode, parent);
  13116. }
  13117. };
  13118. /**
  13119. * Gets if the loading has finished.
  13120. * @returns whether the loading has finished or not
  13121. */
  13122. XmlLoader.prototype.isLoaded = function () {
  13123. return this._isLoaded;
  13124. };
  13125. /**
  13126. * Gets a loaded node / control by id.
  13127. * @param id the Controls id set in the xml
  13128. * @returns element of type Control
  13129. */
  13130. XmlLoader.prototype.getNodeById = function (id) {
  13131. return this._nodes[id];
  13132. };
  13133. /**
  13134. * Gets all loaded nodes / controls
  13135. * @returns Array of controls
  13136. */
  13137. XmlLoader.prototype.getNodes = function () {
  13138. return this._nodes;
  13139. };
  13140. /**
  13141. * Initiates the xml layout loading
  13142. * @param xmlFile defines the xml layout to load
  13143. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  13144. * @param callback defines the callback called on layout load.
  13145. */
  13146. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  13147. var xhttp = new XMLHttpRequest();
  13148. xhttp.onreadystatechange = function () {
  13149. if (xhttp.readyState == 4 && xhttp.status == 200) {
  13150. if (!xhttp.responseXML) {
  13151. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  13152. }
  13153. var xmlDoc = xhttp.responseXML.documentElement;
  13154. this._parseXml(xmlDoc.firstChild, rootNode);
  13155. this._isLoaded = true;
  13156. if (callback) {
  13157. callback();
  13158. }
  13159. }
  13160. }.bind(this);
  13161. xhttp.open("GET", xmlFile, true);
  13162. xhttp.send();
  13163. };
  13164. return XmlLoader;
  13165. }());
  13166. /***/ }),
  13167. /***/ "./3D/controls/abstractButton3D.ts":
  13168. /*!*****************************************!*\
  13169. !*** ./3D/controls/abstractButton3D.ts ***!
  13170. \*****************************************/
  13171. /*! exports provided: AbstractButton3D */
  13172. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13173. "use strict";
  13174. __webpack_require__.r(__webpack_exports__);
  13175. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  13176. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13177. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  13178. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13179. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13180. /**
  13181. * Class used as a root to all buttons
  13182. */
  13183. var AbstractButton3D = /** @class */ (function (_super) {
  13184. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  13185. /**
  13186. * Creates a new button
  13187. * @param name defines the control name
  13188. */
  13189. function AbstractButton3D(name) {
  13190. return _super.call(this, name) || this;
  13191. }
  13192. AbstractButton3D.prototype._getTypeName = function () {
  13193. return "AbstractButton3D";
  13194. };
  13195. // Mesh association
  13196. AbstractButton3D.prototype._createNode = function (scene) {
  13197. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  13198. };
  13199. return AbstractButton3D;
  13200. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13201. /***/ }),
  13202. /***/ "./3D/controls/button3D.ts":
  13203. /*!*********************************!*\
  13204. !*** ./3D/controls/button3D.ts ***!
  13205. \*********************************/
  13206. /*! exports provided: Button3D */
  13207. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13208. "use strict";
  13209. __webpack_require__.r(__webpack_exports__);
  13210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  13211. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13212. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  13213. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13214. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13215. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13216. /**
  13217. * Class used to create a button in 3D
  13218. */
  13219. var Button3D = /** @class */ (function (_super) {
  13220. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  13221. /**
  13222. * Creates a new button
  13223. * @param name defines the control name
  13224. */
  13225. function Button3D(name) {
  13226. var _this = _super.call(this, name) || this;
  13227. _this._contentResolution = 512;
  13228. _this._contentScaleRatio = 2;
  13229. // Default animations
  13230. _this.pointerEnterAnimation = function () {
  13231. if (!_this.mesh) {
  13232. return;
  13233. }
  13234. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  13235. };
  13236. _this.pointerOutAnimation = function () {
  13237. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13238. };
  13239. _this.pointerDownAnimation = function () {
  13240. if (!_this.mesh) {
  13241. return;
  13242. }
  13243. _this.mesh.scaling.scaleInPlace(0.95);
  13244. };
  13245. _this.pointerUpAnimation = function () {
  13246. if (!_this.mesh) {
  13247. return;
  13248. }
  13249. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13250. };
  13251. return _this;
  13252. }
  13253. Object.defineProperty(Button3D.prototype, "contentResolution", {
  13254. /**
  13255. * Gets or sets the texture resolution used to render content (512 by default)
  13256. */
  13257. get: function () {
  13258. return this._contentResolution;
  13259. },
  13260. set: function (value) {
  13261. if (this._contentResolution === value) {
  13262. return;
  13263. }
  13264. this._contentResolution = value;
  13265. this._resetContent();
  13266. },
  13267. enumerable: true,
  13268. configurable: true
  13269. });
  13270. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  13271. /**
  13272. * Gets or sets the texture scale ratio used to render content (2 by default)
  13273. */
  13274. get: function () {
  13275. return this._contentScaleRatio;
  13276. },
  13277. set: function (value) {
  13278. if (this._contentScaleRatio === value) {
  13279. return;
  13280. }
  13281. this._contentScaleRatio = value;
  13282. this._resetContent();
  13283. },
  13284. enumerable: true,
  13285. configurable: true
  13286. });
  13287. Button3D.prototype._disposeFacadeTexture = function () {
  13288. if (this._facadeTexture) {
  13289. this._facadeTexture.dispose();
  13290. this._facadeTexture = null;
  13291. }
  13292. };
  13293. Button3D.prototype._resetContent = function () {
  13294. this._disposeFacadeTexture();
  13295. this.content = this._content;
  13296. };
  13297. Object.defineProperty(Button3D.prototype, "content", {
  13298. /**
  13299. * Gets or sets the GUI 2D content used to display the button's facade
  13300. */
  13301. get: function () {
  13302. return this._content;
  13303. },
  13304. set: function (value) {
  13305. this._content = value;
  13306. if (!this._host || !this._host.utilityLayer) {
  13307. return;
  13308. }
  13309. if (!this._facadeTexture) {
  13310. this._facadeTexture = new _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__["AdvancedDynamicTexture"]("Facade", this._contentResolution, this._contentResolution, this._host.utilityLayer.utilityLayerScene, true, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  13311. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  13312. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  13313. this._facadeTexture.premulAlpha = true;
  13314. }
  13315. else {
  13316. this._facadeTexture.rootContainer.clearControls();
  13317. }
  13318. this._facadeTexture.addControl(value);
  13319. this._applyFacade(this._facadeTexture);
  13320. },
  13321. enumerable: true,
  13322. configurable: true
  13323. });
  13324. /**
  13325. * Apply the facade texture (created from the content property).
  13326. * This function can be overloaded by child classes
  13327. * @param facadeTexture defines the AdvancedDynamicTexture to use
  13328. */
  13329. Button3D.prototype._applyFacade = function (facadeTexture) {
  13330. this._currentMaterial.emissiveTexture = facadeTexture;
  13331. };
  13332. Button3D.prototype._getTypeName = function () {
  13333. return "Button3D";
  13334. };
  13335. // Mesh association
  13336. Button3D.prototype._createNode = function (scene) {
  13337. var faceUV = new Array(6);
  13338. for (var i = 0; i < 6; i++) {
  13339. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  13340. }
  13341. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  13342. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  13343. width: 1.0,
  13344. height: 1.0,
  13345. depth: 0.08,
  13346. faceUV: faceUV
  13347. }, scene);
  13348. return mesh;
  13349. };
  13350. Button3D.prototype._affectMaterial = function (mesh) {
  13351. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  13352. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13353. mesh.material = material;
  13354. this._currentMaterial = material;
  13355. this._resetContent();
  13356. };
  13357. /**
  13358. * Releases all associated resources
  13359. */
  13360. Button3D.prototype.dispose = function () {
  13361. _super.prototype.dispose.call(this);
  13362. this._disposeFacadeTexture();
  13363. if (this._currentMaterial) {
  13364. this._currentMaterial.dispose();
  13365. }
  13366. };
  13367. return Button3D;
  13368. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  13369. /***/ }),
  13370. /***/ "./3D/controls/container3D.ts":
  13371. /*!************************************!*\
  13372. !*** ./3D/controls/container3D.ts ***!
  13373. \************************************/
  13374. /*! exports provided: Container3D */
  13375. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13376. "use strict";
  13377. __webpack_require__.r(__webpack_exports__);
  13378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  13379. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13380. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  13381. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13382. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13383. /**
  13384. * Class used to create containers for controls
  13385. */
  13386. var Container3D = /** @class */ (function (_super) {
  13387. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  13388. /**
  13389. * Creates a new container
  13390. * @param name defines the container name
  13391. */
  13392. function Container3D(name) {
  13393. var _this = _super.call(this, name) || this;
  13394. _this._blockLayout = false;
  13395. /**
  13396. * Gets the list of child controls
  13397. */
  13398. _this._children = new Array();
  13399. return _this;
  13400. }
  13401. Object.defineProperty(Container3D.prototype, "children", {
  13402. /**
  13403. * Gets the list of child controls
  13404. */
  13405. get: function () {
  13406. return this._children;
  13407. },
  13408. enumerable: true,
  13409. configurable: true
  13410. });
  13411. Object.defineProperty(Container3D.prototype, "blockLayout", {
  13412. /**
  13413. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  13414. * This is helpful to optimize layout operation when adding multiple children in a row
  13415. */
  13416. get: function () {
  13417. return this._blockLayout;
  13418. },
  13419. set: function (value) {
  13420. if (this._blockLayout === value) {
  13421. return;
  13422. }
  13423. this._blockLayout = value;
  13424. if (!this._blockLayout) {
  13425. this._arrangeChildren();
  13426. }
  13427. },
  13428. enumerable: true,
  13429. configurable: true
  13430. });
  13431. /**
  13432. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  13433. * @returns the current container
  13434. */
  13435. Container3D.prototype.updateLayout = function () {
  13436. this._arrangeChildren();
  13437. return this;
  13438. };
  13439. /**
  13440. * Gets a boolean indicating if the given control is in the children of this control
  13441. * @param control defines the control to check
  13442. * @returns true if the control is in the child list
  13443. */
  13444. Container3D.prototype.containsControl = function (control) {
  13445. return this._children.indexOf(control) !== -1;
  13446. };
  13447. /**
  13448. * Adds a control to the children of this control
  13449. * @param control defines the control to add
  13450. * @returns the current container
  13451. */
  13452. Container3D.prototype.addControl = function (control) {
  13453. var index = this._children.indexOf(control);
  13454. if (index !== -1) {
  13455. return this;
  13456. }
  13457. control.parent = this;
  13458. control._host = this._host;
  13459. this._children.push(control);
  13460. if (this._host.utilityLayer) {
  13461. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  13462. if (control.node) {
  13463. control.node.parent = this.node;
  13464. }
  13465. if (!this.blockLayout) {
  13466. this._arrangeChildren();
  13467. }
  13468. }
  13469. return this;
  13470. };
  13471. /**
  13472. * This function will be called everytime a new control is added
  13473. */
  13474. Container3D.prototype._arrangeChildren = function () {
  13475. };
  13476. Container3D.prototype._createNode = function (scene) {
  13477. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  13478. };
  13479. /**
  13480. * Removes a control from the children of this control
  13481. * @param control defines the control to remove
  13482. * @returns the current container
  13483. */
  13484. Container3D.prototype.removeControl = function (control) {
  13485. var index = this._children.indexOf(control);
  13486. if (index !== -1) {
  13487. this._children.splice(index, 1);
  13488. control.parent = null;
  13489. control._disposeNode();
  13490. }
  13491. return this;
  13492. };
  13493. Container3D.prototype._getTypeName = function () {
  13494. return "Container3D";
  13495. };
  13496. /**
  13497. * Releases all associated resources
  13498. */
  13499. Container3D.prototype.dispose = function () {
  13500. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13501. var control = _a[_i];
  13502. control.dispose();
  13503. }
  13504. this._children = [];
  13505. _super.prototype.dispose.call(this);
  13506. };
  13507. /** Control rotation will remain unchanged */
  13508. Container3D.UNSET_ORIENTATION = 0;
  13509. /** Control will rotate to make it look at sphere central axis */
  13510. Container3D.FACEORIGIN_ORIENTATION = 1;
  13511. /** Control will rotate to make it look back at sphere central axis */
  13512. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  13513. /** Control will rotate to look at z axis (0, 0, 1) */
  13514. Container3D.FACEFORWARD_ORIENTATION = 3;
  13515. /** Control will rotate to look at negative z axis (0, 0, -1) */
  13516. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  13517. return Container3D;
  13518. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13519. /***/ }),
  13520. /***/ "./3D/controls/control3D.ts":
  13521. /*!**********************************!*\
  13522. !*** ./3D/controls/control3D.ts ***!
  13523. \**********************************/
  13524. /*! exports provided: Control3D */
  13525. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13526. "use strict";
  13527. __webpack_require__.r(__webpack_exports__);
  13528. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  13529. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  13530. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13531. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  13532. /**
  13533. * Class used as base class for controls
  13534. */
  13535. var Control3D = /** @class */ (function () {
  13536. /**
  13537. * Creates a new control
  13538. * @param name defines the control name
  13539. */
  13540. function Control3D(
  13541. /** Defines the control name */
  13542. name) {
  13543. this.name = name;
  13544. this._downCount = 0;
  13545. this._enterCount = -1;
  13546. this._downPointerIds = {};
  13547. this._isVisible = true;
  13548. /**
  13549. * An event triggered when the pointer move over the control
  13550. */
  13551. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13552. /**
  13553. * An event triggered when the pointer move out of the control
  13554. */
  13555. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13556. /**
  13557. * An event triggered when the pointer taps the control
  13558. */
  13559. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13560. /**
  13561. * An event triggered when pointer is up
  13562. */
  13563. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13564. /**
  13565. * An event triggered when a control is clicked on (with a mouse)
  13566. */
  13567. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13568. /**
  13569. * An event triggered when pointer enters the control
  13570. */
  13571. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13572. // Behaviors
  13573. this._behaviors = new Array();
  13574. }
  13575. Object.defineProperty(Control3D.prototype, "position", {
  13576. /** Gets or sets the control position in world space */
  13577. get: function () {
  13578. if (!this._node) {
  13579. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  13580. }
  13581. return this._node.position;
  13582. },
  13583. set: function (value) {
  13584. if (!this._node) {
  13585. return;
  13586. }
  13587. this._node.position = value;
  13588. },
  13589. enumerable: true,
  13590. configurable: true
  13591. });
  13592. Object.defineProperty(Control3D.prototype, "scaling", {
  13593. /** Gets or sets the control scaling in world space */
  13594. get: function () {
  13595. if (!this._node) {
  13596. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  13597. }
  13598. return this._node.scaling;
  13599. },
  13600. set: function (value) {
  13601. if (!this._node) {
  13602. return;
  13603. }
  13604. this._node.scaling = value;
  13605. },
  13606. enumerable: true,
  13607. configurable: true
  13608. });
  13609. Object.defineProperty(Control3D.prototype, "behaviors", {
  13610. /**
  13611. * Gets the list of attached behaviors
  13612. * @see http://doc.babylonjs.com/features/behaviour
  13613. */
  13614. get: function () {
  13615. return this._behaviors;
  13616. },
  13617. enumerable: true,
  13618. configurable: true
  13619. });
  13620. /**
  13621. * Attach a behavior to the control
  13622. * @see http://doc.babylonjs.com/features/behaviour
  13623. * @param behavior defines the behavior to attach
  13624. * @returns the current control
  13625. */
  13626. Control3D.prototype.addBehavior = function (behavior) {
  13627. var _this = this;
  13628. var index = this._behaviors.indexOf(behavior);
  13629. if (index !== -1) {
  13630. return this;
  13631. }
  13632. behavior.init();
  13633. var scene = this._host.scene;
  13634. if (scene.isLoading) {
  13635. // We defer the attach when the scene will be loaded
  13636. scene.onDataLoadedObservable.addOnce(function () {
  13637. behavior.attach(_this);
  13638. });
  13639. }
  13640. else {
  13641. behavior.attach(this);
  13642. }
  13643. this._behaviors.push(behavior);
  13644. return this;
  13645. };
  13646. /**
  13647. * Remove an attached behavior
  13648. * @see http://doc.babylonjs.com/features/behaviour
  13649. * @param behavior defines the behavior to attach
  13650. * @returns the current control
  13651. */
  13652. Control3D.prototype.removeBehavior = function (behavior) {
  13653. var index = this._behaviors.indexOf(behavior);
  13654. if (index === -1) {
  13655. return this;
  13656. }
  13657. this._behaviors[index].detach();
  13658. this._behaviors.splice(index, 1);
  13659. return this;
  13660. };
  13661. /**
  13662. * Gets an attached behavior by name
  13663. * @param name defines the name of the behavior to look for
  13664. * @see http://doc.babylonjs.com/features/behaviour
  13665. * @returns null if behavior was not found else the requested behavior
  13666. */
  13667. Control3D.prototype.getBehaviorByName = function (name) {
  13668. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13669. var behavior = _a[_i];
  13670. if (behavior.name === name) {
  13671. return behavior;
  13672. }
  13673. }
  13674. return null;
  13675. };
  13676. Object.defineProperty(Control3D.prototype, "isVisible", {
  13677. /** Gets or sets a boolean indicating if the control is visible */
  13678. get: function () {
  13679. return this._isVisible;
  13680. },
  13681. set: function (value) {
  13682. if (this._isVisible === value) {
  13683. return;
  13684. }
  13685. this._isVisible = value;
  13686. var mesh = this.mesh;
  13687. if (mesh) {
  13688. mesh.setEnabled(value);
  13689. }
  13690. },
  13691. enumerable: true,
  13692. configurable: true
  13693. });
  13694. Object.defineProperty(Control3D.prototype, "typeName", {
  13695. /**
  13696. * Gets a string representing the class name
  13697. */
  13698. get: function () {
  13699. return this._getTypeName();
  13700. },
  13701. enumerable: true,
  13702. configurable: true
  13703. });
  13704. /**
  13705. * Get the current class name of the control.
  13706. * @returns current class name
  13707. */
  13708. Control3D.prototype.getClassName = function () {
  13709. return this._getTypeName();
  13710. };
  13711. Control3D.prototype._getTypeName = function () {
  13712. return "Control3D";
  13713. };
  13714. Object.defineProperty(Control3D.prototype, "node", {
  13715. /**
  13716. * Gets the transform node used by this control
  13717. */
  13718. get: function () {
  13719. return this._node;
  13720. },
  13721. enumerable: true,
  13722. configurable: true
  13723. });
  13724. Object.defineProperty(Control3D.prototype, "mesh", {
  13725. /**
  13726. * Gets the mesh used to render this control
  13727. */
  13728. get: function () {
  13729. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  13730. return this._node;
  13731. }
  13732. return null;
  13733. },
  13734. enumerable: true,
  13735. configurable: true
  13736. });
  13737. /**
  13738. * Link the control as child of the given node
  13739. * @param node defines the node to link to. Use null to unlink the control
  13740. * @returns the current control
  13741. */
  13742. Control3D.prototype.linkToTransformNode = function (node) {
  13743. if (this._node) {
  13744. this._node.parent = node;
  13745. }
  13746. return this;
  13747. };
  13748. /** @hidden **/
  13749. Control3D.prototype._prepareNode = function (scene) {
  13750. if (!this._node) {
  13751. this._node = this._createNode(scene);
  13752. if (!this.node) {
  13753. return;
  13754. }
  13755. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  13756. this._node.position = this.position;
  13757. this._node.scaling = this.scaling;
  13758. var mesh = this.mesh;
  13759. if (mesh) {
  13760. mesh.isPickable = true;
  13761. this._affectMaterial(mesh);
  13762. }
  13763. }
  13764. };
  13765. /**
  13766. * Node creation.
  13767. * Can be overriden by children
  13768. * @param scene defines the scene where the node must be attached
  13769. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  13770. */
  13771. Control3D.prototype._createNode = function (scene) {
  13772. // Do nothing by default
  13773. return null;
  13774. };
  13775. /**
  13776. * Affect a material to the given mesh
  13777. * @param mesh defines the mesh which will represent the control
  13778. */
  13779. Control3D.prototype._affectMaterial = function (mesh) {
  13780. mesh.material = null;
  13781. };
  13782. // Pointers
  13783. /** @hidden */
  13784. Control3D.prototype._onPointerMove = function (target, coordinates) {
  13785. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  13786. };
  13787. /** @hidden */
  13788. Control3D.prototype._onPointerEnter = function (target) {
  13789. if (this._enterCount > 0) {
  13790. return false;
  13791. }
  13792. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  13793. this._enterCount = 0;
  13794. }
  13795. this._enterCount++;
  13796. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  13797. if (this.pointerEnterAnimation) {
  13798. this.pointerEnterAnimation();
  13799. }
  13800. return true;
  13801. };
  13802. /** @hidden */
  13803. Control3D.prototype._onPointerOut = function (target) {
  13804. this._enterCount = 0;
  13805. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  13806. if (this.pointerOutAnimation) {
  13807. this.pointerOutAnimation();
  13808. }
  13809. };
  13810. /** @hidden */
  13811. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  13812. if (this._downCount !== 0) {
  13813. this._downCount++;
  13814. return false;
  13815. }
  13816. this._downCount++;
  13817. this._downPointerIds[pointerId] = true;
  13818. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13819. if (this.pointerDownAnimation) {
  13820. this.pointerDownAnimation();
  13821. }
  13822. return true;
  13823. };
  13824. /** @hidden */
  13825. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  13826. this._downCount--;
  13827. delete this._downPointerIds[pointerId];
  13828. if (this._downCount < 0) {
  13829. // Handle if forcePointerUp was called prior to this
  13830. this._downCount = 0;
  13831. return;
  13832. }
  13833. if (this._downCount == 0) {
  13834. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  13835. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13836. }
  13837. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13838. if (this.pointerUpAnimation) {
  13839. this.pointerUpAnimation();
  13840. }
  13841. }
  13842. };
  13843. /** @hidden */
  13844. Control3D.prototype.forcePointerUp = function (pointerId) {
  13845. if (pointerId === void 0) { pointerId = null; }
  13846. if (pointerId !== null) {
  13847. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  13848. }
  13849. else {
  13850. for (var key in this._downPointerIds) {
  13851. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  13852. }
  13853. if (this._downCount > 0) {
  13854. this._downCount = 1;
  13855. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  13856. }
  13857. }
  13858. };
  13859. /** @hidden */
  13860. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  13861. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  13862. this._onPointerMove(this, pickedPoint);
  13863. var previousControlOver = this._host._lastControlOver[pointerId];
  13864. if (previousControlOver && previousControlOver !== this) {
  13865. previousControlOver._onPointerOut(this);
  13866. }
  13867. if (previousControlOver !== this) {
  13868. this._onPointerEnter(this);
  13869. }
  13870. this._host._lastControlOver[pointerId] = this;
  13871. return true;
  13872. }
  13873. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  13874. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  13875. this._host._lastControlDown[pointerId] = this;
  13876. this._host._lastPickedControl = this;
  13877. return true;
  13878. }
  13879. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  13880. if (this._host._lastControlDown[pointerId]) {
  13881. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  13882. }
  13883. delete this._host._lastControlDown[pointerId];
  13884. return true;
  13885. }
  13886. return false;
  13887. };
  13888. /** @hidden */
  13889. Control3D.prototype._disposeNode = function () {
  13890. if (this._node) {
  13891. this._node.dispose();
  13892. this._node = null;
  13893. }
  13894. };
  13895. /**
  13896. * Releases all associated resources
  13897. */
  13898. Control3D.prototype.dispose = function () {
  13899. this.onPointerDownObservable.clear();
  13900. this.onPointerEnterObservable.clear();
  13901. this.onPointerMoveObservable.clear();
  13902. this.onPointerOutObservable.clear();
  13903. this.onPointerUpObservable.clear();
  13904. this.onPointerClickObservable.clear();
  13905. this._disposeNode();
  13906. // Behaviors
  13907. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13908. var behavior = _a[_i];
  13909. behavior.detach();
  13910. }
  13911. };
  13912. return Control3D;
  13913. }());
  13914. /***/ }),
  13915. /***/ "./3D/controls/cylinderPanel.ts":
  13916. /*!**************************************!*\
  13917. !*** ./3D/controls/cylinderPanel.ts ***!
  13918. \**************************************/
  13919. /*! exports provided: CylinderPanel */
  13920. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13921. "use strict";
  13922. __webpack_require__.r(__webpack_exports__);
  13923. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13924. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13925. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  13926. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13927. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13928. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13929. /**
  13930. * Class used to create a container panel deployed on the surface of a cylinder
  13931. */
  13932. var CylinderPanel = /** @class */ (function (_super) {
  13933. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  13934. function CylinderPanel() {
  13935. var _this = _super !== null && _super.apply(this, arguments) || this;
  13936. _this._radius = 5.0;
  13937. return _this;
  13938. }
  13939. Object.defineProperty(CylinderPanel.prototype, "radius", {
  13940. /**
  13941. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  13942. */
  13943. get: function () {
  13944. return this._radius;
  13945. },
  13946. set: function (value) {
  13947. var _this = this;
  13948. if (this._radius === value) {
  13949. return;
  13950. }
  13951. this._radius = value;
  13952. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13953. _this._arrangeChildren();
  13954. });
  13955. },
  13956. enumerable: true,
  13957. configurable: true
  13958. });
  13959. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13960. var mesh = control.mesh;
  13961. if (!mesh) {
  13962. return;
  13963. }
  13964. var newPos = this._cylindricalMapping(nodePosition);
  13965. control.position = newPos;
  13966. switch (this.orientation) {
  13967. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13968. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13969. break;
  13970. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13971. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13972. break;
  13973. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13974. break;
  13975. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13976. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13977. break;
  13978. }
  13979. };
  13980. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13981. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13982. var yAngle = (source.x / this._radius);
  13983. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13984. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13985. };
  13986. return CylinderPanel;
  13987. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13988. /***/ }),
  13989. /***/ "./3D/controls/holographicButton.ts":
  13990. /*!******************************************!*\
  13991. !*** ./3D/controls/holographicButton.ts ***!
  13992. \******************************************/
  13993. /*! exports provided: HolographicButton */
  13994. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13995. "use strict";
  13996. __webpack_require__.r(__webpack_exports__);
  13997. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13998. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13999. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14000. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  14001. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  14002. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14003. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  14004. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  14005. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  14006. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14007. /**
  14008. * Class used to create a holographic button in 3D
  14009. */
  14010. var HolographicButton = /** @class */ (function (_super) {
  14011. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  14012. /**
  14013. * Creates a new button
  14014. * @param name defines the control name
  14015. */
  14016. function HolographicButton(name, shareMaterials) {
  14017. if (shareMaterials === void 0) { shareMaterials = true; }
  14018. var _this = _super.call(this, name) || this;
  14019. _this._shareMaterials = true;
  14020. _this._shareMaterials = shareMaterials;
  14021. // Default animations
  14022. _this.pointerEnterAnimation = function () {
  14023. if (!_this.mesh) {
  14024. return;
  14025. }
  14026. _this._frontPlate.setEnabled(true);
  14027. };
  14028. _this.pointerOutAnimation = function () {
  14029. if (!_this.mesh) {
  14030. return;
  14031. }
  14032. _this._frontPlate.setEnabled(false);
  14033. };
  14034. return _this;
  14035. }
  14036. HolographicButton.prototype._disposeTooltip = function () {
  14037. this._tooltipFade = null;
  14038. if (this._tooltipTextBlock) {
  14039. this._tooltipTextBlock.dispose();
  14040. }
  14041. if (this._tooltipTexture) {
  14042. this._tooltipTexture.dispose();
  14043. }
  14044. if (this._tooltipMesh) {
  14045. this._tooltipMesh.dispose();
  14046. }
  14047. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  14048. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  14049. };
  14050. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  14051. get: function () {
  14052. if (this._tooltipTextBlock) {
  14053. return this._tooltipTextBlock.text;
  14054. }
  14055. return null;
  14056. },
  14057. /**
  14058. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  14059. */
  14060. set: function (text) {
  14061. var _this = this;
  14062. if (!text) {
  14063. this._disposeTooltip();
  14064. return;
  14065. }
  14066. if (!this._tooltipFade) {
  14067. // Create tooltip with mesh and text
  14068. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  14069. var tooltipBackground = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1, sideOrientation: babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Mesh"].DOUBLESIDE }, this._backPlate._scene);
  14070. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  14071. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  14072. tooltipBackground.material = mat;
  14073. tooltipBackground.isPickable = false;
  14074. this._tooltipMesh.addChild(tooltipBackground);
  14075. tooltipBackground.position.z = 0.05;
  14076. this._tooltipMesh.scaling.y = 1 / 3;
  14077. this._tooltipMesh.position.y = 0.7;
  14078. this._tooltipMesh.position.z = -0.15;
  14079. this._tooltipMesh.isPickable = false;
  14080. this._tooltipMesh.parent = this._backPlate;
  14081. // Create text texture for the tooltip
  14082. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  14083. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14084. this._tooltipTextBlock.scaleY = 3;
  14085. this._tooltipTextBlock.color = "white";
  14086. this._tooltipTextBlock.fontSize = 130;
  14087. this._tooltipTexture.addControl(this._tooltipTextBlock);
  14088. // Add hover action to tooltip
  14089. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  14090. this._tooltipFade.delay = 500;
  14091. this._tooltipMesh.addBehavior(this._tooltipFade);
  14092. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  14093. if (_this._tooltipFade) {
  14094. _this._tooltipFade.fadeIn(true);
  14095. }
  14096. });
  14097. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  14098. if (_this._tooltipFade) {
  14099. _this._tooltipFade.fadeIn(false);
  14100. }
  14101. });
  14102. }
  14103. if (this._tooltipTextBlock) {
  14104. this._tooltipTextBlock.text = text;
  14105. }
  14106. },
  14107. enumerable: true,
  14108. configurable: true
  14109. });
  14110. Object.defineProperty(HolographicButton.prototype, "text", {
  14111. /**
  14112. * Gets or sets text for the button
  14113. */
  14114. get: function () {
  14115. return this._text;
  14116. },
  14117. set: function (value) {
  14118. if (this._text === value) {
  14119. return;
  14120. }
  14121. this._text = value;
  14122. this._rebuildContent();
  14123. },
  14124. enumerable: true,
  14125. configurable: true
  14126. });
  14127. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  14128. /**
  14129. * Gets or sets the image url for the button
  14130. */
  14131. get: function () {
  14132. return this._imageUrl;
  14133. },
  14134. set: function (value) {
  14135. if (this._imageUrl === value) {
  14136. return;
  14137. }
  14138. this._imageUrl = value;
  14139. this._rebuildContent();
  14140. },
  14141. enumerable: true,
  14142. configurable: true
  14143. });
  14144. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  14145. /**
  14146. * Gets the back material used by this button
  14147. */
  14148. get: function () {
  14149. return this._backMaterial;
  14150. },
  14151. enumerable: true,
  14152. configurable: true
  14153. });
  14154. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  14155. /**
  14156. * Gets the front material used by this button
  14157. */
  14158. get: function () {
  14159. return this._frontMaterial;
  14160. },
  14161. enumerable: true,
  14162. configurable: true
  14163. });
  14164. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  14165. /**
  14166. * Gets the plate material used by this button
  14167. */
  14168. get: function () {
  14169. return this._plateMaterial;
  14170. },
  14171. enumerable: true,
  14172. configurable: true
  14173. });
  14174. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  14175. /**
  14176. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  14177. */
  14178. get: function () {
  14179. return this._shareMaterials;
  14180. },
  14181. enumerable: true,
  14182. configurable: true
  14183. });
  14184. HolographicButton.prototype._getTypeName = function () {
  14185. return "HolographicButton";
  14186. };
  14187. HolographicButton.prototype._rebuildContent = function () {
  14188. this._disposeFacadeTexture();
  14189. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  14190. panel.isVertical = true;
  14191. if (this._imageUrl) {
  14192. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  14193. image.source = this._imageUrl;
  14194. image.paddingTop = "40px";
  14195. image.height = "180px";
  14196. image.width = "100px";
  14197. image.paddingBottom = "40px";
  14198. panel.addControl(image);
  14199. }
  14200. if (this._text) {
  14201. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14202. text.text = this._text;
  14203. text.color = "white";
  14204. text.height = "30px";
  14205. text.fontSize = 24;
  14206. panel.addControl(text);
  14207. }
  14208. if (this._frontPlate) {
  14209. this.content = panel;
  14210. }
  14211. };
  14212. // Mesh association
  14213. HolographicButton.prototype._createNode = function (scene) {
  14214. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  14215. width: 1.0,
  14216. height: 1.0,
  14217. depth: 0.08
  14218. }, scene);
  14219. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  14220. width: 1.0,
  14221. height: 1.0,
  14222. depth: 0.08
  14223. }, scene);
  14224. this._frontPlate.parent = this._backPlate;
  14225. this._frontPlate.position.z = -0.08;
  14226. this._frontPlate.isPickable = false;
  14227. this._frontPlate.setEnabled(false);
  14228. this._textPlate = _super.prototype._createNode.call(this, scene);
  14229. this._textPlate.parent = this._backPlate;
  14230. this._textPlate.position.z = -0.08;
  14231. this._textPlate.isPickable = false;
  14232. return this._backPlate;
  14233. };
  14234. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  14235. this._plateMaterial.emissiveTexture = facadeTexture;
  14236. this._plateMaterial.opacityTexture = facadeTexture;
  14237. };
  14238. HolographicButton.prototype._createBackMaterial = function (mesh) {
  14239. var _this = this;
  14240. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  14241. this._backMaterial.renderHoverLight = true;
  14242. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  14243. if (pickedPoint) {
  14244. _this._backMaterial.hoverPosition = pickedPoint;
  14245. _this._backMaterial.hoverColor.a = 1.0;
  14246. }
  14247. else {
  14248. _this._backMaterial.hoverColor.a = 0;
  14249. }
  14250. });
  14251. };
  14252. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  14253. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  14254. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  14255. this._frontMaterial.alpha = 0.5; // Additive
  14256. this._frontMaterial.renderBorders = true;
  14257. };
  14258. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  14259. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  14260. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  14261. };
  14262. HolographicButton.prototype._affectMaterial = function (mesh) {
  14263. // Back
  14264. if (this._shareMaterials) {
  14265. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  14266. this._createBackMaterial(mesh);
  14267. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  14268. }
  14269. else {
  14270. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  14271. }
  14272. // Front
  14273. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  14274. this._createFrontMaterial(mesh);
  14275. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  14276. }
  14277. else {
  14278. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  14279. }
  14280. }
  14281. else {
  14282. this._createBackMaterial(mesh);
  14283. this._createFrontMaterial(mesh);
  14284. }
  14285. this._createPlateMaterial(mesh);
  14286. this._backPlate.material = this._backMaterial;
  14287. this._frontPlate.material = this._frontMaterial;
  14288. this._textPlate.material = this._plateMaterial;
  14289. this._rebuildContent();
  14290. };
  14291. /**
  14292. * Releases all associated resources
  14293. */
  14294. HolographicButton.prototype.dispose = function () {
  14295. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  14296. this._disposeTooltip();
  14297. if (!this.shareMaterials) {
  14298. this._backMaterial.dispose();
  14299. this._frontMaterial.dispose();
  14300. this._plateMaterial.dispose();
  14301. if (this._pickedPointObserver) {
  14302. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  14303. this._pickedPointObserver = null;
  14304. }
  14305. }
  14306. };
  14307. return HolographicButton;
  14308. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14309. /***/ }),
  14310. /***/ "./3D/controls/index.ts":
  14311. /*!******************************!*\
  14312. !*** ./3D/controls/index.ts ***!
  14313. \******************************/
  14314. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  14315. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14316. "use strict";
  14317. __webpack_require__.r(__webpack_exports__);
  14318. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  14319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14320. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14322. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  14324. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  14326. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  14327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  14328. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  14329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  14330. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  14331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  14332. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  14333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  14334. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  14335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  14336. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  14337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  14338. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  14339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  14340. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  14342. /***/ }),
  14343. /***/ "./3D/controls/meshButton3D.ts":
  14344. /*!*************************************!*\
  14345. !*** ./3D/controls/meshButton3D.ts ***!
  14346. \*************************************/
  14347. /*! exports provided: MeshButton3D */
  14348. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14349. "use strict";
  14350. __webpack_require__.r(__webpack_exports__);
  14351. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  14352. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14353. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14354. /**
  14355. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  14356. */
  14357. var MeshButton3D = /** @class */ (function (_super) {
  14358. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  14359. /**
  14360. * Creates a new 3D button based on a mesh
  14361. * @param mesh mesh to become a 3D button
  14362. * @param name defines the control name
  14363. */
  14364. function MeshButton3D(mesh, name) {
  14365. var _this = _super.call(this, name) || this;
  14366. _this._currentMesh = mesh;
  14367. /**
  14368. * Provides a default behavior on hover/out & up/down
  14369. * Override those function to create your own desired behavior specific to your mesh
  14370. */
  14371. _this.pointerEnterAnimation = function () {
  14372. if (!_this.mesh) {
  14373. return;
  14374. }
  14375. _this.mesh.scaling.scaleInPlace(1.1);
  14376. };
  14377. _this.pointerOutAnimation = function () {
  14378. if (!_this.mesh) {
  14379. return;
  14380. }
  14381. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  14382. };
  14383. _this.pointerDownAnimation = function () {
  14384. if (!_this.mesh) {
  14385. return;
  14386. }
  14387. _this.mesh.scaling.scaleInPlace(0.95);
  14388. };
  14389. _this.pointerUpAnimation = function () {
  14390. if (!_this.mesh) {
  14391. return;
  14392. }
  14393. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  14394. };
  14395. return _this;
  14396. }
  14397. MeshButton3D.prototype._getTypeName = function () {
  14398. return "MeshButton3D";
  14399. };
  14400. // Mesh association
  14401. MeshButton3D.prototype._createNode = function (scene) {
  14402. var _this = this;
  14403. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  14404. mesh.metadata = _this;
  14405. });
  14406. return this._currentMesh;
  14407. };
  14408. MeshButton3D.prototype._affectMaterial = function (mesh) {
  14409. };
  14410. return MeshButton3D;
  14411. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14412. /***/ }),
  14413. /***/ "./3D/controls/planePanel.ts":
  14414. /*!***********************************!*\
  14415. !*** ./3D/controls/planePanel.ts ***!
  14416. \***********************************/
  14417. /*! exports provided: PlanePanel */
  14418. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14419. "use strict";
  14420. __webpack_require__.r(__webpack_exports__);
  14421. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  14422. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14423. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  14424. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14425. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14426. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14427. /**
  14428. * Class used to create a container panel deployed on the surface of a plane
  14429. */
  14430. var PlanePanel = /** @class */ (function (_super) {
  14431. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  14432. function PlanePanel() {
  14433. return _super !== null && _super.apply(this, arguments) || this;
  14434. }
  14435. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  14436. var mesh = control.mesh;
  14437. if (!mesh) {
  14438. return;
  14439. }
  14440. control.position = nodePosition.clone();
  14441. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14442. target.copyFrom(nodePosition);
  14443. switch (this.orientation) {
  14444. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  14445. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  14446. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  14447. mesh.lookAt(target);
  14448. break;
  14449. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14450. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14451. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  14452. mesh.lookAt(target);
  14453. break;
  14454. }
  14455. };
  14456. return PlanePanel;
  14457. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  14458. /***/ }),
  14459. /***/ "./3D/controls/scatterPanel.ts":
  14460. /*!*************************************!*\
  14461. !*** ./3D/controls/scatterPanel.ts ***!
  14462. \*************************************/
  14463. /*! exports provided: ScatterPanel */
  14464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14465. "use strict";
  14466. __webpack_require__.r(__webpack_exports__);
  14467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  14468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14469. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  14470. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14471. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14472. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14473. /**
  14474. * Class used to create a container panel where items get randomized planar mapping
  14475. */
  14476. var ScatterPanel = /** @class */ (function (_super) {
  14477. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  14478. function ScatterPanel() {
  14479. var _this = _super !== null && _super.apply(this, arguments) || this;
  14480. _this._iteration = 100.0;
  14481. return _this;
  14482. }
  14483. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  14484. /**
  14485. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  14486. */
  14487. get: function () {
  14488. return this._iteration;
  14489. },
  14490. set: function (value) {
  14491. var _this = this;
  14492. if (this._iteration === value) {
  14493. return;
  14494. }
  14495. this._iteration = value;
  14496. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14497. _this._arrangeChildren();
  14498. });
  14499. },
  14500. enumerable: true,
  14501. configurable: true
  14502. });
  14503. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  14504. var mesh = control.mesh;
  14505. var newPos = this._scatterMapping(nodePosition);
  14506. if (!mesh) {
  14507. return;
  14508. }
  14509. switch (this.orientation) {
  14510. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14511. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14512. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  14513. break;
  14514. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14515. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14516. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  14517. break;
  14518. }
  14519. control.position = newPos;
  14520. };
  14521. ScatterPanel.prototype._scatterMapping = function (source) {
  14522. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  14523. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  14524. return source;
  14525. };
  14526. ScatterPanel.prototype._finalProcessing = function () {
  14527. var meshes = [];
  14528. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14529. var child = _a[_i];
  14530. if (!child.mesh) {
  14531. continue;
  14532. }
  14533. meshes.push(child.mesh);
  14534. }
  14535. for (var count = 0; count < this._iteration; count++) {
  14536. meshes.sort(function (a, b) {
  14537. var distance1 = a.position.lengthSquared();
  14538. var distance2 = b.position.lengthSquared();
  14539. if (distance1 < distance2) {
  14540. return 1;
  14541. }
  14542. else if (distance1 > distance2) {
  14543. return -1;
  14544. }
  14545. return 0;
  14546. });
  14547. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  14548. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  14549. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  14550. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14551. for (var i = 0; i < meshes.length - 1; i++) {
  14552. for (var j = i + 1; j < meshes.length; j++) {
  14553. if (i != j) {
  14554. meshes[j].position.subtractToRef(meshes[i].position, difference);
  14555. // Ignore Z axis
  14556. difference2D.x = difference.x;
  14557. difference2D.y = difference.y;
  14558. var combinedRadius = cellSize;
  14559. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  14560. var minSeparation = Math.min(distance, radiusPaddingSquared);
  14561. distance -= minSeparation;
  14562. if (distance < (Math.pow(combinedRadius, 2.0))) {
  14563. difference2D.normalize();
  14564. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  14565. meshes[j].position.addInPlace(difference);
  14566. meshes[i].position.subtractInPlace(difference);
  14567. }
  14568. }
  14569. }
  14570. }
  14571. }
  14572. };
  14573. return ScatterPanel;
  14574. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14575. /***/ }),
  14576. /***/ "./3D/controls/spherePanel.ts":
  14577. /*!************************************!*\
  14578. !*** ./3D/controls/spherePanel.ts ***!
  14579. \************************************/
  14580. /*! exports provided: SpherePanel */
  14581. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14582. "use strict";
  14583. __webpack_require__.r(__webpack_exports__);
  14584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  14585. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14586. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  14587. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14588. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14589. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14590. /**
  14591. * Class used to create a container panel deployed on the surface of a sphere
  14592. */
  14593. var SpherePanel = /** @class */ (function (_super) {
  14594. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  14595. function SpherePanel() {
  14596. var _this = _super !== null && _super.apply(this, arguments) || this;
  14597. _this._radius = 5.0;
  14598. return _this;
  14599. }
  14600. Object.defineProperty(SpherePanel.prototype, "radius", {
  14601. /**
  14602. * Gets or sets the radius of the sphere where to project controls (5 by default)
  14603. */
  14604. get: function () {
  14605. return this._radius;
  14606. },
  14607. set: function (value) {
  14608. var _this = this;
  14609. if (this._radius === value) {
  14610. return;
  14611. }
  14612. this._radius = value;
  14613. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14614. _this._arrangeChildren();
  14615. });
  14616. },
  14617. enumerable: true,
  14618. configurable: true
  14619. });
  14620. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  14621. var mesh = control.mesh;
  14622. if (!mesh) {
  14623. return;
  14624. }
  14625. var newPos = this._sphericalMapping(nodePosition);
  14626. control.position = newPos;
  14627. switch (this.orientation) {
  14628. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14629. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  14630. break;
  14631. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14632. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  14633. break;
  14634. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14635. break;
  14636. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14637. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14638. break;
  14639. }
  14640. };
  14641. SpherePanel.prototype._sphericalMapping = function (source) {
  14642. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  14643. var xAngle = (source.y / this._radius);
  14644. var yAngle = -(source.x / this._radius);
  14645. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14646. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14647. };
  14648. return SpherePanel;
  14649. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14650. /***/ }),
  14651. /***/ "./3D/controls/stackPanel3D.ts":
  14652. /*!*************************************!*\
  14653. !*** ./3D/controls/stackPanel3D.ts ***!
  14654. \*************************************/
  14655. /*! exports provided: StackPanel3D */
  14656. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14657. "use strict";
  14658. __webpack_require__.r(__webpack_exports__);
  14659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  14660. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14661. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  14662. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14663. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14664. /**
  14665. * Class used to create a stack panel in 3D on XY plane
  14666. */
  14667. var StackPanel3D = /** @class */ (function (_super) {
  14668. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  14669. /**
  14670. * Creates new StackPanel
  14671. * @param isVertical
  14672. */
  14673. function StackPanel3D(isVertical) {
  14674. if (isVertical === void 0) { isVertical = false; }
  14675. var _this = _super.call(this) || this;
  14676. _this._isVertical = false;
  14677. /**
  14678. * Gets or sets the distance between elements
  14679. */
  14680. _this.margin = 0.1;
  14681. _this._isVertical = isVertical;
  14682. return _this;
  14683. }
  14684. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  14685. /**
  14686. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  14687. */
  14688. get: function () {
  14689. return this._isVertical;
  14690. },
  14691. set: function (value) {
  14692. var _this = this;
  14693. if (this._isVertical === value) {
  14694. return;
  14695. }
  14696. this._isVertical = value;
  14697. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14698. _this._arrangeChildren();
  14699. });
  14700. },
  14701. enumerable: true,
  14702. configurable: true
  14703. });
  14704. StackPanel3D.prototype._arrangeChildren = function () {
  14705. var width = 0;
  14706. var height = 0;
  14707. var controlCount = 0;
  14708. var extendSizes = [];
  14709. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14710. // Measure
  14711. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14712. var child = _a[_i];
  14713. if (!child.mesh) {
  14714. continue;
  14715. }
  14716. controlCount++;
  14717. child.mesh.computeWorldMatrix(true);
  14718. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14719. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  14720. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14721. extendSizes.push(extendSize);
  14722. if (this._isVertical) {
  14723. height += extendSize.y;
  14724. }
  14725. else {
  14726. width += extendSize.x;
  14727. }
  14728. }
  14729. if (this._isVertical) {
  14730. height += (controlCount - 1) * this.margin / 2;
  14731. }
  14732. else {
  14733. width += (controlCount - 1) * this.margin / 2;
  14734. }
  14735. // Arrange
  14736. var offset;
  14737. if (this._isVertical) {
  14738. offset = -height;
  14739. }
  14740. else {
  14741. offset = -width;
  14742. }
  14743. var index = 0;
  14744. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14745. var child = _c[_b];
  14746. if (!child.mesh) {
  14747. continue;
  14748. }
  14749. controlCount--;
  14750. var extendSize = extendSizes[index++];
  14751. if (this._isVertical) {
  14752. child.position.y = offset + extendSize.y;
  14753. child.position.x = 0;
  14754. offset += extendSize.y * 2;
  14755. }
  14756. else {
  14757. child.position.x = offset + extendSize.x;
  14758. child.position.y = 0;
  14759. offset += extendSize.x * 2;
  14760. }
  14761. offset += (controlCount > 0 ? this.margin : 0);
  14762. }
  14763. };
  14764. return StackPanel3D;
  14765. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14766. /***/ }),
  14767. /***/ "./3D/controls/volumeBasedPanel.ts":
  14768. /*!*****************************************!*\
  14769. !*** ./3D/controls/volumeBasedPanel.ts ***!
  14770. \*****************************************/
  14771. /*! exports provided: VolumeBasedPanel */
  14772. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14773. "use strict";
  14774. __webpack_require__.r(__webpack_exports__);
  14775. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  14776. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14777. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  14778. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14779. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14780. /**
  14781. * Abstract class used to create a container panel deployed on the surface of a volume
  14782. */
  14783. var VolumeBasedPanel = /** @class */ (function (_super) {
  14784. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  14785. /**
  14786. * Creates new VolumeBasedPanel
  14787. */
  14788. function VolumeBasedPanel() {
  14789. var _this = _super.call(this) || this;
  14790. _this._columns = 10;
  14791. _this._rows = 0;
  14792. _this._rowThenColum = true;
  14793. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  14794. /**
  14795. * Gets or sets the distance between elements
  14796. */
  14797. _this.margin = 0;
  14798. return _this;
  14799. }
  14800. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  14801. /**
  14802. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  14803. * | Value | Type | Description |
  14804. * | ----- | ----------------------------------- | ----------- |
  14805. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  14806. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  14807. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  14808. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  14809. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  14810. */
  14811. get: function () {
  14812. return this._orientation;
  14813. },
  14814. set: function (value) {
  14815. var _this = this;
  14816. if (this._orientation === value) {
  14817. return;
  14818. }
  14819. this._orientation = value;
  14820. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14821. _this._arrangeChildren();
  14822. });
  14823. },
  14824. enumerable: true,
  14825. configurable: true
  14826. });
  14827. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  14828. /**
  14829. * Gets or sets the number of columns requested (10 by default).
  14830. * The panel will automatically compute the number of rows based on number of child controls.
  14831. */
  14832. get: function () {
  14833. return this._columns;
  14834. },
  14835. set: function (value) {
  14836. var _this = this;
  14837. if (this._columns === value) {
  14838. return;
  14839. }
  14840. this._columns = value;
  14841. this._rowThenColum = true;
  14842. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14843. _this._arrangeChildren();
  14844. });
  14845. },
  14846. enumerable: true,
  14847. configurable: true
  14848. });
  14849. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  14850. /**
  14851. * Gets or sets a the number of rows requested.
  14852. * The panel will automatically compute the number of columns based on number of child controls.
  14853. */
  14854. get: function () {
  14855. return this._rows;
  14856. },
  14857. set: function (value) {
  14858. var _this = this;
  14859. if (this._rows === value) {
  14860. return;
  14861. }
  14862. this._rows = value;
  14863. this._rowThenColum = false;
  14864. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14865. _this._arrangeChildren();
  14866. });
  14867. },
  14868. enumerable: true,
  14869. configurable: true
  14870. });
  14871. VolumeBasedPanel.prototype._arrangeChildren = function () {
  14872. this._cellWidth = 0;
  14873. this._cellHeight = 0;
  14874. var rows = 0;
  14875. var columns = 0;
  14876. var controlCount = 0;
  14877. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14878. // Measure
  14879. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14880. var child = _a[_i];
  14881. if (!child.mesh) {
  14882. continue;
  14883. }
  14884. controlCount++;
  14885. child.mesh.computeWorldMatrix(true);
  14886. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  14887. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  14888. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14889. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  14890. boundingBox.max.subtractToRef(boundingBox.min, diff);
  14891. diff.scaleInPlace(0.5);
  14892. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  14893. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  14894. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  14895. }
  14896. this._cellWidth += this.margin * 2;
  14897. this._cellHeight += this.margin * 2;
  14898. // Arrange
  14899. if (this._rowThenColum) {
  14900. columns = this._columns;
  14901. rows = Math.ceil(controlCount / this._columns);
  14902. }
  14903. else {
  14904. rows = this._rows;
  14905. columns = Math.ceil(controlCount / this._rows);
  14906. }
  14907. var startOffsetX = (columns * 0.5) * this._cellWidth;
  14908. var startOffsetY = (rows * 0.5) * this._cellHeight;
  14909. var nodeGrid = [];
  14910. var cellCounter = 0;
  14911. if (this._rowThenColum) {
  14912. for (var r = 0; r < rows; r++) {
  14913. for (var c = 0; c < columns; c++) {
  14914. nodeGrid.push(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"]((c * this._cellWidth) - startOffsetX + this._cellWidth / 2, (r * this._cellHeight) - startOffsetY + this._cellHeight / 2, 0));
  14915. cellCounter++;
  14916. if (cellCounter > controlCount) {
  14917. break;
  14918. }
  14919. }
  14920. }
  14921. }
  14922. else {
  14923. for (var c = 0; c < columns; c++) {
  14924. for (var r = 0; r < rows; r++) {
  14925. nodeGrid.push(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"]((c * this._cellWidth) - startOffsetX + this._cellWidth / 2, (r * this._cellHeight) - startOffsetY + this._cellHeight / 2, 0));
  14926. cellCounter++;
  14927. if (cellCounter > controlCount) {
  14928. break;
  14929. }
  14930. }
  14931. }
  14932. }
  14933. cellCounter = 0;
  14934. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14935. var child = _c[_b];
  14936. if (!child.mesh) {
  14937. continue;
  14938. }
  14939. this._mapGridNode(child, nodeGrid[cellCounter]);
  14940. cellCounter++;
  14941. }
  14942. this._finalProcessing();
  14943. };
  14944. /** Child classes can implement this function to provide additional processing */
  14945. VolumeBasedPanel.prototype._finalProcessing = function () {
  14946. };
  14947. return VolumeBasedPanel;
  14948. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14949. /***/ }),
  14950. /***/ "./3D/gui3DManager.ts":
  14951. /*!****************************!*\
  14952. !*** ./3D/gui3DManager.ts ***!
  14953. \****************************/
  14954. /*! exports provided: GUI3DManager */
  14955. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14956. "use strict";
  14957. __webpack_require__.r(__webpack_exports__);
  14958. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14959. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  14960. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14961. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14962. /**
  14963. * Class used to manage 3D user interface
  14964. * @see http://doc.babylonjs.com/how_to/gui3d
  14965. */
  14966. var GUI3DManager = /** @class */ (function () {
  14967. /**
  14968. * Creates a new GUI3DManager
  14969. * @param scene
  14970. */
  14971. function GUI3DManager(scene) {
  14972. var _this = this;
  14973. /** @hidden */
  14974. this._lastControlOver = {};
  14975. /** @hidden */
  14976. this._lastControlDown = {};
  14977. /**
  14978. * Observable raised when the point picked by the pointer events changed
  14979. */
  14980. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14981. // Shared resources
  14982. /** @hidden */
  14983. this._sharedMaterials = {};
  14984. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14985. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14986. _this._sceneDisposeObserver = null;
  14987. _this._utilityLayer = null;
  14988. _this.dispose();
  14989. });
  14990. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14991. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14992. this._utilityLayer.pickUtilitySceneFirst = false;
  14993. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14994. return mesh && mesh.metadata && mesh.metadata._node;
  14995. };
  14996. // Root
  14997. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14998. this._rootContainer._host = this;
  14999. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  15000. // Events
  15001. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  15002. _this._handlePointerOut(pointerId, true);
  15003. });
  15004. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  15005. _this._doPicking(pi);
  15006. });
  15007. // Scene
  15008. this._utilityLayer.utilityLayerScene.autoClear = false;
  15009. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  15010. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  15011. }
  15012. Object.defineProperty(GUI3DManager.prototype, "scene", {
  15013. /** Gets the hosting scene */
  15014. get: function () {
  15015. return this._scene;
  15016. },
  15017. enumerable: true,
  15018. configurable: true
  15019. });
  15020. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  15021. /** Gets associated utility layer */
  15022. get: function () {
  15023. return this._utilityLayer;
  15024. },
  15025. enumerable: true,
  15026. configurable: true
  15027. });
  15028. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  15029. var previousControlOver = this._lastControlOver[pointerId];
  15030. if (previousControlOver) {
  15031. previousControlOver._onPointerOut(previousControlOver);
  15032. delete this._lastControlOver[pointerId];
  15033. }
  15034. if (isPointerUp) {
  15035. if (this._lastControlDown[pointerId]) {
  15036. this._lastControlDown[pointerId].forcePointerUp();
  15037. delete this._lastControlDown[pointerId];
  15038. }
  15039. }
  15040. this.onPickedPointChangedObservable.notifyObservers(null);
  15041. };
  15042. GUI3DManager.prototype._doPicking = function (pi) {
  15043. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  15044. return false;
  15045. }
  15046. var pointerEvent = (pi.event);
  15047. var pointerId = pointerEvent.pointerId || 0;
  15048. var buttonIndex = pointerEvent.button;
  15049. var pickingInfo = pi.pickInfo;
  15050. if (!pickingInfo || !pickingInfo.hit) {
  15051. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  15052. return false;
  15053. }
  15054. var control = (pickingInfo.pickedMesh.metadata);
  15055. if (pickingInfo.pickedPoint) {
  15056. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  15057. }
  15058. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  15059. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15060. if (this._lastControlOver[pointerId]) {
  15061. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  15062. }
  15063. delete this._lastControlOver[pointerId];
  15064. }
  15065. }
  15066. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  15067. if (this._lastControlDown[pointerEvent.pointerId]) {
  15068. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  15069. delete this._lastControlDown[pointerEvent.pointerId];
  15070. }
  15071. if (pointerEvent.pointerType === "touch") {
  15072. this._handlePointerOut(pointerId, false);
  15073. }
  15074. }
  15075. return true;
  15076. };
  15077. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  15078. /**
  15079. * Gets the root container
  15080. */
  15081. get: function () {
  15082. return this._rootContainer;
  15083. },
  15084. enumerable: true,
  15085. configurable: true
  15086. });
  15087. /**
  15088. * Gets a boolean indicating if the given control is in the root child list
  15089. * @param control defines the control to check
  15090. * @returns true if the control is in the root child list
  15091. */
  15092. GUI3DManager.prototype.containsControl = function (control) {
  15093. return this._rootContainer.containsControl(control);
  15094. };
  15095. /**
  15096. * Adds a control to the root child list
  15097. * @param control defines the control to add
  15098. * @returns the current manager
  15099. */
  15100. GUI3DManager.prototype.addControl = function (control) {
  15101. this._rootContainer.addControl(control);
  15102. return this;
  15103. };
  15104. /**
  15105. * Removes a control from the root child list
  15106. * @param control defines the control to remove
  15107. * @returns the current container
  15108. */
  15109. GUI3DManager.prototype.removeControl = function (control) {
  15110. this._rootContainer.removeControl(control);
  15111. return this;
  15112. };
  15113. /**
  15114. * Releases all associated resources
  15115. */
  15116. GUI3DManager.prototype.dispose = function () {
  15117. this._rootContainer.dispose();
  15118. for (var materialName in this._sharedMaterials) {
  15119. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  15120. continue;
  15121. }
  15122. this._sharedMaterials[materialName].dispose();
  15123. }
  15124. this._sharedMaterials = {};
  15125. if (this._pointerOutObserver && this._utilityLayer) {
  15126. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  15127. this._pointerOutObserver = null;
  15128. }
  15129. this.onPickedPointChangedObservable.clear();
  15130. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  15131. if (utilityLayerScene) {
  15132. if (this._pointerObserver) {
  15133. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  15134. this._pointerObserver = null;
  15135. }
  15136. }
  15137. if (this._scene) {
  15138. if (this._sceneDisposeObserver) {
  15139. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  15140. this._sceneDisposeObserver = null;
  15141. }
  15142. }
  15143. if (this._utilityLayer) {
  15144. this._utilityLayer.dispose();
  15145. }
  15146. };
  15147. return GUI3DManager;
  15148. }());
  15149. /***/ }),
  15150. /***/ "./3D/index.ts":
  15151. /*!*********************!*\
  15152. !*** ./3D/index.ts ***!
  15153. \*********************/
  15154. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15155. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15156. "use strict";
  15157. __webpack_require__.r(__webpack_exports__);
  15158. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  15159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15171. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  15172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15174. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  15175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  15176. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  15177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  15178. /***/ }),
  15179. /***/ "./3D/materials/fluentMaterial.ts":
  15180. /*!****************************************!*\
  15181. !*** ./3D/materials/fluentMaterial.ts ***!
  15182. \****************************************/
  15183. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  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__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  15188. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  15189. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15190. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  15191. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  15192. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  15193. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  15194. /** @hidden */
  15195. var FluentMaterialDefines = /** @class */ (function (_super) {
  15196. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  15197. function FluentMaterialDefines() {
  15198. var _this = _super.call(this) || this;
  15199. _this.INNERGLOW = false;
  15200. _this.BORDER = false;
  15201. _this.HOVERLIGHT = false;
  15202. _this.TEXTURE = false;
  15203. _this.rebuild();
  15204. return _this;
  15205. }
  15206. return FluentMaterialDefines;
  15207. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  15208. /**
  15209. * Class used to render controls with fluent desgin
  15210. */
  15211. var FluentMaterial = /** @class */ (function (_super) {
  15212. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  15213. /**
  15214. * Creates a new Fluent material
  15215. * @param name defines the name of the material
  15216. * @param scene defines the hosting scene
  15217. */
  15218. function FluentMaterial(name, scene) {
  15219. var _this = _super.call(this, name, scene) || this;
  15220. /**
  15221. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  15222. */
  15223. _this.innerGlowColorIntensity = 0.5;
  15224. /**
  15225. * Gets or sets the inner glow color (white by default)
  15226. */
  15227. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  15228. /**
  15229. * Gets or sets alpha value (default is 1.0)
  15230. */
  15231. _this.alpha = 1.0;
  15232. /**
  15233. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  15234. */
  15235. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  15236. /**
  15237. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  15238. */
  15239. _this.renderBorders = false;
  15240. /**
  15241. * Gets or sets border width (default is 0.5)
  15242. */
  15243. _this.borderWidth = 0.5;
  15244. /**
  15245. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  15246. */
  15247. _this.edgeSmoothingValue = 0.02;
  15248. /**
  15249. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  15250. */
  15251. _this.borderMinValue = 0.1;
  15252. /**
  15253. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  15254. */
  15255. _this.renderHoverLight = false;
  15256. /**
  15257. * Gets or sets the radius used to render the hover light (default is 1.0)
  15258. */
  15259. _this.hoverRadius = 1.0;
  15260. /**
  15261. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  15262. */
  15263. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  15264. /**
  15265. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  15266. */
  15267. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  15268. return _this;
  15269. }
  15270. FluentMaterial.prototype.needAlphaBlending = function () {
  15271. return this.alpha !== 1.0;
  15272. };
  15273. FluentMaterial.prototype.needAlphaTesting = function () {
  15274. return false;
  15275. };
  15276. FluentMaterial.prototype.getAlphaTestTexture = function () {
  15277. return null;
  15278. };
  15279. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  15280. if (this.isFrozen) {
  15281. if (this._wasPreviouslyReady && subMesh.effect) {
  15282. return true;
  15283. }
  15284. }
  15285. if (!subMesh._materialDefines) {
  15286. subMesh._materialDefines = new FluentMaterialDefines();
  15287. }
  15288. var scene = this.getScene();
  15289. var defines = subMesh._materialDefines;
  15290. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  15291. if (defines._renderId === scene.getRenderId()) {
  15292. return true;
  15293. }
  15294. }
  15295. if (defines._areTexturesDirty) {
  15296. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  15297. defines.BORDER = this.renderBorders;
  15298. defines.HOVERLIGHT = this.renderHoverLight;
  15299. if (this._albedoTexture) {
  15300. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  15301. return false;
  15302. }
  15303. else {
  15304. defines.TEXTURE = true;
  15305. }
  15306. }
  15307. else {
  15308. defines.TEXTURE = false;
  15309. }
  15310. }
  15311. var engine = scene.getEngine();
  15312. // Get correct effect
  15313. if (defines.isDirty) {
  15314. defines.markAsProcessed();
  15315. scene.resetCachedMaterial();
  15316. //Attributes
  15317. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  15318. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  15319. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  15320. var shaderName = "fluent";
  15321. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  15322. "hoverColor", "hoverPosition", "hoverRadius"
  15323. ];
  15324. var samplers = ["albedoSampler"];
  15325. var uniformBuffers = new Array();
  15326. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  15327. uniformsNames: uniforms,
  15328. uniformBuffersNames: uniformBuffers,
  15329. samplers: samplers,
  15330. defines: defines,
  15331. maxSimultaneousLights: 4
  15332. });
  15333. var join = defines.toString();
  15334. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  15335. attributes: attribs,
  15336. uniformsNames: uniforms,
  15337. uniformBuffersNames: uniformBuffers,
  15338. samplers: samplers,
  15339. defines: join,
  15340. fallbacks: null,
  15341. onCompiled: this.onCompiled,
  15342. onError: this.onError,
  15343. indexParameters: { maxSimultaneousLights: 4 }
  15344. }, engine));
  15345. }
  15346. if (!subMesh.effect || !subMesh.effect.isReady()) {
  15347. return false;
  15348. }
  15349. defines._renderId = scene.getRenderId();
  15350. this._wasPreviouslyReady = true;
  15351. return true;
  15352. };
  15353. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  15354. var scene = this.getScene();
  15355. var defines = subMesh._materialDefines;
  15356. if (!defines) {
  15357. return;
  15358. }
  15359. var effect = subMesh.effect;
  15360. if (!effect) {
  15361. return;
  15362. }
  15363. this._activeEffect = effect;
  15364. // Matrices
  15365. this.bindOnlyWorldMatrix(world);
  15366. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  15367. if (this._mustRebind(scene, effect)) {
  15368. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  15369. if (defines.INNERGLOW) {
  15370. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  15371. }
  15372. if (defines.BORDER) {
  15373. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  15374. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  15375. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  15376. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15377. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15378. }
  15379. if (defines.HOVERLIGHT) {
  15380. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  15381. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  15382. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  15383. }
  15384. if (defines.TEXTURE) {
  15385. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  15386. }
  15387. }
  15388. this._afterBind(mesh, this._activeEffect);
  15389. };
  15390. FluentMaterial.prototype.getActiveTextures = function () {
  15391. var activeTextures = _super.prototype.getActiveTextures.call(this);
  15392. return activeTextures;
  15393. };
  15394. FluentMaterial.prototype.hasTexture = function (texture) {
  15395. if (_super.prototype.hasTexture.call(this, texture)) {
  15396. return true;
  15397. }
  15398. return false;
  15399. };
  15400. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  15401. _super.prototype.dispose.call(this, forceDisposeEffect);
  15402. };
  15403. FluentMaterial.prototype.clone = function (name) {
  15404. var _this = this;
  15405. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  15406. };
  15407. FluentMaterial.prototype.serialize = function () {
  15408. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  15409. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  15410. return serializationObject;
  15411. };
  15412. FluentMaterial.prototype.getClassName = function () {
  15413. return "FluentMaterial";
  15414. };
  15415. // Statics
  15416. FluentMaterial.Parse = function (source, scene, rootUrl) {
  15417. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  15418. };
  15419. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15420. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15421. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15422. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  15423. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15424. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15425. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  15426. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15427. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15428. ], FluentMaterial.prototype, "alpha", void 0);
  15429. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15430. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15431. ], FluentMaterial.prototype, "albedoColor", void 0);
  15432. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15433. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15434. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15435. ], FluentMaterial.prototype, "renderBorders", void 0);
  15436. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15437. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15438. ], FluentMaterial.prototype, "borderWidth", void 0);
  15439. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15440. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15441. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  15442. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15443. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15444. ], FluentMaterial.prototype, "borderMinValue", void 0);
  15445. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15446. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15447. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15448. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  15449. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15450. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15451. ], FluentMaterial.prototype, "hoverRadius", void 0);
  15452. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15453. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  15454. ], FluentMaterial.prototype, "hoverColor", void 0);
  15455. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15456. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  15457. ], FluentMaterial.prototype, "hoverPosition", void 0);
  15458. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15459. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  15460. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  15461. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15462. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  15463. ], FluentMaterial.prototype, "albedoTexture", void 0);
  15464. return FluentMaterial;
  15465. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  15466. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  15467. /***/ }),
  15468. /***/ "./3D/materials/index.ts":
  15469. /*!*******************************!*\
  15470. !*** ./3D/materials/index.ts ***!
  15471. \*******************************/
  15472. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15474. "use strict";
  15475. __webpack_require__.r(__webpack_exports__);
  15476. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  15477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  15478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  15479. /***/ }),
  15480. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  15481. /*!*************************************************!*\
  15482. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  15483. \*************************************************/
  15484. /*! exports provided: fluentPixelShader */
  15485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15486. "use strict";
  15487. __webpack_require__.r(__webpack_exports__);
  15488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  15489. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  15490. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  15491. var name = 'fluentPixelShader';
  15492. var shader = "precision highp float;\nvarying vec2 vUV;\nuniform vec4 albedoColor;\n#ifdef INNERGLOW\nuniform vec4 innerGlowColor;\n#endif\n#ifdef BORDER\nvarying vec2 scaleInfo;\nuniform float edgeSmoothingValue;\nuniform float borderMinValue;\n#endif\n#ifdef HOVERLIGHT\nvarying vec3 worldPosition;\nuniform vec3 hoverPosition;\nuniform vec4 hoverColor;\nuniform float hoverRadius;\n#endif\n#ifdef TEXTURE\nuniform sampler2D albedoSampler;\n#endif\nvoid main(void) {\nvec3 albedo=albedoColor.rgb;\nfloat alpha=albedoColor.a;\n#ifdef TEXTURE\nalbedo=texture2D(albedoSampler,vUV).rgb;\n#endif\n#ifdef HOVERLIGHT\nfloat pointToHover=(1.0-clamp(length(hoverPosition-worldPosition)/hoverRadius,0.,1.))*hoverColor.a;\nalbedo=clamp(albedo+hoverColor.rgb*pointToHover,0.,1.);\n#else\nfloat pointToHover=1.0;\n#endif\n#ifdef BORDER\nfloat borderPower=10.0;\nfloat inverseBorderPower=1.0/borderPower;\nvec3 borderColor=albedo*borderPower;\nvec2 distanceToEdge;\ndistanceToEdge.x=abs(vUV.x-0.5)*2.0;\ndistanceToEdge.y=abs(vUV.y-0.5)*2.0;\nfloat borderValue=max(smoothstep(scaleInfo.x-edgeSmoothingValue,scaleInfo.x+edgeSmoothingValue,distanceToEdge.x),\nsmoothstep(scaleInfo.y-edgeSmoothingValue,scaleInfo.y+edgeSmoothingValue,distanceToEdge.y));\nborderColor=borderColor*borderValue*max(borderMinValue*inverseBorderPower,pointToHover);\nalbedo+=borderColor;\nalpha=max(alpha,borderValue);\n#endif\n#ifdef INNERGLOW\n\nvec2 uvGlow=(vUV-vec2(0.5,0.5))*(innerGlowColor.a*2.0);\nuvGlow=uvGlow*uvGlow;\nuvGlow=uvGlow*uvGlow;\nalbedo+=mix(vec3(0.0,0.0,0.0),innerGlowColor.rgb,uvGlow.x+uvGlow.y);\n#endif\ngl_FragColor=vec4(albedo,alpha);\n}";
  15493. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  15494. /** @hidden */
  15495. var fluentPixelShader = { name: name, shader: shader };
  15496. /***/ }),
  15497. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  15498. /*!***********************************************!*\
  15499. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  15500. \***********************************************/
  15501. /*! exports provided: fluentVertexShader */
  15502. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15503. "use strict";
  15504. __webpack_require__.r(__webpack_exports__);
  15505. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  15506. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  15507. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  15508. var name = 'fluentVertexShader';
  15509. var shader = "precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n\nuniform mat4 world;\nuniform mat4 viewProjection;\nvarying vec2 vUV;\n#ifdef BORDER\nvarying vec2 scaleInfo;\nuniform float borderWidth;\nuniform vec3 scaleFactor;\n#endif\n#ifdef HOVERLIGHT\nvarying vec3 worldPosition;\n#endif\nvoid main(void) {\nvUV=uv;\n#ifdef BORDER\nvec3 scale=scaleFactor;\nfloat minScale=min(min(scale.x,scale.y),scale.z);\nfloat maxScale=max(max(scale.x,scale.y),scale.z);\nfloat minOverMiddleScale=minScale/(scale.x+scale.y+scale.z-minScale-maxScale);\nfloat areaYZ=scale.y*scale.z;\nfloat areaXZ=scale.x*scale.z;\nfloat areaXY=scale.x*scale.y;\nfloat scaledBorderWidth=borderWidth;\nif (abs(normal.x) == 1.0)\n{\nscale.x=scale.y;\nscale.y=scale.z;\nif (areaYZ>areaXZ && areaYZ>areaXY)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nelse if (abs(normal.y) == 1.0)\n{\nscale.x=scale.z;\nif (areaXZ>areaXY && areaXZ>areaYZ)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nelse\n{\nif (areaXY>areaYZ && areaXY>areaXZ)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nfloat scaleRatio=min(scale.x,scale.y)/max(scale.x,scale.y);\nif (scale.x>scale.y)\n{\nscaleInfo.x=1.0-(scaledBorderWidth*scaleRatio);\nscaleInfo.y=1.0-scaledBorderWidth;\n}\nelse\n{\nscaleInfo.x=1.0-scaledBorderWidth;\nscaleInfo.y=1.0-(scaledBorderWidth*scaleRatio);\n}\n#endif\nvec4 worldPos=world*vec4(position,1.0);\n#ifdef HOVERLIGHT\nworldPosition=worldPos.xyz;\n#endif\ngl_Position=viewProjection*worldPos;\n}\n";
  15510. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  15511. /** @hidden */
  15512. var fluentVertexShader = { name: name, shader: shader };
  15513. /***/ }),
  15514. /***/ "./3D/vector3WithInfo.ts":
  15515. /*!*******************************!*\
  15516. !*** ./3D/vector3WithInfo.ts ***!
  15517. \*******************************/
  15518. /*! exports provided: Vector3WithInfo */
  15519. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15520. "use strict";
  15521. __webpack_require__.r(__webpack_exports__);
  15522. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  15523. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15524. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  15525. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  15526. /**
  15527. * Class used to transport Vector3 information for pointer events
  15528. */
  15529. var Vector3WithInfo = /** @class */ (function (_super) {
  15530. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  15531. /**
  15532. * Creates a new Vector3WithInfo
  15533. * @param source defines the vector3 data to transport
  15534. * @param buttonIndex defines the current mouse button index
  15535. */
  15536. function Vector3WithInfo(source,
  15537. /** defines the current mouse button index */
  15538. buttonIndex) {
  15539. if (buttonIndex === void 0) { buttonIndex = 0; }
  15540. var _this = _super.call(this, source.x, source.y, source.z) || this;
  15541. _this.buttonIndex = buttonIndex;
  15542. return _this;
  15543. }
  15544. return Vector3WithInfo;
  15545. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  15546. /***/ }),
  15547. /***/ "./index.ts":
  15548. /*!******************!*\
  15549. !*** ./index.ts ***!
  15550. \******************/
  15551. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15552. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15553. "use strict";
  15554. __webpack_require__.r(__webpack_exports__);
  15555. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  15556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  15557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  15558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  15559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  15560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  15561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  15562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  15563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  15564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  15565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  15566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  15567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  15568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  15569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  15570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  15571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  15572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  15573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  15574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  15575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  15576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  15577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  15578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  15579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  15580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  15581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  15582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  15583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  15584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  15585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  15586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  15587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  15588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  15589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  15590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  15591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  15592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  15593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  15594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  15595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  15596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  15597. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  15598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  15599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  15600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  15601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  15602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  15603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  15604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  15605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  15606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  15607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  15608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  15609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  15610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  15611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  15612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15614. /***/ }),
  15615. /***/ "./legacy/legacy.ts":
  15616. /*!**************************!*\
  15617. !*** ./legacy/legacy.ts ***!
  15618. \**************************/
  15619. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15621. "use strict";
  15622. __webpack_require__.r(__webpack_exports__);
  15623. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  15624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  15625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  15626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  15627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  15628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  15629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  15630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  15631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  15632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  15633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  15634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  15635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  15636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  15637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  15638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  15639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  15640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  15641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  15642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  15643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  15644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  15645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  15646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  15647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  15648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  15649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  15650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  15651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  15652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  15653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  15654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  15655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  15656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  15657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  15658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  15659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  15660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  15661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  15662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  15663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  15664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  15665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  15666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  15667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  15680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  15681. /**
  15682. * Legacy support, defining window.BABYLON.GUI (global variable).
  15683. *
  15684. * This is the entry point for the UMD module.
  15685. * The entry point for a future ESM package should be index.ts
  15686. */
  15687. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  15688. if (typeof globalObject !== "undefined") {
  15689. globalObject.BABYLON = globalObject.BABYLON || {};
  15690. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  15691. }
  15692. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  15693. /***/ }),
  15694. /***/ "babylonjs/Misc/perfCounter":
  15695. /*!****************************************************************************************************!*\
  15696. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  15697. \****************************************************************************************************/
  15698. /*! no static exports found */
  15699. /***/ (function(module, exports) {
  15700. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__;
  15701. /***/ })
  15702. /******/ });
  15703. });
  15704. //# sourceMappingURL=babylon.gui.js.map