babylon.gui.js 823 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681
  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, __createBinding, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault, __classPrivateFieldGet, __classPrivateFieldSet */
  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__, "__createBinding", function() { return __createBinding; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldGet", function() { return __classPrivateFieldGet; });
  128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldSet", function() { return __classPrivateFieldSet; });
  129. /*! *****************************************************************************
  130. Copyright (c) Microsoft Corporation.
  131. Permission to use, copy, modify, and/or distribute this software for any
  132. purpose with or without fee is hereby granted.
  133. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  134. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  135. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  136. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  137. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  138. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  139. PERFORMANCE OF THIS SOFTWARE.
  140. ***************************************************************************** */
  141. /* global Reflect, Promise */
  142. var extendStatics = function(d, b) {
  143. extendStatics = Object.setPrototypeOf ||
  144. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  145. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  146. return extendStatics(d, b);
  147. };
  148. function __extends(d, b) {
  149. extendStatics(d, b);
  150. function __() { this.constructor = d; }
  151. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  152. }
  153. var __assign = function() {
  154. __assign = Object.assign || function __assign(t) {
  155. for (var s, i = 1, n = arguments.length; i < n; i++) {
  156. s = arguments[i];
  157. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  158. }
  159. return t;
  160. }
  161. return __assign.apply(this, arguments);
  162. }
  163. function __rest(s, e) {
  164. var t = {};
  165. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  166. t[p] = s[p];
  167. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  168. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  169. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  170. t[p[i]] = s[p[i]];
  171. }
  172. return t;
  173. }
  174. function __decorate(decorators, target, key, desc) {
  175. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  176. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  177. 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;
  178. return c > 3 && r && Object.defineProperty(target, key, r), r;
  179. }
  180. function __param(paramIndex, decorator) {
  181. return function (target, key) { decorator(target, key, paramIndex); }
  182. }
  183. function __metadata(metadataKey, metadataValue) {
  184. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  185. }
  186. function __awaiter(thisArg, _arguments, P, generator) {
  187. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  188. return new (P || (P = Promise))(function (resolve, reject) {
  189. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  190. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  191. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  192. step((generator = generator.apply(thisArg, _arguments || [])).next());
  193. });
  194. }
  195. function __generator(thisArg, body) {
  196. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  197. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  198. function verb(n) { return function (v) { return step([n, v]); }; }
  199. function step(op) {
  200. if (f) throw new TypeError("Generator is already executing.");
  201. while (_) try {
  202. 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;
  203. if (y = 0, t) op = [op[0] & 2, t.value];
  204. switch (op[0]) {
  205. case 0: case 1: t = op; break;
  206. case 4: _.label++; return { value: op[1], done: false };
  207. case 5: _.label++; y = op[1]; op = [0]; continue;
  208. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  209. default:
  210. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  211. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  212. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  213. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  214. if (t[2]) _.ops.pop();
  215. _.trys.pop(); continue;
  216. }
  217. op = body.call(thisArg, _);
  218. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  219. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  220. }
  221. }
  222. var __createBinding = Object.create ? (function(o, m, k, k2) {
  223. if (k2 === undefined) k2 = k;
  224. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  225. }) : (function(o, m, k, k2) {
  226. if (k2 === undefined) k2 = k;
  227. o[k2] = m[k];
  228. });
  229. function __exportStar(m, o) {
  230. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
  231. }
  232. function __values(o) {
  233. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  234. if (m) return m.call(o);
  235. if (o && typeof o.length === "number") return {
  236. next: function () {
  237. if (o && i >= o.length) o = void 0;
  238. return { value: o && o[i++], done: !o };
  239. }
  240. };
  241. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  242. }
  243. function __read(o, n) {
  244. var m = typeof Symbol === "function" && o[Symbol.iterator];
  245. if (!m) return o;
  246. var i = m.call(o), r, ar = [], e;
  247. try {
  248. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  249. }
  250. catch (error) { e = { error: error }; }
  251. finally {
  252. try {
  253. if (r && !r.done && (m = i["return"])) m.call(i);
  254. }
  255. finally { if (e) throw e.error; }
  256. }
  257. return ar;
  258. }
  259. function __spread() {
  260. for (var ar = [], i = 0; i < arguments.length; i++)
  261. ar = ar.concat(__read(arguments[i]));
  262. return ar;
  263. }
  264. function __spreadArrays() {
  265. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  266. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  267. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  268. r[k] = a[j];
  269. return r;
  270. };
  271. function __await(v) {
  272. return this instanceof __await ? (this.v = v, this) : new __await(v);
  273. }
  274. function __asyncGenerator(thisArg, _arguments, generator) {
  275. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  276. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  277. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  278. 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); }); }; }
  279. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  280. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  281. function fulfill(value) { resume("next", value); }
  282. function reject(value) { resume("throw", value); }
  283. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  284. }
  285. function __asyncDelegator(o) {
  286. var i, p;
  287. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  288. 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; }
  289. }
  290. function __asyncValues(o) {
  291. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  292. var m = o[Symbol.asyncIterator], i;
  293. 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);
  294. 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); }); }; }
  295. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  296. }
  297. function __makeTemplateObject(cooked, raw) {
  298. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  299. return cooked;
  300. };
  301. var __setModuleDefault = Object.create ? (function(o, v) {
  302. Object.defineProperty(o, "default", { enumerable: true, value: v });
  303. }) : function(o, v) {
  304. o["default"] = v;
  305. };
  306. function __importStar(mod) {
  307. if (mod && mod.__esModule) return mod;
  308. var result = {};
  309. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  310. __setModuleDefault(result, mod);
  311. return result;
  312. }
  313. function __importDefault(mod) {
  314. return (mod && mod.__esModule) ? mod : { default: mod };
  315. }
  316. function __classPrivateFieldGet(receiver, privateMap) {
  317. if (!privateMap.has(receiver)) {
  318. throw new TypeError("attempted to get private field on non-instance");
  319. }
  320. return privateMap.get(receiver);
  321. }
  322. function __classPrivateFieldSet(receiver, privateMap, value) {
  323. if (!privateMap.has(receiver)) {
  324. throw new TypeError("attempted to set private field on non-instance");
  325. }
  326. privateMap.set(receiver, value);
  327. return value;
  328. }
  329. /***/ }),
  330. /***/ "../../node_modules/webpack/buildin/global.js":
  331. /*!***********************************!*\
  332. !*** (webpack)/buildin/global.js ***!
  333. \***********************************/
  334. /*! no static exports found */
  335. /***/ (function(module, exports) {
  336. var g;
  337. // This works in non-strict mode
  338. g = (function() {
  339. return this;
  340. })();
  341. try {
  342. // This works if eval is allowed (see CSP)
  343. g = g || new Function("return this")();
  344. } catch (e) {
  345. // This works if the window reference is available
  346. if (typeof window === "object") g = window;
  347. }
  348. // g can still be undefined, but nothing to do about it...
  349. // We return undefined, instead of nothing here, so it's
  350. // easier to handle this case. if(!global) { ...}
  351. module.exports = g;
  352. /***/ }),
  353. /***/ "./2D/adtInstrumentation.ts":
  354. /*!**********************************!*\
  355. !*** ./2D/adtInstrumentation.ts ***!
  356. \**********************************/
  357. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  359. "use strict";
  360. __webpack_require__.r(__webpack_exports__);
  361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  362. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Misc/perfCounter");
  363. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  364. /**
  365. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  366. */
  367. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  368. /**
  369. * Instantiates a new advanced dynamic texture instrumentation.
  370. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  371. * @param texture Defines the AdvancedDynamicTexture to instrument
  372. */
  373. function AdvancedDynamicTextureInstrumentation(
  374. /**
  375. * Define the instrumented AdvancedDynamicTexture.
  376. */
  377. texture) {
  378. this.texture = texture;
  379. this._captureRenderTime = false;
  380. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  381. this._captureLayoutTime = false;
  382. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  383. // Observers
  384. this._onBeginRenderObserver = null;
  385. this._onEndRenderObserver = null;
  386. this._onBeginLayoutObserver = null;
  387. this._onEndLayoutObserver = null;
  388. }
  389. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  390. // Properties
  391. /**
  392. * Gets the perf counter used to capture render time
  393. */
  394. get: function () {
  395. return this._renderTime;
  396. },
  397. enumerable: false,
  398. configurable: true
  399. });
  400. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  401. /**
  402. * Gets the perf counter used to capture layout time
  403. */
  404. get: function () {
  405. return this._layoutTime;
  406. },
  407. enumerable: false,
  408. configurable: true
  409. });
  410. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  411. /**
  412. * Enable or disable the render time capture
  413. */
  414. get: function () {
  415. return this._captureRenderTime;
  416. },
  417. set: function (value) {
  418. var _this = this;
  419. if (value === this._captureRenderTime) {
  420. return;
  421. }
  422. this._captureRenderTime = value;
  423. if (value) {
  424. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  425. _this._renderTime.beginMonitoring();
  426. });
  427. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  428. _this._renderTime.endMonitoring(true);
  429. });
  430. }
  431. else {
  432. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  433. this._onBeginRenderObserver = null;
  434. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  435. this._onEndRenderObserver = null;
  436. }
  437. },
  438. enumerable: false,
  439. configurable: true
  440. });
  441. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  442. /**
  443. * Enable or disable the layout time capture
  444. */
  445. get: function () {
  446. return this._captureLayoutTime;
  447. },
  448. set: function (value) {
  449. var _this = this;
  450. if (value === this._captureLayoutTime) {
  451. return;
  452. }
  453. this._captureLayoutTime = value;
  454. if (value) {
  455. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  456. _this._layoutTime.beginMonitoring();
  457. });
  458. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  459. _this._layoutTime.endMonitoring(true);
  460. });
  461. }
  462. else {
  463. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  464. this._onBeginLayoutObserver = null;
  465. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  466. this._onEndLayoutObserver = null;
  467. }
  468. },
  469. enumerable: false,
  470. configurable: true
  471. });
  472. /**
  473. * Dispose and release associated resources.
  474. */
  475. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  476. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  477. this._onBeginRenderObserver = null;
  478. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  479. this._onEndRenderObserver = null;
  480. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  481. this._onBeginLayoutObserver = null;
  482. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  483. this._onEndLayoutObserver = null;
  484. this.texture = null;
  485. };
  486. return AdvancedDynamicTextureInstrumentation;
  487. }());
  488. /***/ }),
  489. /***/ "./2D/advancedDynamicTexture.ts":
  490. /*!**************************************!*\
  491. !*** ./2D/advancedDynamicTexture.ts ***!
  492. \**************************************/
  493. /*! exports provided: AdvancedDynamicTexture */
  494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  495. "use strict";
  496. __webpack_require__.r(__webpack_exports__);
  497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  498. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  499. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  500. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  501. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  502. /* harmony import */ var _controls_control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./controls/control */ "./2D/controls/control.ts");
  503. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  504. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  505. /**
  506. * Class used to create texture to support 2D GUI elements
  507. * @see https://doc.babylonjs.com/how_to/gui
  508. */
  509. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  510. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AdvancedDynamicTexture, _super);
  511. /**
  512. * Creates a new AdvancedDynamicTexture
  513. * @param name defines the name of the texture
  514. * @param width defines the width of the texture
  515. * @param height defines the height of the texture
  516. * @param scene defines the hosting scene
  517. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  518. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  519. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  520. */
  521. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode, invertY) {
  522. if (width === void 0) { width = 0; }
  523. if (height === void 0) { height = 0; }
  524. if (generateMipMaps === void 0) { generateMipMaps = false; }
  525. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  526. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA, invertY) || this;
  527. _this._isDirty = false;
  528. /** @hidden */
  529. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  530. /** @hidden */
  531. _this._lastControlOver = {};
  532. /** @hidden */
  533. _this._lastControlDown = {};
  534. /** @hidden */
  535. _this._capturingControl = {};
  536. /** @hidden */
  537. _this._linkedControls = new Array();
  538. _this._isFullscreen = false;
  539. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  540. _this._idealWidth = 0;
  541. _this._idealHeight = 0;
  542. _this._useSmallestIdeal = false;
  543. _this._renderAtIdealSize = false;
  544. _this._blockNextFocusCheck = false;
  545. _this._renderScale = 1;
  546. _this._cursorChanged = false;
  547. _this._defaultMousePointerId = 0;
  548. /** @hidden */
  549. _this._numLayoutCalls = 0;
  550. /** @hidden */
  551. _this._numRenderCalls = 0;
  552. /**
  553. * Define type to string to ensure compatibility across browsers
  554. * Safari doesn't support DataTransfer constructor
  555. */
  556. _this._clipboardData = "";
  557. /**
  558. * Observable event triggered each time an clipboard event is received from the rendering canvas
  559. */
  560. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  561. /**
  562. * Observable event triggered each time a pointer down is intercepted by a control
  563. */
  564. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  565. /**
  566. * Observable event triggered before layout is evaluated
  567. */
  568. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  569. /**
  570. * Observable event triggered after the layout was evaluated
  571. */
  572. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  573. /**
  574. * Observable event triggered before the texture is rendered
  575. */
  576. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  577. /**
  578. * Observable event triggered after the texture was rendered
  579. */
  580. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  581. /**
  582. * Gets or sets a boolean defining if alpha is stored as premultiplied
  583. */
  584. _this.premulAlpha = false;
  585. /**
  586. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  587. */
  588. _this.applyYInversionOnUpdate = true;
  589. _this._useInvalidateRectOptimization = true;
  590. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  591. _this._invalidatedRectangle = null;
  592. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_5__["Measure"](0, 0, 0, 0);
  593. /** @hidden */
  594. _this.onClipboardCopy = function (rawEvt) {
  595. var evt = rawEvt;
  596. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  597. _this.onClipboardObservable.notifyObservers(ev);
  598. evt.preventDefault();
  599. };
  600. /** @hidden */
  601. _this.onClipboardCut = function (rawEvt) {
  602. var evt = rawEvt;
  603. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  604. _this.onClipboardObservable.notifyObservers(ev);
  605. evt.preventDefault();
  606. };
  607. /** @hidden */
  608. _this.onClipboardPaste = function (rawEvt) {
  609. var evt = rawEvt;
  610. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  611. _this.onClipboardObservable.notifyObservers(ev);
  612. evt.preventDefault();
  613. };
  614. scene = _this.getScene();
  615. if (!scene || !_this._texture) {
  616. return _this;
  617. }
  618. _this._rootElement = scene.getEngine().getInputElement();
  619. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  620. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  621. if (!_this._focusedControl) {
  622. return;
  623. }
  624. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  625. _this._focusedControl.processKeyboard(info.event);
  626. }
  627. info.skipOnPointerObservable = true;
  628. });
  629. _this._rootContainer._link(_this);
  630. _this.hasAlpha = true;
  631. if (!width || !height) {
  632. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  633. _this._onResize();
  634. }
  635. _this._texture.isReady = true;
  636. return _this;
  637. }
  638. Object.defineProperty(AdvancedDynamicTexture.prototype, "numLayoutCalls", {
  639. /** Gets the number of layout calls made the last time the ADT has been rendered */
  640. get: function () {
  641. return this._numLayoutCalls;
  642. },
  643. enumerable: false,
  644. configurable: true
  645. });
  646. Object.defineProperty(AdvancedDynamicTexture.prototype, "numRenderCalls", {
  647. /** Gets the number of render calls made the last time the ADT has been rendered */
  648. get: function () {
  649. return this._numRenderCalls;
  650. },
  651. enumerable: false,
  652. configurable: true
  653. });
  654. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  655. /**
  656. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  657. * Useful when you want more antialiasing
  658. */
  659. get: function () {
  660. return this._renderScale;
  661. },
  662. set: function (value) {
  663. if (value === this._renderScale) {
  664. return;
  665. }
  666. this._renderScale = value;
  667. this._onResize();
  668. },
  669. enumerable: false,
  670. configurable: true
  671. });
  672. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  673. /** Gets or sets the background color */
  674. get: function () {
  675. return this._background;
  676. },
  677. set: function (value) {
  678. if (this._background === value) {
  679. return;
  680. }
  681. this._background = value;
  682. this.markAsDirty();
  683. },
  684. enumerable: false,
  685. configurable: true
  686. });
  687. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  688. /**
  689. * Gets or sets the ideal width used to design controls.
  690. * The GUI will then rescale everything accordingly
  691. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  692. */
  693. get: function () {
  694. return this._idealWidth;
  695. },
  696. set: function (value) {
  697. if (this._idealWidth === value) {
  698. return;
  699. }
  700. this._idealWidth = value;
  701. this.markAsDirty();
  702. this._rootContainer._markAllAsDirty();
  703. },
  704. enumerable: false,
  705. configurable: true
  706. });
  707. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  708. /**
  709. * Gets or sets the ideal height used to design controls.
  710. * The GUI will then rescale everything accordingly
  711. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  712. */
  713. get: function () {
  714. return this._idealHeight;
  715. },
  716. set: function (value) {
  717. if (this._idealHeight === value) {
  718. return;
  719. }
  720. this._idealHeight = value;
  721. this.markAsDirty();
  722. this._rootContainer._markAllAsDirty();
  723. },
  724. enumerable: false,
  725. configurable: true
  726. });
  727. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  728. /**
  729. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  730. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  731. */
  732. get: function () {
  733. return this._useSmallestIdeal;
  734. },
  735. set: function (value) {
  736. if (this._useSmallestIdeal === value) {
  737. return;
  738. }
  739. this._useSmallestIdeal = value;
  740. this.markAsDirty();
  741. this._rootContainer._markAllAsDirty();
  742. },
  743. enumerable: false,
  744. configurable: true
  745. });
  746. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  747. /**
  748. * Gets or sets a boolean indicating if adaptive scaling must be used
  749. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  750. */
  751. get: function () {
  752. return this._renderAtIdealSize;
  753. },
  754. set: function (value) {
  755. if (this._renderAtIdealSize === value) {
  756. return;
  757. }
  758. this._renderAtIdealSize = value;
  759. this._onResize();
  760. },
  761. enumerable: false,
  762. configurable: true
  763. });
  764. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealRatio", {
  765. /**
  766. * Gets the ratio used when in "ideal mode"
  767. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  768. * */
  769. get: function () {
  770. var rwidth = 0;
  771. var rheight = 0;
  772. if (this._idealWidth) {
  773. rwidth = (this.getSize().width) / this._idealWidth;
  774. }
  775. if (this._idealHeight) {
  776. rheight = (this.getSize().height) / this._idealHeight;
  777. }
  778. if (this._useSmallestIdeal && this._idealWidth && this._idealHeight) {
  779. return window.innerWidth < window.innerHeight ? rwidth : rheight;
  780. }
  781. if (this._idealWidth) { // horizontal
  782. return rwidth;
  783. }
  784. if (this._idealHeight) { // vertical
  785. return rheight;
  786. }
  787. return 1;
  788. },
  789. enumerable: false,
  790. configurable: true
  791. });
  792. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  793. /**
  794. * Gets the underlying layer used to render the texture when in fullscreen mode
  795. */
  796. get: function () {
  797. return this._layerToDispose;
  798. },
  799. enumerable: false,
  800. configurable: true
  801. });
  802. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  803. /**
  804. * Gets the root container control
  805. */
  806. get: function () {
  807. return this._rootContainer;
  808. },
  809. enumerable: false,
  810. configurable: true
  811. });
  812. /**
  813. * Returns an array containing the root container.
  814. * This is mostly used to let the Inspector introspects the ADT
  815. * @returns an array containing the rootContainer
  816. */
  817. AdvancedDynamicTexture.prototype.getChildren = function () {
  818. return [this._rootContainer];
  819. };
  820. /**
  821. * Will return all controls that are inside this texture
  822. * @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
  823. * @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
  824. * @return all child controls
  825. */
  826. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  827. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  828. };
  829. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  830. /**
  831. * Gets or sets the current focused control
  832. */
  833. get: function () {
  834. return this._focusedControl;
  835. },
  836. set: function (control) {
  837. if (this._focusedControl == control) {
  838. return;
  839. }
  840. if (this._focusedControl) {
  841. this._focusedControl.onBlur();
  842. }
  843. if (control) {
  844. control.onFocus();
  845. }
  846. this._focusedControl = control;
  847. },
  848. enumerable: false,
  849. configurable: true
  850. });
  851. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  852. /**
  853. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  854. */
  855. get: function () {
  856. if (!this.layer) {
  857. return true;
  858. }
  859. return (!this.layer.isBackground);
  860. },
  861. set: function (value) {
  862. if (!this.layer) {
  863. return;
  864. }
  865. if (this.layer.isBackground === !value) {
  866. return;
  867. }
  868. this.layer.isBackground = !value;
  869. },
  870. enumerable: false,
  871. configurable: true
  872. });
  873. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  874. /**
  875. * Gets or set information about clipboardData
  876. */
  877. get: function () {
  878. return this._clipboardData;
  879. },
  880. set: function (value) {
  881. this._clipboardData = value;
  882. },
  883. enumerable: false,
  884. configurable: true
  885. });
  886. /**
  887. * Get the current class name of the texture useful for serialization or dynamic coding.
  888. * @returns "AdvancedDynamicTexture"
  889. */
  890. AdvancedDynamicTexture.prototype.getClassName = function () {
  891. return "AdvancedDynamicTexture";
  892. };
  893. /**
  894. * Function used to execute a function on all controls
  895. * @param func defines the function to execute
  896. * @param container defines the container where controls belong. If null the root container will be used
  897. */
  898. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  899. if (!container) {
  900. container = this._rootContainer;
  901. }
  902. func(container);
  903. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  904. var child = _a[_i];
  905. if (child.children) {
  906. this.executeOnAllControls(func, child);
  907. continue;
  908. }
  909. func(child);
  910. }
  911. };
  912. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  913. /**
  914. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  915. */
  916. get: function () {
  917. return this._useInvalidateRectOptimization;
  918. },
  919. set: function (value) {
  920. this._useInvalidateRectOptimization = value;
  921. },
  922. enumerable: false,
  923. configurable: true
  924. });
  925. /**
  926. * Invalidates a rectangle area on the gui texture
  927. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  928. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  929. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  930. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  931. */
  932. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  933. if (!this._useInvalidateRectOptimization) {
  934. return;
  935. }
  936. if (!this._invalidatedRectangle) {
  937. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_5__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  938. }
  939. else {
  940. // Compute intersection
  941. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  942. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  943. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  944. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  945. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  946. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  947. }
  948. };
  949. /**
  950. * Marks the texture as dirty forcing a complete update
  951. */
  952. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  953. this._isDirty = true;
  954. };
  955. /**
  956. * Helper function used to create a new style
  957. * @returns a new style
  958. * @see https://doc.babylonjs.com/how_to/gui#styles
  959. */
  960. AdvancedDynamicTexture.prototype.createStyle = function () {
  961. return new _style__WEBPACK_IMPORTED_MODULE_4__["Style"](this);
  962. };
  963. /**
  964. * Adds a new control to the root container
  965. * @param control defines the control to add
  966. * @returns the current texture
  967. */
  968. AdvancedDynamicTexture.prototype.addControl = function (control) {
  969. this._rootContainer.addControl(control);
  970. return this;
  971. };
  972. /**
  973. * Removes a control from the root container
  974. * @param control defines the control to remove
  975. * @returns the current texture
  976. */
  977. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  978. this._rootContainer.removeControl(control);
  979. return this;
  980. };
  981. /**
  982. * Release all resources
  983. */
  984. AdvancedDynamicTexture.prototype.dispose = function () {
  985. var scene = this.getScene();
  986. if (!scene) {
  987. return;
  988. }
  989. this._rootElement = null;
  990. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  991. if (this._resizeObserver) {
  992. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  993. }
  994. if (this._pointerMoveObserver) {
  995. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  996. }
  997. if (this._pointerObserver) {
  998. scene.onPointerObservable.remove(this._pointerObserver);
  999. }
  1000. if (this._preKeyboardObserver) {
  1001. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  1002. }
  1003. if (this._canvasPointerOutObserver) {
  1004. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  1005. }
  1006. if (this._canvasBlurObserver) {
  1007. scene.getEngine().onCanvasBlurObservable.remove(this._canvasBlurObserver);
  1008. }
  1009. if (this._layerToDispose) {
  1010. this._layerToDispose.texture = null;
  1011. this._layerToDispose.dispose();
  1012. this._layerToDispose = null;
  1013. }
  1014. this._rootContainer.dispose();
  1015. this.onClipboardObservable.clear();
  1016. this.onControlPickedObservable.clear();
  1017. this.onBeginRenderObservable.clear();
  1018. this.onEndRenderObservable.clear();
  1019. this.onBeginLayoutObservable.clear();
  1020. this.onEndLayoutObservable.clear();
  1021. _super.prototype.dispose.call(this);
  1022. };
  1023. AdvancedDynamicTexture.prototype._onResize = function () {
  1024. var scene = this.getScene();
  1025. if (!scene) {
  1026. return;
  1027. }
  1028. // Check size
  1029. var engine = scene.getEngine();
  1030. var textureSize = this.getSize();
  1031. var renderWidth = engine.getRenderWidth() * this._renderScale;
  1032. var renderHeight = engine.getRenderHeight() * this._renderScale;
  1033. if (this._renderAtIdealSize) {
  1034. if (this._idealWidth) {
  1035. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  1036. renderWidth = this._idealWidth;
  1037. }
  1038. else if (this._idealHeight) {
  1039. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  1040. renderHeight = this._idealHeight;
  1041. }
  1042. }
  1043. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  1044. this.scaleTo(renderWidth, renderHeight);
  1045. this.markAsDirty();
  1046. if (this._idealWidth || this._idealHeight) {
  1047. this._rootContainer._markAllAsDirty();
  1048. }
  1049. }
  1050. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  1051. };
  1052. /** @hidden */
  1053. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  1054. var engine = scene.getEngine();
  1055. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  1056. };
  1057. /**
  1058. * Get screen coordinates for a vector3
  1059. * @param position defines the position to project
  1060. * @param worldMatrix defines the world matrix to use
  1061. * @returns the projected position
  1062. */
  1063. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  1064. var scene = this.getScene();
  1065. if (!scene) {
  1066. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  1067. }
  1068. var globalViewport = this._getGlobalViewport(scene);
  1069. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1070. projectedPosition.scaleInPlace(this.renderScale);
  1071. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  1072. };
  1073. /**
  1074. * Get screen coordinates for a vector3
  1075. * @param position defines the position to project
  1076. * @param worldMatrix defines the world matrix to use
  1077. * @returns the projected position with Z
  1078. */
  1079. AdvancedDynamicTexture.prototype.getProjectedPositionWithZ = function (position, worldMatrix) {
  1080. var scene = this.getScene();
  1081. if (!scene) {
  1082. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  1083. }
  1084. var globalViewport = this._getGlobalViewport(scene);
  1085. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1086. projectedPosition.scaleInPlace(this.renderScale);
  1087. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"](projectedPosition.x, projectedPosition.y, projectedPosition.z);
  1088. };
  1089. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  1090. if (this._layerToDispose) {
  1091. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  1092. return;
  1093. }
  1094. }
  1095. if (this._isFullscreen && this._linkedControls.length) {
  1096. var scene = this.getScene();
  1097. if (!scene) {
  1098. return;
  1099. }
  1100. var globalViewport = this._getGlobalViewport(scene);
  1101. var _loop_1 = function (control) {
  1102. if (!control.isVisible) {
  1103. return "continue";
  1104. }
  1105. var mesh = control._linkedMesh;
  1106. if (!mesh || mesh.isDisposed()) {
  1107. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1108. control.linkWithMesh(null);
  1109. });
  1110. return "continue";
  1111. }
  1112. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1113. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1114. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1115. control.notRenderable = true;
  1116. return "continue";
  1117. }
  1118. control.notRenderable = false;
  1119. // Account for RenderScale.
  1120. projectedPosition.scaleInPlace(this_1.renderScale);
  1121. control._moveToProjectedPosition(projectedPosition);
  1122. };
  1123. var this_1 = this;
  1124. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  1125. var control = _a[_i];
  1126. _loop_1(control);
  1127. }
  1128. }
  1129. if (!this._isDirty && !this._rootContainer.isDirty) {
  1130. return;
  1131. }
  1132. this._isDirty = false;
  1133. this._render();
  1134. this.update(this.applyYInversionOnUpdate, this.premulAlpha);
  1135. };
  1136. AdvancedDynamicTexture.prototype._render = function () {
  1137. var textureSize = this.getSize();
  1138. var renderWidth = textureSize.width;
  1139. var renderHeight = textureSize.height;
  1140. var context = this.getContext();
  1141. context.font = "18px Arial";
  1142. context.strokeStyle = "white";
  1143. // Layout
  1144. this.onBeginLayoutObservable.notifyObservers(this);
  1145. var measure = new _measure__WEBPACK_IMPORTED_MODULE_5__["Measure"](0, 0, renderWidth, renderHeight);
  1146. this._numLayoutCalls = 0;
  1147. this._rootContainer._layout(measure, context);
  1148. this.onEndLayoutObservable.notifyObservers(this);
  1149. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1150. // Clear
  1151. if (this._invalidatedRectangle) {
  1152. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1153. }
  1154. else {
  1155. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1156. }
  1157. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1158. if (this._background) {
  1159. context.save();
  1160. context.fillStyle = this._background;
  1161. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1162. context.restore();
  1163. }
  1164. // Render
  1165. this.onBeginRenderObservable.notifyObservers(this);
  1166. this._numRenderCalls = 0;
  1167. this._rootContainer._render(context, this._invalidatedRectangle);
  1168. this.onEndRenderObservable.notifyObservers(this);
  1169. this._invalidatedRectangle = null;
  1170. };
  1171. /** @hidden */
  1172. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1173. if (this._rootElement) {
  1174. this._rootElement.style.cursor = cursor;
  1175. this._cursorChanged = true;
  1176. }
  1177. };
  1178. /** @hidden */
  1179. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1180. this._lastControlDown[pointerId] = control;
  1181. this.onControlPickedObservable.notifyObservers(control);
  1182. };
  1183. AdvancedDynamicTexture.prototype._doPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  1184. var scene = this.getScene();
  1185. if (!scene) {
  1186. return;
  1187. }
  1188. var engine = scene.getEngine();
  1189. var textureSize = this.getSize();
  1190. if (this._isFullscreen) {
  1191. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1192. var viewport = camera.viewport;
  1193. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1194. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1195. }
  1196. if (this._capturingControl[pointerId]) {
  1197. this._capturingControl[pointerId]._processObservables(type, x, y, pi, pointerId, buttonIndex);
  1198. return;
  1199. }
  1200. this._cursorChanged = false;
  1201. if (!this._rootContainer._processPicking(x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY)) {
  1202. this._changeCursor("");
  1203. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1204. if (this._lastControlOver[pointerId]) {
  1205. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId], pi);
  1206. delete this._lastControlOver[pointerId];
  1207. }
  1208. }
  1209. }
  1210. if (!this._cursorChanged) {
  1211. this._changeCursor("");
  1212. }
  1213. this._manageFocus();
  1214. };
  1215. /** @hidden */
  1216. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1217. for (var pointerId in list) {
  1218. if (!list.hasOwnProperty(pointerId)) {
  1219. continue;
  1220. }
  1221. var lastControlOver = list[pointerId];
  1222. if (lastControlOver === control) {
  1223. delete list[pointerId];
  1224. }
  1225. }
  1226. };
  1227. /** @hidden */
  1228. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1229. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1230. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1231. };
  1232. /** Attach to all scene events required to support pointer events */
  1233. AdvancedDynamicTexture.prototype.attach = function () {
  1234. var _this = this;
  1235. var scene = this.getScene();
  1236. if (!scene) {
  1237. return;
  1238. }
  1239. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1240. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1241. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1242. return;
  1243. }
  1244. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1245. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1246. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN
  1247. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  1248. return;
  1249. }
  1250. if (!scene) {
  1251. return;
  1252. }
  1253. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE && pi.event.pointerId) {
  1254. _this._defaultMousePointerId = pi.event.pointerId; // This is required to make sure we have the correct pointer ID for wheel
  1255. }
  1256. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1257. var engine = scene.getEngine();
  1258. if (!camera) {
  1259. tempViewport.x = 0;
  1260. tempViewport.y = 0;
  1261. tempViewport.width = engine.getRenderWidth();
  1262. tempViewport.height = engine.getRenderHeight();
  1263. }
  1264. else {
  1265. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1266. }
  1267. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1268. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1269. _this._shouldBlockPointer = false;
  1270. // Do picking modifies _shouldBlockPointer
  1271. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1272. _this._doPicking(x, y, pi, pi.type, pointerId, pi.event.button, pi.event.deltaX, pi.event.deltaY);
  1273. // Avoid overwriting a true skipOnPointerObservable to false
  1274. if (_this._shouldBlockPointer) {
  1275. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1276. }
  1277. });
  1278. this._attachToOnPointerOut(scene);
  1279. this._attachToOnBlur(scene);
  1280. };
  1281. /**
  1282. * Register the clipboard Events onto the canvas
  1283. */
  1284. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1285. self.addEventListener("copy", this.onClipboardCopy, false);
  1286. self.addEventListener("cut", this.onClipboardCut, false);
  1287. self.addEventListener("paste", this.onClipboardPaste, false);
  1288. };
  1289. /**
  1290. * Unregister the clipboard Events from the canvas
  1291. */
  1292. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1293. self.removeEventListener("copy", this.onClipboardCopy);
  1294. self.removeEventListener("cut", this.onClipboardCut);
  1295. self.removeEventListener("paste", this.onClipboardPaste);
  1296. };
  1297. /**
  1298. * Connect the texture to a hosting mesh to enable interactions
  1299. * @param mesh defines the mesh to attach to
  1300. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1301. */
  1302. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1303. var _this = this;
  1304. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1305. var scene = this.getScene();
  1306. if (!scene) {
  1307. return;
  1308. }
  1309. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1310. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1311. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1312. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1313. return;
  1314. }
  1315. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1316. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1317. var uv = pi.pickInfo.getTextureCoordinates();
  1318. if (uv) {
  1319. var size = _this.getSize();
  1320. _this._doPicking(uv.x * size.width, (_this.applyYInversionOnUpdate ? (1.0 - uv.y) : uv.y) * size.height, pi, pi.type, pointerId, pi.event.button);
  1321. }
  1322. }
  1323. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1324. if (_this._lastControlDown[pointerId]) {
  1325. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1326. }
  1327. delete _this._lastControlDown[pointerId];
  1328. if (_this.focusedControl) {
  1329. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1330. var canMoveFocus = true;
  1331. if (friendlyControls) {
  1332. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1333. var control = friendlyControls_1[_i];
  1334. // Same host, no need to keep the focus
  1335. if (_this === control._host) {
  1336. continue;
  1337. }
  1338. // Different hosts
  1339. var otherHost = control._host;
  1340. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1341. canMoveFocus = false;
  1342. break;
  1343. }
  1344. }
  1345. }
  1346. if (canMoveFocus) {
  1347. _this.focusedControl = null;
  1348. }
  1349. }
  1350. }
  1351. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1352. if (_this._lastControlOver[pointerId]) {
  1353. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], pi, true);
  1354. }
  1355. delete _this._lastControlOver[pointerId];
  1356. }
  1357. });
  1358. mesh.enablePointerMoveEvents = supportPointerMove;
  1359. this._attachToOnPointerOut(scene);
  1360. this._attachToOnBlur(scene);
  1361. };
  1362. /**
  1363. * Move the focus to a specific control
  1364. * @param control defines the control which will receive the focus
  1365. */
  1366. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1367. this.focusedControl = control;
  1368. this._lastPickedControl = control;
  1369. this._blockNextFocusCheck = true;
  1370. };
  1371. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1372. if (this._blockNextFocusCheck) {
  1373. this._blockNextFocusCheck = false;
  1374. this._lastPickedControl = this._focusedControl;
  1375. return;
  1376. }
  1377. // Focus management
  1378. if (this._focusedControl) {
  1379. if (this._focusedControl !== this._lastPickedControl) {
  1380. if (this._lastPickedControl.isFocusInvisible) {
  1381. return;
  1382. }
  1383. this.focusedControl = null;
  1384. }
  1385. }
  1386. };
  1387. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1388. var _this = this;
  1389. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1390. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1391. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId], null);
  1392. }
  1393. delete _this._lastControlOver[pointerEvent.pointerId];
  1394. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1395. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1396. delete _this._lastControlDown[pointerEvent.pointerId];
  1397. }
  1398. });
  1399. };
  1400. AdvancedDynamicTexture.prototype._attachToOnBlur = function (scene) {
  1401. var _this = this;
  1402. this._canvasBlurObserver = scene.getEngine().onCanvasBlurObservable.add(function (pointerEvent) {
  1403. Object.entries(_this._lastControlDown).forEach(function (_a) {
  1404. var key = _a[0], value = _a[1];
  1405. value._onCanvasBlur();
  1406. });
  1407. _this._lastControlDown = {};
  1408. });
  1409. };
  1410. /**
  1411. * Serializes the entire GUI system
  1412. * @returns an object with the JSON serialized data
  1413. */
  1414. AdvancedDynamicTexture.prototype.serializeContent = function () {
  1415. var serializationObject = {
  1416. root: {}
  1417. };
  1418. this._rootContainer.serialize(serializationObject.root);
  1419. return serializationObject;
  1420. };
  1421. /**
  1422. * Recreate the content of the ADT from a JSON object
  1423. * @param serializedObject define the JSON serialized object to restore from
  1424. */
  1425. AdvancedDynamicTexture.prototype.parseContent = function (serializedObject) {
  1426. this._rootContainer = _controls_control__WEBPACK_IMPORTED_MODULE_3__["Control"].Parse(serializedObject.root, this);
  1427. };
  1428. /**
  1429. * Recreate the content of the ADT from a snippet saved by the GUI editor
  1430. * @param snippetId defines the snippet to load
  1431. * @returns a promise that will resolve on success
  1432. */
  1433. AdvancedDynamicTexture.prototype.parseFromSnippetAsync = function (snippetId) {
  1434. var _this = this;
  1435. if (snippetId === "_BLANK") {
  1436. return Promise.resolve();
  1437. }
  1438. return new Promise(function (resolve, reject) {
  1439. var request = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["WebRequest"]();
  1440. request.addEventListener("readystatechange", function () {
  1441. if (request.readyState == 4) {
  1442. if (request.status == 200) {
  1443. var snippet = JSON.parse(JSON.parse(request.responseText).jsonPayload);
  1444. var serializationObject = JSON.parse(snippet.gui);
  1445. _this.parseContent(serializationObject);
  1446. _this.snippetId = snippetId;
  1447. resolve();
  1448. }
  1449. else {
  1450. reject("Unable to load the snippet " + snippetId);
  1451. }
  1452. }
  1453. });
  1454. request.open("GET", AdvancedDynamicTexture.SnippetUrl + "/" + snippetId.replace(/#/g, "/"));
  1455. request.send();
  1456. });
  1457. };
  1458. // Statics
  1459. /**
  1460. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1461. * @param mesh defines the mesh which will receive the texture
  1462. * @param width defines the texture width (1024 by default)
  1463. * @param height defines the texture height (1024 by default)
  1464. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1465. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1466. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  1467. * @returns a new AdvancedDynamicTexture
  1468. */
  1469. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting, invertY) {
  1470. if (width === void 0) { width = 1024; }
  1471. if (height === void 0) { height = 1024; }
  1472. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1473. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1474. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, invertY);
  1475. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1476. material.backFaceCulling = false;
  1477. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1478. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1479. if (onlyAlphaTesting) {
  1480. material.diffuseTexture = result;
  1481. material.emissiveTexture = result;
  1482. result.hasAlpha = true;
  1483. }
  1484. else {
  1485. material.emissiveTexture = result;
  1486. material.opacityTexture = result;
  1487. }
  1488. mesh.material = material;
  1489. result.attachToMesh(mesh, supportPointerMove);
  1490. return result;
  1491. };
  1492. /**
  1493. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh) BUT do not create a new material for the mesh. You will be responsible for connecting the texture
  1494. * @param mesh defines the mesh which will receive the texture
  1495. * @param width defines the texture width (1024 by default)
  1496. * @param height defines the texture height (1024 by default)
  1497. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1498. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  1499. * @returns a new AdvancedDynamicTexture
  1500. */
  1501. AdvancedDynamicTexture.CreateForMeshTexture = function (mesh, width, height, supportPointerMove, invertY) {
  1502. if (width === void 0) { width = 1024; }
  1503. if (height === void 0) { height = 1024; }
  1504. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1505. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, invertY);
  1506. result.attachToMesh(mesh, supportPointerMove);
  1507. return result;
  1508. };
  1509. /**
  1510. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1511. * In this mode the texture will rely on a layer for its rendering.
  1512. * This allows it to be treated like any other layer.
  1513. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1514. * LayerMask is set through advancedTexture.layer.layerMask
  1515. * @param name defines name for the texture
  1516. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1517. * @param scene defines the hsoting scene
  1518. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1519. * @returns a new AdvancedDynamicTexture
  1520. */
  1521. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1522. if (foreground === void 0) { foreground = true; }
  1523. if (scene === void 0) { scene = null; }
  1524. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1525. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1526. // Display
  1527. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1528. layer.texture = result;
  1529. result._layerToDispose = layer;
  1530. result._isFullscreen = true;
  1531. // Attach
  1532. result.attach();
  1533. return result;
  1534. };
  1535. /** Define the Uurl to load snippets */
  1536. AdvancedDynamicTexture.SnippetUrl = "https://snippet.babylonjs.com";
  1537. return AdvancedDynamicTexture;
  1538. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1539. /***/ }),
  1540. /***/ "./2D/controls/button.ts":
  1541. /*!*******************************!*\
  1542. !*** ./2D/controls/button.ts ***!
  1543. \*******************************/
  1544. /*! exports provided: Button */
  1545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1546. "use strict";
  1547. __webpack_require__.r(__webpack_exports__);
  1548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1549. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1550. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1551. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1552. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1553. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1554. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  1555. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1556. /**
  1557. * Class used to create 2D buttons
  1558. */
  1559. var Button = /** @class */ (function (_super) {
  1560. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1561. /**
  1562. * Creates a new Button
  1563. * @param name defines the name of the button
  1564. */
  1565. function Button(name) {
  1566. var _this = _super.call(this, name) || this;
  1567. _this.name = name;
  1568. /**
  1569. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1570. */
  1571. _this.delegatePickingToChildren = false;
  1572. _this.thickness = 1;
  1573. _this.isPointerBlocker = true;
  1574. var alphaStore = null;
  1575. _this.pointerEnterAnimation = function () {
  1576. alphaStore = _this.alpha;
  1577. _this.alpha -= 0.1;
  1578. };
  1579. _this.pointerOutAnimation = function () {
  1580. if (alphaStore !== null) {
  1581. _this.alpha = alphaStore;
  1582. }
  1583. };
  1584. _this.pointerDownAnimation = function () {
  1585. _this.scaleX -= 0.05;
  1586. _this.scaleY -= 0.05;
  1587. };
  1588. _this.pointerUpAnimation = function () {
  1589. _this.scaleX += 0.05;
  1590. _this.scaleY += 0.05;
  1591. };
  1592. return _this;
  1593. }
  1594. Object.defineProperty(Button.prototype, "image", {
  1595. /**
  1596. * Returns the image part of the button (if any)
  1597. */
  1598. get: function () {
  1599. return this._image;
  1600. },
  1601. enumerable: false,
  1602. configurable: true
  1603. });
  1604. Object.defineProperty(Button.prototype, "textBlock", {
  1605. /**
  1606. * Returns the image part of the button (if any)
  1607. */
  1608. get: function () {
  1609. return this._textBlock;
  1610. },
  1611. enumerable: false,
  1612. configurable: true
  1613. });
  1614. Button.prototype._getTypeName = function () {
  1615. return "Button";
  1616. };
  1617. // While being a container, the button behaves like a control.
  1618. /** @hidden */
  1619. Button.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  1620. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1621. return false;
  1622. }
  1623. if (!_super.prototype.contains.call(this, x, y)) {
  1624. return false;
  1625. }
  1626. if (this.delegatePickingToChildren) {
  1627. var contains = false;
  1628. for (var index = this._children.length - 1; index >= 0; index--) {
  1629. var child = this._children[index];
  1630. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1631. contains = true;
  1632. break;
  1633. }
  1634. }
  1635. if (!contains) {
  1636. return false;
  1637. }
  1638. }
  1639. this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  1640. return true;
  1641. };
  1642. /** @hidden */
  1643. Button.prototype._onPointerEnter = function (target, pi) {
  1644. if (!_super.prototype._onPointerEnter.call(this, target, pi)) {
  1645. return false;
  1646. }
  1647. if (this.pointerEnterAnimation) {
  1648. this.pointerEnterAnimation();
  1649. }
  1650. return true;
  1651. };
  1652. /** @hidden */
  1653. Button.prototype._onPointerOut = function (target, pi, force) {
  1654. if (force === void 0) { force = false; }
  1655. if (this.pointerOutAnimation) {
  1656. this.pointerOutAnimation();
  1657. }
  1658. _super.prototype._onPointerOut.call(this, target, pi, force);
  1659. };
  1660. /** @hidden */
  1661. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  1662. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  1663. return false;
  1664. }
  1665. if (this.pointerDownAnimation) {
  1666. this.pointerDownAnimation();
  1667. }
  1668. return true;
  1669. };
  1670. /** @hidden */
  1671. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  1672. if (this.pointerUpAnimation) {
  1673. this.pointerUpAnimation();
  1674. }
  1675. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick, pi);
  1676. };
  1677. // Statics
  1678. /**
  1679. * Creates a new button made with an image and a text
  1680. * @param name defines the name of the button
  1681. * @param text defines the text of the button
  1682. * @param imageUrl defines the url of the image
  1683. * @returns a new Button
  1684. */
  1685. Button.CreateImageButton = function (name, text, imageUrl) {
  1686. var result = new this(name);
  1687. // Adding text
  1688. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1689. textBlock.textWrapping = true;
  1690. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1691. textBlock.paddingLeft = "20%";
  1692. result.addControl(textBlock);
  1693. // Adding image
  1694. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1695. iconImage.width = "20%";
  1696. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1697. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1698. result.addControl(iconImage);
  1699. // Store
  1700. result._image = iconImage;
  1701. result._textBlock = textBlock;
  1702. return result;
  1703. };
  1704. /**
  1705. * Creates a new button made with an image
  1706. * @param name defines the name of the button
  1707. * @param imageUrl defines the url of the image
  1708. * @returns a new Button
  1709. */
  1710. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1711. var result = new this(name);
  1712. // Adding image
  1713. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1714. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1715. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1716. result.addControl(iconImage);
  1717. // Store
  1718. result._image = iconImage;
  1719. return result;
  1720. };
  1721. /**
  1722. * Creates a new button made with a text
  1723. * @param name defines the name of the button
  1724. * @param text defines the text of the button
  1725. * @returns a new Button
  1726. */
  1727. Button.CreateSimpleButton = function (name, text) {
  1728. var result = new this(name);
  1729. // Adding text
  1730. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1731. textBlock.textWrapping = true;
  1732. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1733. result.addControl(textBlock);
  1734. // Store
  1735. result._textBlock = textBlock;
  1736. return result;
  1737. };
  1738. /**
  1739. * Creates a new button made with an image and a centered text
  1740. * @param name defines the name of the button
  1741. * @param text defines the text of the button
  1742. * @param imageUrl defines the url of the image
  1743. * @returns a new Button
  1744. */
  1745. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1746. var result = new this(name);
  1747. // Adding image
  1748. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1749. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1750. result.addControl(iconImage);
  1751. // Adding text
  1752. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1753. textBlock.textWrapping = true;
  1754. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1755. result.addControl(textBlock);
  1756. // Store
  1757. result._image = iconImage;
  1758. result._textBlock = textBlock;
  1759. return result;
  1760. };
  1761. return Button;
  1762. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1763. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1764. /***/ }),
  1765. /***/ "./2D/controls/checkbox.ts":
  1766. /*!*********************************!*\
  1767. !*** ./2D/controls/checkbox.ts ***!
  1768. \*********************************/
  1769. /*! exports provided: Checkbox */
  1770. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1771. "use strict";
  1772. __webpack_require__.r(__webpack_exports__);
  1773. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1774. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1775. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1776. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1777. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1778. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1779. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1780. /**
  1781. * Class used to represent a 2D checkbox
  1782. */
  1783. var Checkbox = /** @class */ (function (_super) {
  1784. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1785. /**
  1786. * Creates a new CheckBox
  1787. * @param name defines the control name
  1788. */
  1789. function Checkbox(name) {
  1790. var _this = _super.call(this, name) || this;
  1791. _this.name = name;
  1792. _this._isChecked = false;
  1793. _this._background = "black";
  1794. _this._checkSizeRatio = 0.8;
  1795. _this._thickness = 1;
  1796. /**
  1797. * Observable raised when isChecked property changes
  1798. */
  1799. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1800. _this.isPointerBlocker = true;
  1801. return _this;
  1802. }
  1803. Object.defineProperty(Checkbox.prototype, "thickness", {
  1804. /** Gets or sets border thickness */
  1805. get: function () {
  1806. return this._thickness;
  1807. },
  1808. set: function (value) {
  1809. if (this._thickness === value) {
  1810. return;
  1811. }
  1812. this._thickness = value;
  1813. this._markAsDirty();
  1814. },
  1815. enumerable: false,
  1816. configurable: true
  1817. });
  1818. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1819. /** Gets or sets a value indicating the ratio between overall size and check size */
  1820. get: function () {
  1821. return this._checkSizeRatio;
  1822. },
  1823. set: function (value) {
  1824. value = Math.max(Math.min(1, value), 0);
  1825. if (this._checkSizeRatio === value) {
  1826. return;
  1827. }
  1828. this._checkSizeRatio = value;
  1829. this._markAsDirty();
  1830. },
  1831. enumerable: false,
  1832. configurable: true
  1833. });
  1834. Object.defineProperty(Checkbox.prototype, "background", {
  1835. /** Gets or sets background color */
  1836. get: function () {
  1837. return this._background;
  1838. },
  1839. set: function (value) {
  1840. if (this._background === value) {
  1841. return;
  1842. }
  1843. this._background = value;
  1844. this._markAsDirty();
  1845. },
  1846. enumerable: false,
  1847. configurable: true
  1848. });
  1849. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1850. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1851. get: function () {
  1852. return this._isChecked;
  1853. },
  1854. set: function (value) {
  1855. if (this._isChecked === value) {
  1856. return;
  1857. }
  1858. this._isChecked = value;
  1859. this._markAsDirty();
  1860. this.onIsCheckedChangedObservable.notifyObservers(value);
  1861. },
  1862. enumerable: false,
  1863. configurable: true
  1864. });
  1865. Checkbox.prototype._getTypeName = function () {
  1866. return "Checkbox";
  1867. };
  1868. /** @hidden */
  1869. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1870. context.save();
  1871. this._applyStates(context);
  1872. var actualWidth = this._currentMeasure.width - this._thickness;
  1873. var actualHeight = this._currentMeasure.height - this._thickness;
  1874. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1875. context.shadowColor = this.shadowColor;
  1876. context.shadowBlur = this.shadowBlur;
  1877. context.shadowOffsetX = this.shadowOffsetX;
  1878. context.shadowOffsetY = this.shadowOffsetY;
  1879. }
  1880. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1881. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1882. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1883. context.shadowBlur = 0;
  1884. context.shadowOffsetX = 0;
  1885. context.shadowOffsetY = 0;
  1886. }
  1887. if (this._isChecked) {
  1888. context.fillStyle = this._isEnabled ? this.color : this._disabledColorItem;
  1889. var offsetWidth = actualWidth * this._checkSizeRatio;
  1890. var offseHeight = actualHeight * this._checkSizeRatio;
  1891. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1892. }
  1893. context.strokeStyle = this.color;
  1894. context.lineWidth = this._thickness;
  1895. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1896. context.restore();
  1897. };
  1898. // Events
  1899. /** @hidden */
  1900. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  1901. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  1902. return false;
  1903. }
  1904. this.isChecked = !this.isChecked;
  1905. return true;
  1906. };
  1907. /**
  1908. * Utility function to easily create a checkbox with a header
  1909. * @param title defines the label to use for the header
  1910. * @param onValueChanged defines the callback to call when value changes
  1911. * @returns a StackPanel containing the checkbox and a textBlock
  1912. */
  1913. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1914. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1915. panel.isVertical = false;
  1916. panel.height = "30px";
  1917. var checkbox = new Checkbox();
  1918. checkbox.width = "20px";
  1919. checkbox.height = "20px";
  1920. checkbox.isChecked = true;
  1921. checkbox.color = "green";
  1922. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1923. panel.addControl(checkbox);
  1924. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1925. header.text = title;
  1926. header.width = "180px";
  1927. header.paddingLeft = "5px";
  1928. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1929. header.color = "white";
  1930. panel.addControl(header);
  1931. return panel;
  1932. };
  1933. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  1934. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  1935. ], Checkbox.prototype, "thickness", null);
  1936. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  1937. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  1938. ], Checkbox.prototype, "checkSizeRatio", null);
  1939. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  1940. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  1941. ], Checkbox.prototype, "background", null);
  1942. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  1943. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  1944. ], Checkbox.prototype, "isChecked", null);
  1945. return Checkbox;
  1946. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1947. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1948. /***/ }),
  1949. /***/ "./2D/controls/colorpicker.ts":
  1950. /*!************************************!*\
  1951. !*** ./2D/controls/colorpicker.ts ***!
  1952. \************************************/
  1953. /*! exports provided: ColorPicker */
  1954. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1955. "use strict";
  1956. __webpack_require__.r(__webpack_exports__);
  1957. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1958. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1959. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1960. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1961. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1962. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1963. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1964. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1965. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1966. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1967. /** Class used to create color pickers */
  1968. var ColorPicker = /** @class */ (function (_super) {
  1969. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1970. /**
  1971. * Creates a new ColorPicker
  1972. * @param name defines the control name
  1973. */
  1974. function ColorPicker(name) {
  1975. var _this = _super.call(this, name) || this;
  1976. _this.name = name;
  1977. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1978. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1979. _this._pointerStartedOnSquare = false;
  1980. _this._pointerStartedOnWheel = false;
  1981. _this._squareLeft = 0;
  1982. _this._squareTop = 0;
  1983. _this._squareSize = 0;
  1984. _this._h = 360;
  1985. _this._s = 1;
  1986. _this._v = 1;
  1987. _this._lastPointerDownID = -1;
  1988. /**
  1989. * Observable raised when the value changes
  1990. */
  1991. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1992. // Events
  1993. _this._pointerIsDown = false;
  1994. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1995. _this.size = "200px";
  1996. _this.isPointerBlocker = true;
  1997. return _this;
  1998. }
  1999. Object.defineProperty(ColorPicker.prototype, "value", {
  2000. /** Gets or sets the color of the color picker */
  2001. get: function () {
  2002. return this._value;
  2003. },
  2004. set: function (value) {
  2005. if (this._value.equals(value)) {
  2006. return;
  2007. }
  2008. this._value.copyFrom(value);
  2009. this._value.toHSVToRef(this._tmpColor);
  2010. this._h = this._tmpColor.r;
  2011. this._s = Math.max(this._tmpColor.g, 0.00001);
  2012. this._v = Math.max(this._tmpColor.b, 0.00001);
  2013. this._markAsDirty();
  2014. if (this._value.r <= ColorPicker._Epsilon) {
  2015. this._value.r = 0;
  2016. }
  2017. if (this._value.g <= ColorPicker._Epsilon) {
  2018. this._value.g = 0;
  2019. }
  2020. if (this._value.b <= ColorPicker._Epsilon) {
  2021. this._value.b = 0;
  2022. }
  2023. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  2024. this._value.r = 1.0;
  2025. }
  2026. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  2027. this._value.g = 1.0;
  2028. }
  2029. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  2030. this._value.b = 1.0;
  2031. }
  2032. this.onValueChangedObservable.notifyObservers(this._value);
  2033. },
  2034. enumerable: false,
  2035. configurable: true
  2036. });
  2037. Object.defineProperty(ColorPicker.prototype, "width", {
  2038. /**
  2039. * Gets or sets control width
  2040. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  2041. */
  2042. get: function () {
  2043. return this._width.toString(this._host);
  2044. },
  2045. set: function (value) {
  2046. if (this._width.toString(this._host) === value) {
  2047. return;
  2048. }
  2049. if (this._width.fromString(value)) {
  2050. this._height.fromString(value);
  2051. this._markAsDirty();
  2052. }
  2053. },
  2054. enumerable: false,
  2055. configurable: true
  2056. });
  2057. Object.defineProperty(ColorPicker.prototype, "height", {
  2058. /**
  2059. * Gets or sets control height
  2060. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  2061. */
  2062. get: function () {
  2063. return this._height.toString(this._host);
  2064. },
  2065. /** Gets or sets control height */
  2066. set: function (value) {
  2067. if (this._height.toString(this._host) === value) {
  2068. return;
  2069. }
  2070. if (this._height.fromString(value)) {
  2071. this._width.fromString(value);
  2072. this._markAsDirty();
  2073. }
  2074. },
  2075. enumerable: false,
  2076. configurable: true
  2077. });
  2078. Object.defineProperty(ColorPicker.prototype, "size", {
  2079. /** Gets or sets control size */
  2080. get: function () {
  2081. return this.width;
  2082. },
  2083. set: function (value) {
  2084. this.width = value;
  2085. },
  2086. enumerable: false,
  2087. configurable: true
  2088. });
  2089. ColorPicker.prototype._getTypeName = function () {
  2090. return "ColorPicker";
  2091. };
  2092. /** @hidden */
  2093. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  2094. if (parentMeasure.width < parentMeasure.height) {
  2095. this._currentMeasure.height = parentMeasure.width;
  2096. }
  2097. else {
  2098. this._currentMeasure.width = parentMeasure.height;
  2099. }
  2100. };
  2101. ColorPicker.prototype._updateSquareProps = function () {
  2102. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2103. var wheelThickness = radius * .2;
  2104. var innerDiameter = (radius - wheelThickness) * 2;
  2105. var squareSize = innerDiameter / (Math.sqrt(2));
  2106. var offset = radius - squareSize * .5;
  2107. this._squareLeft = this._currentMeasure.left + offset;
  2108. this._squareTop = this._currentMeasure.top + offset;
  2109. this._squareSize = squareSize;
  2110. };
  2111. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  2112. var lgh = context.createLinearGradient(left, top, width + left, top);
  2113. lgh.addColorStop(0, '#fff');
  2114. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  2115. context.fillStyle = lgh;
  2116. context.fillRect(left, top, width, height);
  2117. var lgv = context.createLinearGradient(left, top, left, height + top);
  2118. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  2119. lgv.addColorStop(1, '#000');
  2120. context.fillStyle = lgv;
  2121. context.fillRect(left, top, width, height);
  2122. };
  2123. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  2124. context.beginPath();
  2125. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  2126. context.lineWidth = 3;
  2127. context.strokeStyle = '#333333';
  2128. context.stroke();
  2129. context.beginPath();
  2130. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  2131. context.lineWidth = 3;
  2132. context.strokeStyle = '#ffffff';
  2133. context.stroke();
  2134. };
  2135. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  2136. var canvas = document.createElement("canvas");
  2137. canvas.width = radius * 2;
  2138. canvas.height = radius * 2;
  2139. var context = canvas.getContext("2d");
  2140. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  2141. var data = image.data;
  2142. var color = this._tmpColor;
  2143. var maxDistSq = radius * radius;
  2144. var innerRadius = radius - thickness;
  2145. var minDistSq = innerRadius * innerRadius;
  2146. for (var x = -radius; x < radius; x++) {
  2147. for (var y = -radius; y < radius; y++) {
  2148. var distSq = x * x + y * y;
  2149. if (distSq > maxDistSq || distSq < minDistSq) {
  2150. continue;
  2151. }
  2152. var dist = Math.sqrt(distSq);
  2153. var ang = Math.atan2(y, x);
  2154. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  2155. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  2156. data[index] = color.r * 255;
  2157. data[index + 1] = color.g * 255;
  2158. data[index + 2] = color.b * 255;
  2159. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2160. //apply less alpha to bigger color pickers
  2161. var alphaAmount = .2;
  2162. var maxAlpha = .2;
  2163. var minAlpha = .04;
  2164. var lowerRadius = 50;
  2165. var upperRadius = 150;
  2166. if (radius < lowerRadius) {
  2167. alphaAmount = maxAlpha;
  2168. }
  2169. else if (radius > upperRadius) {
  2170. alphaAmount = minAlpha;
  2171. }
  2172. else {
  2173. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  2174. }
  2175. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2176. if (alphaRatio < alphaAmount) {
  2177. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  2178. }
  2179. else if (alphaRatio > 1 - alphaAmount) {
  2180. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  2181. }
  2182. else {
  2183. data[index + 3] = 255;
  2184. }
  2185. }
  2186. }
  2187. context.putImageData(image, 0, 0);
  2188. return canvas;
  2189. };
  2190. /** @hidden */
  2191. ColorPicker.prototype._draw = function (context) {
  2192. context.save();
  2193. this._applyStates(context);
  2194. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2195. var wheelThickness = radius * .2;
  2196. var left = this._currentMeasure.left;
  2197. var top = this._currentMeasure.top;
  2198. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2199. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2200. }
  2201. this._updateSquareProps();
  2202. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2203. context.shadowColor = this.shadowColor;
  2204. context.shadowBlur = this.shadowBlur;
  2205. context.shadowOffsetX = this.shadowOffsetX;
  2206. context.shadowOffsetY = this.shadowOffsetY;
  2207. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2208. }
  2209. context.drawImage(this._colorWheelCanvas, left, top);
  2210. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2211. context.shadowBlur = 0;
  2212. context.shadowOffsetX = 0;
  2213. context.shadowOffsetY = 0;
  2214. }
  2215. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2216. var cx = this._squareLeft + this._squareSize * this._s;
  2217. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2218. this._drawCircle(cx, cy, radius * .04, context);
  2219. var dist = radius - wheelThickness * .5;
  2220. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2221. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2222. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2223. context.restore();
  2224. };
  2225. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2226. if (this._pointerStartedOnWheel) {
  2227. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2228. var centerX = radius + this._currentMeasure.left;
  2229. var centerY = radius + this._currentMeasure.top;
  2230. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2231. }
  2232. else if (this._pointerStartedOnSquare) {
  2233. this._updateSquareProps();
  2234. this._s = (x - this._squareLeft) / this._squareSize;
  2235. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2236. this._s = Math.min(this._s, 1);
  2237. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2238. this._v = Math.min(this._v, 1);
  2239. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2240. }
  2241. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2242. this.value = this._tmpColor;
  2243. };
  2244. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2245. this._updateSquareProps();
  2246. var left = this._squareLeft;
  2247. var top = this._squareTop;
  2248. var size = this._squareSize;
  2249. if (x >= left && x <= left + size &&
  2250. y >= top && y <= top + size) {
  2251. return true;
  2252. }
  2253. return false;
  2254. };
  2255. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2256. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2257. var centerX = radius + this._currentMeasure.left;
  2258. var centerY = radius + this._currentMeasure.top;
  2259. var wheelThickness = radius * .2;
  2260. var innerRadius = radius - wheelThickness;
  2261. var radiusSq = radius * radius;
  2262. var innerRadiusSq = innerRadius * innerRadius;
  2263. var dx = x - centerX;
  2264. var dy = y - centerY;
  2265. var distSq = dx * dx + dy * dy;
  2266. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2267. return true;
  2268. }
  2269. return false;
  2270. };
  2271. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  2272. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  2273. return false;
  2274. }
  2275. this._pointerIsDown = true;
  2276. this._pointerStartedOnSquare = false;
  2277. this._pointerStartedOnWheel = false;
  2278. // Invert transform
  2279. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2280. var x = this._transformedPosition.x;
  2281. var y = this._transformedPosition.y;
  2282. if (this._isPointOnSquare(x, y)) {
  2283. this._pointerStartedOnSquare = true;
  2284. }
  2285. else if (this._isPointOnWheel(x, y)) {
  2286. this._pointerStartedOnWheel = true;
  2287. }
  2288. this._updateValueFromPointer(x, y);
  2289. this._host._capturingControl[pointerId] = this;
  2290. this._lastPointerDownID = pointerId;
  2291. return true;
  2292. };
  2293. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  2294. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2295. if (pointerId != this._lastPointerDownID) {
  2296. return;
  2297. }
  2298. // Invert transform
  2299. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2300. var x = this._transformedPosition.x;
  2301. var y = this._transformedPosition.y;
  2302. if (this._pointerIsDown) {
  2303. this._updateValueFromPointer(x, y);
  2304. }
  2305. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
  2306. };
  2307. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  2308. this._pointerIsDown = false;
  2309. delete this._host._capturingControl[pointerId];
  2310. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick, pi);
  2311. };
  2312. ColorPicker.prototype._onCanvasBlur = function () {
  2313. this._forcePointerUp();
  2314. _super.prototype._onCanvasBlur.call(this);
  2315. };
  2316. /**
  2317. * This function expands the color picker by creating a color picker dialog with manual
  2318. * color value input and the ability to save colors into an array to be used later in
  2319. * subsequent launches of the dialogue.
  2320. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2321. * @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.
  2322. * @returns picked color as a hex string and the saved colors array as hex strings.
  2323. */
  2324. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2325. return new Promise(function (resolve, reject) {
  2326. // Default options
  2327. options.pickerWidth = options.pickerWidth || "640px";
  2328. options.pickerHeight = options.pickerHeight || "400px";
  2329. options.headerHeight = options.headerHeight || "35px";
  2330. options.lastColor = options.lastColor || "#000000";
  2331. options.swatchLimit = options.swatchLimit || 20;
  2332. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2333. // Window size settings
  2334. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2335. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2336. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2337. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2338. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2339. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2340. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2341. // Button Colors
  2342. var buttonColor = "#c0c0c0";
  2343. var buttonBackgroundColor = "#535353";
  2344. var buttonBackgroundHoverColor = "#414141";
  2345. var buttonBackgroundClickColor = "515151";
  2346. var buttonDisabledColor = "#555555";
  2347. var buttonDisabledBackgroundColor = "#454545";
  2348. var currentSwatchesOutlineColor = "#404040";
  2349. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2350. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2351. var iconColorDark = "#aaaaaa";
  2352. var iconColorLight = "#ffffff";
  2353. var closeIconColor;
  2354. // Button settings
  2355. var buttonFontSize;
  2356. var butEdit;
  2357. var buttonWidth;
  2358. var buttonHeight;
  2359. // Input Text Colors
  2360. var inputFieldLabels = ["R", "G", "B"];
  2361. var inputTextBackgroundColor = "#454545";
  2362. var inputTextColor = "#f0f0f0";
  2363. // This is the current color as set by either the picker or by entering a value
  2364. var currentColor;
  2365. // This int is used for naming swatches and serves as the index for calling them from the list
  2366. var swatchNumber;
  2367. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2368. var swatchDrawer;
  2369. var editSwatchMode = false;
  2370. // Color InputText fields that will be updated upon value change
  2371. var picker;
  2372. var rValInt;
  2373. var gValInt;
  2374. var bValInt;
  2375. var rValDec;
  2376. var gValDec;
  2377. var bValDec;
  2378. var hexVal;
  2379. var newSwatch;
  2380. var lastVal;
  2381. var activeField;
  2382. /**
  2383. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2384. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2385. * are will receive no update. This is to prevent the input from the user being overwritten.
  2386. */
  2387. function updateValues(value, inputField) {
  2388. activeField = inputField;
  2389. var pickedColor = value.toHexString();
  2390. newSwatch.background = pickedColor;
  2391. if (rValInt.name != activeField) {
  2392. rValInt.text = Math.floor(value.r * 255).toString();
  2393. }
  2394. if (gValInt.name != activeField) {
  2395. gValInt.text = Math.floor(value.g * 255).toString();
  2396. }
  2397. if (bValInt.name != activeField) {
  2398. bValInt.text = Math.floor(value.b * 255).toString();
  2399. }
  2400. if (rValDec.name != activeField) {
  2401. rValDec.text = value.r.toString();
  2402. }
  2403. if (gValDec.name != activeField) {
  2404. gValDec.text = value.g.toString();
  2405. }
  2406. if (bValDec.name != activeField) {
  2407. bValDec.text = value.b.toString();
  2408. }
  2409. if (hexVal.name != activeField) {
  2410. var minusPound = pickedColor.split("#");
  2411. hexVal.text = minusPound[1];
  2412. }
  2413. if (picker.name != activeField) {
  2414. picker.value = value;
  2415. }
  2416. }
  2417. // 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.
  2418. function updateInt(field, channel) {
  2419. var newValue = field.text;
  2420. var checkVal = /[^0-9]/g.test(newValue);
  2421. if (checkVal) {
  2422. field.text = lastVal;
  2423. return;
  2424. }
  2425. else {
  2426. if (newValue != "") {
  2427. if (Math.floor(parseInt(newValue)) < 0) {
  2428. newValue = "0";
  2429. }
  2430. else if (Math.floor(parseInt(newValue)) > 255) {
  2431. newValue = "255";
  2432. }
  2433. else if (isNaN(parseInt(newValue))) {
  2434. newValue = "0";
  2435. }
  2436. }
  2437. if (activeField == field.name) {
  2438. lastVal = newValue;
  2439. }
  2440. }
  2441. if (newValue != "") {
  2442. newValue = parseInt(newValue).toString();
  2443. field.text = newValue;
  2444. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2445. if (activeField == field.name) {
  2446. if (channel == "r") {
  2447. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2448. }
  2449. else if (channel == "g") {
  2450. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2451. }
  2452. else {
  2453. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2454. }
  2455. }
  2456. }
  2457. }
  2458. // 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.
  2459. function updateFloat(field, channel) {
  2460. var newValue = field.text;
  2461. var checkVal = /[^0-9\.]/g.test(newValue);
  2462. if (checkVal) {
  2463. field.text = lastVal;
  2464. return;
  2465. }
  2466. else {
  2467. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2468. if (parseFloat(newValue) < 0.0) {
  2469. newValue = "0.0";
  2470. }
  2471. else if (parseFloat(newValue) > 1.0) {
  2472. newValue = "1.0";
  2473. }
  2474. else if (isNaN(parseFloat(newValue))) {
  2475. newValue = "0.0";
  2476. }
  2477. }
  2478. if (activeField == field.name) {
  2479. lastVal = newValue;
  2480. }
  2481. }
  2482. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2483. newValue = parseFloat(newValue).toString();
  2484. field.text = newValue;
  2485. }
  2486. else {
  2487. newValue = "0.0";
  2488. }
  2489. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2490. if (activeField == field.name) {
  2491. if (channel == "r") {
  2492. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2493. }
  2494. else if (channel == "g") {
  2495. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2496. }
  2497. else {
  2498. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2499. }
  2500. }
  2501. }
  2502. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2503. function deleteSwatch(index) {
  2504. if (options.savedColors) {
  2505. options.savedColors.splice(index, 1);
  2506. }
  2507. if (options.savedColors && options.savedColors.length == 0) {
  2508. setEditButtonVisibility(false);
  2509. editSwatchMode = false;
  2510. }
  2511. }
  2512. // Creates and styles an individual swatch when updateSwatches is called.
  2513. function createSwatch() {
  2514. if (options.savedColors && options.savedColors[swatchNumber]) {
  2515. if (editSwatchMode) {
  2516. var icon = "b";
  2517. }
  2518. else {
  2519. var icon = "";
  2520. }
  2521. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2522. swatch.fontFamily = "BabylonJSglyphs";
  2523. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2524. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2525. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2526. if (swatchLuminence > luminanceLimit) {
  2527. swatch.color = iconColorDark;
  2528. }
  2529. else {
  2530. swatch.color = iconColorLight;
  2531. }
  2532. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2533. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2534. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2535. swatch.background = options.savedColors[swatchNumber];
  2536. swatch.thickness = 2;
  2537. var metadata_1 = swatchNumber;
  2538. swatch.pointerDownAnimation = function () {
  2539. swatch.thickness = 4;
  2540. };
  2541. swatch.pointerUpAnimation = function () {
  2542. swatch.thickness = 3;
  2543. };
  2544. swatch.pointerEnterAnimation = function () {
  2545. swatch.thickness = 3;
  2546. };
  2547. swatch.pointerOutAnimation = function () {
  2548. swatch.thickness = 2;
  2549. };
  2550. swatch.onPointerClickObservable.add(function () {
  2551. if (!editSwatchMode) {
  2552. if (options.savedColors) {
  2553. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2554. }
  2555. }
  2556. else {
  2557. deleteSwatch(metadata_1);
  2558. updateSwatches("", butSave);
  2559. }
  2560. });
  2561. return swatch;
  2562. }
  2563. else {
  2564. return null;
  2565. }
  2566. }
  2567. // Mode switch to render button text and close symbols on swatch controls
  2568. function editSwatches(mode) {
  2569. if (mode !== undefined) {
  2570. editSwatchMode = mode;
  2571. }
  2572. if (editSwatchMode) {
  2573. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2574. var thisButton = swatchDrawer.children[i];
  2575. thisButton.textBlock.text = "b";
  2576. }
  2577. if (butEdit !== undefined) {
  2578. butEdit.textBlock.text = "Done";
  2579. }
  2580. }
  2581. else {
  2582. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2583. var thisButton = swatchDrawer.children[i];
  2584. thisButton.textBlock.text = "";
  2585. }
  2586. if (butEdit !== undefined) {
  2587. butEdit.textBlock.text = "Edit";
  2588. }
  2589. }
  2590. }
  2591. /**
  2592. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2593. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2594. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2595. * saved colors there are and how many can be stored per row.
  2596. */
  2597. function updateSwatches(color, button) {
  2598. if (options.savedColors) {
  2599. if (color != "") {
  2600. options.savedColors.push(color);
  2601. }
  2602. swatchNumber = 0;
  2603. swatchDrawer.clearControls();
  2604. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2605. if (rowCount == 0) {
  2606. var gutterCount = 0;
  2607. }
  2608. else {
  2609. var gutterCount = rowCount + 1;
  2610. }
  2611. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2612. var currentRows = swatchDrawer.rowCount;
  2613. for (var i = 0; i < currentRows; i++) {
  2614. swatchDrawer.removeRowDefinition(0);
  2615. }
  2616. for (var i = 0; i < rowCount + gutterCount; i++) {
  2617. if (i % 2) {
  2618. swatchDrawer.addRowDefinition(swatchSize, true);
  2619. }
  2620. else {
  2621. swatchDrawer.addRowDefinition(gutterSize, true);
  2622. }
  2623. }
  2624. }
  2625. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2626. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2627. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2628. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2629. var totalButtonsThisRow = options.numSwatchesPerLine;
  2630. }
  2631. else {
  2632. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2633. }
  2634. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2635. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2636. if (x > options.numSwatchesPerLine) {
  2637. continue;
  2638. }
  2639. var swatch = createSwatch();
  2640. if (swatch != null) {
  2641. swatchDrawer.addControl(swatch, y, w);
  2642. w += 2;
  2643. swatchNumber++;
  2644. }
  2645. else {
  2646. continue;
  2647. }
  2648. }
  2649. }
  2650. if (options.savedColors.length >= options.swatchLimit) {
  2651. disableButton(button, true);
  2652. }
  2653. else {
  2654. disableButton(button, false);
  2655. }
  2656. }
  2657. }
  2658. // Shows or hides edit swatches button depending on if there are saved swatches
  2659. function setEditButtonVisibility(enableButton) {
  2660. if (enableButton) {
  2661. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2662. butEdit.width = buttonWidth;
  2663. butEdit.height = buttonHeight;
  2664. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2665. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2666. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2667. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2668. butEdit.thickness = 2;
  2669. butEdit.color = buttonColor;
  2670. butEdit.fontSize = buttonFontSize;
  2671. butEdit.background = buttonBackgroundColor;
  2672. butEdit.onPointerEnterObservable.add(function () {
  2673. butEdit.background = buttonBackgroundHoverColor;
  2674. });
  2675. butEdit.onPointerOutObservable.add(function () {
  2676. butEdit.background = buttonBackgroundColor;
  2677. });
  2678. butEdit.pointerDownAnimation = function () {
  2679. butEdit.background = buttonBackgroundClickColor;
  2680. };
  2681. butEdit.pointerUpAnimation = function () {
  2682. butEdit.background = buttonBackgroundHoverColor;
  2683. };
  2684. butEdit.onPointerClickObservable.add(function () {
  2685. if (editSwatchMode) {
  2686. editSwatchMode = false;
  2687. }
  2688. else {
  2689. editSwatchMode = true;
  2690. }
  2691. editSwatches();
  2692. });
  2693. pickerGrid.addControl(butEdit, 1, 0);
  2694. }
  2695. else {
  2696. pickerGrid.removeControl(butEdit);
  2697. }
  2698. }
  2699. // Called when the user hits the limit of saved colors in the drawer.
  2700. function disableButton(button, disabled) {
  2701. if (disabled) {
  2702. button.color = buttonDisabledColor;
  2703. button.background = buttonDisabledBackgroundColor;
  2704. }
  2705. else {
  2706. button.color = buttonColor;
  2707. button.background = buttonBackgroundColor;
  2708. }
  2709. }
  2710. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2711. function closePicker(color) {
  2712. if (options.savedColors && options.savedColors.length > 0) {
  2713. resolve({
  2714. savedColors: options.savedColors,
  2715. pickedColor: color
  2716. });
  2717. }
  2718. else {
  2719. resolve({
  2720. pickedColor: color
  2721. });
  2722. }
  2723. advancedTexture.removeControl(dialogContainer);
  2724. }
  2725. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2726. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2727. dialogContainer.name = "Dialog Container";
  2728. dialogContainer.width = options.pickerWidth;
  2729. if (options.savedColors) {
  2730. dialogContainer.height = containerSize;
  2731. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2732. dialogContainer.addRowDefinition(topRow, false);
  2733. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2734. }
  2735. else {
  2736. dialogContainer.height = options.pickerHeight;
  2737. dialogContainer.addRowDefinition(1.0, false);
  2738. }
  2739. advancedTexture.addControl(dialogContainer);
  2740. // Swatch drawer which contains all saved color buttons
  2741. if (options.savedColors) {
  2742. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2743. swatchDrawer.name = "Swatch Drawer";
  2744. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2745. swatchDrawer.background = buttonBackgroundColor;
  2746. swatchDrawer.width = options.pickerWidth;
  2747. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2748. if (initialRows == 0) {
  2749. var gutterCount = 0;
  2750. }
  2751. else {
  2752. var gutterCount = initialRows + 1;
  2753. }
  2754. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2755. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2756. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2757. if (i % 2 != 0) {
  2758. swatchDrawer.addRowDefinition(swatchSize, true);
  2759. }
  2760. else {
  2761. swatchDrawer.addRowDefinition(gutterSize, true);
  2762. }
  2763. }
  2764. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2765. if (i % 2 != 0) {
  2766. swatchDrawer.addColumnDefinition(swatchSize, true);
  2767. }
  2768. else {
  2769. swatchDrawer.addColumnDefinition(gutterSize, true);
  2770. }
  2771. }
  2772. dialogContainer.addControl(swatchDrawer, 1, 0);
  2773. }
  2774. // Picker container
  2775. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2776. pickerPanel.name = "Picker Panel";
  2777. pickerPanel.height = options.pickerHeight;
  2778. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2779. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2780. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2781. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2782. dialogContainer.addControl(pickerPanel, 0, 0);
  2783. // Picker container header
  2784. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2785. header.name = "Dialogue Header Bar";
  2786. header.background = "#cccccc";
  2787. header.thickness = 0;
  2788. pickerPanel.addControl(header, 0, 0);
  2789. // Header close button
  2790. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2791. closeButton.fontFamily = "BabylonJSglyphs";
  2792. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2793. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2794. closeButton.color = closeIconColor.toHexString();
  2795. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2796. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2797. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2798. closeButton.height = closeButton.width = options.headerHeight;
  2799. closeButton.background = header.background;
  2800. closeButton.thickness = 0;
  2801. closeButton.pointerDownAnimation = function () {
  2802. };
  2803. closeButton.pointerUpAnimation = function () {
  2804. closeButton.background = header.background;
  2805. };
  2806. closeButton.pointerEnterAnimation = function () {
  2807. closeButton.color = header.background;
  2808. closeButton.background = "red";
  2809. };
  2810. closeButton.pointerOutAnimation = function () {
  2811. closeButton.color = closeIconColor.toHexString();
  2812. closeButton.background = header.background;
  2813. };
  2814. closeButton.onPointerClickObservable.add(function () {
  2815. closePicker(currentSwatch.background);
  2816. });
  2817. pickerPanel.addControl(closeButton, 0, 0);
  2818. // Dialog container body
  2819. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2820. dialogBody.name = "Dialogue Body";
  2821. dialogBody.background = buttonBackgroundColor;
  2822. var dialogBodyCols = [0.4375, 0.5625];
  2823. dialogBody.addRowDefinition(1.0, false);
  2824. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2825. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2826. pickerPanel.addControl(dialogBody, 1, 0);
  2827. // Picker grid
  2828. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2829. pickerGrid.name = "Picker Grid";
  2830. pickerGrid.addRowDefinition(0.85, false);
  2831. pickerGrid.addRowDefinition(0.15, false);
  2832. dialogBody.addControl(pickerGrid, 0, 0);
  2833. // Picker control
  2834. picker = new ColorPicker();
  2835. picker.name = "GUI Color Picker";
  2836. if (options.pickerHeight < options.pickerWidth) {
  2837. picker.width = 0.89;
  2838. }
  2839. else {
  2840. picker.height = 0.89;
  2841. }
  2842. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2843. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2844. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2845. picker.onPointerDownObservable.add(function () {
  2846. activeField = picker.name;
  2847. lastVal = "";
  2848. editSwatches(false);
  2849. });
  2850. picker.onValueChangedObservable.add(function (value) {
  2851. if (activeField == picker.name) {
  2852. updateValues(value, picker.name);
  2853. }
  2854. });
  2855. pickerGrid.addControl(picker, 0, 0);
  2856. // Picker body right quarant
  2857. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2858. pickerBodyRight.name = "Dialogue Right Half";
  2859. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2860. var pickerBodyRightRows = [0.514, 0.486];
  2861. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2862. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2863. dialogBody.addControl(pickerBodyRight, 1, 1);
  2864. // Picker container swatches and buttons
  2865. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2866. pickerSwatchesButtons.name = "Swatches and Buttons";
  2867. var pickerButtonsCol = [0.417, 0.583];
  2868. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2869. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2870. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2871. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2872. // Picker Swatches quadrant
  2873. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2874. pickerSwatches.name = "New and Current Swatches";
  2875. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2876. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2877. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2878. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2879. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2880. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2881. // Active swatches
  2882. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2883. activeSwatches.name = "Active Swatches";
  2884. activeSwatches.width = 0.67;
  2885. activeSwatches.addRowDefinition(0.5, false);
  2886. activeSwatches.addRowDefinition(0.5, false);
  2887. pickerSwatches.addControl(activeSwatches, 2, 0);
  2888. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2889. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2890. if (options.pickerWidth > options.pickerHeight) {
  2891. var labelTextSize = labelHeight;
  2892. }
  2893. else {
  2894. var labelTextSize = labelWidth;
  2895. }
  2896. // New color swatch and previous color button
  2897. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2898. newText.text = "new";
  2899. newText.name = "New Color Label";
  2900. newText.color = buttonColor;
  2901. newText.fontSize = labelTextSize;
  2902. pickerSwatches.addControl(newText, 1, 0);
  2903. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2904. newSwatch.name = "New Color Swatch";
  2905. newSwatch.background = options.lastColor;
  2906. newSwatch.thickness = 0;
  2907. activeSwatches.addControl(newSwatch, 0, 0);
  2908. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2909. currentSwatch.background = options.lastColor;
  2910. currentSwatch.thickness = 0;
  2911. currentSwatch.onPointerClickObservable.add(function () {
  2912. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2913. updateValues(revertColor, currentSwatch.name);
  2914. editSwatches(false);
  2915. });
  2916. currentSwatch.pointerDownAnimation = function () { };
  2917. currentSwatch.pointerUpAnimation = function () { };
  2918. currentSwatch.pointerEnterAnimation = function () { };
  2919. currentSwatch.pointerOutAnimation = function () { };
  2920. activeSwatches.addControl(currentSwatch, 1, 0);
  2921. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2922. swatchOutline.name = "Swatch Outline";
  2923. swatchOutline.width = 0.67;
  2924. swatchOutline.thickness = 2;
  2925. swatchOutline.color = currentSwatchesOutlineColor;
  2926. swatchOutline.isHitTestVisible = false;
  2927. pickerSwatches.addControl(swatchOutline, 2, 0);
  2928. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2929. currentText.name = "Current Color Label";
  2930. currentText.text = "current";
  2931. currentText.color = buttonColor;
  2932. currentText.fontSize = labelTextSize;
  2933. pickerSwatches.addControl(currentText, 3, 0);
  2934. // Buttons grid
  2935. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2936. buttonGrid.name = "Button Grid";
  2937. buttonGrid.height = 0.8;
  2938. var buttonGridRows = 1 / 3;
  2939. buttonGrid.addRowDefinition(buttonGridRows, false);
  2940. buttonGrid.addRowDefinition(buttonGridRows, false);
  2941. buttonGrid.addRowDefinition(buttonGridRows, false);
  2942. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2943. // Determine pixel width and height for all buttons from overall panel dimensions
  2944. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2945. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2946. // Determine button type size
  2947. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2948. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2949. }
  2950. else {
  2951. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2952. }
  2953. // Panel Buttons
  2954. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2955. butOK.width = buttonWidth;
  2956. butOK.height = buttonHeight;
  2957. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2958. butOK.thickness = 2;
  2959. butOK.color = buttonColor;
  2960. butOK.fontSize = buttonFontSize;
  2961. butOK.background = buttonBackgroundColor;
  2962. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2963. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2964. butOK.pointerDownAnimation = function () {
  2965. butOK.background = buttonBackgroundClickColor;
  2966. };
  2967. butOK.pointerUpAnimation = function () {
  2968. butOK.background = buttonBackgroundHoverColor;
  2969. };
  2970. butOK.onPointerClickObservable.add(function () {
  2971. editSwatches(false);
  2972. closePicker(newSwatch.background);
  2973. });
  2974. buttonGrid.addControl(butOK, 0, 0);
  2975. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2976. butCancel.width = buttonWidth;
  2977. butCancel.height = buttonHeight;
  2978. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2979. butCancel.thickness = 2;
  2980. butCancel.color = buttonColor;
  2981. butCancel.fontSize = buttonFontSize;
  2982. butCancel.background = buttonBackgroundColor;
  2983. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2984. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2985. butCancel.pointerDownAnimation = function () {
  2986. butCancel.background = buttonBackgroundClickColor;
  2987. };
  2988. butCancel.pointerUpAnimation = function () {
  2989. butCancel.background = buttonBackgroundHoverColor;
  2990. };
  2991. butCancel.onPointerClickObservable.add(function () {
  2992. editSwatches(false);
  2993. closePicker(currentSwatch.background);
  2994. });
  2995. buttonGrid.addControl(butCancel, 1, 0);
  2996. if (options.savedColors) {
  2997. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2998. butSave.width = buttonWidth;
  2999. butSave.height = buttonHeight;
  3000. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  3001. butSave.thickness = 2;
  3002. butSave.fontSize = buttonFontSize;
  3003. if (options.savedColors.length < options.swatchLimit) {
  3004. butSave.color = buttonColor;
  3005. butSave.background = buttonBackgroundColor;
  3006. }
  3007. else {
  3008. disableButton(butSave, true);
  3009. }
  3010. butSave.onPointerEnterObservable.add(function () {
  3011. if (options.savedColors) {
  3012. if (options.savedColors.length < options.swatchLimit) {
  3013. butSave.background = buttonBackgroundHoverColor;
  3014. }
  3015. }
  3016. });
  3017. butSave.onPointerOutObservable.add(function () {
  3018. if (options.savedColors) {
  3019. if (options.savedColors.length < options.swatchLimit) {
  3020. butSave.background = buttonBackgroundColor;
  3021. }
  3022. }
  3023. });
  3024. butSave.pointerDownAnimation = function () {
  3025. if (options.savedColors) {
  3026. if (options.savedColors.length < options.swatchLimit) {
  3027. butSave.background = buttonBackgroundClickColor;
  3028. }
  3029. }
  3030. };
  3031. butSave.pointerUpAnimation = function () {
  3032. if (options.savedColors) {
  3033. if (options.savedColors.length < options.swatchLimit) {
  3034. butSave.background = buttonBackgroundHoverColor;
  3035. }
  3036. }
  3037. };
  3038. butSave.onPointerClickObservable.add(function () {
  3039. if (options.savedColors) {
  3040. if (options.savedColors.length == 0) {
  3041. setEditButtonVisibility(true);
  3042. }
  3043. if (options.savedColors.length < options.swatchLimit) {
  3044. updateSwatches(newSwatch.background, butSave);
  3045. }
  3046. editSwatches(false);
  3047. }
  3048. });
  3049. if (options.savedColors.length > 0) {
  3050. setEditButtonVisibility(true);
  3051. }
  3052. buttonGrid.addControl(butSave, 2, 0);
  3053. }
  3054. // Picker color values input
  3055. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3056. pickerColorValues.name = "Dialog Lower Right";
  3057. pickerColorValues.addRowDefinition(0.02, false);
  3058. pickerColorValues.addRowDefinition(0.63, false);
  3059. pickerColorValues.addRowDefinition(0.21, false);
  3060. pickerColorValues.addRowDefinition(0.14, false);
  3061. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  3062. // RGB values text boxes
  3063. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  3064. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3065. rgbValuesQuadrant.name = "RGB Values";
  3066. rgbValuesQuadrant.width = 0.82;
  3067. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  3068. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  3069. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  3070. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  3071. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  3072. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  3073. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  3074. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  3075. for (var i = 0; i < inputFieldLabels.length; i++) {
  3076. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3077. labelText.text = inputFieldLabels[i];
  3078. labelText.color = buttonColor;
  3079. labelText.fontSize = buttonFontSize;
  3080. rgbValuesQuadrant.addControl(labelText, i, 0);
  3081. }
  3082. // Input fields for RGB values
  3083. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3084. rValInt.width = 0.83;
  3085. rValInt.height = 0.72;
  3086. rValInt.name = "rIntField";
  3087. rValInt.fontSize = buttonFontSize;
  3088. rValInt.text = (currentColor.r * 255).toString();
  3089. rValInt.color = inputTextColor;
  3090. rValInt.background = inputTextBackgroundColor;
  3091. rValInt.onFocusObservable.add(function () {
  3092. activeField = rValInt.name;
  3093. lastVal = rValInt.text;
  3094. editSwatches(false);
  3095. });
  3096. rValInt.onBlurObservable.add(function () {
  3097. if (rValInt.text == "") {
  3098. rValInt.text = "0";
  3099. }
  3100. updateInt(rValInt, "r");
  3101. if (activeField == rValInt.name) {
  3102. activeField = "";
  3103. }
  3104. });
  3105. rValInt.onTextChangedObservable.add(function () {
  3106. if (activeField == rValInt.name) {
  3107. updateInt(rValInt, "r");
  3108. }
  3109. });
  3110. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  3111. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3112. gValInt.width = 0.83;
  3113. gValInt.height = 0.72;
  3114. gValInt.name = "gIntField";
  3115. gValInt.fontSize = buttonFontSize;
  3116. gValInt.text = (currentColor.g * 255).toString();
  3117. gValInt.color = inputTextColor;
  3118. gValInt.background = inputTextBackgroundColor;
  3119. gValInt.onFocusObservable.add(function () {
  3120. activeField = gValInt.name;
  3121. lastVal = gValInt.text;
  3122. editSwatches(false);
  3123. });
  3124. gValInt.onBlurObservable.add(function () {
  3125. if (gValInt.text == "") {
  3126. gValInt.text = "0";
  3127. }
  3128. updateInt(gValInt, "g");
  3129. if (activeField == gValInt.name) {
  3130. activeField = "";
  3131. }
  3132. });
  3133. gValInt.onTextChangedObservable.add(function () {
  3134. if (activeField == gValInt.name) {
  3135. updateInt(gValInt, "g");
  3136. }
  3137. });
  3138. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  3139. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3140. bValInt.width = 0.83;
  3141. bValInt.height = 0.72;
  3142. bValInt.name = "bIntField";
  3143. bValInt.fontSize = buttonFontSize;
  3144. bValInt.text = (currentColor.b * 255).toString();
  3145. bValInt.color = inputTextColor;
  3146. bValInt.background = inputTextBackgroundColor;
  3147. bValInt.onFocusObservable.add(function () {
  3148. activeField = bValInt.name;
  3149. lastVal = bValInt.text;
  3150. editSwatches(false);
  3151. });
  3152. bValInt.onBlurObservable.add(function () {
  3153. if (bValInt.text == "") {
  3154. bValInt.text = "0";
  3155. }
  3156. updateInt(bValInt, "b");
  3157. if (activeField == bValInt.name) {
  3158. activeField = "";
  3159. }
  3160. });
  3161. bValInt.onTextChangedObservable.add(function () {
  3162. if (activeField == bValInt.name) {
  3163. updateInt(bValInt, "b");
  3164. }
  3165. });
  3166. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  3167. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3168. rValDec.width = 0.95;
  3169. rValDec.height = 0.72;
  3170. rValDec.name = "rDecField";
  3171. rValDec.fontSize = buttonFontSize;
  3172. rValDec.text = currentColor.r.toString();
  3173. rValDec.color = inputTextColor;
  3174. rValDec.background = inputTextBackgroundColor;
  3175. rValDec.onFocusObservable.add(function () {
  3176. activeField = rValDec.name;
  3177. lastVal = rValDec.text;
  3178. editSwatches(false);
  3179. });
  3180. rValDec.onBlurObservable.add(function () {
  3181. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3182. rValDec.text = "0";
  3183. updateFloat(rValDec, "r");
  3184. }
  3185. if (activeField == rValDec.name) {
  3186. activeField = "";
  3187. }
  3188. });
  3189. rValDec.onTextChangedObservable.add(function () {
  3190. if (activeField == rValDec.name) {
  3191. updateFloat(rValDec, "r");
  3192. }
  3193. });
  3194. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3195. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3196. gValDec.width = 0.95;
  3197. gValDec.height = 0.72;
  3198. gValDec.name = "gDecField";
  3199. gValDec.fontSize = buttonFontSize;
  3200. gValDec.text = currentColor.g.toString();
  3201. gValDec.color = inputTextColor;
  3202. gValDec.background = inputTextBackgroundColor;
  3203. gValDec.onFocusObservable.add(function () {
  3204. activeField = gValDec.name;
  3205. lastVal = gValDec.text;
  3206. editSwatches(false);
  3207. });
  3208. gValDec.onBlurObservable.add(function () {
  3209. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3210. gValDec.text = "0";
  3211. updateFloat(gValDec, "g");
  3212. }
  3213. if (activeField == gValDec.name) {
  3214. activeField = "";
  3215. }
  3216. });
  3217. gValDec.onTextChangedObservable.add(function () {
  3218. if (activeField == gValDec.name) {
  3219. updateFloat(gValDec, "g");
  3220. }
  3221. });
  3222. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3223. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3224. bValDec.width = 0.95;
  3225. bValDec.height = 0.72;
  3226. bValDec.name = "bDecField";
  3227. bValDec.fontSize = buttonFontSize;
  3228. bValDec.text = currentColor.b.toString();
  3229. bValDec.color = inputTextColor;
  3230. bValDec.background = inputTextBackgroundColor;
  3231. bValDec.onFocusObservable.add(function () {
  3232. activeField = bValDec.name;
  3233. lastVal = bValDec.text;
  3234. editSwatches(false);
  3235. });
  3236. bValDec.onBlurObservable.add(function () {
  3237. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3238. bValDec.text = "0";
  3239. updateFloat(bValDec, "b");
  3240. }
  3241. if (activeField == bValDec.name) {
  3242. activeField = "";
  3243. }
  3244. });
  3245. bValDec.onTextChangedObservable.add(function () {
  3246. if (activeField == bValDec.name) {
  3247. updateFloat(bValDec, "b");
  3248. }
  3249. });
  3250. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3251. // Hex value input
  3252. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3253. hexValueQuadrant.name = "Hex Value";
  3254. hexValueQuadrant.width = 0.82;
  3255. hexValueQuadrant.addRowDefinition(1.0, false);
  3256. hexValueQuadrant.addColumnDefinition(0.1, false);
  3257. hexValueQuadrant.addColumnDefinition(0.9, false);
  3258. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3259. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3260. labelText.text = "#";
  3261. labelText.color = buttonColor;
  3262. labelText.fontSize = buttonFontSize;
  3263. hexValueQuadrant.addControl(labelText, 0, 0);
  3264. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3265. hexVal.width = 0.96;
  3266. hexVal.height = 0.72;
  3267. hexVal.name = "hexField";
  3268. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3269. hexVal.fontSize = buttonFontSize;
  3270. var minusPound = options.lastColor.split("#");
  3271. hexVal.text = minusPound[1];
  3272. hexVal.color = inputTextColor;
  3273. hexVal.background = inputTextBackgroundColor;
  3274. hexVal.onFocusObservable.add(function () {
  3275. activeField = hexVal.name;
  3276. lastVal = hexVal.text;
  3277. editSwatches(false);
  3278. });
  3279. hexVal.onBlurObservable.add(function () {
  3280. if (hexVal.text.length == 3) {
  3281. var val = hexVal.text.split("");
  3282. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3283. }
  3284. if (hexVal.text == "") {
  3285. hexVal.text = "000000";
  3286. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3287. }
  3288. if (activeField == hexVal.name) {
  3289. activeField = "";
  3290. }
  3291. });
  3292. hexVal.onTextChangedObservable.add(function () {
  3293. var newHexValue = hexVal.text;
  3294. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3295. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3296. hexVal.text = lastVal;
  3297. }
  3298. else {
  3299. if (hexVal.text.length < 6) {
  3300. var leadingZero = 6 - hexVal.text.length;
  3301. for (var i = 0; i < leadingZero; i++) {
  3302. newHexValue = "0" + newHexValue;
  3303. }
  3304. }
  3305. if (hexVal.text.length == 3) {
  3306. var val = hexVal.text.split("");
  3307. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3308. }
  3309. newHexValue = "#" + newHexValue;
  3310. if (activeField == hexVal.name) {
  3311. lastVal = hexVal.text;
  3312. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3313. }
  3314. }
  3315. });
  3316. hexValueQuadrant.addControl(hexVal, 0, 1);
  3317. if (options.savedColors && options.savedColors.length > 0) {
  3318. updateSwatches("", butSave);
  3319. }
  3320. });
  3321. };
  3322. ColorPicker._Epsilon = 0.000001;
  3323. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3324. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3325. ], ColorPicker.prototype, "value", null);
  3326. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3327. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3328. ], ColorPicker.prototype, "width", null);
  3329. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3330. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3331. ], ColorPicker.prototype, "height", null);
  3332. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3333. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3334. ], ColorPicker.prototype, "size", null);
  3335. return ColorPicker;
  3336. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3337. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3338. /***/ }),
  3339. /***/ "./2D/controls/container.ts":
  3340. /*!**********************************!*\
  3341. !*** ./2D/controls/container.ts ***!
  3342. \**********************************/
  3343. /*! exports provided: Container */
  3344. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3345. "use strict";
  3346. __webpack_require__.r(__webpack_exports__);
  3347. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3348. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3349. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/perfCounter");
  3350. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3351. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3352. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3353. /**
  3354. * Root class for 2D containers
  3355. * @see https://doc.babylonjs.com/how_to/gui#containers
  3356. */
  3357. var Container = /** @class */ (function (_super) {
  3358. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3359. /**
  3360. * Creates a new Container
  3361. * @param name defines the name of the container
  3362. */
  3363. function Container(name) {
  3364. var _this = _super.call(this, name) || this;
  3365. _this.name = name;
  3366. /** @hidden */
  3367. _this._children = new Array();
  3368. /** @hidden */
  3369. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3370. /** @hidden */
  3371. _this._background = "";
  3372. /** @hidden */
  3373. _this._adaptWidthToChildren = false;
  3374. /** @hidden */
  3375. _this._adaptHeightToChildren = false;
  3376. /**
  3377. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3378. */
  3379. _this.logLayoutCycleErrors = false;
  3380. /**
  3381. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3382. */
  3383. _this.maxLayoutCycle = 3;
  3384. return _this;
  3385. }
  3386. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3387. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3388. get: function () {
  3389. return this._adaptHeightToChildren;
  3390. },
  3391. set: function (value) {
  3392. if (this._adaptHeightToChildren === value) {
  3393. return;
  3394. }
  3395. this._adaptHeightToChildren = value;
  3396. if (value) {
  3397. this.height = "100%";
  3398. }
  3399. this._markAsDirty();
  3400. },
  3401. enumerable: false,
  3402. configurable: true
  3403. });
  3404. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3405. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3406. get: function () {
  3407. return this._adaptWidthToChildren;
  3408. },
  3409. set: function (value) {
  3410. if (this._adaptWidthToChildren === value) {
  3411. return;
  3412. }
  3413. this._adaptWidthToChildren = value;
  3414. if (value) {
  3415. this.width = "100%";
  3416. }
  3417. this._markAsDirty();
  3418. },
  3419. enumerable: false,
  3420. configurable: true
  3421. });
  3422. Object.defineProperty(Container.prototype, "background", {
  3423. /** Gets or sets background color */
  3424. get: function () {
  3425. return this._background;
  3426. },
  3427. set: function (value) {
  3428. if (this._background === value) {
  3429. return;
  3430. }
  3431. this._background = value;
  3432. this._markAsDirty();
  3433. },
  3434. enumerable: false,
  3435. configurable: true
  3436. });
  3437. Object.defineProperty(Container.prototype, "children", {
  3438. /** Gets the list of children */
  3439. get: function () {
  3440. return this._children;
  3441. },
  3442. enumerable: false,
  3443. configurable: true
  3444. });
  3445. Container.prototype._getTypeName = function () {
  3446. return "Container";
  3447. };
  3448. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3449. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3450. var child = _a[_i];
  3451. child._markMatrixAsDirty();
  3452. }
  3453. };
  3454. /**
  3455. * Gets a child using its name
  3456. * @param name defines the child name to look for
  3457. * @returns the child control if found
  3458. */
  3459. Container.prototype.getChildByName = function (name) {
  3460. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3461. var child = _a[_i];
  3462. if (child.name === name) {
  3463. return child;
  3464. }
  3465. }
  3466. return null;
  3467. };
  3468. /**
  3469. * Gets a child using its type and its name
  3470. * @param name defines the child name to look for
  3471. * @param type defines the child type to look for
  3472. * @returns the child control if found
  3473. */
  3474. Container.prototype.getChildByType = function (name, type) {
  3475. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3476. var child = _a[_i];
  3477. if (child.typeName === type) {
  3478. return child;
  3479. }
  3480. }
  3481. return null;
  3482. };
  3483. /**
  3484. * Search for a specific control in children
  3485. * @param control defines the control to look for
  3486. * @returns true if the control is in child list
  3487. */
  3488. Container.prototype.containsControl = function (control) {
  3489. return this.children.indexOf(control) !== -1;
  3490. };
  3491. /**
  3492. * Adds a new control to the current container
  3493. * @param control defines the control to add
  3494. * @returns the current container
  3495. */
  3496. Container.prototype.addControl = function (control) {
  3497. if (!control) {
  3498. return this;
  3499. }
  3500. var index = this._children.indexOf(control);
  3501. if (index !== -1) {
  3502. return this;
  3503. }
  3504. control._link(this._host);
  3505. control._markAllAsDirty();
  3506. this._reOrderControl(control);
  3507. this._markAsDirty();
  3508. return this;
  3509. };
  3510. /**
  3511. * Removes all controls from the current container
  3512. * @returns the current container
  3513. */
  3514. Container.prototype.clearControls = function () {
  3515. var children = this.children.slice();
  3516. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3517. var child = children_1[_i];
  3518. this.removeControl(child);
  3519. }
  3520. return this;
  3521. };
  3522. /**
  3523. * Removes a control from the current container
  3524. * @param control defines the control to remove
  3525. * @returns the current container
  3526. */
  3527. Container.prototype.removeControl = function (control) {
  3528. var index = this._children.indexOf(control);
  3529. if (index !== -1) {
  3530. this._children.splice(index, 1);
  3531. control.parent = null;
  3532. }
  3533. control.linkWithMesh(null);
  3534. if (this._host) {
  3535. this._host._cleanControlAfterRemoval(control);
  3536. }
  3537. this._markAsDirty();
  3538. return this;
  3539. };
  3540. /** @hidden */
  3541. Container.prototype._reOrderControl = function (control) {
  3542. this.removeControl(control);
  3543. var wasAdded = false;
  3544. for (var index = 0; index < this._children.length; index++) {
  3545. if (this._children[index].zIndex > control.zIndex) {
  3546. this._children.splice(index, 0, control);
  3547. wasAdded = true;
  3548. break;
  3549. }
  3550. }
  3551. if (!wasAdded) {
  3552. this._children.push(control);
  3553. }
  3554. control.parent = this;
  3555. this._markAsDirty();
  3556. };
  3557. /** @hidden */
  3558. Container.prototype._offsetLeft = function (offset) {
  3559. _super.prototype._offsetLeft.call(this, offset);
  3560. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3561. var child = _a[_i];
  3562. child._offsetLeft(offset);
  3563. }
  3564. };
  3565. /** @hidden */
  3566. Container.prototype._offsetTop = function (offset) {
  3567. _super.prototype._offsetTop.call(this, offset);
  3568. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3569. var child = _a[_i];
  3570. child._offsetTop(offset);
  3571. }
  3572. };
  3573. /** @hidden */
  3574. Container.prototype._markAllAsDirty = function () {
  3575. _super.prototype._markAllAsDirty.call(this);
  3576. for (var index = 0; index < this._children.length; index++) {
  3577. this._children[index]._markAllAsDirty();
  3578. }
  3579. };
  3580. /** @hidden */
  3581. Container.prototype._localDraw = function (context) {
  3582. if (this._background) {
  3583. context.save();
  3584. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3585. context.shadowColor = this.shadowColor;
  3586. context.shadowBlur = this.shadowBlur;
  3587. context.shadowOffsetX = this.shadowOffsetX;
  3588. context.shadowOffsetY = this.shadowOffsetY;
  3589. }
  3590. context.fillStyle = this._background;
  3591. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3592. context.restore();
  3593. }
  3594. };
  3595. /** @hidden */
  3596. Container.prototype._link = function (host) {
  3597. _super.prototype._link.call(this, host);
  3598. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3599. var child = _a[_i];
  3600. child._link(host);
  3601. }
  3602. };
  3603. /** @hidden */
  3604. Container.prototype._beforeLayout = function () {
  3605. // Do nothing
  3606. };
  3607. /** @hidden */
  3608. Container.prototype._processMeasures = function (parentMeasure, context) {
  3609. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3610. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3611. this._evaluateClippingState(parentMeasure);
  3612. }
  3613. };
  3614. /** @hidden */
  3615. Container.prototype._layout = function (parentMeasure, context) {
  3616. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3617. return false;
  3618. }
  3619. this.host._numLayoutCalls++;
  3620. if (this._isDirty) {
  3621. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3622. }
  3623. var rebuildCount = 0;
  3624. context.save();
  3625. this._applyStates(context);
  3626. this._beforeLayout();
  3627. do {
  3628. var computedWidth = -1;
  3629. var computedHeight = -1;
  3630. this._rebuildLayout = false;
  3631. this._processMeasures(parentMeasure, context);
  3632. if (!this._isClipped) {
  3633. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3634. var child = _a[_i];
  3635. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3636. if (child._layout(this._measureForChildren, context)) {
  3637. if (this.adaptWidthToChildren && child._width.isPixel) {
  3638. computedWidth = Math.max(computedWidth, child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels);
  3639. }
  3640. if (this.adaptHeightToChildren && child._height.isPixel) {
  3641. computedHeight = Math.max(computedHeight, child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels);
  3642. }
  3643. }
  3644. }
  3645. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3646. computedWidth += this.paddingLeftInPixels + this.paddingRightInPixels;
  3647. if (this.width !== computedWidth + "px") {
  3648. this.width = computedWidth + "px";
  3649. this._rebuildLayout = true;
  3650. }
  3651. }
  3652. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3653. computedHeight += this.paddingTopInPixels + this.paddingBottomInPixels;
  3654. if (this.height !== computedHeight + "px") {
  3655. this.height = computedHeight + "px";
  3656. this._rebuildLayout = true;
  3657. }
  3658. }
  3659. this._postMeasure();
  3660. }
  3661. rebuildCount++;
  3662. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3663. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3664. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3665. }
  3666. context.restore();
  3667. if (this._isDirty) {
  3668. this.invalidateRect();
  3669. this._isDirty = false;
  3670. }
  3671. return true;
  3672. };
  3673. Container.prototype._postMeasure = function () {
  3674. // Do nothing by default
  3675. };
  3676. /** @hidden */
  3677. Container.prototype._draw = function (context, invalidatedRectangle) {
  3678. this._localDraw(context);
  3679. if (this.clipChildren) {
  3680. this._clipForChildren(context);
  3681. }
  3682. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3683. var child = _a[_i];
  3684. // Only redraw parts of the screen that are invalidated
  3685. if (invalidatedRectangle) {
  3686. if (!child._intersectsRect(invalidatedRectangle)) {
  3687. continue;
  3688. }
  3689. }
  3690. child._render(context, invalidatedRectangle);
  3691. }
  3692. };
  3693. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3694. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3695. if (!this.children) {
  3696. return;
  3697. }
  3698. for (var index = 0; index < this.children.length; index++) {
  3699. var item = this.children[index];
  3700. if (!predicate || predicate(item)) {
  3701. results.push(item);
  3702. }
  3703. if (!directDescendantsOnly) {
  3704. item.getDescendantsToRef(results, false, predicate);
  3705. }
  3706. }
  3707. };
  3708. /** @hidden */
  3709. Container.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  3710. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3711. return false;
  3712. }
  3713. if (!_super.prototype.contains.call(this, x, y)) {
  3714. return false;
  3715. }
  3716. // Checking backwards to pick closest first
  3717. for (var index = this._children.length - 1; index >= 0; index--) {
  3718. var child = this._children[index];
  3719. if (child._processPicking(x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY)) {
  3720. if (child.hoverCursor) {
  3721. this._host._changeCursor(child.hoverCursor);
  3722. }
  3723. return true;
  3724. }
  3725. }
  3726. if (!this.isHitTestVisible) {
  3727. return false;
  3728. }
  3729. return this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  3730. };
  3731. /** @hidden */
  3732. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3733. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3734. this._measureForChildren.copyFrom(this._currentMeasure);
  3735. };
  3736. /**
  3737. * Serializes the current control
  3738. * @param serializationObject defined the JSON serialized object
  3739. */
  3740. Container.prototype.serialize = function (serializationObject) {
  3741. _super.prototype.serialize.call(this, serializationObject);
  3742. if (!this.children.length) {
  3743. return;
  3744. }
  3745. serializationObject.children = [];
  3746. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3747. var child = _a[_i];
  3748. var childSerializationObject = {};
  3749. child.serialize(childSerializationObject);
  3750. serializationObject.children.push(childSerializationObject);
  3751. }
  3752. };
  3753. /** Releases associated resources */
  3754. Container.prototype.dispose = function () {
  3755. _super.prototype.dispose.call(this);
  3756. for (var index = this.children.length - 1; index >= 0; index--) {
  3757. this.children[index].dispose();
  3758. }
  3759. };
  3760. /** @hidden */
  3761. Container.prototype._parseFromContent = function (serializedObject, host) {
  3762. _super.prototype._parseFromContent.call(this, serializedObject, host);
  3763. this._link(host);
  3764. if (!serializedObject.children) {
  3765. return;
  3766. }
  3767. for (var _i = 0, _a = serializedObject.children; _i < _a.length; _i++) {
  3768. var childData = _a[_i];
  3769. this.addControl(_control__WEBPACK_IMPORTED_MODULE_2__["Control"].Parse(childData, host));
  3770. }
  3771. };
  3772. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3773. Object(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3774. ], Container.prototype, "maxLayoutCycle", void 0);
  3775. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3776. Object(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3777. ], Container.prototype, "adaptHeightToChildren", null);
  3778. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3779. Object(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3780. ], Container.prototype, "adaptWidthToChildren", null);
  3781. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3782. Object(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3783. ], Container.prototype, "background", null);
  3784. return Container;
  3785. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3786. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3787. /***/ }),
  3788. /***/ "./2D/controls/control.ts":
  3789. /*!********************************!*\
  3790. !*** ./2D/controls/control.ts ***!
  3791. \********************************/
  3792. /*! exports provided: Control */
  3793. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3794. "use strict";
  3795. __webpack_require__.r(__webpack_exports__);
  3796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3797. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3798. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  3799. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  3800. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3801. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3802. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3803. /**
  3804. * Root class used for all 2D controls
  3805. * @see https://doc.babylonjs.com/how_to/gui#controls
  3806. */
  3807. var Control = /** @class */ (function () {
  3808. // Functions
  3809. /**
  3810. * Creates a new control
  3811. * @param name defines the name of the control
  3812. */
  3813. function Control(
  3814. /** defines the name of the control */
  3815. name) {
  3816. this.name = name;
  3817. this._alpha = 1;
  3818. this._alphaSet = false;
  3819. this._zIndex = 0;
  3820. /** @hidden */
  3821. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3822. this._fontFamily = "Arial";
  3823. this._fontStyle = "";
  3824. this._fontWeight = "";
  3825. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3826. /** @hidden */
  3827. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3828. /** @hidden */
  3829. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3830. this._color = "";
  3831. this._style = null;
  3832. /** @hidden */
  3833. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3834. /** @hidden */
  3835. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3836. /** @hidden */
  3837. this._isDirty = true;
  3838. /** @hidden */
  3839. this._wasDirty = false;
  3840. /** @hidden */
  3841. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3842. /** @hidden */
  3843. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3844. /** @hidden */
  3845. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3846. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3847. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3848. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3849. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3850. /** @hidden */
  3851. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3852. /** @hidden */
  3853. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3854. this._scaleX = 1.0;
  3855. this._scaleY = 1.0;
  3856. this._rotation = 0;
  3857. this._transformCenterX = 0.5;
  3858. this._transformCenterY = 0.5;
  3859. /** @hidden */
  3860. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_4__["Matrix2D"].Identity();
  3861. /** @hidden */
  3862. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_4__["Matrix2D"].Identity();
  3863. /** @hidden */
  3864. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  3865. this._isMatrixDirty = true;
  3866. this._isVisible = true;
  3867. this._isHighlighted = false;
  3868. this._fontSet = false;
  3869. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  3870. this._downCount = 0;
  3871. this._enterCount = -1;
  3872. this._doNotRender = false;
  3873. this._downPointerIds = {};
  3874. this._isEnabled = true;
  3875. this._disabledColor = "#9a9a9a";
  3876. this._disabledColorItem = "#6a6a6a";
  3877. /** @hidden */
  3878. this._rebuildLayout = false;
  3879. /** @hidden */
  3880. this._customData = {};
  3881. /** @hidden */
  3882. this._isClipped = false;
  3883. /** @hidden */
  3884. this._automaticSize = false;
  3885. /**
  3886. * Gets or sets an object used to store user defined information for the node
  3887. */
  3888. this.metadata = null;
  3889. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3890. this.isHitTestVisible = true;
  3891. /** Gets or sets a boolean indicating if the control can block pointer events */
  3892. this.isPointerBlocker = false;
  3893. /** Gets or sets a boolean indicating if the control can be focusable */
  3894. this.isFocusInvisible = false;
  3895. /**
  3896. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3897. * 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
  3898. */
  3899. this.clipChildren = true;
  3900. /**
  3901. * Gets or sets a boolean indicating that control content must be clipped
  3902. * 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
  3903. */
  3904. this.clipContent = true;
  3905. /**
  3906. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3907. */
  3908. this.useBitmapCache = false;
  3909. this._shadowOffsetX = 0;
  3910. this._shadowOffsetY = 0;
  3911. this._shadowBlur = 0;
  3912. this._shadowColor = 'black';
  3913. /** Gets or sets the cursor to use when the control is hovered */
  3914. this.hoverCursor = "";
  3915. /** @hidden */
  3916. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3917. /** @hidden */
  3918. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3919. /**
  3920. * An event triggered when pointer wheel is scrolled
  3921. */
  3922. this.onWheelObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3923. /**
  3924. * An event triggered when the pointer move over the control.
  3925. */
  3926. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3927. /**
  3928. * An event triggered when the pointer move out of the control.
  3929. */
  3930. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3931. /**
  3932. * An event triggered when the pointer taps the control
  3933. */
  3934. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3935. /**
  3936. * An event triggered when pointer up
  3937. */
  3938. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3939. /**
  3940. * An event triggered when a control is clicked on
  3941. */
  3942. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3943. /**
  3944. * An event triggered when pointer enters the control
  3945. */
  3946. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3947. /**
  3948. * An event triggered when the control is marked as dirty
  3949. */
  3950. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3951. /**
  3952. * An event triggered before drawing the control
  3953. */
  3954. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3955. /**
  3956. * An event triggered after the control was drawn
  3957. */
  3958. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3959. /**
  3960. * An event triggered when the control has been disposed
  3961. */
  3962. this.onDisposeObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3963. /**
  3964. * Gets or sets a fixed ratio for this control.
  3965. * When different from 0, the ratio is used to compute the "second" dimension.
  3966. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  3967. * second dimension is computed as first dimension * fixedRatio
  3968. */
  3969. this.fixedRatio = 0;
  3970. this._fixedRatioMasterIsWidth = true;
  3971. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"](0, 0, 0, 0);
  3972. }
  3973. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3974. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3975. get: function () {
  3976. return this._shadowOffsetX;
  3977. },
  3978. set: function (value) {
  3979. if (this._shadowOffsetX === value) {
  3980. return;
  3981. }
  3982. this._shadowOffsetX = value;
  3983. this._markAsDirty();
  3984. },
  3985. enumerable: false,
  3986. configurable: true
  3987. });
  3988. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3989. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3990. get: function () {
  3991. return this._shadowOffsetY;
  3992. },
  3993. set: function (value) {
  3994. if (this._shadowOffsetY === value) {
  3995. return;
  3996. }
  3997. this._shadowOffsetY = value;
  3998. this._markAsDirty();
  3999. },
  4000. enumerable: false,
  4001. configurable: true
  4002. });
  4003. Object.defineProperty(Control.prototype, "shadowBlur", {
  4004. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  4005. get: function () {
  4006. return this._shadowBlur;
  4007. },
  4008. set: function (value) {
  4009. if (this._shadowBlur === value) {
  4010. return;
  4011. }
  4012. this._shadowBlur = value;
  4013. this._markAsDirty();
  4014. },
  4015. enumerable: false,
  4016. configurable: true
  4017. });
  4018. Object.defineProperty(Control.prototype, "shadowColor", {
  4019. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  4020. get: function () {
  4021. return this._shadowColor;
  4022. },
  4023. set: function (value) {
  4024. if (this._shadowColor === value) {
  4025. return;
  4026. }
  4027. this._shadowColor = value;
  4028. this._markAsDirty();
  4029. },
  4030. enumerable: false,
  4031. configurable: true
  4032. });
  4033. Object.defineProperty(Control.prototype, "typeName", {
  4034. // Properties
  4035. /** Gets the control type name */
  4036. get: function () {
  4037. return this._getTypeName();
  4038. },
  4039. enumerable: false,
  4040. configurable: true
  4041. });
  4042. /**
  4043. * Get the current class name of the control.
  4044. * @returns current class name
  4045. */
  4046. Control.prototype.getClassName = function () {
  4047. return this._getTypeName();
  4048. };
  4049. Object.defineProperty(Control.prototype, "host", {
  4050. /**
  4051. * Get the hosting AdvancedDynamicTexture
  4052. */
  4053. get: function () {
  4054. return this._host;
  4055. },
  4056. enumerable: false,
  4057. configurable: true
  4058. });
  4059. Object.defineProperty(Control.prototype, "fontOffset", {
  4060. /** Gets or set information about font offsets (used to render and align text) */
  4061. get: function () {
  4062. return this._fontOffset;
  4063. },
  4064. set: function (offset) {
  4065. this._fontOffset = offset;
  4066. },
  4067. enumerable: false,
  4068. configurable: true
  4069. });
  4070. Object.defineProperty(Control.prototype, "alpha", {
  4071. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  4072. get: function () {
  4073. return this._alpha;
  4074. },
  4075. set: function (value) {
  4076. if (this._alpha === value) {
  4077. return;
  4078. }
  4079. this._alphaSet = true;
  4080. this._alpha = value;
  4081. this._markAsDirty();
  4082. },
  4083. enumerable: false,
  4084. configurable: true
  4085. });
  4086. Object.defineProperty(Control.prototype, "isHighlighted", {
  4087. /**
  4088. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  4089. */
  4090. get: function () {
  4091. return this._isHighlighted;
  4092. },
  4093. set: function (value) {
  4094. if (this._isHighlighted === value) {
  4095. return;
  4096. }
  4097. this._isHighlighted = value;
  4098. this._markAsDirty();
  4099. },
  4100. enumerable: false,
  4101. configurable: true
  4102. });
  4103. Object.defineProperty(Control.prototype, "scaleX", {
  4104. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  4105. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4106. */
  4107. get: function () {
  4108. return this._scaleX;
  4109. },
  4110. set: function (value) {
  4111. if (this._scaleX === value) {
  4112. return;
  4113. }
  4114. this._scaleX = value;
  4115. this._markAsDirty();
  4116. this._markMatrixAsDirty();
  4117. },
  4118. enumerable: false,
  4119. configurable: true
  4120. });
  4121. Object.defineProperty(Control.prototype, "scaleY", {
  4122. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  4123. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4124. */
  4125. get: function () {
  4126. return this._scaleY;
  4127. },
  4128. set: function (value) {
  4129. if (this._scaleY === value) {
  4130. return;
  4131. }
  4132. this._scaleY = value;
  4133. this._markAsDirty();
  4134. this._markMatrixAsDirty();
  4135. },
  4136. enumerable: false,
  4137. configurable: true
  4138. });
  4139. Object.defineProperty(Control.prototype, "rotation", {
  4140. /** Gets or sets the rotation angle (0 by default)
  4141. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4142. */
  4143. get: function () {
  4144. return this._rotation;
  4145. },
  4146. set: function (value) {
  4147. if (this._rotation === value) {
  4148. return;
  4149. }
  4150. this._rotation = value;
  4151. this._markAsDirty();
  4152. this._markMatrixAsDirty();
  4153. },
  4154. enumerable: false,
  4155. configurable: true
  4156. });
  4157. Object.defineProperty(Control.prototype, "transformCenterY", {
  4158. /** Gets or sets the transformation center on Y axis (0 by default)
  4159. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4160. */
  4161. get: function () {
  4162. return this._transformCenterY;
  4163. },
  4164. set: function (value) {
  4165. if (this._transformCenterY === value) {
  4166. return;
  4167. }
  4168. this._transformCenterY = value;
  4169. this._markAsDirty();
  4170. this._markMatrixAsDirty();
  4171. },
  4172. enumerable: false,
  4173. configurable: true
  4174. });
  4175. Object.defineProperty(Control.prototype, "transformCenterX", {
  4176. /** Gets or sets the transformation center on X axis (0 by default)
  4177. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4178. */
  4179. get: function () {
  4180. return this._transformCenterX;
  4181. },
  4182. set: function (value) {
  4183. if (this._transformCenterX === value) {
  4184. return;
  4185. }
  4186. this._transformCenterX = value;
  4187. this._markAsDirty();
  4188. this._markMatrixAsDirty();
  4189. },
  4190. enumerable: false,
  4191. configurable: true
  4192. });
  4193. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  4194. /**
  4195. * Gets or sets the horizontal alignment
  4196. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4197. */
  4198. get: function () {
  4199. return this._horizontalAlignment;
  4200. },
  4201. set: function (value) {
  4202. if (this._horizontalAlignment === value) {
  4203. return;
  4204. }
  4205. this._horizontalAlignment = value;
  4206. this._markAsDirty();
  4207. },
  4208. enumerable: false,
  4209. configurable: true
  4210. });
  4211. Object.defineProperty(Control.prototype, "verticalAlignment", {
  4212. /**
  4213. * Gets or sets the vertical alignment
  4214. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4215. */
  4216. get: function () {
  4217. return this._verticalAlignment;
  4218. },
  4219. set: function (value) {
  4220. if (this._verticalAlignment === value) {
  4221. return;
  4222. }
  4223. this._verticalAlignment = value;
  4224. this._markAsDirty();
  4225. },
  4226. enumerable: false,
  4227. configurable: true
  4228. });
  4229. Object.defineProperty(Control.prototype, "width", {
  4230. /**
  4231. * Gets or sets control width
  4232. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4233. */
  4234. get: function () {
  4235. return this._width.toString(this._host);
  4236. },
  4237. set: function (value) {
  4238. this._fixedRatioMasterIsWidth = true;
  4239. if (this._width.toString(this._host) === value) {
  4240. return;
  4241. }
  4242. if (this._width.fromString(value)) {
  4243. this._markAsDirty();
  4244. }
  4245. },
  4246. enumerable: false,
  4247. configurable: true
  4248. });
  4249. Object.defineProperty(Control.prototype, "widthInPixels", {
  4250. /**
  4251. * Gets or sets the control width in pixel
  4252. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4253. */
  4254. get: function () {
  4255. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4256. },
  4257. set: function (value) {
  4258. if (isNaN(value)) {
  4259. return;
  4260. }
  4261. this._fixedRatioMasterIsWidth = true;
  4262. this.width = value + "px";
  4263. },
  4264. enumerable: false,
  4265. configurable: true
  4266. });
  4267. Object.defineProperty(Control.prototype, "height", {
  4268. /**
  4269. * Gets or sets control height
  4270. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4271. */
  4272. get: function () {
  4273. return this._height.toString(this._host);
  4274. },
  4275. set: function (value) {
  4276. this._fixedRatioMasterIsWidth = false;
  4277. if (this._height.toString(this._host) === value) {
  4278. return;
  4279. }
  4280. if (this._height.fromString(value)) {
  4281. this._markAsDirty();
  4282. }
  4283. },
  4284. enumerable: false,
  4285. configurable: true
  4286. });
  4287. Object.defineProperty(Control.prototype, "heightInPixels", {
  4288. /**
  4289. * Gets or sets control height in pixel
  4290. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4291. */
  4292. get: function () {
  4293. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4294. },
  4295. set: function (value) {
  4296. if (isNaN(value)) {
  4297. return;
  4298. }
  4299. this._fixedRatioMasterIsWidth = false;
  4300. this.height = value + "px";
  4301. },
  4302. enumerable: false,
  4303. configurable: true
  4304. });
  4305. Object.defineProperty(Control.prototype, "fontFamily", {
  4306. /** Gets or set font family */
  4307. get: function () {
  4308. if (!this._fontSet) {
  4309. return "";
  4310. }
  4311. return this._fontFamily;
  4312. },
  4313. set: function (value) {
  4314. if (this._fontFamily === value) {
  4315. return;
  4316. }
  4317. this._fontFamily = value;
  4318. this._resetFontCache();
  4319. },
  4320. enumerable: false,
  4321. configurable: true
  4322. });
  4323. Object.defineProperty(Control.prototype, "fontStyle", {
  4324. /** Gets or sets font style */
  4325. get: function () {
  4326. return this._fontStyle;
  4327. },
  4328. set: function (value) {
  4329. if (this._fontStyle === value) {
  4330. return;
  4331. }
  4332. this._fontStyle = value;
  4333. this._resetFontCache();
  4334. },
  4335. enumerable: false,
  4336. configurable: true
  4337. });
  4338. Object.defineProperty(Control.prototype, "fontWeight", {
  4339. /** Gets or sets font weight */
  4340. get: function () {
  4341. return this._fontWeight;
  4342. },
  4343. set: function (value) {
  4344. if (this._fontWeight === value) {
  4345. return;
  4346. }
  4347. this._fontWeight = value;
  4348. this._resetFontCache();
  4349. },
  4350. enumerable: false,
  4351. configurable: true
  4352. });
  4353. Object.defineProperty(Control.prototype, "style", {
  4354. /**
  4355. * Gets or sets style
  4356. * @see https://doc.babylonjs.com/how_to/gui#styles
  4357. */
  4358. get: function () {
  4359. return this._style;
  4360. },
  4361. set: function (value) {
  4362. var _this = this;
  4363. if (this._style) {
  4364. this._style.onChangedObservable.remove(this._styleObserver);
  4365. this._styleObserver = null;
  4366. }
  4367. this._style = value;
  4368. if (this._style) {
  4369. this._styleObserver = this._style.onChangedObservable.add(function () {
  4370. _this._markAsDirty();
  4371. _this._resetFontCache();
  4372. });
  4373. }
  4374. this._markAsDirty();
  4375. this._resetFontCache();
  4376. },
  4377. enumerable: false,
  4378. configurable: true
  4379. });
  4380. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4381. /** @hidden */
  4382. get: function () {
  4383. return this._fontSize.isPercentage;
  4384. },
  4385. enumerable: false,
  4386. configurable: true
  4387. });
  4388. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4389. /** Gets or sets font size in pixels */
  4390. get: function () {
  4391. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4392. if (fontSizeToUse.isPixel) {
  4393. return fontSizeToUse.getValue(this._host);
  4394. }
  4395. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4396. },
  4397. set: function (value) {
  4398. if (isNaN(value)) {
  4399. return;
  4400. }
  4401. this.fontSize = value + "px";
  4402. },
  4403. enumerable: false,
  4404. configurable: true
  4405. });
  4406. Object.defineProperty(Control.prototype, "fontSize", {
  4407. /** Gets or sets font size */
  4408. get: function () {
  4409. return this._fontSize.toString(this._host);
  4410. },
  4411. set: function (value) {
  4412. if (this._fontSize.toString(this._host) === value) {
  4413. return;
  4414. }
  4415. if (this._fontSize.fromString(value)) {
  4416. this._markAsDirty();
  4417. this._resetFontCache();
  4418. }
  4419. },
  4420. enumerable: false,
  4421. configurable: true
  4422. });
  4423. Object.defineProperty(Control.prototype, "color", {
  4424. /** Gets or sets foreground color */
  4425. get: function () {
  4426. return this._color;
  4427. },
  4428. set: function (value) {
  4429. if (this._color === value) {
  4430. return;
  4431. }
  4432. this._color = value;
  4433. this._markAsDirty();
  4434. },
  4435. enumerable: false,
  4436. configurable: true
  4437. });
  4438. Object.defineProperty(Control.prototype, "zIndex", {
  4439. /** Gets or sets z index which is used to reorder controls on the z axis */
  4440. get: function () {
  4441. return this._zIndex;
  4442. },
  4443. set: function (value) {
  4444. if (this.zIndex === value) {
  4445. return;
  4446. }
  4447. this._zIndex = value;
  4448. if (this.parent) {
  4449. this.parent._reOrderControl(this);
  4450. }
  4451. },
  4452. enumerable: false,
  4453. configurable: true
  4454. });
  4455. Object.defineProperty(Control.prototype, "notRenderable", {
  4456. /** Gets or sets a boolean indicating if the control can be rendered */
  4457. get: function () {
  4458. return this._doNotRender;
  4459. },
  4460. set: function (value) {
  4461. if (this._doNotRender === value) {
  4462. return;
  4463. }
  4464. this._doNotRender = value;
  4465. this._markAsDirty();
  4466. },
  4467. enumerable: false,
  4468. configurable: true
  4469. });
  4470. Object.defineProperty(Control.prototype, "isVisible", {
  4471. /** Gets or sets a boolean indicating if the control is visible */
  4472. get: function () {
  4473. return this._isVisible;
  4474. },
  4475. set: function (value) {
  4476. if (this._isVisible === value) {
  4477. return;
  4478. }
  4479. this._isVisible = value;
  4480. this._markAsDirty(true);
  4481. },
  4482. enumerable: false,
  4483. configurable: true
  4484. });
  4485. Object.defineProperty(Control.prototype, "isDirty", {
  4486. /** Gets a boolean indicating that the control needs to update its rendering */
  4487. get: function () {
  4488. return this._isDirty;
  4489. },
  4490. enumerable: false,
  4491. configurable: true
  4492. });
  4493. Object.defineProperty(Control.prototype, "linkedMesh", {
  4494. /**
  4495. * Gets the current linked mesh (or null if none)
  4496. */
  4497. get: function () {
  4498. return this._linkedMesh;
  4499. },
  4500. enumerable: false,
  4501. configurable: true
  4502. });
  4503. Object.defineProperty(Control.prototype, "paddingLeft", {
  4504. /**
  4505. * Gets or sets a value indicating the padding to use on the left of the control
  4506. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4507. */
  4508. get: function () {
  4509. return this._paddingLeft.toString(this._host);
  4510. },
  4511. set: function (value) {
  4512. if (this._paddingLeft.fromString(value)) {
  4513. this._markAsDirty();
  4514. }
  4515. },
  4516. enumerable: false,
  4517. configurable: true
  4518. });
  4519. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4520. /**
  4521. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4522. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4523. */
  4524. get: function () {
  4525. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4526. },
  4527. set: function (value) {
  4528. if (isNaN(value)) {
  4529. return;
  4530. }
  4531. this.paddingLeft = value + "px";
  4532. },
  4533. enumerable: false,
  4534. configurable: true
  4535. });
  4536. Object.defineProperty(Control.prototype, "paddingRight", {
  4537. /**
  4538. * Gets or sets a value indicating the padding to use on the right of the control
  4539. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4540. */
  4541. get: function () {
  4542. return this._paddingRight.toString(this._host);
  4543. },
  4544. set: function (value) {
  4545. if (this._paddingRight.fromString(value)) {
  4546. this._markAsDirty();
  4547. }
  4548. },
  4549. enumerable: false,
  4550. configurable: true
  4551. });
  4552. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4553. /**
  4554. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4555. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4556. */
  4557. get: function () {
  4558. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4559. },
  4560. set: function (value) {
  4561. if (isNaN(value)) {
  4562. return;
  4563. }
  4564. this.paddingRight = value + "px";
  4565. },
  4566. enumerable: false,
  4567. configurable: true
  4568. });
  4569. Object.defineProperty(Control.prototype, "paddingTop", {
  4570. /**
  4571. * Gets or sets a value indicating the padding to use on the top of the control
  4572. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4573. */
  4574. get: function () {
  4575. return this._paddingTop.toString(this._host);
  4576. },
  4577. set: function (value) {
  4578. if (this._paddingTop.fromString(value)) {
  4579. this._markAsDirty();
  4580. }
  4581. },
  4582. enumerable: false,
  4583. configurable: true
  4584. });
  4585. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4586. /**
  4587. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4588. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4589. */
  4590. get: function () {
  4591. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4592. },
  4593. set: function (value) {
  4594. if (isNaN(value)) {
  4595. return;
  4596. }
  4597. this.paddingTop = value + "px";
  4598. },
  4599. enumerable: false,
  4600. configurable: true
  4601. });
  4602. Object.defineProperty(Control.prototype, "paddingBottom", {
  4603. /**
  4604. * Gets or sets a value indicating the padding to use on the bottom of the control
  4605. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4606. */
  4607. get: function () {
  4608. return this._paddingBottom.toString(this._host);
  4609. },
  4610. set: function (value) {
  4611. if (this._paddingBottom.fromString(value)) {
  4612. this._markAsDirty();
  4613. }
  4614. },
  4615. enumerable: false,
  4616. configurable: true
  4617. });
  4618. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4619. /**
  4620. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4621. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4622. */
  4623. get: function () {
  4624. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4625. },
  4626. set: function (value) {
  4627. if (isNaN(value)) {
  4628. return;
  4629. }
  4630. this.paddingBottom = value + "px";
  4631. },
  4632. enumerable: false,
  4633. configurable: true
  4634. });
  4635. Object.defineProperty(Control.prototype, "left", {
  4636. /**
  4637. * Gets or sets a value indicating the left coordinate of the control
  4638. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4639. */
  4640. get: function () {
  4641. return this._left.toString(this._host);
  4642. },
  4643. set: function (value) {
  4644. if (this._left.fromString(value)) {
  4645. this._markAsDirty();
  4646. }
  4647. },
  4648. enumerable: false,
  4649. configurable: true
  4650. });
  4651. Object.defineProperty(Control.prototype, "leftInPixels", {
  4652. /**
  4653. * Gets or sets a value indicating the left coordinate in pixels of the control
  4654. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4655. */
  4656. get: function () {
  4657. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4658. },
  4659. set: function (value) {
  4660. if (isNaN(value)) {
  4661. return;
  4662. }
  4663. this.left = value + "px";
  4664. },
  4665. enumerable: false,
  4666. configurable: true
  4667. });
  4668. Object.defineProperty(Control.prototype, "top", {
  4669. /**
  4670. * Gets or sets a value indicating the top coordinate of the control
  4671. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4672. */
  4673. get: function () {
  4674. return this._top.toString(this._host);
  4675. },
  4676. set: function (value) {
  4677. if (this._top.fromString(value)) {
  4678. this._markAsDirty();
  4679. }
  4680. },
  4681. enumerable: false,
  4682. configurable: true
  4683. });
  4684. Object.defineProperty(Control.prototype, "topInPixels", {
  4685. /**
  4686. * Gets or sets a value indicating the top coordinate in pixels of the control
  4687. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4688. */
  4689. get: function () {
  4690. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4691. },
  4692. set: function (value) {
  4693. if (isNaN(value)) {
  4694. return;
  4695. }
  4696. this.top = value + "px";
  4697. },
  4698. enumerable: false,
  4699. configurable: true
  4700. });
  4701. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4702. /**
  4703. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4704. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4705. */
  4706. get: function () {
  4707. return this._linkOffsetX.toString(this._host);
  4708. },
  4709. set: function (value) {
  4710. if (this._linkOffsetX.fromString(value)) {
  4711. this._markAsDirty();
  4712. }
  4713. },
  4714. enumerable: false,
  4715. configurable: true
  4716. });
  4717. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4718. /**
  4719. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4720. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4721. */
  4722. get: function () {
  4723. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4724. },
  4725. set: function (value) {
  4726. if (isNaN(value)) {
  4727. return;
  4728. }
  4729. this.linkOffsetX = value + "px";
  4730. },
  4731. enumerable: false,
  4732. configurable: true
  4733. });
  4734. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4735. /**
  4736. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4737. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4738. */
  4739. get: function () {
  4740. return this._linkOffsetY.toString(this._host);
  4741. },
  4742. set: function (value) {
  4743. if (this._linkOffsetY.fromString(value)) {
  4744. this._markAsDirty();
  4745. }
  4746. },
  4747. enumerable: false,
  4748. configurable: true
  4749. });
  4750. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4751. /**
  4752. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4753. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4754. */
  4755. get: function () {
  4756. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4757. },
  4758. set: function (value) {
  4759. if (isNaN(value)) {
  4760. return;
  4761. }
  4762. this.linkOffsetY = value + "px";
  4763. },
  4764. enumerable: false,
  4765. configurable: true
  4766. });
  4767. Object.defineProperty(Control.prototype, "centerX", {
  4768. /** Gets the center coordinate on X axis */
  4769. get: function () {
  4770. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4771. },
  4772. enumerable: false,
  4773. configurable: true
  4774. });
  4775. Object.defineProperty(Control.prototype, "centerY", {
  4776. /** Gets the center coordinate on Y axis */
  4777. get: function () {
  4778. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4779. },
  4780. enumerable: false,
  4781. configurable: true
  4782. });
  4783. Object.defineProperty(Control.prototype, "isEnabled", {
  4784. /** Gets or sets if control is Enabled */
  4785. get: function () {
  4786. return this._isEnabled;
  4787. },
  4788. set: function (value) {
  4789. if (this._isEnabled === value) {
  4790. return;
  4791. }
  4792. this._isEnabled = value;
  4793. this._markAsDirty();
  4794. },
  4795. enumerable: false,
  4796. configurable: true
  4797. });
  4798. Object.defineProperty(Control.prototype, "disabledColor", {
  4799. /** Gets or sets background color of control if it's disabled */
  4800. get: function () {
  4801. return this._disabledColor;
  4802. },
  4803. set: function (value) {
  4804. if (this._disabledColor === value) {
  4805. return;
  4806. }
  4807. this._disabledColor = value;
  4808. this._markAsDirty();
  4809. },
  4810. enumerable: false,
  4811. configurable: true
  4812. });
  4813. Object.defineProperty(Control.prototype, "disabledColorItem", {
  4814. /** Gets or sets front color of control if it's disabled */
  4815. get: function () {
  4816. return this._disabledColorItem;
  4817. },
  4818. set: function (value) {
  4819. if (this._disabledColorItem === value) {
  4820. return;
  4821. }
  4822. this._disabledColorItem = value;
  4823. this._markAsDirty();
  4824. },
  4825. enumerable: false,
  4826. configurable: true
  4827. });
  4828. /** @hidden */
  4829. Control.prototype._getTypeName = function () {
  4830. return "Control";
  4831. };
  4832. /**
  4833. * Gets the first ascendant in the hierarchy of the given type
  4834. * @param className defines the required type
  4835. * @returns the ascendant or null if not found
  4836. */
  4837. Control.prototype.getAscendantOfClass = function (className) {
  4838. if (!this.parent) {
  4839. return null;
  4840. }
  4841. if (this.parent.getClassName() === className) {
  4842. return this.parent;
  4843. }
  4844. return this.parent.getAscendantOfClass(className);
  4845. };
  4846. /** @hidden */
  4847. Control.prototype._resetFontCache = function () {
  4848. this._fontSet = true;
  4849. this._markAsDirty();
  4850. };
  4851. /**
  4852. * Determines if a container is an ascendant of the current control
  4853. * @param container defines the container to look for
  4854. * @returns true if the container is one of the ascendant of the control
  4855. */
  4856. Control.prototype.isAscendant = function (container) {
  4857. if (!this.parent) {
  4858. return false;
  4859. }
  4860. if (this.parent === container) {
  4861. return true;
  4862. }
  4863. return this.parent.isAscendant(container);
  4864. };
  4865. /**
  4866. * Gets coordinates in local control space
  4867. * @param globalCoordinates defines the coordinates to transform
  4868. * @returns the new coordinates in local space
  4869. */
  4870. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4871. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  4872. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4873. return result;
  4874. };
  4875. /**
  4876. * Gets coordinates in local control space
  4877. * @param globalCoordinates defines the coordinates to transform
  4878. * @param result defines the target vector2 where to store the result
  4879. * @returns the current control
  4880. */
  4881. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4882. result.x = globalCoordinates.x - this._currentMeasure.left;
  4883. result.y = globalCoordinates.y - this._currentMeasure.top;
  4884. return this;
  4885. };
  4886. /**
  4887. * Gets coordinates in parent local control space
  4888. * @param globalCoordinates defines the coordinates to transform
  4889. * @returns the new coordinates in parent local space
  4890. */
  4891. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4892. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  4893. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4894. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4895. return result;
  4896. };
  4897. /**
  4898. * Move the current control to a vector3 position projected onto the screen.
  4899. * @param position defines the target position
  4900. * @param scene defines the hosting scene
  4901. */
  4902. Control.prototype.moveToVector3 = function (position, scene) {
  4903. if (!this._host || this.parent !== this._host._rootContainer) {
  4904. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4905. return;
  4906. }
  4907. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4908. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4909. var globalViewport = this._host._getGlobalViewport(scene);
  4910. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4911. this._moveToProjectedPosition(projectedPosition);
  4912. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4913. this.notRenderable = true;
  4914. return;
  4915. }
  4916. this.notRenderable = false;
  4917. };
  4918. /**
  4919. * Will store all controls that have this control as ascendant in a given array
  4920. * @param results defines the array where to store the descendants
  4921. * @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
  4922. * @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
  4923. */
  4924. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4925. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4926. // Do nothing by default
  4927. };
  4928. /**
  4929. * Will return all controls that have this control as ascendant
  4930. * @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
  4931. * @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
  4932. * @return all child controls
  4933. */
  4934. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4935. var results = new Array();
  4936. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4937. return results;
  4938. };
  4939. /**
  4940. * Link current control with a target mesh
  4941. * @param mesh defines the mesh to link with
  4942. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4943. */
  4944. Control.prototype.linkWithMesh = function (mesh) {
  4945. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4946. if (mesh) {
  4947. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4948. }
  4949. return;
  4950. }
  4951. var index = this._host._linkedControls.indexOf(this);
  4952. if (index !== -1) {
  4953. this._linkedMesh = mesh;
  4954. if (!mesh) {
  4955. this._host._linkedControls.splice(index, 1);
  4956. }
  4957. return;
  4958. }
  4959. else if (!mesh) {
  4960. return;
  4961. }
  4962. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4963. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4964. this._linkedMesh = mesh;
  4965. this._host._linkedControls.push(this);
  4966. };
  4967. /**
  4968. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  4969. * @param { string | number} paddingTop - The value of the top padding.
  4970. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  4971. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  4972. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  4973. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4974. */
  4975. Control.prototype.setPadding = function (paddingTop, paddingRight, paddingBottom, paddingLeft) {
  4976. var top = paddingTop;
  4977. var right = paddingRight !== null && paddingRight !== void 0 ? paddingRight : top;
  4978. var bottom = paddingBottom !== null && paddingBottom !== void 0 ? paddingBottom : top;
  4979. var left = paddingLeft !== null && paddingLeft !== void 0 ? paddingLeft : right;
  4980. this.paddingTop = top;
  4981. this.paddingRight = right;
  4982. this.paddingBottom = bottom;
  4983. this.paddingLeft = left;
  4984. };
  4985. /**
  4986. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  4987. * @param { number} paddingTop - The value in pixels of the top padding.
  4988. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  4989. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  4990. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  4991. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4992. */
  4993. Control.prototype.setPaddingInPixels = function (paddingTop, paddingRight, paddingBottom, paddingLeft) {
  4994. var top = paddingTop;
  4995. var right = paddingRight !== null && paddingRight !== void 0 ? paddingRight : top;
  4996. var bottom = paddingBottom !== null && paddingBottom !== void 0 ? paddingBottom : top;
  4997. var left = paddingLeft !== null && paddingLeft !== void 0 ? paddingLeft : right;
  4998. this.paddingTopInPixels = top;
  4999. this.paddingRightInPixels = right;
  5000. this.paddingBottomInPixels = bottom;
  5001. this.paddingLeftInPixels = left;
  5002. };
  5003. /** @hidden */
  5004. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  5005. var oldLeft = this._left.getValue(this._host);
  5006. var oldTop = this._top.getValue(this._host);
  5007. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  5008. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  5009. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  5010. if (Math.abs(newLeft - oldLeft) < 0.5) {
  5011. newLeft = oldLeft;
  5012. }
  5013. if (Math.abs(newTop - oldTop) < 0.5) {
  5014. newTop = oldTop;
  5015. }
  5016. }
  5017. this.left = newLeft + "px";
  5018. this.top = newTop + "px";
  5019. this._left.ignoreAdaptiveScaling = true;
  5020. this._top.ignoreAdaptiveScaling = true;
  5021. this._markAsDirty();
  5022. };
  5023. /** @hidden */
  5024. Control.prototype._offsetLeft = function (offset) {
  5025. this._isDirty = true;
  5026. this._currentMeasure.left += offset;
  5027. };
  5028. /** @hidden */
  5029. Control.prototype._offsetTop = function (offset) {
  5030. this._isDirty = true;
  5031. this._currentMeasure.top += offset;
  5032. };
  5033. /** @hidden */
  5034. Control.prototype._markMatrixAsDirty = function () {
  5035. this._isMatrixDirty = true;
  5036. this._flagDescendantsAsMatrixDirty();
  5037. };
  5038. /** @hidden */
  5039. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  5040. // No child
  5041. };
  5042. /** @hidden */
  5043. Control.prototype._intersectsRect = function (rect) {
  5044. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  5045. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  5046. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  5047. return false;
  5048. }
  5049. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  5050. return false;
  5051. }
  5052. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  5053. return false;
  5054. }
  5055. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  5056. return false;
  5057. }
  5058. return true;
  5059. };
  5060. /** @hidden */
  5061. Control.prototype.invalidateRect = function () {
  5062. this._transform();
  5063. if (this.host && this.host.useInvalidateRectOptimization) {
  5064. // Rotate by transform to get the measure transformed to global space
  5065. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  5066. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  5067. // the previous measure is used to properly clear a control that is scaled down
  5068. _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  5069. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5070. // Expand rect based on shadows
  5071. var shadowOffsetX = this.shadowOffsetX;
  5072. var shadowOffsetY = this.shadowOffsetY;
  5073. var shadowBlur = this.shadowBlur;
  5074. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5075. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5076. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5077. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5078. 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));
  5079. }
  5080. else {
  5081. 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));
  5082. }
  5083. }
  5084. };
  5085. /** @hidden */
  5086. Control.prototype._markAsDirty = function (force) {
  5087. if (force === void 0) { force = false; }
  5088. if (!this._isVisible && !force) {
  5089. return;
  5090. }
  5091. this._isDirty = true;
  5092. // Redraw only this rectangle
  5093. if (this._host) {
  5094. this._host.markAsDirty();
  5095. }
  5096. };
  5097. /** @hidden */
  5098. Control.prototype._markAllAsDirty = function () {
  5099. this._markAsDirty();
  5100. if (this._font) {
  5101. this._prepareFont();
  5102. }
  5103. };
  5104. /** @hidden */
  5105. Control.prototype._link = function (host) {
  5106. this._host = host;
  5107. if (this._host) {
  5108. this.uniqueId = this._host.getScene().getUniqueId();
  5109. }
  5110. };
  5111. /** @hidden */
  5112. Control.prototype._transform = function (context) {
  5113. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  5114. return;
  5115. }
  5116. // postTranslate
  5117. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  5118. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  5119. if (context) {
  5120. context.translate(offsetX, offsetY);
  5121. // rotate
  5122. context.rotate(this._rotation);
  5123. // scale
  5124. context.scale(this._scaleX, this._scaleY);
  5125. // preTranslate
  5126. context.translate(-offsetX, -offsetY);
  5127. }
  5128. // Need to update matrices?
  5129. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  5130. this._cachedOffsetX = offsetX;
  5131. this._cachedOffsetY = offsetY;
  5132. this._isMatrixDirty = false;
  5133. this._flagDescendantsAsMatrixDirty();
  5134. _math2D__WEBPACK_IMPORTED_MODULE_4__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  5135. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  5136. }
  5137. };
  5138. /** @hidden */
  5139. Control.prototype._renderHighlight = function (context) {
  5140. if (!this.isHighlighted) {
  5141. return;
  5142. }
  5143. context.save();
  5144. context.strokeStyle = "#4affff";
  5145. context.lineWidth = 2;
  5146. this._renderHighlightSpecific(context);
  5147. context.restore();
  5148. };
  5149. /** @hidden */
  5150. Control.prototype._renderHighlightSpecific = function (context) {
  5151. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5152. };
  5153. /** @hidden */
  5154. Control.prototype._applyStates = function (context) {
  5155. if (this._isFontSizeInPercentage) {
  5156. this._fontSet = true;
  5157. }
  5158. if (this._fontSet) {
  5159. this._prepareFont();
  5160. this._fontSet = false;
  5161. }
  5162. if (this._font) {
  5163. context.font = this._font;
  5164. }
  5165. if (this._color) {
  5166. context.fillStyle = this._color;
  5167. }
  5168. if (Control.AllowAlphaInheritance) {
  5169. context.globalAlpha *= this._alpha;
  5170. }
  5171. else if (this._alphaSet) {
  5172. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  5173. }
  5174. };
  5175. /** @hidden */
  5176. Control.prototype._layout = function (parentMeasure, context) {
  5177. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  5178. return false;
  5179. }
  5180. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  5181. this.host._numLayoutCalls++;
  5182. this._currentMeasure.addAndTransformToRef(this._transformMatrix, -this.paddingLeftInPixels | 0, -this.paddingTopInPixels | 0, this.paddingRightInPixels | 0, this.paddingBottomInPixels | 0, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  5183. context.save();
  5184. this._applyStates(context);
  5185. var rebuildCount = 0;
  5186. do {
  5187. this._rebuildLayout = false;
  5188. this._processMeasures(parentMeasure, context);
  5189. rebuildCount++;
  5190. } while (this._rebuildLayout && rebuildCount < 3);
  5191. if (rebuildCount >= 3) {
  5192. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  5193. }
  5194. context.restore();
  5195. this.invalidateRect();
  5196. this._evaluateClippingState(parentMeasure);
  5197. }
  5198. this._wasDirty = this._isDirty;
  5199. this._isDirty = false;
  5200. return true;
  5201. };
  5202. /** @hidden */
  5203. Control.prototype._processMeasures = function (parentMeasure, context) {
  5204. this._currentMeasure.copyFrom(parentMeasure);
  5205. // Let children take some pre-measurement actions
  5206. this._preMeasure(parentMeasure, context);
  5207. this._measure();
  5208. this._computeAlignment(parentMeasure, context);
  5209. // Convert to int values
  5210. this._currentMeasure.left = this._currentMeasure.left | 0;
  5211. this._currentMeasure.top = this._currentMeasure.top | 0;
  5212. this._currentMeasure.width = this._currentMeasure.width | 0;
  5213. this._currentMeasure.height = this._currentMeasure.height | 0;
  5214. // Let children add more features
  5215. this._additionalProcessing(parentMeasure, context);
  5216. this._cachedParentMeasure.copyFrom(parentMeasure);
  5217. if (this.onDirtyObservable.hasObservers()) {
  5218. this.onDirtyObservable.notifyObservers(this);
  5219. }
  5220. };
  5221. Control.prototype._evaluateClippingState = function (parentMeasure) {
  5222. if (this.parent && this.parent.clipChildren) {
  5223. // Early clip
  5224. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  5225. this._isClipped = true;
  5226. return;
  5227. }
  5228. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  5229. this._isClipped = true;
  5230. return;
  5231. }
  5232. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  5233. this._isClipped = true;
  5234. return;
  5235. }
  5236. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  5237. this._isClipped = true;
  5238. return;
  5239. }
  5240. }
  5241. this._isClipped = false;
  5242. };
  5243. /** @hidden */
  5244. Control.prototype._measure = function () {
  5245. // Width / Height
  5246. if (this._width.isPixel) {
  5247. this._currentMeasure.width = this._width.getValue(this._host);
  5248. }
  5249. else {
  5250. this._currentMeasure.width *= this._width.getValue(this._host);
  5251. }
  5252. if (this._height.isPixel) {
  5253. this._currentMeasure.height = this._height.getValue(this._host);
  5254. }
  5255. else {
  5256. this._currentMeasure.height *= this._height.getValue(this._host);
  5257. }
  5258. if (this.fixedRatio !== 0) {
  5259. if (this._fixedRatioMasterIsWidth) {
  5260. this._currentMeasure.height = this._currentMeasure.width * this.fixedRatio;
  5261. }
  5262. else {
  5263. this._currentMeasure.width = this._currentMeasure.height * this.fixedRatio;
  5264. }
  5265. }
  5266. };
  5267. /** @hidden */
  5268. Control.prototype._computeAlignment = function (parentMeasure, context) {
  5269. var width = this._currentMeasure.width;
  5270. var height = this._currentMeasure.height;
  5271. var parentWidth = parentMeasure.width;
  5272. var parentHeight = parentMeasure.height;
  5273. // Left / top
  5274. var x = 0;
  5275. var y = 0;
  5276. switch (this.horizontalAlignment) {
  5277. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  5278. x = 0;
  5279. break;
  5280. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  5281. x = parentWidth - width;
  5282. break;
  5283. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  5284. x = (parentWidth - width) / 2;
  5285. break;
  5286. }
  5287. switch (this.verticalAlignment) {
  5288. case Control.VERTICAL_ALIGNMENT_TOP:
  5289. y = 0;
  5290. break;
  5291. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  5292. y = parentHeight - height;
  5293. break;
  5294. case Control.VERTICAL_ALIGNMENT_CENTER:
  5295. y = (parentHeight - height) / 2;
  5296. break;
  5297. }
  5298. if (this._paddingLeft.isPixel) {
  5299. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  5300. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  5301. }
  5302. else {
  5303. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  5304. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  5305. }
  5306. if (this._paddingRight.isPixel) {
  5307. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  5308. }
  5309. else {
  5310. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  5311. }
  5312. if (this._paddingTop.isPixel) {
  5313. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  5314. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  5315. }
  5316. else {
  5317. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  5318. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  5319. }
  5320. if (this._paddingBottom.isPixel) {
  5321. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  5322. }
  5323. else {
  5324. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  5325. }
  5326. if (this._left.isPixel) {
  5327. this._currentMeasure.left += this._left.getValue(this._host);
  5328. }
  5329. else {
  5330. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  5331. }
  5332. if (this._top.isPixel) {
  5333. this._currentMeasure.top += this._top.getValue(this._host);
  5334. }
  5335. else {
  5336. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5337. }
  5338. this._currentMeasure.left += x;
  5339. this._currentMeasure.top += y;
  5340. };
  5341. /** @hidden */
  5342. Control.prototype._preMeasure = function (parentMeasure, context) {
  5343. // Do nothing
  5344. };
  5345. /** @hidden */
  5346. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5347. // Do nothing
  5348. };
  5349. /** @hidden */
  5350. Control.prototype._clipForChildren = function (context) {
  5351. // DO nothing
  5352. };
  5353. Control.prototype._clip = function (context, invalidatedRectangle) {
  5354. context.beginPath();
  5355. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5356. if (invalidatedRectangle) {
  5357. // Rotate the invalidated rect into the control's space
  5358. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5359. // Get the intersection of the rect in context space and the current context
  5360. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"](0, 0, 0, 0);
  5361. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5362. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5363. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5364. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5365. Control._ClipMeasure.copyFrom(intersection);
  5366. }
  5367. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5368. var shadowOffsetX = this.shadowOffsetX;
  5369. var shadowOffsetY = this.shadowOffsetY;
  5370. var shadowBlur = this.shadowBlur;
  5371. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5372. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5373. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5374. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5375. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5376. }
  5377. else {
  5378. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5379. }
  5380. context.clip();
  5381. };
  5382. /** @hidden */
  5383. Control.prototype._render = function (context, invalidatedRectangle) {
  5384. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5385. this._isDirty = false;
  5386. return false;
  5387. }
  5388. this.host._numRenderCalls++;
  5389. context.save();
  5390. this._applyStates(context);
  5391. // Transform
  5392. this._transform(context);
  5393. // Clip
  5394. if (this.clipContent) {
  5395. this._clip(context, invalidatedRectangle);
  5396. }
  5397. if (this.onBeforeDrawObservable.hasObservers()) {
  5398. this.onBeforeDrawObservable.notifyObservers(this);
  5399. }
  5400. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5401. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5402. }
  5403. else {
  5404. this._draw(context, invalidatedRectangle);
  5405. }
  5406. if (this.useBitmapCache && this._wasDirty) {
  5407. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5408. }
  5409. this._renderHighlight(context);
  5410. if (this.onAfterDrawObservable.hasObservers()) {
  5411. this.onAfterDrawObservable.notifyObservers(this);
  5412. }
  5413. context.restore();
  5414. return true;
  5415. };
  5416. /** @hidden */
  5417. Control.prototype._draw = function (context, invalidatedRectangle) {
  5418. // Do nothing
  5419. };
  5420. /**
  5421. * Tests if a given coordinates belong to the current control
  5422. * @param x defines x coordinate to test
  5423. * @param y defines y coordinate to test
  5424. * @returns true if the coordinates are inside the control
  5425. */
  5426. Control.prototype.contains = function (x, y) {
  5427. // Invert transform
  5428. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5429. x = this._transformedPosition.x;
  5430. y = this._transformedPosition.y;
  5431. // Check
  5432. if (x < this._currentMeasure.left) {
  5433. return false;
  5434. }
  5435. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5436. return false;
  5437. }
  5438. if (y < this._currentMeasure.top) {
  5439. return false;
  5440. }
  5441. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5442. return false;
  5443. }
  5444. if (this.isPointerBlocker) {
  5445. this._host._shouldBlockPointer = true;
  5446. }
  5447. return true;
  5448. };
  5449. /** @hidden */
  5450. Control.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  5451. if (!this._isEnabled) {
  5452. return false;
  5453. }
  5454. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5455. return false;
  5456. }
  5457. if (!this.contains(x, y)) {
  5458. return false;
  5459. }
  5460. this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  5461. return true;
  5462. };
  5463. /** @hidden */
  5464. Control.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  5465. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this, pi);
  5466. if (canNotify && this.parent != null) {
  5467. this.parent._onPointerMove(target, coordinates, pointerId, pi);
  5468. }
  5469. };
  5470. /** @hidden */
  5471. Control.prototype._onPointerEnter = function (target, pi) {
  5472. if (!this._isEnabled) {
  5473. return false;
  5474. }
  5475. if (this._enterCount > 0) {
  5476. return false;
  5477. }
  5478. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5479. this._enterCount = 0;
  5480. }
  5481. this._enterCount++;
  5482. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this, pi);
  5483. if (canNotify && this.parent != null) {
  5484. this.parent._onPointerEnter(target, pi);
  5485. }
  5486. return true;
  5487. };
  5488. /** @hidden */
  5489. Control.prototype._onPointerOut = function (target, pi, force) {
  5490. if (force === void 0) { force = false; }
  5491. if (!force && (!this._isEnabled || target === this)) {
  5492. return;
  5493. }
  5494. this._enterCount = 0;
  5495. var canNotify = true;
  5496. if (!target.isAscendant(this)) {
  5497. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this, pi);
  5498. }
  5499. if (canNotify && this.parent != null) {
  5500. this.parent._onPointerOut(target, pi, force);
  5501. }
  5502. };
  5503. /** @hidden */
  5504. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  5505. // Prevent pointerout to lose control context.
  5506. // Event redundancy is checked inside the function.
  5507. this._onPointerEnter(this, pi);
  5508. if (this._downCount !== 0) {
  5509. return false;
  5510. }
  5511. this._downCount++;
  5512. this._downPointerIds[pointerId] = true;
  5513. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_4__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this, pi);
  5514. if (canNotify && this.parent != null) {
  5515. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex, pi);
  5516. }
  5517. return true;
  5518. };
  5519. /** @hidden */
  5520. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  5521. if (!this._isEnabled) {
  5522. return;
  5523. }
  5524. this._downCount = 0;
  5525. delete this._downPointerIds[pointerId];
  5526. var canNotifyClick = notifyClick;
  5527. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5528. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_4__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this, pi);
  5529. }
  5530. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_4__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this, pi);
  5531. if (canNotify && this.parent != null) {
  5532. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick, pi);
  5533. }
  5534. };
  5535. /** @hidden */
  5536. Control.prototype._forcePointerUp = function (pointerId) {
  5537. if (pointerId === void 0) { pointerId = null; }
  5538. if (pointerId !== null) {
  5539. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero(), pointerId, 0, true);
  5540. }
  5541. else {
  5542. for (var key in this._downPointerIds) {
  5543. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero(), +key, 0, true);
  5544. }
  5545. }
  5546. };
  5547. /** @hidden */
  5548. Control.prototype._onWheelScroll = function (deltaX, deltaY) {
  5549. if (!this._isEnabled) {
  5550. return;
  5551. }
  5552. var canNotify = this.onWheelObservable.notifyObservers(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](deltaX, deltaY));
  5553. if (canNotify && this.parent != null) {
  5554. this.parent._onWheelScroll(deltaX, deltaY);
  5555. }
  5556. };
  5557. /** @hidden */
  5558. Control.prototype._onCanvasBlur = function () { };
  5559. /** @hidden */
  5560. Control.prototype._processObservables = function (type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY) {
  5561. if (!this._isEnabled) {
  5562. return false;
  5563. }
  5564. this._dummyVector2.copyFromFloats(x, y);
  5565. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  5566. this._onPointerMove(this, this._dummyVector2, pointerId, pi);
  5567. var previousControlOver = this._host._lastControlOver[pointerId];
  5568. if (previousControlOver && previousControlOver !== this) {
  5569. previousControlOver._onPointerOut(this, pi);
  5570. }
  5571. if (previousControlOver !== this) {
  5572. this._onPointerEnter(this, pi);
  5573. }
  5574. this._host._lastControlOver[pointerId] = this;
  5575. return true;
  5576. }
  5577. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  5578. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex, pi);
  5579. this._host._registerLastControlDown(this, pointerId);
  5580. this._host._lastPickedControl = this;
  5581. return true;
  5582. }
  5583. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  5584. if (this._host._lastControlDown[pointerId]) {
  5585. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true, pi);
  5586. }
  5587. delete this._host._lastControlDown[pointerId];
  5588. return true;
  5589. }
  5590. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  5591. if (this._host._lastControlOver[pointerId]) {
  5592. this._host._lastControlOver[pointerId]._onWheelScroll(deltaX, deltaY);
  5593. return true;
  5594. }
  5595. }
  5596. return false;
  5597. };
  5598. Control.prototype._prepareFont = function () {
  5599. if (!this._font && !this._fontSet) {
  5600. return;
  5601. }
  5602. if (this._style) {
  5603. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5604. }
  5605. else {
  5606. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5607. }
  5608. this._fontOffset = Control._GetFontOffset(this._font);
  5609. };
  5610. /**
  5611. * Serializes the current control
  5612. * @param serializationObject defined the JSON serialized object
  5613. */
  5614. Control.prototype.serialize = function (serializationObject) {
  5615. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, serializationObject);
  5616. serializationObject.name = this.name;
  5617. serializationObject.className = this.getClassName();
  5618. if (this._font) {
  5619. serializationObject.fontFamily = this.fontFamily;
  5620. serializationObject.fontSize = this.fontSize;
  5621. serializationObject.fontWeight = this.fontWeight;
  5622. serializationObject.fontStyle = this.fontStyle;
  5623. }
  5624. };
  5625. /** @hidden */
  5626. Control.prototype._parseFromContent = function (serializedObject, host) {
  5627. if (serializedObject.fontFamily) {
  5628. this.fontFamily = serializedObject.fontFamily;
  5629. }
  5630. if (serializedObject.fontSize) {
  5631. this.fontSize = serializedObject.fontSize;
  5632. }
  5633. if (serializedObject.fontWeight) {
  5634. this.fontWeight = serializedObject.fontWeight;
  5635. }
  5636. if (serializedObject.fontStyle) {
  5637. this.fontStyle = serializedObject.fontStyle;
  5638. }
  5639. };
  5640. /** Releases associated resources */
  5641. Control.prototype.dispose = function () {
  5642. this.onDirtyObservable.clear();
  5643. this.onBeforeDrawObservable.clear();
  5644. this.onAfterDrawObservable.clear();
  5645. this.onPointerDownObservable.clear();
  5646. this.onPointerEnterObservable.clear();
  5647. this.onPointerMoveObservable.clear();
  5648. this.onPointerOutObservable.clear();
  5649. this.onPointerUpObservable.clear();
  5650. this.onPointerClickObservable.clear();
  5651. this.onWheelObservable.clear();
  5652. if (this._styleObserver && this._style) {
  5653. this._style.onChangedObservable.remove(this._styleObserver);
  5654. this._styleObserver = null;
  5655. }
  5656. if (this.parent) {
  5657. this.parent.removeControl(this);
  5658. this.parent = null;
  5659. }
  5660. if (this._host) {
  5661. var index = this._host._linkedControls.indexOf(this);
  5662. if (index > -1) {
  5663. this.linkWithMesh(null);
  5664. }
  5665. }
  5666. // Callback
  5667. this.onDisposeObservable.notifyObservers(this);
  5668. this.onDisposeObservable.clear();
  5669. };
  5670. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5671. /** HORIZONTAL_ALIGNMENT_LEFT */
  5672. get: function () {
  5673. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5674. },
  5675. enumerable: false,
  5676. configurable: true
  5677. });
  5678. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5679. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5680. get: function () {
  5681. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5682. },
  5683. enumerable: false,
  5684. configurable: true
  5685. });
  5686. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5687. /** HORIZONTAL_ALIGNMENT_CENTER */
  5688. get: function () {
  5689. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5690. },
  5691. enumerable: false,
  5692. configurable: true
  5693. });
  5694. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5695. /** VERTICAL_ALIGNMENT_TOP */
  5696. get: function () {
  5697. return Control._VERTICAL_ALIGNMENT_TOP;
  5698. },
  5699. enumerable: false,
  5700. configurable: true
  5701. });
  5702. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5703. /** VERTICAL_ALIGNMENT_BOTTOM */
  5704. get: function () {
  5705. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5706. },
  5707. enumerable: false,
  5708. configurable: true
  5709. });
  5710. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5711. /** VERTICAL_ALIGNMENT_CENTER */
  5712. get: function () {
  5713. return Control._VERTICAL_ALIGNMENT_CENTER;
  5714. },
  5715. enumerable: false,
  5716. configurable: true
  5717. });
  5718. /** @hidden */
  5719. Control._GetFontOffset = function (font) {
  5720. if (Control._FontHeightSizes[font]) {
  5721. return Control._FontHeightSizes[font];
  5722. }
  5723. var text = document.createElement("span");
  5724. text.innerHTML = "Hg";
  5725. text.style.font = font;
  5726. var block = document.createElement("div");
  5727. block.style.display = "inline-block";
  5728. block.style.width = "1px";
  5729. block.style.height = "0px";
  5730. block.style.verticalAlign = "bottom";
  5731. var div = document.createElement("div");
  5732. div.style.whiteSpace = "nowrap";
  5733. div.appendChild(text);
  5734. div.appendChild(block);
  5735. document.body.appendChild(div);
  5736. var fontAscent = 0;
  5737. var fontHeight = 0;
  5738. try {
  5739. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5740. block.style.verticalAlign = "baseline";
  5741. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5742. }
  5743. finally {
  5744. document.body.removeChild(div);
  5745. }
  5746. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5747. Control._FontHeightSizes[font] = result;
  5748. return result;
  5749. };
  5750. /**
  5751. * Creates a Control from parsed data
  5752. * @param serializedObject defines parsed data
  5753. * @param host defines the hosting AdvancedDynamicTexture
  5754. * @returns a new Control
  5755. */
  5756. Control.Parse = function (serializedObject, host) {
  5757. var controlType = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].Instantiate("BABYLON.GUI." + serializedObject.className);
  5758. var control = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new controlType(); }, serializedObject, null);
  5759. control.name = serializedObject.name;
  5760. control._parseFromContent(serializedObject, host);
  5761. return control;
  5762. };
  5763. /** @hidden */
  5764. Control.drawEllipse = function (x, y, width, height, context) {
  5765. context.translate(x, y);
  5766. context.scale(width, height);
  5767. context.beginPath();
  5768. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5769. context.closePath();
  5770. context.scale(1 / width, 1 / height);
  5771. context.translate(-x, -y);
  5772. };
  5773. /**
  5774. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5775. */
  5776. Control.AllowAlphaInheritance = false;
  5777. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"](0, 0, 0, 0);
  5778. // Statics
  5779. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5780. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5781. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5782. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5783. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5784. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5785. Control._FontHeightSizes = {};
  5786. /**
  5787. * Creates a stack panel that can be used to render headers
  5788. * @param control defines the control to associate with the header
  5789. * @param text defines the text of the header
  5790. * @param size defines the size of the header
  5791. * @param options defines options used to configure the header
  5792. * @returns a new StackPanel
  5793. * @ignore
  5794. * @hidden
  5795. */
  5796. Control.AddHeader = function () { };
  5797. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5798. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5799. ], Control.prototype, "metadata", void 0);
  5800. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5801. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5802. ], Control.prototype, "isHitTestVisible", void 0);
  5803. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5804. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5805. ], Control.prototype, "isPointerBlocker", void 0);
  5806. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5807. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5808. ], Control.prototype, "isFocusInvisible", void 0);
  5809. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5810. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5811. ], Control.prototype, "clipChildren", void 0);
  5812. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5813. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5814. ], Control.prototype, "clipContent", void 0);
  5815. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5816. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5817. ], Control.prototype, "useBitmapCache", void 0);
  5818. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5819. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5820. ], Control.prototype, "shadowOffsetX", null);
  5821. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5822. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5823. ], Control.prototype, "shadowOffsetY", null);
  5824. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5825. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5826. ], Control.prototype, "shadowBlur", null);
  5827. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5828. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5829. ], Control.prototype, "shadowColor", null);
  5830. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5831. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5832. ], Control.prototype, "hoverCursor", void 0);
  5833. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5834. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5835. ], Control.prototype, "fontOffset", null);
  5836. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5837. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5838. ], Control.prototype, "alpha", null);
  5839. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5840. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5841. ], Control.prototype, "scaleX", null);
  5842. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5843. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5844. ], Control.prototype, "scaleY", null);
  5845. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5846. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5847. ], Control.prototype, "rotation", null);
  5848. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5849. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5850. ], Control.prototype, "transformCenterY", null);
  5851. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5852. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5853. ], Control.prototype, "transformCenterX", null);
  5854. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5855. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5856. ], Control.prototype, "horizontalAlignment", null);
  5857. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5858. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5859. ], Control.prototype, "verticalAlignment", null);
  5860. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5861. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5862. ], Control.prototype, "fixedRatio", void 0);
  5863. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5864. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5865. ], Control.prototype, "width", null);
  5866. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5867. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5868. ], Control.prototype, "height", null);
  5869. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5870. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5871. ], Control.prototype, "style", null);
  5872. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5873. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5874. ], Control.prototype, "color", null);
  5875. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5876. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5877. ], Control.prototype, "zIndex", null);
  5878. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5879. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5880. ], Control.prototype, "notRenderable", null);
  5881. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5882. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5883. ], Control.prototype, "isVisible", null);
  5884. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5885. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5886. ], Control.prototype, "paddingLeft", null);
  5887. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5888. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5889. ], Control.prototype, "paddingRight", null);
  5890. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5891. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5892. ], Control.prototype, "paddingTop", null);
  5893. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5894. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5895. ], Control.prototype, "paddingBottom", null);
  5896. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5897. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5898. ], Control.prototype, "left", null);
  5899. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5900. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5901. ], Control.prototype, "top", null);
  5902. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5903. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5904. ], Control.prototype, "linkOffsetX", null);
  5905. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5906. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5907. ], Control.prototype, "linkOffsetY", null);
  5908. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5909. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5910. ], Control.prototype, "isEnabled", null);
  5911. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5912. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5913. ], Control.prototype, "disabledColor", null);
  5914. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5915. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5916. ], Control.prototype, "disabledColorItem", null);
  5917. return Control;
  5918. }());
  5919. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5920. /***/ }),
  5921. /***/ "./2D/controls/displayGrid.ts":
  5922. /*!************************************!*\
  5923. !*** ./2D/controls/displayGrid.ts ***!
  5924. \************************************/
  5925. /*! exports provided: DisplayGrid */
  5926. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5927. "use strict";
  5928. __webpack_require__.r(__webpack_exports__);
  5929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5930. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5931. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5932. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5933. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5934. /** Class used to render a grid */
  5935. var DisplayGrid = /** @class */ (function (_super) {
  5936. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5937. /**
  5938. * Creates a new GridDisplayRectangle
  5939. * @param name defines the control name
  5940. */
  5941. function DisplayGrid(name) {
  5942. var _this = _super.call(this, name) || this;
  5943. _this.name = name;
  5944. _this._cellWidth = 20;
  5945. _this._cellHeight = 20;
  5946. _this._minorLineTickness = 1;
  5947. _this._minorLineColor = "DarkGray";
  5948. _this._majorLineTickness = 2;
  5949. _this._majorLineColor = "White";
  5950. _this._majorLineFrequency = 5;
  5951. _this._background = "Black";
  5952. _this._displayMajorLines = true;
  5953. _this._displayMinorLines = true;
  5954. return _this;
  5955. }
  5956. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5957. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5958. get: function () {
  5959. return this._displayMinorLines;
  5960. },
  5961. set: function (value) {
  5962. if (this._displayMinorLines === value) {
  5963. return;
  5964. }
  5965. this._displayMinorLines = value;
  5966. this._markAsDirty();
  5967. },
  5968. enumerable: false,
  5969. configurable: true
  5970. });
  5971. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5972. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5973. get: function () {
  5974. return this._displayMajorLines;
  5975. },
  5976. set: function (value) {
  5977. if (this._displayMajorLines === value) {
  5978. return;
  5979. }
  5980. this._displayMajorLines = value;
  5981. this._markAsDirty();
  5982. },
  5983. enumerable: false,
  5984. configurable: true
  5985. });
  5986. Object.defineProperty(DisplayGrid.prototype, "background", {
  5987. /** Gets or sets background color (Black by default) */
  5988. get: function () {
  5989. return this._background;
  5990. },
  5991. set: function (value) {
  5992. if (this._background === value) {
  5993. return;
  5994. }
  5995. this._background = value;
  5996. this._markAsDirty();
  5997. },
  5998. enumerable: false,
  5999. configurable: true
  6000. });
  6001. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  6002. /** Gets or sets the width of each cell (20 by default) */
  6003. get: function () {
  6004. return this._cellWidth;
  6005. },
  6006. set: function (value) {
  6007. this._cellWidth = value;
  6008. this._markAsDirty();
  6009. },
  6010. enumerable: false,
  6011. configurable: true
  6012. });
  6013. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  6014. /** Gets or sets the height of each cell (20 by default) */
  6015. get: function () {
  6016. return this._cellHeight;
  6017. },
  6018. set: function (value) {
  6019. this._cellHeight = value;
  6020. this._markAsDirty();
  6021. },
  6022. enumerable: false,
  6023. configurable: true
  6024. });
  6025. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  6026. /** Gets or sets the tickness of minor lines (1 by default) */
  6027. get: function () {
  6028. return this._minorLineTickness;
  6029. },
  6030. set: function (value) {
  6031. this._minorLineTickness = value;
  6032. this._markAsDirty();
  6033. },
  6034. enumerable: false,
  6035. configurable: true
  6036. });
  6037. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  6038. /** Gets or sets the color of minor lines (DarkGray by default) */
  6039. get: function () {
  6040. return this._minorLineColor;
  6041. },
  6042. set: function (value) {
  6043. this._minorLineColor = value;
  6044. this._markAsDirty();
  6045. },
  6046. enumerable: false,
  6047. configurable: true
  6048. });
  6049. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  6050. /** Gets or sets the tickness of major lines (2 by default) */
  6051. get: function () {
  6052. return this._majorLineTickness;
  6053. },
  6054. set: function (value) {
  6055. this._majorLineTickness = value;
  6056. this._markAsDirty();
  6057. },
  6058. enumerable: false,
  6059. configurable: true
  6060. });
  6061. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  6062. /** Gets or sets the color of major lines (White by default) */
  6063. get: function () {
  6064. return this._majorLineColor;
  6065. },
  6066. set: function (value) {
  6067. this._majorLineColor = value;
  6068. this._markAsDirty();
  6069. },
  6070. enumerable: false,
  6071. configurable: true
  6072. });
  6073. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  6074. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  6075. get: function () {
  6076. return this._majorLineFrequency;
  6077. },
  6078. set: function (value) {
  6079. this._majorLineFrequency = value;
  6080. this._markAsDirty();
  6081. },
  6082. enumerable: false,
  6083. configurable: true
  6084. });
  6085. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  6086. context.save();
  6087. this._applyStates(context);
  6088. if (this._isEnabled) {
  6089. if (this._background) {
  6090. context.fillStyle = this._background;
  6091. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6092. }
  6093. var cellCountX = this._currentMeasure.width / this._cellWidth;
  6094. var cellCountY = this._currentMeasure.height / this._cellHeight;
  6095. // Minor lines
  6096. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  6097. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  6098. if (this._displayMinorLines) {
  6099. context.strokeStyle = this._minorLineColor;
  6100. context.lineWidth = this._minorLineTickness;
  6101. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  6102. var cellX = left + x * this.cellWidth;
  6103. context.beginPath();
  6104. context.moveTo(cellX, this._currentMeasure.top);
  6105. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  6106. context.stroke();
  6107. }
  6108. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  6109. var cellY = top_1 + y * this.cellHeight;
  6110. context.beginPath();
  6111. context.moveTo(this._currentMeasure.left, cellY);
  6112. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  6113. context.stroke();
  6114. }
  6115. }
  6116. // Major lines
  6117. if (this._displayMajorLines) {
  6118. context.strokeStyle = this._majorLineColor;
  6119. context.lineWidth = this._majorLineTickness;
  6120. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  6121. var cellX = left + x * this.cellWidth;
  6122. context.beginPath();
  6123. context.moveTo(cellX, this._currentMeasure.top);
  6124. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  6125. context.stroke();
  6126. }
  6127. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  6128. var cellY = top_1 + y * this.cellHeight;
  6129. context.moveTo(this._currentMeasure.left, cellY);
  6130. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  6131. context.closePath();
  6132. context.stroke();
  6133. }
  6134. }
  6135. }
  6136. context.restore();
  6137. };
  6138. DisplayGrid.prototype._getTypeName = function () {
  6139. return "DisplayGrid";
  6140. };
  6141. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6142. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6143. ], DisplayGrid.prototype, "displayMinorLines", null);
  6144. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6145. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6146. ], DisplayGrid.prototype, "displayMajorLines", null);
  6147. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6148. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6149. ], DisplayGrid.prototype, "background", null);
  6150. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6151. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6152. ], DisplayGrid.prototype, "cellWidth", null);
  6153. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6154. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6155. ], DisplayGrid.prototype, "cellHeight", null);
  6156. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6157. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6158. ], DisplayGrid.prototype, "minorLineTickness", null);
  6159. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6160. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6161. ], DisplayGrid.prototype, "minorLineColor", null);
  6162. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6163. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6164. ], DisplayGrid.prototype, "majorLineTickness", null);
  6165. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6166. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6167. ], DisplayGrid.prototype, "majorLineColor", null);
  6168. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6169. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6170. ], DisplayGrid.prototype, "majorLineFrequency", null);
  6171. return DisplayGrid;
  6172. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  6173. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  6174. /***/ }),
  6175. /***/ "./2D/controls/ellipse.ts":
  6176. /*!********************************!*\
  6177. !*** ./2D/controls/ellipse.ts ***!
  6178. \********************************/
  6179. /*! exports provided: Ellipse */
  6180. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6181. "use strict";
  6182. __webpack_require__.r(__webpack_exports__);
  6183. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  6184. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6185. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6186. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6187. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  6188. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  6189. /** Class used to create 2D ellipse containers */
  6190. var Ellipse = /** @class */ (function (_super) {
  6191. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  6192. /**
  6193. * Creates a new Ellipse
  6194. * @param name defines the control name
  6195. */
  6196. function Ellipse(name) {
  6197. var _this = _super.call(this, name) || this;
  6198. _this.name = name;
  6199. _this._thickness = 1;
  6200. return _this;
  6201. }
  6202. Object.defineProperty(Ellipse.prototype, "thickness", {
  6203. /** Gets or sets border thickness */
  6204. get: function () {
  6205. return this._thickness;
  6206. },
  6207. set: function (value) {
  6208. if (this._thickness === value) {
  6209. return;
  6210. }
  6211. this._thickness = value;
  6212. this._markAsDirty();
  6213. },
  6214. enumerable: false,
  6215. configurable: true
  6216. });
  6217. Ellipse.prototype._getTypeName = function () {
  6218. return "Ellipse";
  6219. };
  6220. Ellipse.prototype._localDraw = function (context) {
  6221. context.save();
  6222. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6223. context.shadowColor = this.shadowColor;
  6224. context.shadowBlur = this.shadowBlur;
  6225. context.shadowOffsetX = this.shadowOffsetX;
  6226. context.shadowOffsetY = this.shadowOffsetY;
  6227. }
  6228. _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);
  6229. if (this._background) {
  6230. context.fillStyle = this._background;
  6231. context.fill();
  6232. }
  6233. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6234. context.shadowBlur = 0;
  6235. context.shadowOffsetX = 0;
  6236. context.shadowOffsetY = 0;
  6237. }
  6238. if (this._thickness) {
  6239. if (this.color) {
  6240. context.strokeStyle = this.color;
  6241. }
  6242. context.lineWidth = this._thickness;
  6243. context.stroke();
  6244. }
  6245. context.restore();
  6246. };
  6247. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  6248. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6249. this._measureForChildren.width -= 2 * this._thickness;
  6250. this._measureForChildren.height -= 2 * this._thickness;
  6251. this._measureForChildren.left += this._thickness;
  6252. this._measureForChildren.top += this._thickness;
  6253. };
  6254. Ellipse.prototype._clipForChildren = function (context) {
  6255. _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);
  6256. context.clip();
  6257. };
  6258. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6259. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["serialize"])()
  6260. ], Ellipse.prototype, "thickness", null);
  6261. return Ellipse;
  6262. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6263. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  6264. /***/ }),
  6265. /***/ "./2D/controls/focusableButton.ts":
  6266. /*!****************************************!*\
  6267. !*** ./2D/controls/focusableButton.ts ***!
  6268. \****************************************/
  6269. /*! exports provided: FocusableButton */
  6270. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6271. "use strict";
  6272. __webpack_require__.r(__webpack_exports__);
  6273. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return FocusableButton; });
  6274. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6275. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6276. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  6277. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  6278. /**
  6279. * Class used to create a focusable button that can easily handle keyboard events
  6280. */
  6281. var FocusableButton = /** @class */ (function (_super) {
  6282. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FocusableButton, _super);
  6283. function FocusableButton(name) {
  6284. var _this = _super.call(this, name) || this;
  6285. _this.name = name;
  6286. /** Highlight color when button is focused */
  6287. _this.focusedColor = null;
  6288. _this._isFocused = false;
  6289. _this._unfocusedColor = null;
  6290. /** Observable raised when the control gets the focus */
  6291. _this.onFocusObservable = new babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  6292. /** Observable raised when the control loses the focus */
  6293. _this.onBlurObservable = new babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  6294. /** Observable raised when a key event was processed */
  6295. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  6296. _this._unfocusedColor = _this.color;
  6297. return _this;
  6298. }
  6299. /** @hidden */
  6300. FocusableButton.prototype.onBlur = function () {
  6301. if (this._isFocused) {
  6302. this._isFocused = false;
  6303. if (this.focusedColor && this._unfocusedColor != null) {
  6304. // Set color back to saved unfocused color
  6305. this.color = this._unfocusedColor;
  6306. }
  6307. this.onBlurObservable.notifyObservers(this);
  6308. }
  6309. };
  6310. /** @hidden */
  6311. FocusableButton.prototype.onFocus = function () {
  6312. this._isFocused = true;
  6313. if (this.focusedColor) {
  6314. // Save the unfocused color
  6315. this._unfocusedColor = this.color;
  6316. this.color = this.focusedColor;
  6317. }
  6318. this.onFocusObservable.notifyObservers(this);
  6319. };
  6320. /**
  6321. * Function called to get the list of controls that should not steal the focus from this control
  6322. * @returns an array of controls
  6323. */
  6324. FocusableButton.prototype.keepsFocusWith = function () {
  6325. return null;
  6326. };
  6327. /**
  6328. * Function to focus a button programmatically
  6329. */
  6330. FocusableButton.prototype.focus = function () {
  6331. this._host.moveFocusToControl(this);
  6332. };
  6333. /**
  6334. * Function to unfocus a button programmatically
  6335. */
  6336. FocusableButton.prototype.blur = function () {
  6337. this._host.focusedControl = null;
  6338. };
  6339. /**
  6340. * Handles the keyboard event
  6341. * @param evt Defines the KeyboardEvent
  6342. */
  6343. FocusableButton.prototype.processKeyboard = function (evt) {
  6344. this.onKeyboardEventProcessedObservable.notifyObservers(evt, -1, this);
  6345. };
  6346. /** @hidden */
  6347. FocusableButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  6348. // Clicking on button should focus
  6349. this.focus();
  6350. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi);
  6351. };
  6352. /** @hidden */
  6353. FocusableButton.prototype.displose = function () {
  6354. _super.prototype.dispose.call(this);
  6355. this.onBlurObservable.clear();
  6356. this.onFocusObservable.clear();
  6357. this.onKeyboardEventProcessedObservable.clear();
  6358. };
  6359. return FocusableButton;
  6360. }(_button__WEBPACK_IMPORTED_MODULE_1__["Button"]));
  6361. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FocusableButton"] = FocusableButton;
  6362. /***/ }),
  6363. /***/ "./2D/controls/grid.ts":
  6364. /*!*****************************!*\
  6365. !*** ./2D/controls/grid.ts ***!
  6366. \*****************************/
  6367. /*! exports provided: Grid */
  6368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6369. "use strict";
  6370. __webpack_require__.r(__webpack_exports__);
  6371. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  6372. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6373. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6374. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6375. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6376. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  6377. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  6378. /**
  6379. * Class used to create a 2D grid container
  6380. */
  6381. var Grid = /** @class */ (function (_super) {
  6382. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  6383. /**
  6384. * Creates a new Grid
  6385. * @param name defines control name
  6386. */
  6387. function Grid(name) {
  6388. var _this = _super.call(this, name) || this;
  6389. _this.name = name;
  6390. _this._rowDefinitions = new Array();
  6391. _this._columnDefinitions = new Array();
  6392. _this._cells = {};
  6393. _this._childControls = new Array();
  6394. return _this;
  6395. }
  6396. Object.defineProperty(Grid.prototype, "columnCount", {
  6397. /**
  6398. * Gets the number of columns
  6399. */
  6400. get: function () {
  6401. return this._columnDefinitions.length;
  6402. },
  6403. enumerable: false,
  6404. configurable: true
  6405. });
  6406. Object.defineProperty(Grid.prototype, "rowCount", {
  6407. /**
  6408. * Gets the number of rows
  6409. */
  6410. get: function () {
  6411. return this._rowDefinitions.length;
  6412. },
  6413. enumerable: false,
  6414. configurable: true
  6415. });
  6416. Object.defineProperty(Grid.prototype, "children", {
  6417. /** Gets the list of children */
  6418. get: function () {
  6419. return this._childControls;
  6420. },
  6421. enumerable: false,
  6422. configurable: true
  6423. });
  6424. Object.defineProperty(Grid.prototype, "cells", {
  6425. /** Gets the list of cells (e.g. the containers) */
  6426. get: function () {
  6427. return this._cells;
  6428. },
  6429. enumerable: false,
  6430. configurable: true
  6431. });
  6432. /**
  6433. * Gets the definition of a specific row
  6434. * @param index defines the index of the row
  6435. * @returns the row definition
  6436. */
  6437. Grid.prototype.getRowDefinition = function (index) {
  6438. if (index < 0 || index >= this._rowDefinitions.length) {
  6439. return null;
  6440. }
  6441. return this._rowDefinitions[index];
  6442. };
  6443. /**
  6444. * Gets the definition of a specific column
  6445. * @param index defines the index of the column
  6446. * @returns the column definition
  6447. */
  6448. Grid.prototype.getColumnDefinition = function (index) {
  6449. if (index < 0 || index >= this._columnDefinitions.length) {
  6450. return null;
  6451. }
  6452. return this._columnDefinitions[index];
  6453. };
  6454. /**
  6455. * Adds a new row to the grid
  6456. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  6457. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  6458. * @returns the current grid
  6459. */
  6460. Grid.prototype.addRowDefinition = function (height, isPixel) {
  6461. if (isPixel === void 0) { isPixel = false; }
  6462. 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));
  6463. this._markAsDirty();
  6464. return this;
  6465. };
  6466. /**
  6467. * Adds a new column to the grid
  6468. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  6469. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  6470. * @returns the current grid
  6471. */
  6472. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  6473. if (isPixel === void 0) { isPixel = false; }
  6474. 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));
  6475. this._markAsDirty();
  6476. return this;
  6477. };
  6478. /**
  6479. * Update a row definition
  6480. * @param index defines the index of the row to update
  6481. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  6482. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  6483. * @returns the current grid
  6484. */
  6485. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  6486. if (isPixel === void 0) { isPixel = false; }
  6487. if (index < 0 || index >= this._rowDefinitions.length) {
  6488. return this;
  6489. }
  6490. var current = this._rowDefinitions[index];
  6491. if (current && current.isPixel === isPixel && current.internalValue === height) {
  6492. return this;
  6493. }
  6494. 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);
  6495. this._markAsDirty();
  6496. return this;
  6497. };
  6498. /**
  6499. * Update a column definition
  6500. * @param index defines the index of the column to update
  6501. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  6502. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  6503. * @returns the current grid
  6504. */
  6505. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  6506. if (isPixel === void 0) { isPixel = false; }
  6507. if (index < 0 || index >= this._columnDefinitions.length) {
  6508. return this;
  6509. }
  6510. var current = this._columnDefinitions[index];
  6511. if (current && current.isPixel === isPixel && current.internalValue === width) {
  6512. return this;
  6513. }
  6514. 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);
  6515. this._markAsDirty();
  6516. return this;
  6517. };
  6518. /**
  6519. * Gets the list of children stored in a specific cell
  6520. * @param row defines the row to check
  6521. * @param column defines the column to check
  6522. * @returns the list of controls
  6523. */
  6524. Grid.prototype.getChildrenAt = function (row, column) {
  6525. var cell = this._cells[row + ":" + column];
  6526. if (!cell) {
  6527. return null;
  6528. }
  6529. return cell.children;
  6530. };
  6531. /**
  6532. * Gets a string representing the child cell info (row x column)
  6533. * @param child defines the control to get info from
  6534. * @returns a string containing the child cell info (row x column)
  6535. */
  6536. Grid.prototype.getChildCellInfo = function (child) {
  6537. return child._tag;
  6538. };
  6539. Grid.prototype._removeCell = function (cell, key) {
  6540. if (!cell) {
  6541. return;
  6542. }
  6543. _super.prototype.removeControl.call(this, cell);
  6544. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  6545. var control = _a[_i];
  6546. var childIndex = this._childControls.indexOf(control);
  6547. if (childIndex !== -1) {
  6548. this._childControls.splice(childIndex, 1);
  6549. }
  6550. }
  6551. delete this._cells[key];
  6552. };
  6553. Grid.prototype._offsetCell = function (previousKey, key) {
  6554. if (!this._cells[key]) {
  6555. return;
  6556. }
  6557. this._cells[previousKey] = this._cells[key];
  6558. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  6559. var control = _a[_i];
  6560. control._tag = previousKey;
  6561. }
  6562. delete this._cells[key];
  6563. };
  6564. /**
  6565. * Remove a column definition at specified index
  6566. * @param index defines the index of the column to remove
  6567. * @returns the current grid
  6568. */
  6569. Grid.prototype.removeColumnDefinition = function (index) {
  6570. if (index < 0 || index >= this._columnDefinitions.length) {
  6571. return this;
  6572. }
  6573. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6574. var key = x + ":" + index;
  6575. var cell = this._cells[key];
  6576. this._removeCell(cell, key);
  6577. }
  6578. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6579. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  6580. var previousKey = x + ":" + (y - 1);
  6581. var key = x + ":" + y;
  6582. this._offsetCell(previousKey, key);
  6583. }
  6584. }
  6585. this._columnDefinitions.splice(index, 1);
  6586. this._markAsDirty();
  6587. return this;
  6588. };
  6589. /**
  6590. * Remove a row definition at specified index
  6591. * @param index defines the index of the row to remove
  6592. * @returns the current grid
  6593. */
  6594. Grid.prototype.removeRowDefinition = function (index) {
  6595. if (index < 0 || index >= this._rowDefinitions.length) {
  6596. return this;
  6597. }
  6598. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6599. var key = index + ":" + y;
  6600. var cell = this._cells[key];
  6601. this._removeCell(cell, key);
  6602. }
  6603. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6604. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  6605. var previousKey = x - 1 + ":" + y;
  6606. var key = x + ":" + y;
  6607. this._offsetCell(previousKey, key);
  6608. }
  6609. }
  6610. this._rowDefinitions.splice(index, 1);
  6611. this._markAsDirty();
  6612. return this;
  6613. };
  6614. /**
  6615. * Adds a new control to the current grid
  6616. * @param control defines the control to add
  6617. * @param row defines the row where to add the control (0 by default)
  6618. * @param column defines the column where to add the control (0 by default)
  6619. * @returns the current grid
  6620. */
  6621. Grid.prototype.addControl = function (control, row, column) {
  6622. if (row === void 0) { row = 0; }
  6623. if (column === void 0) { column = 0; }
  6624. if (this._rowDefinitions.length === 0) {
  6625. // Add default row definition
  6626. this.addRowDefinition(1, false);
  6627. }
  6628. if (this._columnDefinitions.length === 0) {
  6629. // Add default column definition
  6630. this.addColumnDefinition(1, false);
  6631. }
  6632. if (this._childControls.indexOf(control) !== -1) {
  6633. 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");
  6634. return this;
  6635. }
  6636. var x = Math.min(row, this._rowDefinitions.length - 1);
  6637. var y = Math.min(column, this._columnDefinitions.length - 1);
  6638. var key = x + ":" + y;
  6639. var goodContainer = this._cells[key];
  6640. if (!goodContainer) {
  6641. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6642. this._cells[key] = goodContainer;
  6643. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6644. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6645. _super.prototype.addControl.call(this, goodContainer);
  6646. }
  6647. goodContainer.addControl(control);
  6648. this._childControls.push(control);
  6649. control._tag = key;
  6650. control.parent = this;
  6651. this._markAsDirty();
  6652. return this;
  6653. };
  6654. /**
  6655. * Removes a control from the current container
  6656. * @param control defines the control to remove
  6657. * @returns the current container
  6658. */
  6659. Grid.prototype.removeControl = function (control) {
  6660. var index = this._childControls.indexOf(control);
  6661. if (index !== -1) {
  6662. this._childControls.splice(index, 1);
  6663. }
  6664. var cell = this._cells[control._tag];
  6665. if (cell) {
  6666. cell.removeControl(control);
  6667. control._tag = null;
  6668. }
  6669. this._markAsDirty();
  6670. return this;
  6671. };
  6672. Grid.prototype._getTypeName = function () {
  6673. return "Grid";
  6674. };
  6675. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6676. var widths = [];
  6677. var heights = [];
  6678. var lefts = [];
  6679. var tops = [];
  6680. var availableWidth = this._currentMeasure.width;
  6681. var globalWidthPercentage = 0;
  6682. var availableHeight = this._currentMeasure.height;
  6683. var globalHeightPercentage = 0;
  6684. // Heights
  6685. var index = 0;
  6686. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6687. var value = _a[_i];
  6688. if (value.isPixel) {
  6689. var height = value.getValue(this._host);
  6690. availableHeight -= height;
  6691. heights[index] = height;
  6692. }
  6693. else {
  6694. globalHeightPercentage += value.internalValue;
  6695. }
  6696. index++;
  6697. }
  6698. var top = 0;
  6699. index = 0;
  6700. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6701. var value = _c[_b];
  6702. tops.push(top);
  6703. if (!value.isPixel) {
  6704. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6705. top += height;
  6706. heights[index] = height;
  6707. }
  6708. else {
  6709. top += value.getValue(this._host);
  6710. }
  6711. index++;
  6712. }
  6713. // Widths
  6714. index = 0;
  6715. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6716. var value = _e[_d];
  6717. if (value.isPixel) {
  6718. var width = value.getValue(this._host);
  6719. availableWidth -= width;
  6720. widths[index] = width;
  6721. }
  6722. else {
  6723. globalWidthPercentage += value.internalValue;
  6724. }
  6725. index++;
  6726. }
  6727. var left = 0;
  6728. index = 0;
  6729. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6730. var value = _g[_f];
  6731. lefts.push(left);
  6732. if (!value.isPixel) {
  6733. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6734. left += width;
  6735. widths[index] = width;
  6736. }
  6737. else {
  6738. left += value.getValue(this._host);
  6739. }
  6740. index++;
  6741. }
  6742. definitionCallback(lefts, tops, widths, heights);
  6743. };
  6744. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6745. var _this = this;
  6746. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6747. // Setting child sizes
  6748. for (var key in _this._cells) {
  6749. if (!_this._cells.hasOwnProperty(key)) {
  6750. continue;
  6751. }
  6752. var split = key.split(":");
  6753. var x = parseInt(split[0]);
  6754. var y = parseInt(split[1]);
  6755. var cell = _this._cells[key];
  6756. cell.left = lefts[y] + "px";
  6757. cell.top = tops[x] + "px";
  6758. cell.width = widths[y] + "px";
  6759. cell.height = heights[x] + "px";
  6760. cell._left.ignoreAdaptiveScaling = true;
  6761. cell._top.ignoreAdaptiveScaling = true;
  6762. cell._width.ignoreAdaptiveScaling = true;
  6763. cell._height.ignoreAdaptiveScaling = true;
  6764. }
  6765. });
  6766. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6767. };
  6768. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6769. for (var key in this._cells) {
  6770. if (!this._cells.hasOwnProperty(key)) {
  6771. continue;
  6772. }
  6773. var child = this._cells[key];
  6774. child._markMatrixAsDirty();
  6775. }
  6776. };
  6777. Grid.prototype._renderHighlightSpecific = function (context) {
  6778. var _this = this;
  6779. _super.prototype._renderHighlightSpecific.call(this, context);
  6780. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6781. // Columns
  6782. for (var index = 0; index < lefts.length; index++) {
  6783. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6784. context.beginPath();
  6785. context.moveTo(left, _this._currentMeasure.top);
  6786. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6787. context.stroke();
  6788. }
  6789. // Rows
  6790. for (var index = 0; index < tops.length; index++) {
  6791. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6792. context.beginPath();
  6793. context.moveTo(_this._currentMeasure.left, top_1);
  6794. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6795. context.stroke();
  6796. }
  6797. });
  6798. context.restore();
  6799. };
  6800. /** Releases associated resources */
  6801. Grid.prototype.dispose = function () {
  6802. _super.prototype.dispose.call(this);
  6803. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6804. var control = _a[_i];
  6805. control.dispose();
  6806. }
  6807. this._childControls = [];
  6808. };
  6809. return Grid;
  6810. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6811. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6812. /***/ }),
  6813. /***/ "./2D/controls/image.ts":
  6814. /*!******************************!*\
  6815. !*** ./2D/controls/image.ts ***!
  6816. \******************************/
  6817. /*! exports provided: Image */
  6818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6819. "use strict";
  6820. __webpack_require__.r(__webpack_exports__);
  6821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6822. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6823. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6824. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6825. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6826. /**
  6827. * Class used to create 2D images
  6828. */
  6829. var Image = /** @class */ (function (_super) {
  6830. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6831. /**
  6832. * Creates a new Image
  6833. * @param name defines the control name
  6834. * @param url defines the image url
  6835. */
  6836. function Image(name, url) {
  6837. if (url === void 0) { url = null; }
  6838. var _this = _super.call(this, name) || this;
  6839. _this.name = name;
  6840. _this._workingCanvas = null;
  6841. _this._loaded = false;
  6842. _this._stretch = Image.STRETCH_FILL;
  6843. _this._autoScale = false;
  6844. _this._sourceLeft = 0;
  6845. _this._sourceTop = 0;
  6846. _this._sourceWidth = 0;
  6847. _this._sourceHeight = 0;
  6848. _this._svgAttributesComputationCompleted = false;
  6849. _this._isSVG = false;
  6850. _this._cellWidth = 0;
  6851. _this._cellHeight = 0;
  6852. _this._cellId = -1;
  6853. _this._populateNinePatchSlicesFromImage = false;
  6854. _this._imageDataCache = { data: null, key: "" };
  6855. /**
  6856. * Observable notified when the content is loaded
  6857. */
  6858. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6859. /**
  6860. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6861. */
  6862. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6863. _this.source = url;
  6864. return _this;
  6865. }
  6866. Object.defineProperty(Image.prototype, "isLoaded", {
  6867. /**
  6868. * Gets a boolean indicating that the content is loaded
  6869. */
  6870. get: function () {
  6871. return this._loaded;
  6872. },
  6873. enumerable: false,
  6874. configurable: true
  6875. });
  6876. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6877. /**
  6878. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6879. */
  6880. get: function () {
  6881. return this._populateNinePatchSlicesFromImage;
  6882. },
  6883. set: function (value) {
  6884. if (this._populateNinePatchSlicesFromImage === value) {
  6885. return;
  6886. }
  6887. this._populateNinePatchSlicesFromImage = value;
  6888. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6889. this._extractNinePatchSliceDataFromImage();
  6890. }
  6891. },
  6892. enumerable: false,
  6893. configurable: true
  6894. });
  6895. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6896. /**
  6897. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6898. * Beware using this as this will comsume more memory as the image has to be stored twice
  6899. */
  6900. get: function () {
  6901. return this._detectPointerOnOpaqueOnly;
  6902. },
  6903. set: function (value) {
  6904. if (this._detectPointerOnOpaqueOnly === value) {
  6905. return;
  6906. }
  6907. this._detectPointerOnOpaqueOnly = value;
  6908. },
  6909. enumerable: false,
  6910. configurable: true
  6911. });
  6912. Object.defineProperty(Image.prototype, "sliceLeft", {
  6913. /**
  6914. * Gets or sets the left value for slicing (9-patch)
  6915. */
  6916. get: function () {
  6917. return this._sliceLeft;
  6918. },
  6919. set: function (value) {
  6920. if (this._sliceLeft === value) {
  6921. return;
  6922. }
  6923. this._sliceLeft = value;
  6924. this._markAsDirty();
  6925. },
  6926. enumerable: false,
  6927. configurable: true
  6928. });
  6929. Object.defineProperty(Image.prototype, "sliceRight", {
  6930. /**
  6931. * Gets or sets the right value for slicing (9-patch)
  6932. */
  6933. get: function () {
  6934. return this._sliceRight;
  6935. },
  6936. set: function (value) {
  6937. if (this._sliceRight === value) {
  6938. return;
  6939. }
  6940. this._sliceRight = value;
  6941. this._markAsDirty();
  6942. },
  6943. enumerable: false,
  6944. configurable: true
  6945. });
  6946. Object.defineProperty(Image.prototype, "sliceTop", {
  6947. /**
  6948. * Gets or sets the top value for slicing (9-patch)
  6949. */
  6950. get: function () {
  6951. return this._sliceTop;
  6952. },
  6953. set: function (value) {
  6954. if (this._sliceTop === value) {
  6955. return;
  6956. }
  6957. this._sliceTop = value;
  6958. this._markAsDirty();
  6959. },
  6960. enumerable: false,
  6961. configurable: true
  6962. });
  6963. Object.defineProperty(Image.prototype, "sliceBottom", {
  6964. /**
  6965. * Gets or sets the bottom value for slicing (9-patch)
  6966. */
  6967. get: function () {
  6968. return this._sliceBottom;
  6969. },
  6970. set: function (value) {
  6971. if (this._sliceBottom === value) {
  6972. return;
  6973. }
  6974. this._sliceBottom = value;
  6975. this._markAsDirty();
  6976. },
  6977. enumerable: false,
  6978. configurable: true
  6979. });
  6980. Object.defineProperty(Image.prototype, "sourceLeft", {
  6981. /**
  6982. * Gets or sets the left coordinate in the source image
  6983. */
  6984. get: function () {
  6985. return this._sourceLeft;
  6986. },
  6987. set: function (value) {
  6988. if (this._sourceLeft === value) {
  6989. return;
  6990. }
  6991. this._sourceLeft = value;
  6992. this._markAsDirty();
  6993. },
  6994. enumerable: false,
  6995. configurable: true
  6996. });
  6997. Object.defineProperty(Image.prototype, "sourceTop", {
  6998. /**
  6999. * Gets or sets the top coordinate in the source image
  7000. */
  7001. get: function () {
  7002. return this._sourceTop;
  7003. },
  7004. set: function (value) {
  7005. if (this._sourceTop === value) {
  7006. return;
  7007. }
  7008. this._sourceTop = value;
  7009. this._markAsDirty();
  7010. },
  7011. enumerable: false,
  7012. configurable: true
  7013. });
  7014. Object.defineProperty(Image.prototype, "sourceWidth", {
  7015. /**
  7016. * Gets or sets the width to capture in the source image
  7017. */
  7018. get: function () {
  7019. return this._sourceWidth;
  7020. },
  7021. set: function (value) {
  7022. if (this._sourceWidth === value) {
  7023. return;
  7024. }
  7025. this._sourceWidth = value;
  7026. this._markAsDirty();
  7027. },
  7028. enumerable: false,
  7029. configurable: true
  7030. });
  7031. Object.defineProperty(Image.prototype, "sourceHeight", {
  7032. /**
  7033. * Gets or sets the height to capture in the source image
  7034. */
  7035. get: function () {
  7036. return this._sourceHeight;
  7037. },
  7038. set: function (value) {
  7039. if (this._sourceHeight === value) {
  7040. return;
  7041. }
  7042. this._sourceHeight = value;
  7043. this._markAsDirty();
  7044. },
  7045. enumerable: false,
  7046. configurable: true
  7047. });
  7048. Object.defineProperty(Image.prototype, "isSVG", {
  7049. /** Indicates if the format of the image is SVG */
  7050. get: function () {
  7051. return this._isSVG;
  7052. },
  7053. enumerable: false,
  7054. configurable: true
  7055. });
  7056. Object.defineProperty(Image.prototype, "svgAttributesComputationCompleted", {
  7057. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  7058. get: function () {
  7059. return this._svgAttributesComputationCompleted;
  7060. },
  7061. enumerable: false,
  7062. configurable: true
  7063. });
  7064. Object.defineProperty(Image.prototype, "autoScale", {
  7065. /**
  7066. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  7067. * @see https://doc.babylonjs.com/how_to/gui#image
  7068. */
  7069. get: function () {
  7070. return this._autoScale;
  7071. },
  7072. set: function (value) {
  7073. if (this._autoScale === value) {
  7074. return;
  7075. }
  7076. this._autoScale = value;
  7077. if (value && this._loaded) {
  7078. this.synchronizeSizeWithContent();
  7079. }
  7080. },
  7081. enumerable: false,
  7082. configurable: true
  7083. });
  7084. Object.defineProperty(Image.prototype, "stretch", {
  7085. /** Gets or sets the streching mode used by the image */
  7086. get: function () {
  7087. return this._stretch;
  7088. },
  7089. set: function (value) {
  7090. if (this._stretch === value) {
  7091. return;
  7092. }
  7093. this._stretch = value;
  7094. this._markAsDirty();
  7095. },
  7096. enumerable: false,
  7097. configurable: true
  7098. });
  7099. /** @hidden */
  7100. Image.prototype._rotate90 = function (n, preserveProperties) {
  7101. if (preserveProperties === void 0) { preserveProperties = false; }
  7102. var canvas = document.createElement("canvas");
  7103. var context = canvas.getContext("2d");
  7104. var width = this._domImage.width;
  7105. var height = this._domImage.height;
  7106. canvas.width = height;
  7107. canvas.height = width;
  7108. context.translate(canvas.width / 2, canvas.height / 2);
  7109. context.rotate((n * Math.PI) / 2);
  7110. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  7111. var dataUrl = canvas.toDataURL("image/jpg");
  7112. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  7113. if (preserveProperties) {
  7114. rotatedImage._stretch = this._stretch;
  7115. rotatedImage._autoScale = this._autoScale;
  7116. rotatedImage._cellId = this._cellId;
  7117. rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;
  7118. rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;
  7119. }
  7120. this._handleRotationForSVGImage(this, rotatedImage, n);
  7121. this._imageDataCache.data = null;
  7122. return rotatedImage;
  7123. };
  7124. Image.prototype._handleRotationForSVGImage = function (srcImage, dstImage, n) {
  7125. var _this = this;
  7126. if (!srcImage._isSVG) {
  7127. return;
  7128. }
  7129. if (srcImage._svgAttributesComputationCompleted) {
  7130. this._rotate90SourceProperties(srcImage, dstImage, n);
  7131. this._markAsDirty();
  7132. }
  7133. else {
  7134. srcImage.onSVGAttributesComputedObservable.addOnce(function () {
  7135. _this._rotate90SourceProperties(srcImage, dstImage, n);
  7136. _this._markAsDirty();
  7137. });
  7138. }
  7139. };
  7140. Image.prototype._rotate90SourceProperties = function (srcImage, dstImage, n) {
  7141. var _a, _b;
  7142. var srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
  7143. var dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
  7144. if (n != 0) {
  7145. var mult = n < 0 ? -1 : 1;
  7146. n = n % 4;
  7147. for (var i = 0; i < Math.abs(n); ++i) {
  7148. dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;
  7149. dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;
  7150. _a = [dstHeight, dstWidth], dstWidth = _a[0], dstHeight = _a[1];
  7151. if (n < 0) {
  7152. dstTop -= dstHeight;
  7153. }
  7154. else {
  7155. dstLeft -= dstWidth;
  7156. }
  7157. srcLeft = dstLeft;
  7158. srcTop = dstTop;
  7159. _b = [srcHeight, srcWidth], srcWidth = _b[0], srcHeight = _b[1];
  7160. }
  7161. }
  7162. dstImage.sourceLeft = dstLeft;
  7163. dstImage.sourceTop = dstTop;
  7164. dstImage.sourceWidth = dstWidth;
  7165. dstImage.sourceHeight = dstHeight;
  7166. };
  7167. Object.defineProperty(Image.prototype, "domImage", {
  7168. get: function () {
  7169. return this._domImage;
  7170. },
  7171. /**
  7172. * Gets or sets the internal DOM image used to render the control
  7173. */
  7174. set: function (value) {
  7175. var _this = this;
  7176. this._domImage = value;
  7177. this._loaded = false;
  7178. this._imageDataCache.data = null;
  7179. if (this._domImage.width) {
  7180. this._onImageLoaded();
  7181. }
  7182. else {
  7183. this._domImage.onload = function () {
  7184. _this._onImageLoaded();
  7185. };
  7186. }
  7187. },
  7188. enumerable: false,
  7189. configurable: true
  7190. });
  7191. Image.prototype._onImageLoaded = function () {
  7192. this._imageDataCache.data = null;
  7193. this._imageWidth = this._domImage.width;
  7194. this._imageHeight = this._domImage.height;
  7195. this._loaded = true;
  7196. if (this._populateNinePatchSlicesFromImage) {
  7197. this._extractNinePatchSliceDataFromImage();
  7198. }
  7199. if (this._autoScale) {
  7200. this.synchronizeSizeWithContent();
  7201. }
  7202. this.onImageLoadedObservable.notifyObservers(this);
  7203. this._markAsDirty();
  7204. };
  7205. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  7206. if (!this._workingCanvas) {
  7207. this._workingCanvas = document.createElement("canvas");
  7208. }
  7209. var canvas = this._workingCanvas;
  7210. var context = canvas.getContext("2d");
  7211. var width = this._domImage.width;
  7212. var height = this._domImage.height;
  7213. canvas.width = width;
  7214. canvas.height = height;
  7215. context.drawImage(this._domImage, 0, 0, width, height);
  7216. var imageData = context.getImageData(0, 0, width, height);
  7217. // Left and right
  7218. this._sliceLeft = -1;
  7219. this._sliceRight = -1;
  7220. for (var x = 0; x < width; x++) {
  7221. var alpha = imageData.data[x * 4 + 3];
  7222. if (alpha > 127 && this._sliceLeft === -1) {
  7223. this._sliceLeft = x;
  7224. continue;
  7225. }
  7226. if (alpha < 127 && this._sliceLeft > -1) {
  7227. this._sliceRight = x;
  7228. break;
  7229. }
  7230. }
  7231. // top and bottom
  7232. this._sliceTop = -1;
  7233. this._sliceBottom = -1;
  7234. for (var y = 0; y < height; y++) {
  7235. var alpha = imageData.data[y * width * 4 + 3];
  7236. if (alpha > 127 && this._sliceTop === -1) {
  7237. this._sliceTop = y;
  7238. continue;
  7239. }
  7240. if (alpha < 127 && this._sliceTop > -1) {
  7241. this._sliceBottom = y;
  7242. break;
  7243. }
  7244. }
  7245. };
  7246. Object.defineProperty(Image.prototype, "source", {
  7247. /**
  7248. * Gets the image source url
  7249. */
  7250. get: function () {
  7251. return this._source;
  7252. },
  7253. /**
  7254. * Gets or sets image source url
  7255. */
  7256. set: function (value) {
  7257. var _this = this;
  7258. if (this._source === value) {
  7259. return;
  7260. }
  7261. this._loaded = false;
  7262. this._source = value;
  7263. this._imageDataCache.data = null;
  7264. if (value) {
  7265. value = this._svgCheck(value);
  7266. }
  7267. this._domImage = document.createElement("img");
  7268. this._domImage.onload = function () {
  7269. _this._onImageLoaded();
  7270. };
  7271. if (value) {
  7272. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  7273. this._domImage.src = value;
  7274. }
  7275. },
  7276. enumerable: false,
  7277. configurable: true
  7278. });
  7279. /**
  7280. * Checks for svg document with icon id present
  7281. */
  7282. Image.prototype._svgCheck = function (value) {
  7283. var _this = this;
  7284. if (window.SVGSVGElement && value.search(/.svg#/gi) !== -1 && value.indexOf("#") === value.lastIndexOf("#")) {
  7285. this._isSVG = true;
  7286. var svgsrc = value.split("#")[0];
  7287. var elemid = value.split("#")[1];
  7288. // check if object alr exist in document
  7289. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  7290. if (svgExist) {
  7291. var svgDoc = svgExist.contentDocument;
  7292. // get viewbox width and height, get svg document width and height in px
  7293. if (svgDoc && svgDoc.documentElement) {
  7294. var vb = svgDoc.documentElement.getAttribute("viewBox");
  7295. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  7296. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  7297. var elem = svgDoc.getElementById(elemid);
  7298. if (elem && vb && docwidth && docheight) {
  7299. this._getSVGAttribs(svgExist, elemid);
  7300. return value;
  7301. }
  7302. }
  7303. // wait for object to load
  7304. svgExist.addEventListener("load", function () {
  7305. _this._getSVGAttribs(svgExist, elemid);
  7306. });
  7307. }
  7308. else {
  7309. // create document object
  7310. var svgImage = document.createElement("object");
  7311. svgImage.data = svgsrc;
  7312. svgImage.type = "image/svg+xml";
  7313. svgImage.width = "0%";
  7314. svgImage.height = "0%";
  7315. document.body.appendChild(svgImage);
  7316. // when the object has loaded, get the element attribs
  7317. svgImage.onload = function () {
  7318. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  7319. if (svgobj) {
  7320. _this._getSVGAttribs(svgobj, elemid);
  7321. }
  7322. };
  7323. }
  7324. return svgsrc;
  7325. }
  7326. else {
  7327. return value;
  7328. }
  7329. };
  7330. /**
  7331. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  7332. * given external svg file and icon id
  7333. */
  7334. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  7335. var svgDoc = svgsrc.contentDocument;
  7336. // get viewbox width and height, get svg document width and height in px
  7337. if (svgDoc && svgDoc.documentElement) {
  7338. var vb = svgDoc.documentElement.getAttribute("viewBox");
  7339. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  7340. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  7341. // get element bbox and matrix transform
  7342. var elem = svgDoc.getElementById(elemid);
  7343. if (vb && docwidth && docheight && elem) {
  7344. var vb_width = Number(vb.split(" ")[2]);
  7345. var vb_height = Number(vb.split(" ")[3]);
  7346. var elem_bbox = elem.getBBox();
  7347. var elem_matrix_a = 1;
  7348. var elem_matrix_d = 1;
  7349. var elem_matrix_e = 0;
  7350. var elem_matrix_f = 0;
  7351. if (elem.transform && elem.transform.baseVal.consolidate()) {
  7352. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  7353. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  7354. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  7355. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  7356. }
  7357. // compute source coordinates and dimensions
  7358. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  7359. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  7360. this.sourceWidth = elem_bbox.width * elem_matrix_a * (docwidth / vb_width);
  7361. this.sourceHeight = elem_bbox.height * elem_matrix_d * (docheight / vb_height);
  7362. this._svgAttributesComputationCompleted = true;
  7363. this.onSVGAttributesComputedObservable.notifyObservers(this);
  7364. }
  7365. }
  7366. };
  7367. Object.defineProperty(Image.prototype, "cellWidth", {
  7368. /**
  7369. * Gets or sets the cell width to use when animation sheet is enabled
  7370. * @see https://doc.babylonjs.com/how_to/gui#image
  7371. */
  7372. get: function () {
  7373. return this._cellWidth;
  7374. },
  7375. set: function (value) {
  7376. if (this._cellWidth === value) {
  7377. return;
  7378. }
  7379. this._cellWidth = value;
  7380. this._markAsDirty();
  7381. },
  7382. enumerable: false,
  7383. configurable: true
  7384. });
  7385. Object.defineProperty(Image.prototype, "cellHeight", {
  7386. /**
  7387. * Gets or sets the cell height to use when animation sheet is enabled
  7388. * @see https://doc.babylonjs.com/how_to/gui#image
  7389. */
  7390. get: function () {
  7391. return this._cellHeight;
  7392. },
  7393. set: function (value) {
  7394. if (this._cellHeight === value) {
  7395. return;
  7396. }
  7397. this._cellHeight = value;
  7398. this._markAsDirty();
  7399. },
  7400. enumerable: false,
  7401. configurable: true
  7402. });
  7403. Object.defineProperty(Image.prototype, "cellId", {
  7404. /**
  7405. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  7406. * @see https://doc.babylonjs.com/how_to/gui#image
  7407. */
  7408. get: function () {
  7409. return this._cellId;
  7410. },
  7411. set: function (value) {
  7412. if (this._cellId === value) {
  7413. return;
  7414. }
  7415. this._cellId = value;
  7416. this._markAsDirty();
  7417. },
  7418. enumerable: false,
  7419. configurable: true
  7420. });
  7421. /**
  7422. * Tests if a given coordinates belong to the current control
  7423. * @param x defines x coordinate to test
  7424. * @param y defines y coordinate to test
  7425. * @returns true if the coordinates are inside the control
  7426. */
  7427. Image.prototype.contains = function (x, y) {
  7428. if (!_super.prototype.contains.call(this, x, y)) {
  7429. return false;
  7430. }
  7431. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  7432. return true;
  7433. }
  7434. var width = this._currentMeasure.width | 0;
  7435. var height = this._currentMeasure.height | 0;
  7436. var key = width + "_" + height;
  7437. var imageData = this._imageDataCache.data;
  7438. if (!imageData || this._imageDataCache.key !== key) {
  7439. var canvas = this._workingCanvas;
  7440. var context_1 = canvas.getContext("2d");
  7441. this._imageDataCache.data = imageData = context_1.getImageData(0, 0, width, height).data;
  7442. this._imageDataCache.key = key;
  7443. }
  7444. x = (x - this._currentMeasure.left) | 0;
  7445. y = (y - this._currentMeasure.top) | 0;
  7446. var pickedPixel = imageData[(x + y * width) * 4 + 3];
  7447. return pickedPixel > 0;
  7448. };
  7449. Image.prototype._getTypeName = function () {
  7450. return "Image";
  7451. };
  7452. /** Force the control to synchronize with its content */
  7453. Image.prototype.synchronizeSizeWithContent = function () {
  7454. if (!this._loaded) {
  7455. return;
  7456. }
  7457. this.width = this._domImage.width + "px";
  7458. this.height = this._domImage.height + "px";
  7459. };
  7460. Image.prototype._processMeasures = function (parentMeasure, context) {
  7461. if (this._loaded) {
  7462. switch (this._stretch) {
  7463. case Image.STRETCH_NONE:
  7464. break;
  7465. case Image.STRETCH_FILL:
  7466. break;
  7467. case Image.STRETCH_UNIFORM:
  7468. break;
  7469. case Image.STRETCH_NINE_PATCH:
  7470. break;
  7471. case Image.STRETCH_EXTEND:
  7472. if (this._autoScale) {
  7473. this.synchronizeSizeWithContent();
  7474. }
  7475. if (this.parent && this.parent.parent) {
  7476. // Will update root size if root is not the top root
  7477. this.parent.adaptWidthToChildren = true;
  7478. this.parent.adaptHeightToChildren = true;
  7479. }
  7480. break;
  7481. }
  7482. }
  7483. _super.prototype._processMeasures.call(this, parentMeasure, context);
  7484. };
  7485. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  7486. if (!this._detectPointerOnOpaqueOnly) {
  7487. return;
  7488. }
  7489. if (!this._workingCanvas) {
  7490. this._workingCanvas = document.createElement("canvas");
  7491. }
  7492. var canvas = this._workingCanvas;
  7493. var width = this._currentMeasure.width;
  7494. var height = this._currentMeasure.height;
  7495. var context = canvas.getContext("2d");
  7496. canvas.width = width;
  7497. canvas.height = height;
  7498. context.clearRect(0, 0, width, height);
  7499. };
  7500. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  7501. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  7502. if (!this._detectPointerOnOpaqueOnly) {
  7503. return;
  7504. }
  7505. var canvas = this._workingCanvas;
  7506. context = canvas.getContext("2d");
  7507. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  7508. };
  7509. Image.prototype._draw = function (context) {
  7510. context.save();
  7511. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7512. context.shadowColor = this.shadowColor;
  7513. context.shadowBlur = this.shadowBlur;
  7514. context.shadowOffsetX = this.shadowOffsetX;
  7515. context.shadowOffsetY = this.shadowOffsetY;
  7516. }
  7517. var x, y, width, height;
  7518. if (this.cellId == -1) {
  7519. x = this._sourceLeft;
  7520. y = this._sourceTop;
  7521. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  7522. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  7523. }
  7524. else {
  7525. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  7526. var column = (this.cellId / rowCount) >> 0;
  7527. var row = this.cellId % rowCount;
  7528. x = this.cellWidth * row;
  7529. y = this.cellHeight * column;
  7530. width = this.cellWidth;
  7531. height = this.cellHeight;
  7532. }
  7533. this._prepareWorkingCanvasForOpaqueDetection();
  7534. this._applyStates(context);
  7535. if (this._loaded) {
  7536. switch (this._stretch) {
  7537. case Image.STRETCH_NONE:
  7538. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7539. break;
  7540. case Image.STRETCH_FILL:
  7541. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7542. break;
  7543. case Image.STRETCH_UNIFORM:
  7544. var hRatio = this._currentMeasure.width / width;
  7545. var vRatio = this._currentMeasure.height / height;
  7546. var ratio = Math.min(hRatio, vRatio);
  7547. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  7548. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  7549. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  7550. break;
  7551. case Image.STRETCH_EXTEND:
  7552. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7553. break;
  7554. case Image.STRETCH_NINE_PATCH:
  7555. this._renderNinePatch(context);
  7556. break;
  7557. }
  7558. }
  7559. context.restore();
  7560. };
  7561. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  7562. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  7563. };
  7564. Image.prototype._renderNinePatch = function (context) {
  7565. var height = this._imageHeight;
  7566. var leftWidth = this._sliceLeft;
  7567. var topHeight = this._sliceTop;
  7568. var bottomHeight = this._imageHeight - this._sliceBottom;
  7569. var rightWidth = this._imageWidth - this._sliceRight;
  7570. var left = 0;
  7571. var top = 0;
  7572. if (this._populateNinePatchSlicesFromImage) {
  7573. left = 1;
  7574. top = 1;
  7575. height -= 2;
  7576. leftWidth -= 1;
  7577. topHeight -= 1;
  7578. bottomHeight -= 1;
  7579. rightWidth -= 1;
  7580. }
  7581. var centerWidth = this._sliceRight - this._sliceLeft;
  7582. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft;
  7583. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  7584. // Corners
  7585. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  7586. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  7587. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  7588. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  7589. // Center
  7590. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight);
  7591. // Borders
  7592. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  7593. 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);
  7594. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  7595. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  7596. };
  7597. Image.prototype.dispose = function () {
  7598. _super.prototype.dispose.call(this);
  7599. this.onImageLoadedObservable.clear();
  7600. this.onSVGAttributesComputedObservable.clear();
  7601. };
  7602. // Static
  7603. /** STRETCH_NONE */
  7604. Image.STRETCH_NONE = 0;
  7605. /** STRETCH_FILL */
  7606. Image.STRETCH_FILL = 1;
  7607. /** STRETCH_UNIFORM */
  7608. Image.STRETCH_UNIFORM = 2;
  7609. /** STRETCH_EXTEND */
  7610. Image.STRETCH_EXTEND = 3;
  7611. /** NINE_PATCH */
  7612. Image.STRETCH_NINE_PATCH = 4;
  7613. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7614. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7615. ], Image.prototype, "populateNinePatchSlicesFromImage", null);
  7616. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7617. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7618. ], Image.prototype, "detectPointerOnOpaqueOnly", null);
  7619. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7620. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7621. ], Image.prototype, "sliceLeft", null);
  7622. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7623. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7624. ], Image.prototype, "sliceRight", null);
  7625. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7626. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7627. ], Image.prototype, "sliceTop", null);
  7628. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7629. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7630. ], Image.prototype, "sliceBottom", null);
  7631. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7632. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7633. ], Image.prototype, "sourceLeft", null);
  7634. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7635. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7636. ], Image.prototype, "sourceTop", null);
  7637. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7638. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7639. ], Image.prototype, "sourceWidth", null);
  7640. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7641. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7642. ], Image.prototype, "sourceHeight", null);
  7643. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7644. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7645. ], Image.prototype, "autoScale", null);
  7646. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7647. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7648. ], Image.prototype, "stretch", null);
  7649. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7650. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7651. ], Image.prototype, "source", null);
  7652. return Image;
  7653. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7654. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  7655. /***/ }),
  7656. /***/ "./2D/controls/index.ts":
  7657. /*!******************************!*\
  7658. !*** ./2D/controls/index.ts ***!
  7659. \******************************/
  7660. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, FocusableButton, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, TextWrapper, ToggleButton, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  7661. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7662. "use strict";
  7663. __webpack_require__.r(__webpack_exports__);
  7664. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  7665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  7666. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  7667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  7668. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  7669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  7670. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  7671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  7672. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  7674. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  7675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  7676. /* harmony import */ var _focusableButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./focusableButton */ "./2D/controls/focusableButton.ts");
  7677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return _focusableButton__WEBPACK_IMPORTED_MODULE_6__["FocusableButton"]; });
  7678. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  7679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_7__["Grid"]; });
  7680. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  7681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_8__["Image"]; });
  7682. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_9__["InputText"]; });
  7684. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  7685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_10__["InputPassword"]; });
  7686. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  7687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_11__["Line"]; });
  7688. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  7689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_12__["MultiLine"]; });
  7690. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  7691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_13__["RadioButton"]; });
  7692. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  7693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_14__["StackPanel"]; });
  7694. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  7695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["SelectorGroup"]; });
  7696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["CheckboxGroup"]; });
  7697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["RadioGroup"]; });
  7698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["SliderGroup"]; });
  7699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["SelectionPanel"]; });
  7700. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  7701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_16__["ScrollViewer"]; });
  7702. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  7703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_17__["TextWrapping"]; });
  7704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_17__["TextBlock"]; });
  7705. /* harmony import */ var _textWrapper__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./textWrapper */ "./2D/controls/textWrapper.ts");
  7706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _textWrapper__WEBPACK_IMPORTED_MODULE_18__["TextWrapper"]; });
  7707. /* harmony import */ var _toggleButton__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./toggleButton */ "./2D/controls/toggleButton.ts");
  7708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return _toggleButton__WEBPACK_IMPORTED_MODULE_19__["ToggleButton"]; });
  7709. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  7710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_20__["KeyPropertySet"]; });
  7711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_20__["VirtualKeyboard"]; });
  7712. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  7713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_21__["Rectangle"]; });
  7714. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  7715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_22__["DisplayGrid"]; });
  7716. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  7717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_23__["BaseSlider"]; });
  7718. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  7719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_24__["Slider"]; });
  7720. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  7721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_25__["ImageBasedSlider"]; });
  7722. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  7723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_26__["ScrollBar"]; });
  7724. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  7725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_27__["ImageScrollBar"]; });
  7726. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  7727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_28__["name"]; });
  7728. /***/ }),
  7729. /***/ "./2D/controls/inputPassword.ts":
  7730. /*!**************************************!*\
  7731. !*** ./2D/controls/inputPassword.ts ***!
  7732. \**************************************/
  7733. /*! exports provided: InputPassword */
  7734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7735. "use strict";
  7736. __webpack_require__.r(__webpack_exports__);
  7737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  7738. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7739. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7740. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  7741. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  7742. /* harmony import */ var _textWrapper__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textWrapper */ "./2D/controls/textWrapper.ts");
  7743. /**
  7744. * Class used to create a password control
  7745. */
  7746. var InputPassword = /** @class */ (function (_super) {
  7747. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  7748. function InputPassword() {
  7749. return _super !== null && _super.apply(this, arguments) || this;
  7750. }
  7751. InputPassword.prototype._beforeRenderText = function (textWrapper) {
  7752. var pwdTextWrapper = new _textWrapper__WEBPACK_IMPORTED_MODULE_3__["TextWrapper"]();
  7753. var txt = "";
  7754. for (var i = 0; i < textWrapper.length; i++) {
  7755. txt += "\u2022";
  7756. }
  7757. pwdTextWrapper.text = txt;
  7758. return pwdTextWrapper;
  7759. };
  7760. return InputPassword;
  7761. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  7762. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  7763. /***/ }),
  7764. /***/ "./2D/controls/inputText.ts":
  7765. /*!**********************************!*\
  7766. !*** ./2D/controls/inputText.ts ***!
  7767. \**********************************/
  7768. /*! exports provided: InputText */
  7769. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7770. "use strict";
  7771. __webpack_require__.r(__webpack_exports__);
  7772. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  7773. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7774. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  7775. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  7776. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7777. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7778. /* harmony import */ var _textWrapper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textWrapper */ "./2D/controls/textWrapper.ts");
  7779. /**
  7780. * Class used to create input text control
  7781. */
  7782. var InputText = /** @class */ (function (_super) {
  7783. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7784. /**
  7785. * Creates a new InputText
  7786. * @param name defines the control name
  7787. * @param text defines the text of the control
  7788. */
  7789. function InputText(name, text) {
  7790. if (text === void 0) { text = ""; }
  7791. var _this = _super.call(this, name) || this;
  7792. _this.name = name;
  7793. _this._placeholderText = "";
  7794. _this._background = "#222222";
  7795. _this._focusedBackground = "#000000";
  7796. _this._focusedColor = "white";
  7797. _this._placeholderColor = "gray";
  7798. _this._thickness = 1;
  7799. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7800. _this._autoStretchWidth = true;
  7801. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7802. _this._isFocused = false;
  7803. _this._blinkIsEven = false;
  7804. _this._cursorOffset = 0;
  7805. _this._deadKey = false;
  7806. _this._addKey = true;
  7807. _this._currentKey = "";
  7808. _this._isTextHighlightOn = false;
  7809. _this._textHighlightColor = "#d5e0ff";
  7810. _this._highligherOpacity = 0.4;
  7811. _this._highlightedText = "";
  7812. _this._startHighlightIndex = 0;
  7813. _this._endHighlightIndex = 0;
  7814. _this._cursorIndex = -1;
  7815. _this._onFocusSelectAll = false;
  7816. _this._isPointerDown = false;
  7817. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7818. _this.promptMessage = "Please enter text:";
  7819. /** Force disable prompt on mobile device */
  7820. _this.disableMobilePrompt = false;
  7821. /** Observable raised when the text changes */
  7822. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7823. /** Observable raised just before an entered character is to be added */
  7824. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7825. /** Observable raised when the control gets the focus */
  7826. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7827. /** Observable raised when the control loses the focus */
  7828. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7829. /**Observable raised when the text is highlighted */
  7830. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7831. /**Observable raised when copy event is triggered */
  7832. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7833. /** Observable raised when cut event is triggered */
  7834. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7835. /** Observable raised when paste event is triggered */
  7836. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7837. /** Observable raised when a key event was processed */
  7838. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7839. _this.text = text;
  7840. _this.isPointerBlocker = true;
  7841. return _this;
  7842. }
  7843. Object.defineProperty(InputText.prototype, "maxWidth", {
  7844. /** Gets or sets the maximum width allowed by the control */
  7845. get: function () {
  7846. return this._maxWidth.toString(this._host);
  7847. },
  7848. set: function (value) {
  7849. if (this._maxWidth.toString(this._host) === value) {
  7850. return;
  7851. }
  7852. if (this._maxWidth.fromString(value)) {
  7853. this._markAsDirty();
  7854. }
  7855. },
  7856. enumerable: false,
  7857. configurable: true
  7858. });
  7859. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7860. /** Gets the maximum width allowed by the control in pixels */
  7861. get: function () {
  7862. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7863. },
  7864. enumerable: false,
  7865. configurable: true
  7866. });
  7867. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7868. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7869. get: function () {
  7870. return this._highligherOpacity;
  7871. },
  7872. set: function (value) {
  7873. if (this._highligherOpacity === value) {
  7874. return;
  7875. }
  7876. this._highligherOpacity = value;
  7877. this._markAsDirty();
  7878. },
  7879. enumerable: false,
  7880. configurable: true
  7881. });
  7882. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7883. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7884. get: function () {
  7885. return this._onFocusSelectAll;
  7886. },
  7887. set: function (value) {
  7888. if (this._onFocusSelectAll === value) {
  7889. return;
  7890. }
  7891. this._onFocusSelectAll = value;
  7892. this._markAsDirty();
  7893. },
  7894. enumerable: false,
  7895. configurable: true
  7896. });
  7897. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7898. /** Gets or sets the text hightlight color */
  7899. get: function () {
  7900. return this._textHighlightColor;
  7901. },
  7902. set: function (value) {
  7903. if (this._textHighlightColor === value) {
  7904. return;
  7905. }
  7906. this._textHighlightColor = value;
  7907. this._markAsDirty();
  7908. },
  7909. enumerable: false,
  7910. configurable: true
  7911. });
  7912. Object.defineProperty(InputText.prototype, "margin", {
  7913. /** Gets or sets control margin */
  7914. get: function () {
  7915. return this._margin.toString(this._host);
  7916. },
  7917. set: function (value) {
  7918. if (this._margin.toString(this._host) === value) {
  7919. return;
  7920. }
  7921. if (this._margin.fromString(value)) {
  7922. this._markAsDirty();
  7923. }
  7924. },
  7925. enumerable: false,
  7926. configurable: true
  7927. });
  7928. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7929. /** Gets control margin in pixels */
  7930. get: function () {
  7931. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7932. },
  7933. enumerable: false,
  7934. configurable: true
  7935. });
  7936. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7937. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7938. get: function () {
  7939. return this._autoStretchWidth;
  7940. },
  7941. set: function (value) {
  7942. if (this._autoStretchWidth === value) {
  7943. return;
  7944. }
  7945. this._autoStretchWidth = value;
  7946. this._markAsDirty();
  7947. },
  7948. enumerable: false,
  7949. configurable: true
  7950. });
  7951. Object.defineProperty(InputText.prototype, "thickness", {
  7952. /** Gets or sets border thickness */
  7953. get: function () {
  7954. return this._thickness;
  7955. },
  7956. set: function (value) {
  7957. if (this._thickness === value) {
  7958. return;
  7959. }
  7960. this._thickness = value;
  7961. this._markAsDirty();
  7962. },
  7963. enumerable: false,
  7964. configurable: true
  7965. });
  7966. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7967. /** Gets or sets the background color when focused */
  7968. get: function () {
  7969. return this._focusedBackground;
  7970. },
  7971. set: function (value) {
  7972. if (this._focusedBackground === value) {
  7973. return;
  7974. }
  7975. this._focusedBackground = value;
  7976. this._markAsDirty();
  7977. },
  7978. enumerable: false,
  7979. configurable: true
  7980. });
  7981. Object.defineProperty(InputText.prototype, "focusedColor", {
  7982. /** Gets or sets the background color when focused */
  7983. get: function () {
  7984. return this._focusedColor;
  7985. },
  7986. set: function (value) {
  7987. if (this._focusedColor === value) {
  7988. return;
  7989. }
  7990. this._focusedColor = value;
  7991. this._markAsDirty();
  7992. },
  7993. enumerable: false,
  7994. configurable: true
  7995. });
  7996. Object.defineProperty(InputText.prototype, "background", {
  7997. /** Gets or sets the background color */
  7998. get: function () {
  7999. return this._background;
  8000. },
  8001. set: function (value) {
  8002. if (this._background === value) {
  8003. return;
  8004. }
  8005. this._background = value;
  8006. this._markAsDirty();
  8007. },
  8008. enumerable: false,
  8009. configurable: true
  8010. });
  8011. Object.defineProperty(InputText.prototype, "placeholderColor", {
  8012. /** Gets or sets the placeholder color */
  8013. get: function () {
  8014. return this._placeholderColor;
  8015. },
  8016. set: function (value) {
  8017. if (this._placeholderColor === value) {
  8018. return;
  8019. }
  8020. this._placeholderColor = value;
  8021. this._markAsDirty();
  8022. },
  8023. enumerable: false,
  8024. configurable: true
  8025. });
  8026. Object.defineProperty(InputText.prototype, "placeholderText", {
  8027. /** Gets or sets the text displayed when the control is empty */
  8028. get: function () {
  8029. return this._placeholderText;
  8030. },
  8031. set: function (value) {
  8032. if (this._placeholderText === value) {
  8033. return;
  8034. }
  8035. this._placeholderText = value;
  8036. this._markAsDirty();
  8037. },
  8038. enumerable: false,
  8039. configurable: true
  8040. });
  8041. Object.defineProperty(InputText.prototype, "deadKey", {
  8042. /** Gets or sets the dead key flag */
  8043. get: function () {
  8044. return this._deadKey;
  8045. },
  8046. set: function (flag) {
  8047. this._deadKey = flag;
  8048. },
  8049. enumerable: false,
  8050. configurable: true
  8051. });
  8052. Object.defineProperty(InputText.prototype, "highlightedText", {
  8053. /** Gets or sets the highlight text */
  8054. get: function () {
  8055. return this._highlightedText;
  8056. },
  8057. set: function (text) {
  8058. if (this._highlightedText === text) {
  8059. return;
  8060. }
  8061. this._highlightedText = text;
  8062. this._markAsDirty();
  8063. },
  8064. enumerable: false,
  8065. configurable: true
  8066. });
  8067. Object.defineProperty(InputText.prototype, "addKey", {
  8068. /** Gets or sets if the current key should be added */
  8069. get: function () {
  8070. return this._addKey;
  8071. },
  8072. set: function (flag) {
  8073. this._addKey = flag;
  8074. },
  8075. enumerable: false,
  8076. configurable: true
  8077. });
  8078. Object.defineProperty(InputText.prototype, "currentKey", {
  8079. /** Gets or sets the value of the current key being entered */
  8080. get: function () {
  8081. return this._currentKey;
  8082. },
  8083. set: function (key) {
  8084. this._currentKey = key;
  8085. },
  8086. enumerable: false,
  8087. configurable: true
  8088. });
  8089. Object.defineProperty(InputText.prototype, "text", {
  8090. /** Gets or sets the text displayed in the control */
  8091. get: function () {
  8092. return this._textWrapper.text;
  8093. },
  8094. set: function (value) {
  8095. var valueAsString = value.toString(); // Forcing convertion
  8096. if (!this._textWrapper) {
  8097. this._textWrapper = new _textWrapper__WEBPACK_IMPORTED_MODULE_4__["TextWrapper"]();
  8098. }
  8099. if (this._textWrapper.text === valueAsString) {
  8100. return;
  8101. }
  8102. this._textWrapper.text = valueAsString;
  8103. this._textHasChanged();
  8104. },
  8105. enumerable: false,
  8106. configurable: true
  8107. });
  8108. InputText.prototype._textHasChanged = function () {
  8109. this._markAsDirty();
  8110. this.onTextChangedObservable.notifyObservers(this);
  8111. };
  8112. Object.defineProperty(InputText.prototype, "width", {
  8113. /** Gets or sets control width */
  8114. get: function () {
  8115. return this._width.toString(this._host);
  8116. },
  8117. set: function (value) {
  8118. if (this._width.toString(this._host) === value) {
  8119. return;
  8120. }
  8121. if (this._width.fromString(value)) {
  8122. this._markAsDirty();
  8123. }
  8124. this.autoStretchWidth = false;
  8125. },
  8126. enumerable: false,
  8127. configurable: true
  8128. });
  8129. /** @hidden */
  8130. InputText.prototype.onBlur = function () {
  8131. this._isFocused = false;
  8132. this._scrollLeft = null;
  8133. this._cursorOffset = 0;
  8134. clearTimeout(this._blinkTimeout);
  8135. this._markAsDirty();
  8136. this.onBlurObservable.notifyObservers(this);
  8137. this._host.unRegisterClipboardEvents();
  8138. if (this._onClipboardObserver) {
  8139. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  8140. }
  8141. var scene = this._host.getScene();
  8142. if (this._onPointerDblTapObserver && scene) {
  8143. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  8144. }
  8145. };
  8146. /** @hidden */
  8147. InputText.prototype.onFocus = function () {
  8148. var _this = this;
  8149. if (!this._isEnabled) {
  8150. return;
  8151. }
  8152. this._scrollLeft = null;
  8153. this._isFocused = true;
  8154. this._blinkIsEven = false;
  8155. this._cursorOffset = 0;
  8156. this._markAsDirty();
  8157. this.onFocusObservable.notifyObservers(this);
  8158. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  8159. var value = prompt(this.promptMessage);
  8160. if (value !== null) {
  8161. this.text = value;
  8162. }
  8163. this._host.focusedControl = null;
  8164. return;
  8165. }
  8166. this._host.registerClipboardEvents();
  8167. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  8168. // process clipboard event, can be configured.
  8169. switch (clipboardInfo.type) {
  8170. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  8171. _this._onCopyText(clipboardInfo.event);
  8172. _this.onTextCopyObservable.notifyObservers(_this);
  8173. break;
  8174. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  8175. _this._onCutText(clipboardInfo.event);
  8176. _this.onTextCutObservable.notifyObservers(_this);
  8177. break;
  8178. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  8179. _this._onPasteText(clipboardInfo.event);
  8180. _this.onTextPasteObservable.notifyObservers(_this);
  8181. break;
  8182. default: return;
  8183. }
  8184. });
  8185. var scene = this._host.getScene();
  8186. if (scene) {
  8187. //register the pointer double tap event
  8188. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  8189. if (!_this._isFocused) {
  8190. return;
  8191. }
  8192. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  8193. _this._processDblClick(pointerInfo);
  8194. }
  8195. });
  8196. }
  8197. if (this._onFocusSelectAll) {
  8198. this._selectAllText();
  8199. }
  8200. };
  8201. /**
  8202. * Function to focus an inputText programmatically
  8203. */
  8204. InputText.prototype.focus = function () {
  8205. this._host.moveFocusToControl(this);
  8206. };
  8207. /**
  8208. * Function to unfocus an inputText programmatically
  8209. */
  8210. InputText.prototype.blur = function () {
  8211. this._host.focusedControl = null;
  8212. };
  8213. InputText.prototype._getTypeName = function () {
  8214. return "InputText";
  8215. };
  8216. /**
  8217. * Function called to get the list of controls that should not steal the focus from this control
  8218. * @returns an array of controls
  8219. */
  8220. InputText.prototype.keepsFocusWith = function () {
  8221. if (!this._connectedVirtualKeyboard) {
  8222. return null;
  8223. }
  8224. return [this._connectedVirtualKeyboard];
  8225. };
  8226. /** @hidden */
  8227. InputText.prototype.processKey = function (keyCode, key, evt) {
  8228. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  8229. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  8230. return;
  8231. }
  8232. //select all
  8233. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  8234. this._selectAllText();
  8235. evt.preventDefault();
  8236. return;
  8237. }
  8238. // Specific cases
  8239. switch (keyCode) {
  8240. case 32: //SPACE
  8241. key = " "; //ie11 key for space is "Spacebar"
  8242. break;
  8243. case 191: //SLASH
  8244. if (evt) {
  8245. evt.preventDefault();
  8246. }
  8247. break;
  8248. case 8: // BACKSPACE
  8249. if (this._textWrapper.text && this._textWrapper.length > 0) {
  8250. //delete the highlighted text
  8251. if (this._isTextHighlightOn) {
  8252. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
  8253. this._textHasChanged();
  8254. this._isTextHighlightOn = false;
  8255. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8256. this._blinkIsEven = false;
  8257. if (evt) {
  8258. evt.preventDefault();
  8259. }
  8260. return;
  8261. }
  8262. //delete single character
  8263. if (this._cursorOffset === 0) {
  8264. this.text = this._textWrapper.substr(0, this._textWrapper.length - 1);
  8265. }
  8266. else {
  8267. var deletePosition = this._textWrapper.length - this._cursorOffset;
  8268. if (deletePosition > 0) {
  8269. this._textWrapper.removePart(deletePosition - 1, deletePosition);
  8270. this._textHasChanged();
  8271. }
  8272. }
  8273. }
  8274. if (evt) {
  8275. evt.preventDefault();
  8276. }
  8277. return;
  8278. case 46: // DELETE
  8279. if (this._isTextHighlightOn) {
  8280. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
  8281. this._textHasChanged();
  8282. this._isTextHighlightOn = false;
  8283. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8284. if (evt) {
  8285. evt.preventDefault();
  8286. }
  8287. return;
  8288. }
  8289. if (this._textWrapper.text && this._textWrapper.length > 0 && this._cursorOffset > 0) {
  8290. var deletePosition = this._textWrapper.length - this._cursorOffset;
  8291. this._textWrapper.removePart(deletePosition, deletePosition + 1);
  8292. this._textHasChanged();
  8293. this._cursorOffset--;
  8294. }
  8295. if (evt) {
  8296. evt.preventDefault();
  8297. }
  8298. return;
  8299. case 13: // RETURN
  8300. this._host.focusedControl = null;
  8301. this._isTextHighlightOn = false;
  8302. return;
  8303. case 35: // END
  8304. this._cursorOffset = 0;
  8305. this._blinkIsEven = false;
  8306. this._isTextHighlightOn = false;
  8307. this._markAsDirty();
  8308. return;
  8309. case 36: // HOME
  8310. this._cursorOffset = this._textWrapper.length;
  8311. this._blinkIsEven = false;
  8312. this._isTextHighlightOn = false;
  8313. this._markAsDirty();
  8314. return;
  8315. case 37: // LEFT
  8316. this._cursorOffset++;
  8317. if (this._cursorOffset > this._textWrapper.length) {
  8318. this._cursorOffset = this._textWrapper.length;
  8319. }
  8320. if (evt && evt.shiftKey) {
  8321. // update the cursor
  8322. this._blinkIsEven = false;
  8323. // shift + ctrl/cmd + <-
  8324. if (evt.ctrlKey || evt.metaKey) {
  8325. if (!this._isTextHighlightOn) {
  8326. if (this._textWrapper.length === this._cursorOffset) {
  8327. return;
  8328. }
  8329. else {
  8330. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset + 1;
  8331. }
  8332. }
  8333. this._startHighlightIndex = 0;
  8334. this._cursorIndex = this._textWrapper.length - this._endHighlightIndex;
  8335. this._cursorOffset = this._textWrapper.length;
  8336. this._isTextHighlightOn = true;
  8337. this._markAsDirty();
  8338. return;
  8339. }
  8340. //store the starting point
  8341. if (!this._isTextHighlightOn) {
  8342. this._isTextHighlightOn = true;
  8343. this._cursorIndex = (this._cursorOffset >= this._textWrapper.length) ? this._textWrapper.length : this._cursorOffset - 1;
  8344. }
  8345. //if text is already highlighted
  8346. else if (this._cursorIndex === -1) {
  8347. this._cursorIndex = this._textWrapper.length - this._endHighlightIndex;
  8348. this._cursorOffset = (this._startHighlightIndex === 0) ? this._textWrapper.length : this._textWrapper.length - this._startHighlightIndex + 1;
  8349. }
  8350. //set the highlight indexes
  8351. if (this._cursorIndex < this._cursorOffset) {
  8352. this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8353. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8354. }
  8355. else if (this._cursorIndex > this._cursorOffset) {
  8356. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8357. this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8358. }
  8359. else {
  8360. this._isTextHighlightOn = false;
  8361. }
  8362. this._markAsDirty();
  8363. return;
  8364. }
  8365. if (this._isTextHighlightOn) {
  8366. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8367. this._isTextHighlightOn = false;
  8368. }
  8369. if (evt && (evt.ctrlKey || evt.metaKey)) {
  8370. this._cursorOffset = this._textWrapper.length;
  8371. evt.preventDefault();
  8372. }
  8373. this._blinkIsEven = false;
  8374. this._isTextHighlightOn = false;
  8375. this._cursorIndex = -1;
  8376. this._markAsDirty();
  8377. return;
  8378. case 39: // RIGHT
  8379. this._cursorOffset--;
  8380. if (this._cursorOffset < 0) {
  8381. this._cursorOffset = 0;
  8382. }
  8383. if (evt && evt.shiftKey) {
  8384. //update the cursor
  8385. this._blinkIsEven = false;
  8386. //shift + ctrl/cmd + ->
  8387. if (evt.ctrlKey || evt.metaKey) {
  8388. if (!this._isTextHighlightOn) {
  8389. if (this._cursorOffset === 0) {
  8390. return;
  8391. }
  8392. else {
  8393. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset - 1;
  8394. }
  8395. }
  8396. this._endHighlightIndex = this._textWrapper.length;
  8397. this._isTextHighlightOn = true;
  8398. this._cursorIndex = this._textWrapper.length - this._startHighlightIndex;
  8399. this._cursorOffset = 0;
  8400. this._markAsDirty();
  8401. return;
  8402. }
  8403. if (!this._isTextHighlightOn) {
  8404. this._isTextHighlightOn = true;
  8405. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  8406. }
  8407. //if text is already highlighted
  8408. else if (this._cursorIndex === -1) {
  8409. this._cursorIndex = this._textWrapper.length - this._startHighlightIndex;
  8410. this._cursorOffset = (this._textWrapper.length === this._endHighlightIndex) ? 0 : this._textWrapper.length - this._endHighlightIndex - 1;
  8411. }
  8412. //set the highlight indexes
  8413. if (this._cursorIndex < this._cursorOffset) {
  8414. this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8415. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8416. }
  8417. else if (this._cursorIndex > this._cursorOffset) {
  8418. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8419. this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8420. }
  8421. else {
  8422. this._isTextHighlightOn = false;
  8423. }
  8424. this._markAsDirty();
  8425. return;
  8426. }
  8427. if (this._isTextHighlightOn) {
  8428. this._cursorOffset = this._textWrapper.length - this._endHighlightIndex;
  8429. this._isTextHighlightOn = false;
  8430. }
  8431. //ctr + ->
  8432. if (evt && (evt.ctrlKey || evt.metaKey)) {
  8433. this._cursorOffset = 0;
  8434. evt.preventDefault();
  8435. }
  8436. this._blinkIsEven = false;
  8437. this._isTextHighlightOn = false;
  8438. this._cursorIndex = -1;
  8439. this._markAsDirty();
  8440. return;
  8441. case 222: // Dead
  8442. if (evt) {
  8443. evt.preventDefault();
  8444. }
  8445. this._cursorIndex = -1;
  8446. this.deadKey = true;
  8447. break;
  8448. }
  8449. // Printable characters
  8450. if (key &&
  8451. ((keyCode === -1) || // Direct access
  8452. (keyCode === 32) || // Space
  8453. (keyCode > 47 && keyCode < 64) || // Numbers
  8454. (keyCode > 64 && keyCode < 91) || // Letters
  8455. (keyCode > 159 && keyCode < 193) || // Special characters
  8456. (keyCode > 218 && keyCode < 223) || // Special characters
  8457. (keyCode > 95 && keyCode < 112))) { // Numpad
  8458. this._currentKey = key;
  8459. this.onBeforeKeyAddObservable.notifyObservers(this);
  8460. key = this._currentKey;
  8461. if (this._addKey) {
  8462. if (this._isTextHighlightOn) {
  8463. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex, key);
  8464. this._textHasChanged();
  8465. this._cursorOffset = this._textWrapper.length - (this._startHighlightIndex + 1);
  8466. this._isTextHighlightOn = false;
  8467. this._blinkIsEven = false;
  8468. this._markAsDirty();
  8469. }
  8470. else if (this._cursorOffset === 0) {
  8471. this.text += key;
  8472. }
  8473. else {
  8474. var insertPosition = this._textWrapper.length - this._cursorOffset;
  8475. this._textWrapper.removePart(insertPosition, insertPosition, key);
  8476. this._textHasChanged();
  8477. }
  8478. }
  8479. }
  8480. };
  8481. /** @hidden */
  8482. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  8483. //update the cursor
  8484. this._blinkIsEven = false;
  8485. if (this._cursorIndex === -1) {
  8486. this._cursorIndex = offset;
  8487. }
  8488. else {
  8489. if (this._cursorIndex < this._cursorOffset) {
  8490. this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8491. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8492. }
  8493. else if (this._cursorIndex > this._cursorOffset) {
  8494. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8495. this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8496. }
  8497. else {
  8498. this._isTextHighlightOn = false;
  8499. this._markAsDirty();
  8500. return;
  8501. }
  8502. }
  8503. this._isTextHighlightOn = true;
  8504. this._markAsDirty();
  8505. };
  8506. /** @hidden */
  8507. InputText.prototype._processDblClick = function (evt) {
  8508. //pre-find the start and end index of the word under cursor, speeds up the rendering
  8509. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8510. this._endHighlightIndex = this._startHighlightIndex;
  8511. var moveLeft, moveRight;
  8512. do {
  8513. moveRight = this._endHighlightIndex < this._textWrapper.length && this._textWrapper.isWord(this._endHighlightIndex) ? ++this._endHighlightIndex : 0;
  8514. moveLeft = this._startHighlightIndex > 0 && this._textWrapper.isWord(this._startHighlightIndex - 1) ? --this._startHighlightIndex : 0;
  8515. } while (moveLeft || moveRight);
  8516. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8517. this.onTextHighlightObservable.notifyObservers(this);
  8518. this._isTextHighlightOn = true;
  8519. this._clickedCoordinate = null;
  8520. this._blinkIsEven = true;
  8521. this._cursorIndex = -1;
  8522. this._markAsDirty();
  8523. };
  8524. /** @hidden */
  8525. InputText.prototype._selectAllText = function () {
  8526. this._blinkIsEven = true;
  8527. this._isTextHighlightOn = true;
  8528. this._startHighlightIndex = 0;
  8529. this._endHighlightIndex = this._textWrapper.length;
  8530. this._cursorOffset = this._textWrapper.length;
  8531. this._cursorIndex = -1;
  8532. this._markAsDirty();
  8533. };
  8534. /**
  8535. * Handles the keyboard event
  8536. * @param evt Defines the KeyboardEvent
  8537. */
  8538. InputText.prototype.processKeyboard = function (evt) {
  8539. // process pressed key
  8540. this.processKey(evt.keyCode, evt.key, evt);
  8541. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  8542. };
  8543. /** @hidden */
  8544. InputText.prototype._onCopyText = function (ev) {
  8545. this._isTextHighlightOn = false;
  8546. //when write permission to clipbaord data is denied
  8547. try {
  8548. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  8549. }
  8550. catch (_a) { } //pass
  8551. this._host.clipboardData = this._highlightedText;
  8552. };
  8553. /** @hidden */
  8554. InputText.prototype._onCutText = function (ev) {
  8555. if (!this._highlightedText) {
  8556. return;
  8557. }
  8558. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
  8559. this._textHasChanged();
  8560. this._isTextHighlightOn = false;
  8561. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8562. //when write permission to clipbaord data is denied
  8563. try {
  8564. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  8565. }
  8566. catch (_a) { } //pass
  8567. this._host.clipboardData = this._highlightedText;
  8568. this._highlightedText = "";
  8569. };
  8570. /** @hidden */
  8571. InputText.prototype._onPasteText = function (ev) {
  8572. var data = "";
  8573. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  8574. data = ev.clipboardData.getData("text/plain");
  8575. }
  8576. else {
  8577. //get the cached data; returns blank string by default
  8578. data = this._host.clipboardData;
  8579. }
  8580. var insertPosition = this._textWrapper.length - this._cursorOffset;
  8581. this._textWrapper.removePart(insertPosition, insertPosition, data);
  8582. this._textHasChanged();
  8583. };
  8584. InputText.prototype._draw = function (context, invalidatedRectangle) {
  8585. var _this = this;
  8586. context.save();
  8587. this._applyStates(context);
  8588. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8589. context.shadowColor = this.shadowColor;
  8590. context.shadowBlur = this.shadowBlur;
  8591. context.shadowOffsetX = this.shadowOffsetX;
  8592. context.shadowOffsetY = this.shadowOffsetY;
  8593. }
  8594. // Background
  8595. if (this._isFocused) {
  8596. if (this._focusedBackground) {
  8597. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  8598. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8599. }
  8600. }
  8601. else if (this._background) {
  8602. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8603. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8604. }
  8605. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8606. context.shadowBlur = 0;
  8607. context.shadowOffsetX = 0;
  8608. context.shadowOffsetY = 0;
  8609. }
  8610. if (!this._fontOffset) {
  8611. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  8612. }
  8613. // Text
  8614. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  8615. if (this.color) {
  8616. context.fillStyle = this.color;
  8617. }
  8618. var text = this._beforeRenderText(this._textWrapper);
  8619. if (!this._isFocused && !this._textWrapper.text && this._placeholderText) {
  8620. text = new _textWrapper__WEBPACK_IMPORTED_MODULE_4__["TextWrapper"]();
  8621. text.text = this._placeholderText;
  8622. if (this._placeholderColor) {
  8623. context.fillStyle = this._placeholderColor;
  8624. }
  8625. }
  8626. this._textWidth = context.measureText(text.text).width;
  8627. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  8628. if (this._autoStretchWidth) {
  8629. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  8630. }
  8631. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  8632. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  8633. context.save();
  8634. context.beginPath();
  8635. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  8636. context.clip();
  8637. if (this._isFocused && this._textWidth > availableWidth) {
  8638. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  8639. if (!this._scrollLeft) {
  8640. this._scrollLeft = textLeft;
  8641. }
  8642. }
  8643. else {
  8644. this._scrollLeft = clipTextLeft;
  8645. }
  8646. context.fillText(text.text, this._scrollLeft, this._currentMeasure.top + rootY);
  8647. // Cursor
  8648. if (this._isFocused) {
  8649. // Need to move cursor
  8650. if (this._clickedCoordinate) {
  8651. var rightPosition = this._scrollLeft + this._textWidth;
  8652. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  8653. var currentSize = 0;
  8654. this._cursorOffset = 0;
  8655. var previousDist = 0;
  8656. do {
  8657. if (this._cursorOffset) {
  8658. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  8659. }
  8660. this._cursorOffset++;
  8661. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  8662. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  8663. // Find closest move
  8664. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  8665. this._cursorOffset--;
  8666. }
  8667. this._blinkIsEven = false;
  8668. this._clickedCoordinate = null;
  8669. }
  8670. // Render cursor
  8671. if (!this._blinkIsEven) {
  8672. var cursorOffsetText = text.substr(text.length - this._cursorOffset);
  8673. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  8674. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  8675. if (cursorLeft < clipTextLeft) {
  8676. this._scrollLeft += (clipTextLeft - cursorLeft);
  8677. cursorLeft = clipTextLeft;
  8678. this._markAsDirty();
  8679. }
  8680. else if (cursorLeft > clipTextLeft + availableWidth) {
  8681. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  8682. cursorLeft = clipTextLeft + availableWidth;
  8683. this._markAsDirty();
  8684. }
  8685. if (!this._isTextHighlightOn) {
  8686. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  8687. }
  8688. }
  8689. clearTimeout(this._blinkTimeout);
  8690. this._blinkTimeout = setTimeout(function () {
  8691. _this._blinkIsEven = !_this._blinkIsEven;
  8692. _this._markAsDirty();
  8693. }, 500);
  8694. //show the highlighted text
  8695. if (this._isTextHighlightOn) {
  8696. clearTimeout(this._blinkTimeout);
  8697. var highlightCursorOffsetWidth = context.measureText(text.substring(this._startHighlightIndex)).width;
  8698. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  8699. this._highlightedText = text.substring(this._startHighlightIndex, this._endHighlightIndex);
  8700. var width = context.measureText(text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  8701. if (highlightCursorLeft < clipTextLeft) {
  8702. width = width - (clipTextLeft - highlightCursorLeft);
  8703. if (!width) {
  8704. // when using left arrow on text.length > availableWidth;
  8705. // assigns the width of the first letter after clipTextLeft
  8706. width = context.measureText(text.charAt(text.length - this._cursorOffset)).width;
  8707. }
  8708. highlightCursorLeft = clipTextLeft;
  8709. }
  8710. //for transparancy
  8711. context.globalAlpha = this._highligherOpacity;
  8712. context.fillStyle = this._textHighlightColor;
  8713. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  8714. context.globalAlpha = 1.0;
  8715. }
  8716. }
  8717. context.restore();
  8718. // Border
  8719. if (this._thickness) {
  8720. if (this._isFocused) {
  8721. if (this.focusedColor) {
  8722. context.strokeStyle = this.focusedColor;
  8723. }
  8724. }
  8725. else {
  8726. if (this.color) {
  8727. context.strokeStyle = this.color;
  8728. }
  8729. }
  8730. context.lineWidth = this._thickness;
  8731. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8732. }
  8733. context.restore();
  8734. };
  8735. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  8736. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  8737. return false;
  8738. }
  8739. this._clickedCoordinate = coordinates.x;
  8740. this._isTextHighlightOn = false;
  8741. this._highlightedText = "";
  8742. this._cursorIndex = -1;
  8743. this._isPointerDown = true;
  8744. this._host._capturingControl[pointerId] = this;
  8745. if (this._host.focusedControl === this) {
  8746. // Move cursor
  8747. clearTimeout(this._blinkTimeout);
  8748. this._markAsDirty();
  8749. return true;
  8750. }
  8751. if (!this._isEnabled) {
  8752. return false;
  8753. }
  8754. this._host.focusedControl = this;
  8755. return true;
  8756. };
  8757. InputText.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  8758. if (this._host.focusedControl === this && this._isPointerDown) {
  8759. this._clickedCoordinate = coordinates.x;
  8760. this._markAsDirty();
  8761. this._updateValueFromCursorIndex(this._cursorOffset);
  8762. }
  8763. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
  8764. };
  8765. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  8766. this._isPointerDown = false;
  8767. delete this._host._capturingControl[pointerId];
  8768. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  8769. };
  8770. InputText.prototype._beforeRenderText = function (textWrapper) {
  8771. return textWrapper;
  8772. };
  8773. InputText.prototype.dispose = function () {
  8774. _super.prototype.dispose.call(this);
  8775. this.onBlurObservable.clear();
  8776. this.onFocusObservable.clear();
  8777. this.onTextChangedObservable.clear();
  8778. this.onTextCopyObservable.clear();
  8779. this.onTextCutObservable.clear();
  8780. this.onTextPasteObservable.clear();
  8781. this.onTextHighlightObservable.clear();
  8782. this.onKeyboardEventProcessedObservable.clear();
  8783. };
  8784. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8785. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8786. ], InputText.prototype, "promptMessage", void 0);
  8787. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8788. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8789. ], InputText.prototype, "disableMobilePrompt", void 0);
  8790. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8791. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8792. ], InputText.prototype, "maxWidth", null);
  8793. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8794. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8795. ], InputText.prototype, "highligherOpacity", null);
  8796. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8797. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8798. ], InputText.prototype, "onFocusSelectAll", null);
  8799. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8800. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8801. ], InputText.prototype, "textHighlightColor", null);
  8802. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8803. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8804. ], InputText.prototype, "margin", null);
  8805. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8806. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8807. ], InputText.prototype, "autoStretchWidth", null);
  8808. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8809. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8810. ], InputText.prototype, "thickness", null);
  8811. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8812. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8813. ], InputText.prototype, "focusedBackground", null);
  8814. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8815. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8816. ], InputText.prototype, "focusedColor", null);
  8817. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8818. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8819. ], InputText.prototype, "background", null);
  8820. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8821. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8822. ], InputText.prototype, "placeholderColor", null);
  8823. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8824. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8825. ], InputText.prototype, "placeholderText", null);
  8826. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8827. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8828. ], InputText.prototype, "deadKey", null);
  8829. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8830. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8831. ], InputText.prototype, "text", null);
  8832. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8833. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8834. ], InputText.prototype, "width", null);
  8835. return InputText;
  8836. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8837. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  8838. /***/ }),
  8839. /***/ "./2D/controls/line.ts":
  8840. /*!*****************************!*\
  8841. !*** ./2D/controls/line.ts ***!
  8842. \*****************************/
  8843. /*! exports provided: Line */
  8844. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8845. "use strict";
  8846. __webpack_require__.r(__webpack_exports__);
  8847. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  8848. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8849. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  8850. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  8851. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8852. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  8853. /** Class used to render 2D lines */
  8854. var Line = /** @class */ (function (_super) {
  8855. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8856. /**
  8857. * Creates a new Line
  8858. * @param name defines the control name
  8859. */
  8860. function Line(name) {
  8861. var _this = _super.call(this, name) || this;
  8862. _this.name = name;
  8863. _this._lineWidth = 1;
  8864. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8865. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8866. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8867. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8868. _this._dash = new Array();
  8869. _this._automaticSize = true;
  8870. _this.isHitTestVisible = false;
  8871. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8872. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8873. return _this;
  8874. }
  8875. Object.defineProperty(Line.prototype, "dash", {
  8876. /** Gets or sets the dash pattern */
  8877. get: function () {
  8878. return this._dash;
  8879. },
  8880. set: function (value) {
  8881. if (this._dash === value) {
  8882. return;
  8883. }
  8884. this._dash = value;
  8885. this._markAsDirty();
  8886. },
  8887. enumerable: false,
  8888. configurable: true
  8889. });
  8890. Object.defineProperty(Line.prototype, "connectedControl", {
  8891. /** Gets or sets the control connected with the line end */
  8892. get: function () {
  8893. return this._connectedControl;
  8894. },
  8895. set: function (value) {
  8896. var _this = this;
  8897. if (this._connectedControl === value) {
  8898. return;
  8899. }
  8900. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8901. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8902. this._connectedControlDirtyObserver = null;
  8903. }
  8904. if (value) {
  8905. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8906. }
  8907. this._connectedControl = value;
  8908. this._markAsDirty();
  8909. },
  8910. enumerable: false,
  8911. configurable: true
  8912. });
  8913. Object.defineProperty(Line.prototype, "x1", {
  8914. /** Gets or sets start coordinates on X axis */
  8915. get: function () {
  8916. return this._x1.toString(this._host);
  8917. },
  8918. set: function (value) {
  8919. if (this._x1.toString(this._host) === value) {
  8920. return;
  8921. }
  8922. if (this._x1.fromString(value)) {
  8923. this._markAsDirty();
  8924. }
  8925. },
  8926. enumerable: false,
  8927. configurable: true
  8928. });
  8929. Object.defineProperty(Line.prototype, "y1", {
  8930. /** Gets or sets start coordinates on Y axis */
  8931. get: function () {
  8932. return this._y1.toString(this._host);
  8933. },
  8934. set: function (value) {
  8935. if (this._y1.toString(this._host) === value) {
  8936. return;
  8937. }
  8938. if (this._y1.fromString(value)) {
  8939. this._markAsDirty();
  8940. }
  8941. },
  8942. enumerable: false,
  8943. configurable: true
  8944. });
  8945. Object.defineProperty(Line.prototype, "x2", {
  8946. /** Gets or sets end coordinates on X axis */
  8947. get: function () {
  8948. return this._x2.toString(this._host);
  8949. },
  8950. set: function (value) {
  8951. if (this._x2.toString(this._host) === value) {
  8952. return;
  8953. }
  8954. if (this._x2.fromString(value)) {
  8955. this._markAsDirty();
  8956. }
  8957. },
  8958. enumerable: false,
  8959. configurable: true
  8960. });
  8961. Object.defineProperty(Line.prototype, "y2", {
  8962. /** Gets or sets end coordinates on Y axis */
  8963. get: function () {
  8964. return this._y2.toString(this._host);
  8965. },
  8966. set: function (value) {
  8967. if (this._y2.toString(this._host) === value) {
  8968. return;
  8969. }
  8970. if (this._y2.fromString(value)) {
  8971. this._markAsDirty();
  8972. }
  8973. },
  8974. enumerable: false,
  8975. configurable: true
  8976. });
  8977. Object.defineProperty(Line.prototype, "lineWidth", {
  8978. /** Gets or sets line width */
  8979. get: function () {
  8980. return this._lineWidth;
  8981. },
  8982. set: function (value) {
  8983. if (this._lineWidth === value) {
  8984. return;
  8985. }
  8986. this._lineWidth = value;
  8987. this._markAsDirty();
  8988. },
  8989. enumerable: false,
  8990. configurable: true
  8991. });
  8992. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8993. /** Gets or sets horizontal alignment */
  8994. set: function (value) {
  8995. return;
  8996. },
  8997. enumerable: false,
  8998. configurable: true
  8999. });
  9000. Object.defineProperty(Line.prototype, "verticalAlignment", {
  9001. /** Gets or sets vertical alignment */
  9002. set: function (value) {
  9003. return;
  9004. },
  9005. enumerable: false,
  9006. configurable: true
  9007. });
  9008. Object.defineProperty(Line.prototype, "_effectiveX2", {
  9009. get: function () {
  9010. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  9011. },
  9012. enumerable: false,
  9013. configurable: true
  9014. });
  9015. Object.defineProperty(Line.prototype, "_effectiveY2", {
  9016. get: function () {
  9017. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  9018. },
  9019. enumerable: false,
  9020. configurable: true
  9021. });
  9022. Line.prototype._getTypeName = function () {
  9023. return "Line";
  9024. };
  9025. Line.prototype._draw = function (context) {
  9026. context.save();
  9027. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9028. context.shadowColor = this.shadowColor;
  9029. context.shadowBlur = this.shadowBlur;
  9030. context.shadowOffsetX = this.shadowOffsetX;
  9031. context.shadowOffsetY = this.shadowOffsetY;
  9032. }
  9033. this._applyStates(context);
  9034. context.strokeStyle = this.color;
  9035. context.lineWidth = this._lineWidth;
  9036. context.setLineDash(this._dash);
  9037. context.beginPath();
  9038. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  9039. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  9040. context.stroke();
  9041. context.restore();
  9042. };
  9043. Line.prototype._measure = function () {
  9044. // Width / Height
  9045. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  9046. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  9047. };
  9048. Line.prototype._computeAlignment = function (parentMeasure, context) {
  9049. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  9050. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  9051. };
  9052. /**
  9053. * Move one end of the line given 3D cartesian coordinates.
  9054. * @param position Targeted world position
  9055. * @param scene Scene
  9056. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  9057. */
  9058. Line.prototype.moveToVector3 = function (position, scene, end) {
  9059. if (end === void 0) { end = false; }
  9060. if (!this._host || this.parent !== this._host._rootContainer) {
  9061. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  9062. return;
  9063. }
  9064. var globalViewport = this._host._getGlobalViewport(scene);
  9065. var projectedPosition = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  9066. this._moveToProjectedPosition(projectedPosition, end);
  9067. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  9068. this.notRenderable = true;
  9069. return;
  9070. }
  9071. this.notRenderable = false;
  9072. };
  9073. /**
  9074. * Move one end of the line to a position in screen absolute space.
  9075. * @param projectedPosition Position in screen absolute space (X, Y)
  9076. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  9077. */
  9078. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  9079. if (end === void 0) { end = false; }
  9080. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  9081. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  9082. if (end) {
  9083. this.x2 = x;
  9084. this.y2 = y;
  9085. this._x2.ignoreAdaptiveScaling = true;
  9086. this._y2.ignoreAdaptiveScaling = true;
  9087. }
  9088. else {
  9089. this.x1 = x;
  9090. this.y1 = y;
  9091. this._x1.ignoreAdaptiveScaling = true;
  9092. this._y1.ignoreAdaptiveScaling = true;
  9093. }
  9094. };
  9095. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9096. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9097. ], Line.prototype, "dash", null);
  9098. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9099. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9100. ], Line.prototype, "x1", null);
  9101. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9102. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9103. ], Line.prototype, "y1", null);
  9104. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9105. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9106. ], Line.prototype, "x2", null);
  9107. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9108. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9109. ], Line.prototype, "y2", null);
  9110. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9111. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9112. ], Line.prototype, "lineWidth", null);
  9113. return Line;
  9114. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9115. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  9116. /***/ }),
  9117. /***/ "./2D/controls/multiLine.ts":
  9118. /*!**********************************!*\
  9119. !*** ./2D/controls/multiLine.ts ***!
  9120. \**********************************/
  9121. /*! exports provided: MultiLine */
  9122. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9123. "use strict";
  9124. __webpack_require__.r(__webpack_exports__);
  9125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  9126. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9127. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/perfCounter");
  9128. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  9129. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9130. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  9131. /**
  9132. * Class used to create multi line control
  9133. */
  9134. var MultiLine = /** @class */ (function (_super) {
  9135. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  9136. /**
  9137. * Creates a new MultiLine
  9138. * @param name defines the control name
  9139. */
  9140. function MultiLine(name) {
  9141. var _this = _super.call(this, name) || this;
  9142. _this.name = name;
  9143. _this._lineWidth = 1;
  9144. /** Function called when a point is updated */
  9145. _this.onPointUpdate = function () {
  9146. _this._markAsDirty();
  9147. };
  9148. _this._automaticSize = true;
  9149. _this.isHitTestVisible = false;
  9150. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9151. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  9152. _this._dash = [];
  9153. _this._points = [];
  9154. return _this;
  9155. }
  9156. Object.defineProperty(MultiLine.prototype, "dash", {
  9157. /** Gets or sets dash pattern */
  9158. get: function () {
  9159. return this._dash;
  9160. },
  9161. set: function (value) {
  9162. if (this._dash === value) {
  9163. return;
  9164. }
  9165. this._dash = value;
  9166. this._markAsDirty();
  9167. },
  9168. enumerable: false,
  9169. configurable: true
  9170. });
  9171. /**
  9172. * Gets point stored at specified index
  9173. * @param index defines the index to look for
  9174. * @returns the requested point if found
  9175. */
  9176. MultiLine.prototype.getAt = function (index) {
  9177. if (!this._points[index]) {
  9178. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  9179. }
  9180. return this._points[index];
  9181. };
  9182. /**
  9183. * Adds new points to the point collection
  9184. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  9185. * @returns the list of created MultiLinePoint
  9186. */
  9187. MultiLine.prototype.add = function () {
  9188. var _this = this;
  9189. var items = [];
  9190. for (var _i = 0; _i < arguments.length; _i++) {
  9191. items[_i] = arguments[_i];
  9192. }
  9193. return items.map(function (item) { return _this.push(item); });
  9194. };
  9195. /**
  9196. * Adds a new point to the point collection
  9197. * @param item defines the item (mesh, control or 2d coordiantes) to add
  9198. * @returns the created MultiLinePoint
  9199. */
  9200. MultiLine.prototype.push = function (item) {
  9201. var point = this.getAt(this._points.length);
  9202. if (item == null) {
  9203. return point;
  9204. }
  9205. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  9206. point.mesh = item;
  9207. }
  9208. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  9209. point.control = item;
  9210. }
  9211. else if (item.x != null && item.y != null) {
  9212. point.x = item.x;
  9213. point.y = item.y;
  9214. }
  9215. return point;
  9216. };
  9217. /**
  9218. * Remove a specific value or point from the active point collection
  9219. * @param value defines the value or point to remove
  9220. */
  9221. MultiLine.prototype.remove = function (value) {
  9222. var index;
  9223. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  9224. index = this._points.indexOf(value);
  9225. if (index === -1) {
  9226. return;
  9227. }
  9228. }
  9229. else {
  9230. index = value;
  9231. }
  9232. var point = this._points[index];
  9233. if (!point) {
  9234. return;
  9235. }
  9236. point.dispose();
  9237. this._points.splice(index, 1);
  9238. };
  9239. /**
  9240. * Resets this object to initial state (no point)
  9241. */
  9242. MultiLine.prototype.reset = function () {
  9243. while (this._points.length > 0) {
  9244. this.remove(this._points.length - 1);
  9245. }
  9246. };
  9247. /**
  9248. * Resets all links
  9249. */
  9250. MultiLine.prototype.resetLinks = function () {
  9251. this._points.forEach(function (point) {
  9252. if (point != null) {
  9253. point.resetLinks();
  9254. }
  9255. });
  9256. };
  9257. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  9258. /** Gets or sets line width */
  9259. get: function () {
  9260. return this._lineWidth;
  9261. },
  9262. set: function (value) {
  9263. if (this._lineWidth === value) {
  9264. return;
  9265. }
  9266. this._lineWidth = value;
  9267. this._markAsDirty();
  9268. },
  9269. enumerable: false,
  9270. configurable: true
  9271. });
  9272. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  9273. set: function (value) {
  9274. return;
  9275. },
  9276. enumerable: false,
  9277. configurable: true
  9278. });
  9279. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  9280. set: function (value) {
  9281. return;
  9282. },
  9283. enumerable: false,
  9284. configurable: true
  9285. });
  9286. MultiLine.prototype._getTypeName = function () {
  9287. return "MultiLine";
  9288. };
  9289. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  9290. context.save();
  9291. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9292. context.shadowColor = this.shadowColor;
  9293. context.shadowBlur = this.shadowBlur;
  9294. context.shadowOffsetX = this.shadowOffsetX;
  9295. context.shadowOffsetY = this.shadowOffsetY;
  9296. }
  9297. this._applyStates(context);
  9298. context.strokeStyle = this.color;
  9299. context.lineWidth = this._lineWidth;
  9300. context.setLineDash(this._dash);
  9301. context.beginPath();
  9302. var first = true; //first index is not necessarily 0
  9303. var previousPoint;
  9304. this._points.forEach(function (point) {
  9305. if (!point) {
  9306. return;
  9307. }
  9308. if (first) {
  9309. context.moveTo(point._point.x, point._point.y);
  9310. first = false;
  9311. }
  9312. else {
  9313. if (point._point.z < 1 && previousPoint.z < 1) {
  9314. context.lineTo(point._point.x, point._point.y);
  9315. }
  9316. else {
  9317. context.moveTo(point._point.x, point._point.y);
  9318. }
  9319. }
  9320. previousPoint = point._point;
  9321. });
  9322. context.stroke();
  9323. context.restore();
  9324. };
  9325. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  9326. var _this = this;
  9327. this._minX = null;
  9328. this._minY = null;
  9329. this._maxX = null;
  9330. this._maxY = null;
  9331. this._points.forEach(function (point, index) {
  9332. if (!point) {
  9333. return;
  9334. }
  9335. point.translate();
  9336. if (_this._minX == null || point._point.x < _this._minX) {
  9337. _this._minX = point._point.x;
  9338. }
  9339. if (_this._minY == null || point._point.y < _this._minY) {
  9340. _this._minY = point._point.y;
  9341. }
  9342. if (_this._maxX == null || point._point.x > _this._maxX) {
  9343. _this._maxX = point._point.x;
  9344. }
  9345. if (_this._maxY == null || point._point.y > _this._maxY) {
  9346. _this._maxY = point._point.y;
  9347. }
  9348. });
  9349. if (this._minX == null) {
  9350. this._minX = 0;
  9351. }
  9352. if (this._minY == null) {
  9353. this._minY = 0;
  9354. }
  9355. if (this._maxX == null) {
  9356. this._maxX = 0;
  9357. }
  9358. if (this._maxY == null) {
  9359. this._maxY = 0;
  9360. }
  9361. };
  9362. MultiLine.prototype._measure = function () {
  9363. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  9364. return;
  9365. }
  9366. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  9367. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  9368. };
  9369. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  9370. if (this._minX == null || this._minY == null) {
  9371. return;
  9372. }
  9373. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  9374. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  9375. };
  9376. MultiLine.prototype.dispose = function () {
  9377. this.reset();
  9378. _super.prototype.dispose.call(this);
  9379. };
  9380. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9381. Object(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9382. ], MultiLine.prototype, "dash", null);
  9383. return MultiLine;
  9384. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9385. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  9386. /***/ }),
  9387. /***/ "./2D/controls/radioButton.ts":
  9388. /*!************************************!*\
  9389. !*** ./2D/controls/radioButton.ts ***!
  9390. \************************************/
  9391. /*! exports provided: RadioButton */
  9392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9393. "use strict";
  9394. __webpack_require__.r(__webpack_exports__);
  9395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  9396. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9397. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  9398. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9399. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9400. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9401. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9402. /**
  9403. * Class used to create radio button controls
  9404. */
  9405. var RadioButton = /** @class */ (function (_super) {
  9406. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  9407. /**
  9408. * Creates a new RadioButton
  9409. * @param name defines the control name
  9410. */
  9411. function RadioButton(name) {
  9412. var _this = _super.call(this, name) || this;
  9413. _this.name = name;
  9414. _this._isChecked = false;
  9415. _this._background = "black";
  9416. _this._checkSizeRatio = 0.8;
  9417. _this._thickness = 1;
  9418. /** Gets or sets group name */
  9419. _this.group = "";
  9420. /** Observable raised when isChecked is changed */
  9421. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9422. _this.isPointerBlocker = true;
  9423. return _this;
  9424. }
  9425. Object.defineProperty(RadioButton.prototype, "thickness", {
  9426. /** Gets or sets border thickness */
  9427. get: function () {
  9428. return this._thickness;
  9429. },
  9430. set: function (value) {
  9431. if (this._thickness === value) {
  9432. return;
  9433. }
  9434. this._thickness = value;
  9435. this._markAsDirty();
  9436. },
  9437. enumerable: false,
  9438. configurable: true
  9439. });
  9440. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  9441. /** Gets or sets a value indicating the ratio between overall size and check size */
  9442. get: function () {
  9443. return this._checkSizeRatio;
  9444. },
  9445. set: function (value) {
  9446. value = Math.max(Math.min(1, value), 0);
  9447. if (this._checkSizeRatio === value) {
  9448. return;
  9449. }
  9450. this._checkSizeRatio = value;
  9451. this._markAsDirty();
  9452. },
  9453. enumerable: false,
  9454. configurable: true
  9455. });
  9456. Object.defineProperty(RadioButton.prototype, "background", {
  9457. /** Gets or sets background color */
  9458. get: function () {
  9459. return this._background;
  9460. },
  9461. set: function (value) {
  9462. if (this._background === value) {
  9463. return;
  9464. }
  9465. this._background = value;
  9466. this._markAsDirty();
  9467. },
  9468. enumerable: false,
  9469. configurable: true
  9470. });
  9471. Object.defineProperty(RadioButton.prototype, "isChecked", {
  9472. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  9473. get: function () {
  9474. return this._isChecked;
  9475. },
  9476. set: function (value) {
  9477. var _this = this;
  9478. if (this._isChecked === value) {
  9479. return;
  9480. }
  9481. this._isChecked = value;
  9482. this._markAsDirty();
  9483. this.onIsCheckedChangedObservable.notifyObservers(value);
  9484. if (this._isChecked && this._host) {
  9485. // Update all controls from same group
  9486. this._host.executeOnAllControls(function (control) {
  9487. if (control === _this) {
  9488. return;
  9489. }
  9490. if (control.group === undefined) {
  9491. return;
  9492. }
  9493. var childRadio = control;
  9494. if (childRadio.group === _this.group) {
  9495. childRadio.isChecked = false;
  9496. }
  9497. });
  9498. }
  9499. },
  9500. enumerable: false,
  9501. configurable: true
  9502. });
  9503. RadioButton.prototype._getTypeName = function () {
  9504. return "RadioButton";
  9505. };
  9506. RadioButton.prototype._draw = function (context) {
  9507. context.save();
  9508. this._applyStates(context);
  9509. var actualWidth = this._currentMeasure.width - this._thickness;
  9510. var actualHeight = this._currentMeasure.height - this._thickness;
  9511. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9512. context.shadowColor = this.shadowColor;
  9513. context.shadowBlur = this.shadowBlur;
  9514. context.shadowOffsetX = this.shadowOffsetX;
  9515. context.shadowOffsetY = this.shadowOffsetY;
  9516. }
  9517. // Outer
  9518. _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);
  9519. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  9520. context.fill();
  9521. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9522. context.shadowBlur = 0;
  9523. context.shadowOffsetX = 0;
  9524. context.shadowOffsetY = 0;
  9525. }
  9526. context.strokeStyle = this.color;
  9527. context.lineWidth = this._thickness;
  9528. context.stroke();
  9529. // Inner
  9530. if (this._isChecked) {
  9531. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  9532. var offsetWidth = actualWidth * this._checkSizeRatio;
  9533. var offseHeight = actualHeight * this._checkSizeRatio;
  9534. _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);
  9535. context.fill();
  9536. }
  9537. context.restore();
  9538. };
  9539. // Events
  9540. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  9541. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  9542. return false;
  9543. }
  9544. if (!this.isChecked) {
  9545. this.isChecked = true;
  9546. }
  9547. return true;
  9548. };
  9549. /**
  9550. * Utility function to easily create a radio button with a header
  9551. * @param title defines the label to use for the header
  9552. * @param group defines the group to use for the radio button
  9553. * @param isChecked defines the initial state of the radio button
  9554. * @param onValueChanged defines the callback to call when value changes
  9555. * @returns a StackPanel containing the radio button and a textBlock
  9556. */
  9557. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  9558. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  9559. panel.isVertical = false;
  9560. panel.height = "30px";
  9561. var radio = new RadioButton();
  9562. radio.width = "20px";
  9563. radio.height = "20px";
  9564. radio.isChecked = isChecked;
  9565. radio.color = "green";
  9566. radio.group = group;
  9567. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  9568. panel.addControl(radio);
  9569. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  9570. header.text = title;
  9571. header.width = "180px";
  9572. header.paddingLeft = "5px";
  9573. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9574. header.color = "white";
  9575. panel.addControl(header);
  9576. return panel;
  9577. };
  9578. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9579. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9580. ], RadioButton.prototype, "thickness", null);
  9581. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9582. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9583. ], RadioButton.prototype, "group", void 0);
  9584. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9585. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9586. ], RadioButton.prototype, "checkSizeRatio", null);
  9587. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9588. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9589. ], RadioButton.prototype, "background", null);
  9590. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9591. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9592. ], RadioButton.prototype, "isChecked", null);
  9593. return RadioButton;
  9594. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9595. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  9596. /***/ }),
  9597. /***/ "./2D/controls/rectangle.ts":
  9598. /*!**********************************!*\
  9599. !*** ./2D/controls/rectangle.ts ***!
  9600. \**********************************/
  9601. /*! exports provided: Rectangle */
  9602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9603. "use strict";
  9604. __webpack_require__.r(__webpack_exports__);
  9605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  9606. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9607. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9608. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  9609. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  9610. /** Class used to create rectangle container */
  9611. var Rectangle = /** @class */ (function (_super) {
  9612. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  9613. /**
  9614. * Creates a new Rectangle
  9615. * @param name defines the control name
  9616. */
  9617. function Rectangle(name) {
  9618. var _this = _super.call(this, name) || this;
  9619. _this.name = name;
  9620. _this._thickness = 1;
  9621. _this._cornerRadius = 0;
  9622. return _this;
  9623. }
  9624. Object.defineProperty(Rectangle.prototype, "thickness", {
  9625. /** Gets or sets border thickness */
  9626. get: function () {
  9627. return this._thickness;
  9628. },
  9629. set: function (value) {
  9630. if (this._thickness === value) {
  9631. return;
  9632. }
  9633. this._thickness = value;
  9634. this._markAsDirty();
  9635. },
  9636. enumerable: false,
  9637. configurable: true
  9638. });
  9639. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  9640. /** Gets or sets the corner radius angle */
  9641. get: function () {
  9642. return this._cornerRadius;
  9643. },
  9644. set: function (value) {
  9645. if (value < 0) {
  9646. value = 0;
  9647. }
  9648. if (this._cornerRadius === value) {
  9649. return;
  9650. }
  9651. this._cornerRadius = value;
  9652. this._markAsDirty();
  9653. },
  9654. enumerable: false,
  9655. configurable: true
  9656. });
  9657. Rectangle.prototype._getTypeName = function () {
  9658. return "Rectangle";
  9659. };
  9660. Rectangle.prototype._localDraw = function (context) {
  9661. context.save();
  9662. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9663. context.shadowColor = this.shadowColor;
  9664. context.shadowBlur = this.shadowBlur;
  9665. context.shadowOffsetX = this.shadowOffsetX;
  9666. context.shadowOffsetY = this.shadowOffsetY;
  9667. }
  9668. if (this._background) {
  9669. context.fillStyle = this._background;
  9670. if (this._cornerRadius) {
  9671. this._drawRoundedRect(context, this._thickness / 2);
  9672. context.fill();
  9673. }
  9674. else {
  9675. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  9676. }
  9677. }
  9678. if (this._thickness) {
  9679. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9680. context.shadowBlur = 0;
  9681. context.shadowOffsetX = 0;
  9682. context.shadowOffsetY = 0;
  9683. }
  9684. if (this.color) {
  9685. context.strokeStyle = this.color;
  9686. }
  9687. context.lineWidth = this._thickness;
  9688. if (this._cornerRadius) {
  9689. this._drawRoundedRect(context, this._thickness / 2);
  9690. context.stroke();
  9691. }
  9692. else {
  9693. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  9694. }
  9695. }
  9696. context.restore();
  9697. };
  9698. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  9699. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9700. this._measureForChildren.width -= 2 * this._thickness;
  9701. this._measureForChildren.height -= 2 * this._thickness;
  9702. this._measureForChildren.left += this._thickness;
  9703. this._measureForChildren.top += this._thickness;
  9704. };
  9705. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  9706. if (offset === void 0) { offset = 0; }
  9707. var x = this._currentMeasure.left + offset;
  9708. var y = this._currentMeasure.top + offset;
  9709. var width = this._currentMeasure.width - offset * 2;
  9710. var height = this._currentMeasure.height - offset * 2;
  9711. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  9712. context.beginPath();
  9713. context.moveTo(x + radius, y);
  9714. context.lineTo(x + width - radius, y);
  9715. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  9716. context.lineTo(x + width, y + height - radius);
  9717. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  9718. context.lineTo(x + radius, y + height);
  9719. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  9720. context.lineTo(x, y + radius);
  9721. context.quadraticCurveTo(x, y, x + radius, y);
  9722. context.closePath();
  9723. };
  9724. Rectangle.prototype._clipForChildren = function (context) {
  9725. if (this._cornerRadius) {
  9726. this._drawRoundedRect(context, this._thickness);
  9727. context.clip();
  9728. }
  9729. };
  9730. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9731. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  9732. ], Rectangle.prototype, "thickness", null);
  9733. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9734. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  9735. ], Rectangle.prototype, "cornerRadius", null);
  9736. return Rectangle;
  9737. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9738. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  9739. /***/ }),
  9740. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  9741. /*!***************************************************!*\
  9742. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  9743. \***************************************************/
  9744. /*! exports provided: ScrollViewer */
  9745. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9746. "use strict";
  9747. __webpack_require__.r(__webpack_exports__);
  9748. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  9749. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9750. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  9751. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  9752. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9753. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  9754. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  9755. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  9756. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  9757. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__);
  9758. /**
  9759. * Class used to hold a viewer window and sliders in a grid
  9760. */
  9761. var ScrollViewer = /** @class */ (function (_super) {
  9762. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  9763. /**
  9764. * Creates a new ScrollViewer
  9765. * @param name of ScrollViewer
  9766. */
  9767. function ScrollViewer(name, isImageBased) {
  9768. var _this = _super.call(this, name) || this;
  9769. _this._barSize = 20;
  9770. _this._pointerIsOver = false;
  9771. _this._wheelPrecision = 0.05;
  9772. _this._thumbLength = 0.5;
  9773. _this._thumbHeight = 1;
  9774. _this._barImageHeight = 1;
  9775. _this._horizontalBarImageHeight = 1;
  9776. _this._verticalBarImageHeight = 1;
  9777. _this._oldWindowContentsWidth = 0;
  9778. _this._oldWindowContentsHeight = 0;
  9779. _this._forceHorizontalBar = false;
  9780. _this._forceVerticalBar = false;
  9781. _this._useImageBar = isImageBased ? isImageBased : false;
  9782. _this.onDirtyObservable.add(function () {
  9783. _this._horizontalBarSpace.color = _this.color;
  9784. _this._verticalBarSpace.color = _this.color;
  9785. _this._dragSpace.color = _this.color;
  9786. });
  9787. _this.onPointerEnterObservable.add(function () {
  9788. _this._pointerIsOver = true;
  9789. });
  9790. _this.onPointerOutObservable.add(function () {
  9791. _this._pointerIsOver = false;
  9792. });
  9793. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_2__["Grid"]();
  9794. if (_this._useImageBar) {
  9795. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9796. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9797. }
  9798. else {
  9799. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9800. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9801. }
  9802. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__["_ScrollViewerWindow"]("scrollViewer_window");
  9803. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9804. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9805. _this._grid.addColumnDefinition(1);
  9806. _this._grid.addColumnDefinition(0, true);
  9807. _this._grid.addRowDefinition(1);
  9808. _this._grid.addRowDefinition(0, true);
  9809. _super.prototype.addControl.call(_this, _this._grid);
  9810. _this._grid.addControl(_this._window, 0, 0);
  9811. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9812. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9813. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9814. _this._verticalBarSpace.thickness = 1;
  9815. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  9816. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  9817. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9818. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9819. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9820. _this._horizontalBarSpace.thickness = 1;
  9821. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  9822. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  9823. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9824. _this._dragSpace.thickness = 1;
  9825. _this._grid.addControl(_this._dragSpace, 1, 1);
  9826. // Colors
  9827. if (!_this._useImageBar) {
  9828. _this.barColor = "grey";
  9829. _this.barBackground = "transparent";
  9830. }
  9831. return _this;
  9832. }
  9833. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  9834. /**
  9835. * Gets the horizontal scrollbar
  9836. */
  9837. get: function () {
  9838. return this._horizontalBar;
  9839. },
  9840. enumerable: false,
  9841. configurable: true
  9842. });
  9843. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  9844. /**
  9845. * Gets the vertical scrollbar
  9846. */
  9847. get: function () {
  9848. return this._verticalBar;
  9849. },
  9850. enumerable: false,
  9851. configurable: true
  9852. });
  9853. /**
  9854. * Adds a new control to the current container
  9855. * @param control defines the control to add
  9856. * @returns the current container
  9857. */
  9858. ScrollViewer.prototype.addControl = function (control) {
  9859. if (!control) {
  9860. return this;
  9861. }
  9862. this._window.addControl(control);
  9863. return this;
  9864. };
  9865. /**
  9866. * Removes a control from the current container
  9867. * @param control defines the control to remove
  9868. * @returns the current container
  9869. */
  9870. ScrollViewer.prototype.removeControl = function (control) {
  9871. this._window.removeControl(control);
  9872. return this;
  9873. };
  9874. Object.defineProperty(ScrollViewer.prototype, "children", {
  9875. /** Gets the list of children */
  9876. get: function () {
  9877. return this._window.children;
  9878. },
  9879. enumerable: false,
  9880. configurable: true
  9881. });
  9882. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  9883. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9884. var child = _a[_i];
  9885. child._markMatrixAsDirty();
  9886. }
  9887. };
  9888. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  9889. /**
  9890. * Freezes or unfreezes the controls in the window.
  9891. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  9892. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  9893. */
  9894. get: function () {
  9895. return this._window.freezeControls;
  9896. },
  9897. set: function (value) {
  9898. this._window.freezeControls = value;
  9899. },
  9900. enumerable: false,
  9901. configurable: true
  9902. });
  9903. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  9904. /** Gets the bucket width */
  9905. get: function () {
  9906. return this._window.bucketWidth;
  9907. },
  9908. enumerable: false,
  9909. configurable: true
  9910. });
  9911. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9912. /** Gets the bucket height */
  9913. get: function () {
  9914. return this._window.bucketHeight;
  9915. },
  9916. enumerable: false,
  9917. configurable: true
  9918. });
  9919. /**
  9920. * Sets the bucket sizes.
  9921. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9922. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9923. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9924. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9925. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9926. * used), that's why it is not enabled by default.
  9927. * @param width width of the bucket
  9928. * @param height height of the bucket
  9929. */
  9930. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9931. this._window.setBucketSizes(width, height);
  9932. };
  9933. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9934. /**
  9935. * Forces the horizontal scroll bar to be displayed
  9936. */
  9937. get: function () {
  9938. return this._forceHorizontalBar;
  9939. },
  9940. set: function (value) {
  9941. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9942. this._horizontalBar.isVisible = value;
  9943. this._forceHorizontalBar = value;
  9944. },
  9945. enumerable: false,
  9946. configurable: true
  9947. });
  9948. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9949. /**
  9950. * Forces the vertical scroll bar to be displayed
  9951. */
  9952. get: function () {
  9953. return this._forceVerticalBar;
  9954. },
  9955. set: function (value) {
  9956. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9957. this._verticalBar.isVisible = value;
  9958. this._forceVerticalBar = value;
  9959. },
  9960. enumerable: false,
  9961. configurable: true
  9962. });
  9963. /** Reset the scroll viewer window to initial size */
  9964. ScrollViewer.prototype.resetWindow = function () {
  9965. this._window.width = "100%";
  9966. this._window.height = "100%";
  9967. };
  9968. ScrollViewer.prototype._getTypeName = function () {
  9969. return "ScrollViewer";
  9970. };
  9971. ScrollViewer.prototype._buildClientSizes = function () {
  9972. var ratio = this.host.idealRatio;
  9973. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9974. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9975. this._clientWidth = this._window.parentClientWidth;
  9976. this._clientHeight = this._window.parentClientHeight;
  9977. };
  9978. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  9979. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9980. this._buildClientSizes();
  9981. };
  9982. ScrollViewer.prototype._postMeasure = function () {
  9983. _super.prototype._postMeasure.call(this);
  9984. this._updateScroller();
  9985. this._setWindowPosition(false);
  9986. };
  9987. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  9988. /**
  9989. * Gets or sets the mouse wheel precision
  9990. * from 0 to 1 with a default value of 0.05
  9991. * */
  9992. get: function () {
  9993. return this._wheelPrecision;
  9994. },
  9995. set: function (value) {
  9996. if (this._wheelPrecision === value) {
  9997. return;
  9998. }
  9999. if (value < 0) {
  10000. value = 0;
  10001. }
  10002. if (value > 1) {
  10003. value = 1;
  10004. }
  10005. this._wheelPrecision = value;
  10006. },
  10007. enumerable: false,
  10008. configurable: true
  10009. });
  10010. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  10011. /** Gets or sets the scroll bar container background color */
  10012. get: function () {
  10013. return this._horizontalBarSpace.background;
  10014. },
  10015. set: function (color) {
  10016. if (this._horizontalBarSpace.background === color) {
  10017. return;
  10018. }
  10019. this._horizontalBarSpace.background = color;
  10020. this._verticalBarSpace.background = color;
  10021. },
  10022. enumerable: false,
  10023. configurable: true
  10024. });
  10025. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  10026. /** Gets or sets the bar color */
  10027. get: function () {
  10028. return this._barColor;
  10029. },
  10030. set: function (color) {
  10031. if (this._barColor === color) {
  10032. return;
  10033. }
  10034. this._barColor = color;
  10035. this._horizontalBar.color = color;
  10036. this._verticalBar.color = color;
  10037. },
  10038. enumerable: false,
  10039. configurable: true
  10040. });
  10041. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  10042. /** Gets or sets the bar image */
  10043. get: function () {
  10044. return this._barImage;
  10045. },
  10046. set: function (value) {
  10047. if (this._barImage === value) {
  10048. return;
  10049. }
  10050. this._barImage = value;
  10051. var hb = this._horizontalBar;
  10052. var vb = this._verticalBar;
  10053. hb.thumbImage = value;
  10054. vb.thumbImage = value;
  10055. },
  10056. enumerable: false,
  10057. configurable: true
  10058. });
  10059. Object.defineProperty(ScrollViewer.prototype, "horizontalThumbImage", {
  10060. /** Gets or sets the horizontal bar image */
  10061. get: function () {
  10062. return this._horizontalBarImage;
  10063. },
  10064. set: function (value) {
  10065. if (this._horizontalBarImage === value) {
  10066. return;
  10067. }
  10068. this._horizontalBarImage = value;
  10069. var hb = this._horizontalBar;
  10070. hb.thumbImage = value;
  10071. },
  10072. enumerable: false,
  10073. configurable: true
  10074. });
  10075. Object.defineProperty(ScrollViewer.prototype, "verticalThumbImage", {
  10076. /** Gets or sets the vertical bar image */
  10077. get: function () {
  10078. return this._verticalBarImage;
  10079. },
  10080. set: function (value) {
  10081. if (this._verticalBarImage === value) {
  10082. return;
  10083. }
  10084. this._verticalBarImage = value;
  10085. var vb = this._verticalBar;
  10086. vb.thumbImage = value;
  10087. },
  10088. enumerable: false,
  10089. configurable: true
  10090. });
  10091. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  10092. /** Gets or sets the size of the bar */
  10093. get: function () {
  10094. return this._barSize;
  10095. },
  10096. set: function (value) {
  10097. if (this._barSize === value) {
  10098. return;
  10099. }
  10100. this._barSize = value;
  10101. this._markAsDirty();
  10102. if (this._horizontalBar.isVisible) {
  10103. this._grid.setRowDefinition(1, this._barSize, true);
  10104. }
  10105. if (this._verticalBar.isVisible) {
  10106. this._grid.setColumnDefinition(1, this._barSize, true);
  10107. }
  10108. },
  10109. enumerable: false,
  10110. configurable: true
  10111. });
  10112. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  10113. /** Gets or sets the length of the thumb */
  10114. get: function () {
  10115. return this._thumbLength;
  10116. },
  10117. set: function (value) {
  10118. if (this._thumbLength === value) {
  10119. return;
  10120. }
  10121. if (value <= 0) {
  10122. value = 0.1;
  10123. }
  10124. if (value > 1) {
  10125. value = 1;
  10126. }
  10127. this._thumbLength = value;
  10128. var hb = this._horizontalBar;
  10129. var vb = this._verticalBar;
  10130. hb.thumbLength = value;
  10131. vb.thumbLength = value;
  10132. this._markAsDirty();
  10133. },
  10134. enumerable: false,
  10135. configurable: true
  10136. });
  10137. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  10138. /** Gets or sets the height of the thumb */
  10139. get: function () {
  10140. return this._thumbHeight;
  10141. },
  10142. set: function (value) {
  10143. if (this._thumbHeight === value) {
  10144. return;
  10145. }
  10146. if (value <= 0) {
  10147. value = 0.1;
  10148. }
  10149. if (value > 1) {
  10150. value = 1;
  10151. }
  10152. this._thumbHeight = value;
  10153. var hb = this._horizontalBar;
  10154. var vb = this._verticalBar;
  10155. hb.thumbHeight = value;
  10156. vb.thumbHeight = value;
  10157. this._markAsDirty();
  10158. },
  10159. enumerable: false,
  10160. configurable: true
  10161. });
  10162. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  10163. /** Gets or sets the height of the bar image */
  10164. get: function () {
  10165. return this._barImageHeight;
  10166. },
  10167. set: function (value) {
  10168. if (this._barImageHeight === value) {
  10169. return;
  10170. }
  10171. if (value <= 0) {
  10172. value = 0.1;
  10173. }
  10174. if (value > 1) {
  10175. value = 1;
  10176. }
  10177. this._barImageHeight = value;
  10178. var hb = this._horizontalBar;
  10179. var vb = this._verticalBar;
  10180. hb.barImageHeight = value;
  10181. vb.barImageHeight = value;
  10182. this._markAsDirty();
  10183. },
  10184. enumerable: false,
  10185. configurable: true
  10186. });
  10187. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImageHeight", {
  10188. /** Gets or sets the height of the horizontal bar image */
  10189. get: function () {
  10190. return this._horizontalBarImageHeight;
  10191. },
  10192. set: function (value) {
  10193. if (this._horizontalBarImageHeight === value) {
  10194. return;
  10195. }
  10196. if (value <= 0) {
  10197. value = 0.1;
  10198. }
  10199. if (value > 1) {
  10200. value = 1;
  10201. }
  10202. this._horizontalBarImageHeight = value;
  10203. var hb = this._horizontalBar;
  10204. hb.barImageHeight = value;
  10205. this._markAsDirty();
  10206. },
  10207. enumerable: false,
  10208. configurable: true
  10209. });
  10210. Object.defineProperty(ScrollViewer.prototype, "verticalBarImageHeight", {
  10211. /** Gets or sets the height of the vertical bar image */
  10212. get: function () {
  10213. return this._verticalBarImageHeight;
  10214. },
  10215. set: function (value) {
  10216. if (this._verticalBarImageHeight === value) {
  10217. return;
  10218. }
  10219. if (value <= 0) {
  10220. value = 0.1;
  10221. }
  10222. if (value > 1) {
  10223. value = 1;
  10224. }
  10225. this._verticalBarImageHeight = value;
  10226. var vb = this._verticalBar;
  10227. vb.barImageHeight = value;
  10228. this._markAsDirty();
  10229. },
  10230. enumerable: false,
  10231. configurable: true
  10232. });
  10233. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  10234. /** Gets or sets the bar background */
  10235. get: function () {
  10236. return this._barBackground;
  10237. },
  10238. set: function (color) {
  10239. if (this._barBackground === color) {
  10240. return;
  10241. }
  10242. this._barBackground = color;
  10243. var hb = this._horizontalBar;
  10244. var vb = this._verticalBar;
  10245. hb.background = color;
  10246. vb.background = color;
  10247. this._dragSpace.background = color;
  10248. },
  10249. enumerable: false,
  10250. configurable: true
  10251. });
  10252. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  10253. /** Gets or sets the bar background image */
  10254. get: function () {
  10255. return this._barBackgroundImage;
  10256. },
  10257. set: function (value) {
  10258. if (this._barBackgroundImage === value) {
  10259. }
  10260. this._barBackgroundImage = value;
  10261. var hb = this._horizontalBar;
  10262. var vb = this._verticalBar;
  10263. hb.backgroundImage = value;
  10264. vb.backgroundImage = value;
  10265. },
  10266. enumerable: false,
  10267. configurable: true
  10268. });
  10269. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImage", {
  10270. /** Gets or sets the horizontal bar background image */
  10271. get: function () {
  10272. return this._horizontalBarBackgroundImage;
  10273. },
  10274. set: function (value) {
  10275. if (this._horizontalBarBackgroundImage === value) {
  10276. }
  10277. this._horizontalBarBackgroundImage = value;
  10278. var hb = this._horizontalBar;
  10279. hb.backgroundImage = value;
  10280. },
  10281. enumerable: false,
  10282. configurable: true
  10283. });
  10284. Object.defineProperty(ScrollViewer.prototype, "verticalBarImage", {
  10285. /** Gets or sets the vertical bar background image */
  10286. get: function () {
  10287. return this._verticalBarBackgroundImage;
  10288. },
  10289. set: function (value) {
  10290. if (this._verticalBarBackgroundImage === value) {
  10291. }
  10292. this._verticalBarBackgroundImage = value;
  10293. var vb = this._verticalBar;
  10294. vb.backgroundImage = value;
  10295. },
  10296. enumerable: false,
  10297. configurable: true
  10298. });
  10299. ScrollViewer.prototype._setWindowPosition = function (force) {
  10300. if (force === void 0) { force = true; }
  10301. var ratio = this.host.idealRatio;
  10302. var windowContentsWidth = this._window._currentMeasure.width;
  10303. var windowContentsHeight = this._window._currentMeasure.height;
  10304. if (!force && this._oldWindowContentsWidth === windowContentsWidth && this._oldWindowContentsHeight === windowContentsHeight) {
  10305. return;
  10306. }
  10307. this._oldWindowContentsWidth = windowContentsWidth;
  10308. this._oldWindowContentsHeight = windowContentsHeight;
  10309. var _endLeft = this._clientWidth - windowContentsWidth;
  10310. var _endTop = this._clientHeight - windowContentsHeight;
  10311. var newLeft = (this._horizontalBar.value / ratio) * _endLeft + "px";
  10312. var newTop = (this._verticalBar.value / ratio) * _endTop + "px";
  10313. if (newLeft !== this._window.left) {
  10314. this._window.left = newLeft;
  10315. if (!this.freezeControls) {
  10316. this._rebuildLayout = true;
  10317. }
  10318. }
  10319. if (newTop !== this._window.top) {
  10320. this._window.top = newTop;
  10321. if (!this.freezeControls) {
  10322. this._rebuildLayout = true;
  10323. }
  10324. }
  10325. };
  10326. /** @hidden */
  10327. ScrollViewer.prototype._updateScroller = function () {
  10328. var windowContentsWidth = this._window._currentMeasure.width;
  10329. var windowContentsHeight = this._window._currentMeasure.height;
  10330. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  10331. this._grid.setRowDefinition(1, 0, true);
  10332. this._horizontalBar.isVisible = false;
  10333. this._horizontalBar.value = 0;
  10334. this._rebuildLayout = true;
  10335. }
  10336. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  10337. this._grid.setRowDefinition(1, this._barSize, true);
  10338. this._horizontalBar.isVisible = true;
  10339. this._rebuildLayout = true;
  10340. }
  10341. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  10342. this._grid.setColumnDefinition(1, 0, true);
  10343. this._verticalBar.isVisible = false;
  10344. this._verticalBar.value = 0;
  10345. this._rebuildLayout = true;
  10346. }
  10347. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  10348. this._grid.setColumnDefinition(1, this._barSize, true);
  10349. this._verticalBar.isVisible = true;
  10350. this._rebuildLayout = true;
  10351. }
  10352. this._buildClientSizes();
  10353. var ratio = this.host.idealRatio;
  10354. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientWidth / ratio) + "px";
  10355. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientHeight / ratio) + "px";
  10356. };
  10357. ScrollViewer.prototype._link = function (host) {
  10358. _super.prototype._link.call(this, host);
  10359. this._attachWheel();
  10360. };
  10361. /** @hidden */
  10362. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  10363. var _this = this;
  10364. barControl.paddingLeft = 0;
  10365. barControl.width = "100%";
  10366. barControl.height = "100%";
  10367. barControl.barOffset = 0;
  10368. barControl.value = 0;
  10369. barControl.maximum = 1;
  10370. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10371. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10372. barControl.isVertical = isVertical;
  10373. barControl.rotation = rotation;
  10374. barControl.isVisible = false;
  10375. barContainer.addControl(barControl);
  10376. barControl.onValueChangedObservable.add(function (value) {
  10377. _this._setWindowPosition();
  10378. });
  10379. };
  10380. /** @hidden */
  10381. ScrollViewer.prototype._attachWheel = function () {
  10382. var _this = this;
  10383. if (!this._host || this._onWheelObserver) {
  10384. return;
  10385. }
  10386. this._onWheelObserver = this.onWheelObservable.add(function (pi) {
  10387. if (!_this._pointerIsOver) {
  10388. return;
  10389. }
  10390. if (_this._verticalBar.isVisible == true) {
  10391. if (pi.y < 0 && _this._verticalBar.value > 0) {
  10392. _this._verticalBar.value -= _this._wheelPrecision;
  10393. }
  10394. else if (pi.y > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  10395. _this._verticalBar.value += _this._wheelPrecision;
  10396. }
  10397. }
  10398. if (_this._horizontalBar.isVisible == true) {
  10399. if (pi.x < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  10400. _this._horizontalBar.value += _this._wheelPrecision;
  10401. }
  10402. else if (pi.x > 0 && _this._horizontalBar.value > 0) {
  10403. _this._horizontalBar.value -= _this._wheelPrecision;
  10404. }
  10405. }
  10406. });
  10407. };
  10408. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  10409. if (!this.isHighlighted) {
  10410. return;
  10411. }
  10412. _super.prototype._renderHighlightSpecific.call(this, context);
  10413. this._grid._renderHighlightSpecific(context);
  10414. context.restore();
  10415. };
  10416. /** Releases associated resources */
  10417. ScrollViewer.prototype.dispose = function () {
  10418. this.onWheelObservable.remove(this._onWheelObserver);
  10419. this._onWheelObserver = null;
  10420. _super.prototype.dispose.call(this);
  10421. };
  10422. return ScrollViewer;
  10423. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10424. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  10425. /***/ }),
  10426. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  10427. /*!*********************************************************!*\
  10428. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  10429. \*********************************************************/
  10430. /*! exports provided: _ScrollViewerWindow */
  10431. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10432. "use strict";
  10433. __webpack_require__.r(__webpack_exports__);
  10434. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  10435. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10436. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10437. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  10438. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10439. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10440. /**
  10441. * Class used to hold a the container for ScrollViewer
  10442. * @hidden
  10443. */
  10444. var _ScrollViewerWindow = /** @class */ (function (_super) {
  10445. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  10446. /**
  10447. * Creates a new ScrollViewerWindow
  10448. * @param name of ScrollViewerWindow
  10449. */
  10450. function _ScrollViewerWindow(name) {
  10451. var _this = _super.call(this, name) || this;
  10452. _this._freezeControls = false;
  10453. _this._bucketWidth = 0;
  10454. _this._bucketHeight = 0;
  10455. _this._buckets = {};
  10456. return _this;
  10457. }
  10458. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  10459. get: function () {
  10460. return this._freezeControls;
  10461. },
  10462. set: function (value) {
  10463. if (this._freezeControls === value) {
  10464. return;
  10465. }
  10466. if (!value) {
  10467. this._restoreMeasures();
  10468. }
  10469. // trigger a full normal layout calculation to be sure all children have their measures up to date
  10470. this._freezeControls = false;
  10471. var textureSize = this.host.getSize();
  10472. var renderWidth = textureSize.width;
  10473. var renderHeight = textureSize.height;
  10474. var context = this.host.getContext();
  10475. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  10476. this.host._numLayoutCalls = 0;
  10477. this.host._rootContainer._layout(measure, context);
  10478. // in freeze mode, prepare children measures accordingly
  10479. if (value) {
  10480. this._updateMeasures();
  10481. if (this._useBuckets()) {
  10482. this._makeBuckets();
  10483. }
  10484. }
  10485. this._freezeControls = value;
  10486. this.host.markAsDirty(); // redraw with the (new) current settings
  10487. },
  10488. enumerable: false,
  10489. configurable: true
  10490. });
  10491. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  10492. get: function () {
  10493. return this._bucketWidth;
  10494. },
  10495. enumerable: false,
  10496. configurable: true
  10497. });
  10498. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  10499. get: function () {
  10500. return this._bucketHeight;
  10501. },
  10502. enumerable: false,
  10503. configurable: true
  10504. });
  10505. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  10506. this._bucketWidth = width;
  10507. this._bucketHeight = height;
  10508. if (this._useBuckets()) {
  10509. if (this._freezeControls) {
  10510. this._makeBuckets();
  10511. }
  10512. }
  10513. else {
  10514. this._buckets = {};
  10515. }
  10516. };
  10517. _ScrollViewerWindow.prototype._useBuckets = function () {
  10518. return this._bucketWidth > 0 && this._bucketHeight > 0;
  10519. };
  10520. _ScrollViewerWindow.prototype._makeBuckets = function () {
  10521. this._buckets = {};
  10522. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  10523. this._dispatchInBuckets(this._children);
  10524. this._oldLeft = null;
  10525. this._oldTop = null;
  10526. };
  10527. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  10528. for (var i = 0; i < children.length; ++i) {
  10529. var child = children[i];
  10530. var bStartX = Math.max(0, Math.floor((child._customData._origLeft - this._customData.origLeft) / this._bucketWidth)), bEndX = Math.floor((child._customData._origLeft - this._customData.origLeft + child._currentMeasure.width - 1) / this._bucketWidth), bStartY = Math.max(0, Math.floor((child._customData._origTop - this._customData.origTop) / this._bucketHeight)), bEndY = Math.floor((child._customData._origTop - this._customData.origTop + child._currentMeasure.height - 1) / this._bucketHeight);
  10531. while (bStartY <= bEndY) {
  10532. for (var x = bStartX; x <= bEndX; ++x) {
  10533. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  10534. if (!lstc) {
  10535. lstc = [];
  10536. this._buckets[bucket] = lstc;
  10537. }
  10538. lstc.push(child);
  10539. }
  10540. bStartY++;
  10541. }
  10542. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  10543. this._dispatchInBuckets(child._children);
  10544. }
  10545. }
  10546. };
  10547. // reset left and top measures for the window and all its children
  10548. _ScrollViewerWindow.prototype._updateMeasures = function () {
  10549. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  10550. this._measureForChildren.left -= left;
  10551. this._measureForChildren.top -= top;
  10552. this._currentMeasure.left -= left;
  10553. this._currentMeasure.top -= top;
  10554. this._customData.origLeftForChildren = this._measureForChildren.left;
  10555. this._customData.origTopForChildren = this._measureForChildren.top;
  10556. this._customData.origLeft = this._currentMeasure.left;
  10557. this._customData.origTop = this._currentMeasure.top;
  10558. this._updateChildrenMeasures(this._children, left, top);
  10559. };
  10560. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  10561. for (var i = 0; i < children.length; ++i) {
  10562. var child = children[i];
  10563. child._currentMeasure.left -= left;
  10564. child._currentMeasure.top -= top;
  10565. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  10566. child._customData._origTop = child._currentMeasure.top;
  10567. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  10568. this._updateChildrenMeasures(child._children, left, top);
  10569. }
  10570. }
  10571. };
  10572. _ScrollViewerWindow.prototype._restoreMeasures = function () {
  10573. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  10574. this._measureForChildren.left = this._customData.origLeftForChildren + left;
  10575. this._measureForChildren.top = this._customData.origTopForChildren + top;
  10576. this._currentMeasure.left = this._customData.origLeft + left;
  10577. this._currentMeasure.top = this._customData.origTop + top;
  10578. };
  10579. _ScrollViewerWindow.prototype._getTypeName = function () {
  10580. return "ScrollViewerWindow";
  10581. };
  10582. /** @hidden */
  10583. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  10584. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10585. this._parentMeasure = parentMeasure;
  10586. this._measureForChildren.left = this._currentMeasure.left;
  10587. this._measureForChildren.top = this._currentMeasure.top;
  10588. this._measureForChildren.width = parentMeasure.width;
  10589. this._measureForChildren.height = parentMeasure.height;
  10590. };
  10591. /** @hidden */
  10592. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  10593. if (this._freezeControls) {
  10594. this.invalidateRect(); // will trigger a redraw of the window
  10595. return false;
  10596. }
  10597. return _super.prototype._layout.call(this, parentMeasure, context);
  10598. };
  10599. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  10600. for (var i = 0; i < children.length; ++i) {
  10601. var child = children[i];
  10602. child._currentMeasure.left = child._customData._origLeft + left;
  10603. child._currentMeasure.top = child._customData._origTop + top;
  10604. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  10605. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  10606. this._scrollChildren(child._children, left, top);
  10607. }
  10608. }
  10609. };
  10610. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  10611. var bStartX = Math.max(0, Math.floor(-left / this._bucketWidth)), bEndX = Math.floor((-left + this._parentMeasure.width - 1) / this._bucketWidth), bStartY = Math.max(0, Math.floor(-top / this._bucketHeight)), bEndY = Math.floor((-top + this._parentMeasure.height - 1) / this._bucketHeight);
  10612. while (bStartY <= bEndY) {
  10613. for (var x = bStartX; x <= bEndX; ++x) {
  10614. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  10615. if (lstc) {
  10616. for (var i = 0; i < lstc.length; ++i) {
  10617. var child = lstc[i];
  10618. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  10619. child._currentMeasure.top = child._customData._origTop + scrollTop;
  10620. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  10621. }
  10622. }
  10623. }
  10624. bStartY++;
  10625. }
  10626. };
  10627. /** @hidden */
  10628. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  10629. if (!this._freezeControls) {
  10630. _super.prototype._draw.call(this, context, invalidatedRectangle);
  10631. return;
  10632. }
  10633. this._localDraw(context);
  10634. if (this.clipChildren) {
  10635. this._clipForChildren(context);
  10636. }
  10637. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  10638. if (this._useBuckets()) {
  10639. if (this._oldLeft !== null && this._oldTop !== null) {
  10640. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  10641. this._scrollChildrenWithBuckets(left, top, left, top);
  10642. }
  10643. else {
  10644. this._scrollChildren(this._children, left, top);
  10645. }
  10646. }
  10647. else {
  10648. this._scrollChildren(this._children, left, top);
  10649. }
  10650. this._oldLeft = left;
  10651. this._oldTop = top;
  10652. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10653. var child = _a[_i];
  10654. if (!child._intersectsRect(this._parentMeasure)) {
  10655. continue;
  10656. }
  10657. child._render(context, this._parentMeasure);
  10658. }
  10659. };
  10660. _ScrollViewerWindow.prototype._postMeasure = function () {
  10661. if (this._freezeControls) {
  10662. _super.prototype._postMeasure.call(this);
  10663. return;
  10664. }
  10665. var maxWidth = this.parentClientWidth;
  10666. var maxHeight = this.parentClientHeight;
  10667. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10668. var child = _a[_i];
  10669. if (!child.isVisible || child.notRenderable) {
  10670. continue;
  10671. }
  10672. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  10673. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  10674. }
  10675. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  10676. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  10677. }
  10678. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width + child.paddingRightInPixels);
  10679. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height + child.paddingBottomInPixels);
  10680. }
  10681. if (this._currentMeasure.width !== maxWidth) {
  10682. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  10683. this._currentMeasure.width = maxWidth;
  10684. this._rebuildLayout = true;
  10685. this._isDirty = true;
  10686. }
  10687. if (this._currentMeasure.height !== maxHeight) {
  10688. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  10689. this._currentMeasure.height = maxHeight;
  10690. this._rebuildLayout = true;
  10691. this._isDirty = true;
  10692. }
  10693. _super.prototype._postMeasure.call(this);
  10694. };
  10695. return _ScrollViewerWindow;
  10696. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10697. /***/ }),
  10698. /***/ "./2D/controls/selector.ts":
  10699. /*!*********************************!*\
  10700. !*** ./2D/controls/selector.ts ***!
  10701. \*********************************/
  10702. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  10703. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10704. "use strict";
  10705. __webpack_require__.r(__webpack_exports__);
  10706. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  10707. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  10708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  10709. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  10710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  10711. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10712. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  10713. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10714. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10715. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10716. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  10717. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  10718. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  10719. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10720. /** Class used to create a RadioGroup
  10721. * which contains groups of radio buttons
  10722. */
  10723. var SelectorGroup = /** @class */ (function () {
  10724. /**
  10725. * Creates a new SelectorGroup
  10726. * @param name of group, used as a group heading
  10727. */
  10728. function SelectorGroup(
  10729. /** name of SelectorGroup */
  10730. name) {
  10731. this.name = name;
  10732. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10733. this._selectors = new Array();
  10734. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10735. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10736. this._groupHeader = this._addGroupHeader(name);
  10737. }
  10738. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  10739. /** Gets the groupPanel of the SelectorGroup */
  10740. get: function () {
  10741. return this._groupPanel;
  10742. },
  10743. enumerable: false,
  10744. configurable: true
  10745. });
  10746. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  10747. /** Gets the selectors array */
  10748. get: function () {
  10749. return this._selectors;
  10750. },
  10751. enumerable: false,
  10752. configurable: true
  10753. });
  10754. Object.defineProperty(SelectorGroup.prototype, "header", {
  10755. /** Gets and sets the group header */
  10756. get: function () {
  10757. return this._groupHeader.text;
  10758. },
  10759. set: function (label) {
  10760. if (this._groupHeader.text === "label") {
  10761. return;
  10762. }
  10763. this._groupHeader.text = label;
  10764. },
  10765. enumerable: false,
  10766. configurable: true
  10767. });
  10768. /** @hidden */
  10769. SelectorGroup.prototype._addGroupHeader = function (text) {
  10770. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  10771. groupHeading.width = 0.9;
  10772. groupHeading.height = "30px";
  10773. groupHeading.textWrapping = true;
  10774. groupHeading.color = "black";
  10775. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10776. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10777. groupHeading.left = "2px";
  10778. this._groupPanel.addControl(groupHeading);
  10779. return groupHeading;
  10780. };
  10781. /** @hidden*/
  10782. SelectorGroup.prototype._getSelector = function (selectorNb) {
  10783. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10784. return;
  10785. }
  10786. return this._selectors[selectorNb];
  10787. };
  10788. /** Removes the selector at the given position
  10789. * @param selectorNb the position of the selector within the group
  10790. */
  10791. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  10792. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10793. return;
  10794. }
  10795. this._groupPanel.removeControl(this._selectors[selectorNb]);
  10796. this._selectors.splice(selectorNb, 1);
  10797. };
  10798. return SelectorGroup;
  10799. }());
  10800. /** Class used to create a CheckboxGroup
  10801. * which contains groups of checkbox buttons
  10802. */
  10803. var CheckboxGroup = /** @class */ (function (_super) {
  10804. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  10805. function CheckboxGroup() {
  10806. return _super !== null && _super.apply(this, arguments) || this;
  10807. }
  10808. /** Adds a checkbox as a control
  10809. * @param text is the label for the selector
  10810. * @param func is the function called when the Selector is checked
  10811. * @param checked is true when Selector is checked
  10812. */
  10813. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  10814. if (func === void 0) { func = function (s) { }; }
  10815. if (checked === void 0) { checked = false; }
  10816. var checked = checked || false;
  10817. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  10818. button.width = "20px";
  10819. button.height = "20px";
  10820. button.color = "#364249";
  10821. button.background = "#CCCCCC";
  10822. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10823. button.onIsCheckedChangedObservable.add(function (state) {
  10824. func(state);
  10825. });
  10826. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  10827. _selector.height = "30px";
  10828. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10829. _selector.left = "4px";
  10830. this.groupPanel.addControl(_selector);
  10831. this.selectors.push(_selector);
  10832. button.isChecked = checked;
  10833. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10834. button.color = this.groupPanel.parent.parent.buttonColor;
  10835. button.background = this.groupPanel.parent.parent.buttonBackground;
  10836. }
  10837. };
  10838. /** @hidden */
  10839. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10840. this.selectors[selectorNb].children[1].text = label;
  10841. };
  10842. /** @hidden */
  10843. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10844. this.selectors[selectorNb].children[1].color = color;
  10845. };
  10846. /** @hidden */
  10847. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10848. this.selectors[selectorNb].children[0].color = color;
  10849. };
  10850. /** @hidden */
  10851. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10852. this.selectors[selectorNb].children[0].background = color;
  10853. };
  10854. return CheckboxGroup;
  10855. }(SelectorGroup));
  10856. /** Class used to create a RadioGroup
  10857. * which contains groups of radio buttons
  10858. */
  10859. var RadioGroup = /** @class */ (function (_super) {
  10860. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  10861. function RadioGroup() {
  10862. var _this = _super !== null && _super.apply(this, arguments) || this;
  10863. _this._selectNb = 0;
  10864. return _this;
  10865. }
  10866. /** Adds a radio button as a control
  10867. * @param label is the label for the selector
  10868. * @param func is the function called when the Selector is checked
  10869. * @param checked is true when Selector is checked
  10870. */
  10871. RadioGroup.prototype.addRadio = function (label, func, checked) {
  10872. if (func === void 0) { func = function (n) { }; }
  10873. if (checked === void 0) { checked = false; }
  10874. var nb = this._selectNb++;
  10875. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  10876. button.name = label;
  10877. button.width = "20px";
  10878. button.height = "20px";
  10879. button.color = "#364249";
  10880. button.background = "#CCCCCC";
  10881. button.group = this.name;
  10882. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10883. button.onIsCheckedChangedObservable.add(function (state) {
  10884. if (state) {
  10885. func(nb);
  10886. }
  10887. });
  10888. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  10889. _selector.height = "30px";
  10890. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10891. _selector.left = "4px";
  10892. this.groupPanel.addControl(_selector);
  10893. this.selectors.push(_selector);
  10894. button.isChecked = checked;
  10895. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10896. button.color = this.groupPanel.parent.parent.buttonColor;
  10897. button.background = this.groupPanel.parent.parent.buttonBackground;
  10898. }
  10899. };
  10900. /** @hidden */
  10901. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10902. this.selectors[selectorNb].children[1].text = label;
  10903. };
  10904. /** @hidden */
  10905. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10906. this.selectors[selectorNb].children[1].color = color;
  10907. };
  10908. /** @hidden */
  10909. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10910. this.selectors[selectorNb].children[0].color = color;
  10911. };
  10912. /** @hidden */
  10913. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10914. this.selectors[selectorNb].children[0].background = color;
  10915. };
  10916. return RadioGroup;
  10917. }(SelectorGroup));
  10918. /** Class used to create a SliderGroup
  10919. * which contains groups of slider buttons
  10920. */
  10921. var SliderGroup = /** @class */ (function (_super) {
  10922. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  10923. function SliderGroup() {
  10924. return _super !== null && _super.apply(this, arguments) || this;
  10925. }
  10926. /**
  10927. * Adds a slider to the SelectorGroup
  10928. * @param label is the label for the SliderBar
  10929. * @param func is the function called when the Slider moves
  10930. * @param unit is a string describing the units used, eg degrees or metres
  10931. * @param min is the minimum value for the Slider
  10932. * @param max is the maximum value for the Slider
  10933. * @param value is the start value for the Slider between min and max
  10934. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  10935. */
  10936. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  10937. if (func === void 0) { func = function (v) { }; }
  10938. if (unit === void 0) { unit = "Units"; }
  10939. if (min === void 0) { min = 0; }
  10940. if (max === void 0) { max = 0; }
  10941. if (value === void 0) { value = 0; }
  10942. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  10943. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  10944. button.name = unit;
  10945. button.value = value;
  10946. button.minimum = min;
  10947. button.maximum = max;
  10948. button.width = 0.9;
  10949. button.height = "20px";
  10950. button.color = "#364249";
  10951. button.background = "#CCCCCC";
  10952. button.borderColor = "black";
  10953. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10954. button.left = "4px";
  10955. button.paddingBottom = "4px";
  10956. button.onValueChangedObservable.add(function (value) {
  10957. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  10958. func(value);
  10959. });
  10960. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  10961. _selector.height = "60px";
  10962. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10963. _selector.left = "4px";
  10964. _selector.children[0].name = label;
  10965. this.groupPanel.addControl(_selector);
  10966. this.selectors.push(_selector);
  10967. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10968. button.color = this.groupPanel.parent.parent.buttonColor;
  10969. button.background = this.groupPanel.parent.parent.buttonBackground;
  10970. }
  10971. };
  10972. /** @hidden */
  10973. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10974. this.selectors[selectorNb].children[0].name = label;
  10975. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  10976. };
  10977. /** @hidden */
  10978. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10979. this.selectors[selectorNb].children[0].color = color;
  10980. };
  10981. /** @hidden */
  10982. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10983. this.selectors[selectorNb].children[1].color = color;
  10984. };
  10985. /** @hidden */
  10986. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10987. this.selectors[selectorNb].children[1].background = color;
  10988. };
  10989. return SliderGroup;
  10990. }(SelectorGroup));
  10991. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  10992. * @see https://doc.babylonjs.com/how_to/selector
  10993. */
  10994. var SelectionPanel = /** @class */ (function (_super) {
  10995. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  10996. /**
  10997. * Creates a new SelectionPanel
  10998. * @param name of SelectionPanel
  10999. * @param groups is an array of SelectionGroups
  11000. */
  11001. function SelectionPanel(
  11002. /** name of SelectionPanel */
  11003. name,
  11004. /** an array of SelectionGroups */
  11005. groups) {
  11006. if (groups === void 0) { groups = []; }
  11007. var _this = _super.call(this, name) || this;
  11008. _this.name = name;
  11009. _this.groups = groups;
  11010. _this._buttonColor = "#364249";
  11011. _this._buttonBackground = "#CCCCCC";
  11012. _this._headerColor = "black";
  11013. _this._barColor = "white";
  11014. _this._barHeight = "2px";
  11015. _this._spacerHeight = "20px";
  11016. _this._bars = new Array();
  11017. _this._groups = groups;
  11018. _this.thickness = 2;
  11019. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11020. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11021. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11022. _this._panel.top = 5;
  11023. _this._panel.left = 5;
  11024. _this._panel.width = 0.95;
  11025. if (groups.length > 0) {
  11026. for (var i = 0; i < groups.length - 1; i++) {
  11027. _this._panel.addControl(groups[i].groupPanel);
  11028. _this._addSpacer();
  11029. }
  11030. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  11031. }
  11032. _this.addControl(_this._panel);
  11033. return _this;
  11034. }
  11035. SelectionPanel.prototype._getTypeName = function () {
  11036. return "SelectionPanel";
  11037. };
  11038. Object.defineProperty(SelectionPanel.prototype, "panel", {
  11039. /** Gets the (stack) panel of the SelectionPanel */
  11040. get: function () {
  11041. return this._panel;
  11042. },
  11043. enumerable: false,
  11044. configurable: true
  11045. });
  11046. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  11047. /** Gets or sets the headerColor */
  11048. get: function () {
  11049. return this._headerColor;
  11050. },
  11051. set: function (color) {
  11052. if (this._headerColor === color) {
  11053. return;
  11054. }
  11055. this._headerColor = color;
  11056. this._setHeaderColor();
  11057. },
  11058. enumerable: false,
  11059. configurable: true
  11060. });
  11061. SelectionPanel.prototype._setHeaderColor = function () {
  11062. for (var i = 0; i < this._groups.length; i++) {
  11063. this._groups[i].groupPanel.children[0].color = this._headerColor;
  11064. }
  11065. };
  11066. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  11067. /** Gets or sets the button color */
  11068. get: function () {
  11069. return this._buttonColor;
  11070. },
  11071. set: function (color) {
  11072. if (this._buttonColor === color) {
  11073. return;
  11074. }
  11075. this._buttonColor = color;
  11076. this._setbuttonColor();
  11077. },
  11078. enumerable: false,
  11079. configurable: true
  11080. });
  11081. SelectionPanel.prototype._setbuttonColor = function () {
  11082. for (var i = 0; i < this._groups.length; i++) {
  11083. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  11084. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  11085. }
  11086. }
  11087. };
  11088. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  11089. /** Gets or sets the label color */
  11090. get: function () {
  11091. return this._labelColor;
  11092. },
  11093. set: function (color) {
  11094. if (this._labelColor === color) {
  11095. return;
  11096. }
  11097. this._labelColor = color;
  11098. this._setLabelColor();
  11099. },
  11100. enumerable: false,
  11101. configurable: true
  11102. });
  11103. SelectionPanel.prototype._setLabelColor = function () {
  11104. for (var i = 0; i < this._groups.length; i++) {
  11105. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  11106. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  11107. }
  11108. }
  11109. };
  11110. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  11111. /** Gets or sets the button background */
  11112. get: function () {
  11113. return this._buttonBackground;
  11114. },
  11115. set: function (color) {
  11116. if (this._buttonBackground === color) {
  11117. return;
  11118. }
  11119. this._buttonBackground = color;
  11120. this._setButtonBackground();
  11121. },
  11122. enumerable: false,
  11123. configurable: true
  11124. });
  11125. SelectionPanel.prototype._setButtonBackground = function () {
  11126. for (var i = 0; i < this._groups.length; i++) {
  11127. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  11128. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  11129. }
  11130. }
  11131. };
  11132. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  11133. /** Gets or sets the color of separator bar */
  11134. get: function () {
  11135. return this._barColor;
  11136. },
  11137. set: function (color) {
  11138. if (this._barColor === color) {
  11139. return;
  11140. }
  11141. this._barColor = color;
  11142. this._setBarColor();
  11143. },
  11144. enumerable: false,
  11145. configurable: true
  11146. });
  11147. SelectionPanel.prototype._setBarColor = function () {
  11148. for (var i = 0; i < this._bars.length; i++) {
  11149. this._bars[i].children[0].background = this._barColor;
  11150. }
  11151. };
  11152. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  11153. /** Gets or sets the height of separator bar */
  11154. get: function () {
  11155. return this._barHeight;
  11156. },
  11157. set: function (value) {
  11158. if (this._barHeight === value) {
  11159. return;
  11160. }
  11161. this._barHeight = value;
  11162. this._setBarHeight();
  11163. },
  11164. enumerable: false,
  11165. configurable: true
  11166. });
  11167. SelectionPanel.prototype._setBarHeight = function () {
  11168. for (var i = 0; i < this._bars.length; i++) {
  11169. this._bars[i].children[0].height = this._barHeight;
  11170. }
  11171. };
  11172. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  11173. /** Gets or sets the height of spacers*/
  11174. get: function () {
  11175. return this._spacerHeight;
  11176. },
  11177. set: function (value) {
  11178. if (this._spacerHeight === value) {
  11179. return;
  11180. }
  11181. this._spacerHeight = value;
  11182. this._setSpacerHeight();
  11183. },
  11184. enumerable: false,
  11185. configurable: true
  11186. });
  11187. SelectionPanel.prototype._setSpacerHeight = function () {
  11188. for (var i = 0; i < this._bars.length; i++) {
  11189. this._bars[i].height = this._spacerHeight;
  11190. }
  11191. };
  11192. /** Adds a bar between groups */
  11193. SelectionPanel.prototype._addSpacer = function () {
  11194. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  11195. separator.width = 1;
  11196. separator.height = this._spacerHeight;
  11197. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11198. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  11199. bar.width = 1;
  11200. bar.height = this._barHeight;
  11201. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11202. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  11203. bar.background = this._barColor;
  11204. bar.color = "transparent";
  11205. separator.addControl(bar);
  11206. this._panel.addControl(separator);
  11207. this._bars.push(separator);
  11208. };
  11209. /** Add a group to the selection panel
  11210. * @param group is the selector group to add
  11211. */
  11212. SelectionPanel.prototype.addGroup = function (group) {
  11213. if (this._groups.length > 0) {
  11214. this._addSpacer();
  11215. }
  11216. this._panel.addControl(group.groupPanel);
  11217. this._groups.push(group);
  11218. group.groupPanel.children[0].color = this._headerColor;
  11219. for (var j = 0; j < group.selectors.length; j++) {
  11220. group._setSelectorButtonColor(j, this._buttonColor);
  11221. group._setSelectorButtonBackground(j, this._buttonBackground);
  11222. }
  11223. };
  11224. /** Remove the group from the given position
  11225. * @param groupNb is the position of the group in the list
  11226. */
  11227. SelectionPanel.prototype.removeGroup = function (groupNb) {
  11228. if (groupNb < 0 || groupNb >= this._groups.length) {
  11229. return;
  11230. }
  11231. var group = this._groups[groupNb];
  11232. this._panel.removeControl(group.groupPanel);
  11233. this._groups.splice(groupNb, 1);
  11234. if (groupNb < this._bars.length) {
  11235. this._panel.removeControl(this._bars[groupNb]);
  11236. this._bars.splice(groupNb, 1);
  11237. }
  11238. };
  11239. /** Change a group header label
  11240. * @param label is the new group header label
  11241. * @param groupNb is the number of the group to relabel
  11242. * */
  11243. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  11244. if (groupNb < 0 || groupNb >= this._groups.length) {
  11245. return;
  11246. }
  11247. var group = this._groups[groupNb];
  11248. group.groupPanel.children[0].text = label;
  11249. };
  11250. /** Change selector label to the one given
  11251. * @param label is the new selector label
  11252. * @param groupNb is the number of the groupcontaining the selector
  11253. * @param selectorNb is the number of the selector within a group to relabel
  11254. * */
  11255. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  11256. if (groupNb < 0 || groupNb >= this._groups.length) {
  11257. return;
  11258. }
  11259. var group = this._groups[groupNb];
  11260. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  11261. return;
  11262. }
  11263. group._setSelectorLabel(selectorNb, label);
  11264. };
  11265. /** For a given group position remove the selector at the given position
  11266. * @param groupNb is the number of the group to remove the selector from
  11267. * @param selectorNb is the number of the selector within the group
  11268. */
  11269. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  11270. if (groupNb < 0 || groupNb >= this._groups.length) {
  11271. return;
  11272. }
  11273. var group = this._groups[groupNb];
  11274. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  11275. return;
  11276. }
  11277. group.removeSelector(selectorNb);
  11278. };
  11279. /** For a given group position of correct type add a checkbox button
  11280. * @param groupNb is the number of the group to remove the selector from
  11281. * @param label is the label for the selector
  11282. * @param func is the function called when the Selector is checked
  11283. * @param checked is true when Selector is checked
  11284. */
  11285. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  11286. if (func === void 0) { func = function () { }; }
  11287. if (checked === void 0) { checked = false; }
  11288. if (groupNb < 0 || groupNb >= this._groups.length) {
  11289. return;
  11290. }
  11291. var group = this._groups[groupNb];
  11292. group.addCheckbox(label, func, checked);
  11293. };
  11294. /** For a given group position of correct type add a radio button
  11295. * @param groupNb is the number of the group to remove the selector from
  11296. * @param label is the label for the selector
  11297. * @param func is the function called when the Selector is checked
  11298. * @param checked is true when Selector is checked
  11299. */
  11300. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  11301. if (func === void 0) { func = function () { }; }
  11302. if (checked === void 0) { checked = false; }
  11303. if (groupNb < 0 || groupNb >= this._groups.length) {
  11304. return;
  11305. }
  11306. var group = this._groups[groupNb];
  11307. group.addRadio(label, func, checked);
  11308. };
  11309. /**
  11310. * For a given slider group add a slider
  11311. * @param groupNb is the number of the group to add the slider to
  11312. * @param label is the label for the Slider
  11313. * @param func is the function called when the Slider moves
  11314. * @param unit is a string describing the units used, eg degrees or metres
  11315. * @param min is the minimum value for the Slider
  11316. * @param max is the maximum value for the Slider
  11317. * @param value is the start value for the Slider between min and max
  11318. * @param onVal is the function used to format the value displayed, eg radians to degrees
  11319. */
  11320. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  11321. if (func === void 0) { func = function () { }; }
  11322. if (unit === void 0) { unit = "Units"; }
  11323. if (min === void 0) { min = 0; }
  11324. if (max === void 0) { max = 0; }
  11325. if (value === void 0) { value = 0; }
  11326. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  11327. if (groupNb < 0 || groupNb >= this._groups.length) {
  11328. return;
  11329. }
  11330. var group = this._groups[groupNb];
  11331. group.addSlider(label, func, unit, min, max, value, onVal);
  11332. };
  11333. return SelectionPanel;
  11334. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  11335. /***/ }),
  11336. /***/ "./2D/controls/sliders/baseSlider.ts":
  11337. /*!*******************************************!*\
  11338. !*** ./2D/controls/sliders/baseSlider.ts ***!
  11339. \*******************************************/
  11340. /*! exports provided: BaseSlider */
  11341. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11342. "use strict";
  11343. __webpack_require__.r(__webpack_exports__);
  11344. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  11345. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11346. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  11347. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11348. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  11349. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  11350. /**
  11351. * Class used to create slider controls
  11352. */
  11353. var BaseSlider = /** @class */ (function (_super) {
  11354. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  11355. /**
  11356. * Creates a new BaseSlider
  11357. * @param name defines the control name
  11358. */
  11359. function BaseSlider(name) {
  11360. var _this = _super.call(this, name) || this;
  11361. _this.name = name;
  11362. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  11363. _this._minimum = 0;
  11364. _this._maximum = 100;
  11365. _this._value = 50;
  11366. _this._isVertical = false;
  11367. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  11368. _this._isThumbClamped = false;
  11369. _this._displayThumb = true;
  11370. _this._step = 0;
  11371. _this._lastPointerDownID = -1;
  11372. // Shared rendering info
  11373. _this._effectiveBarOffset = 0;
  11374. /** Observable raised when the sldier value changes */
  11375. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11376. // Events
  11377. _this._pointerIsDown = false;
  11378. _this.isPointerBlocker = true;
  11379. return _this;
  11380. }
  11381. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  11382. /** Gets or sets a boolean indicating if the thumb must be rendered */
  11383. get: function () {
  11384. return this._displayThumb;
  11385. },
  11386. set: function (value) {
  11387. if (this._displayThumb === value) {
  11388. return;
  11389. }
  11390. this._displayThumb = value;
  11391. this._markAsDirty();
  11392. },
  11393. enumerable: false,
  11394. configurable: true
  11395. });
  11396. Object.defineProperty(BaseSlider.prototype, "step", {
  11397. /** Gets or sets a step to apply to values (0 by default) */
  11398. get: function () {
  11399. return this._step;
  11400. },
  11401. set: function (value) {
  11402. if (this._step === value) {
  11403. return;
  11404. }
  11405. this._step = value;
  11406. this._markAsDirty();
  11407. },
  11408. enumerable: false,
  11409. configurable: true
  11410. });
  11411. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  11412. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  11413. get: function () {
  11414. return this._barOffset.toString(this._host);
  11415. },
  11416. set: function (value) {
  11417. if (this._barOffset.toString(this._host) === value) {
  11418. return;
  11419. }
  11420. if (this._barOffset.fromString(value)) {
  11421. this._markAsDirty();
  11422. }
  11423. },
  11424. enumerable: false,
  11425. configurable: true
  11426. });
  11427. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  11428. /** Gets main bar offset in pixels*/
  11429. get: function () {
  11430. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  11431. },
  11432. enumerable: false,
  11433. configurable: true
  11434. });
  11435. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  11436. /** Gets or sets thumb width */
  11437. get: function () {
  11438. return this._thumbWidth.toString(this._host);
  11439. },
  11440. set: function (value) {
  11441. if (this._thumbWidth.toString(this._host) === value) {
  11442. return;
  11443. }
  11444. if (this._thumbWidth.fromString(value)) {
  11445. this._markAsDirty();
  11446. }
  11447. },
  11448. enumerable: false,
  11449. configurable: true
  11450. });
  11451. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  11452. /** Gets thumb width in pixels */
  11453. get: function () {
  11454. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  11455. },
  11456. enumerable: false,
  11457. configurable: true
  11458. });
  11459. Object.defineProperty(BaseSlider.prototype, "minimum", {
  11460. /** Gets or sets minimum value */
  11461. get: function () {
  11462. return this._minimum;
  11463. },
  11464. set: function (value) {
  11465. if (this._minimum === value) {
  11466. return;
  11467. }
  11468. this._minimum = value;
  11469. this._markAsDirty();
  11470. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  11471. },
  11472. enumerable: false,
  11473. configurable: true
  11474. });
  11475. Object.defineProperty(BaseSlider.prototype, "maximum", {
  11476. /** Gets or sets maximum value */
  11477. get: function () {
  11478. return this._maximum;
  11479. },
  11480. set: function (value) {
  11481. if (this._maximum === value) {
  11482. return;
  11483. }
  11484. this._maximum = value;
  11485. this._markAsDirty();
  11486. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  11487. },
  11488. enumerable: false,
  11489. configurable: true
  11490. });
  11491. Object.defineProperty(BaseSlider.prototype, "value", {
  11492. /** Gets or sets current value */
  11493. get: function () {
  11494. return this._value;
  11495. },
  11496. set: function (value) {
  11497. value = Math.max(Math.min(value, this._maximum), this._minimum);
  11498. if (this._value === value) {
  11499. return;
  11500. }
  11501. this._value = value;
  11502. this._markAsDirty();
  11503. this.onValueChangedObservable.notifyObservers(this._value);
  11504. },
  11505. enumerable: false,
  11506. configurable: true
  11507. });
  11508. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  11509. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  11510. get: function () {
  11511. return this._isVertical;
  11512. },
  11513. set: function (value) {
  11514. if (this._isVertical === value) {
  11515. return;
  11516. }
  11517. this._isVertical = value;
  11518. this._markAsDirty();
  11519. },
  11520. enumerable: false,
  11521. configurable: true
  11522. });
  11523. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  11524. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  11525. get: function () {
  11526. return this._isThumbClamped;
  11527. },
  11528. set: function (value) {
  11529. if (this._isThumbClamped === value) {
  11530. return;
  11531. }
  11532. this._isThumbClamped = value;
  11533. this._markAsDirty();
  11534. },
  11535. enumerable: false,
  11536. configurable: true
  11537. });
  11538. BaseSlider.prototype._getTypeName = function () {
  11539. return "BaseSlider";
  11540. };
  11541. BaseSlider.prototype._getThumbPosition = function () {
  11542. if (this.isVertical) {
  11543. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  11544. }
  11545. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  11546. };
  11547. BaseSlider.prototype._getThumbThickness = function (type) {
  11548. var thumbThickness = 0;
  11549. switch (type) {
  11550. case "circle":
  11551. if (this._thumbWidth.isPixel) {
  11552. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  11553. }
  11554. else {
  11555. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11556. }
  11557. break;
  11558. case "rectangle":
  11559. if (this._thumbWidth.isPixel) {
  11560. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  11561. }
  11562. else {
  11563. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11564. }
  11565. }
  11566. return thumbThickness;
  11567. };
  11568. BaseSlider.prototype._prepareRenderingData = function (type) {
  11569. // Main bar
  11570. this._effectiveBarOffset = 0;
  11571. this._renderLeft = this._currentMeasure.left;
  11572. this._renderTop = this._currentMeasure.top;
  11573. this._renderWidth = this._currentMeasure.width;
  11574. this._renderHeight = this._currentMeasure.height;
  11575. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  11576. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  11577. this._effectiveThumbThickness = this._getThumbThickness(type);
  11578. if (this.displayThumb) {
  11579. this._backgroundBoxLength -= this._effectiveThumbThickness;
  11580. }
  11581. //throw error when height is less than width for vertical slider
  11582. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  11583. console.error("Height should be greater than width");
  11584. return;
  11585. }
  11586. if (this._barOffset.isPixel) {
  11587. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  11588. }
  11589. else {
  11590. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  11591. }
  11592. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  11593. if (this.isVertical) {
  11594. this._renderLeft += this._effectiveBarOffset;
  11595. if (!this.isThumbClamped && this.displayThumb) {
  11596. this._renderTop += (this._effectiveThumbThickness / 2);
  11597. }
  11598. this._renderHeight = this._backgroundBoxLength;
  11599. this._renderWidth = this._backgroundBoxThickness;
  11600. }
  11601. else {
  11602. this._renderTop += this._effectiveBarOffset;
  11603. if (!this.isThumbClamped && this.displayThumb) {
  11604. this._renderLeft += (this._effectiveThumbThickness / 2);
  11605. }
  11606. this._renderHeight = this._backgroundBoxThickness;
  11607. this._renderWidth = this._backgroundBoxLength;
  11608. }
  11609. };
  11610. /** @hidden */
  11611. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  11612. if (this.rotation != 0) {
  11613. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11614. x = this._transformedPosition.x;
  11615. y = this._transformedPosition.y;
  11616. }
  11617. var value;
  11618. if (this._isVertical) {
  11619. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  11620. }
  11621. else {
  11622. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  11623. }
  11624. var mult = (1 / this._step) | 0;
  11625. this.value = this._step ? ((value * mult) | 0) / mult : value;
  11626. };
  11627. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  11628. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  11629. return false;
  11630. }
  11631. this._pointerIsDown = true;
  11632. this._updateValueFromPointer(coordinates.x, coordinates.y);
  11633. this._host._capturingControl[pointerId] = this;
  11634. this._lastPointerDownID = pointerId;
  11635. return true;
  11636. };
  11637. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  11638. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  11639. if (pointerId != this._lastPointerDownID) {
  11640. return;
  11641. }
  11642. if (this._pointerIsDown) {
  11643. this._updateValueFromPointer(coordinates.x, coordinates.y);
  11644. }
  11645. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
  11646. };
  11647. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  11648. this._pointerIsDown = false;
  11649. delete this._host._capturingControl[pointerId];
  11650. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  11651. };
  11652. BaseSlider.prototype._onCanvasBlur = function () {
  11653. this._forcePointerUp();
  11654. _super.prototype._onCanvasBlur.call(this);
  11655. };
  11656. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11657. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11658. ], BaseSlider.prototype, "displayThumb", null);
  11659. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11660. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11661. ], BaseSlider.prototype, "step", null);
  11662. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11663. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11664. ], BaseSlider.prototype, "barOffset", null);
  11665. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11666. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11667. ], BaseSlider.prototype, "thumbWidth", null);
  11668. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11669. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11670. ], BaseSlider.prototype, "minimum", null);
  11671. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11672. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11673. ], BaseSlider.prototype, "maximum", null);
  11674. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11675. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11676. ], BaseSlider.prototype, "value", null);
  11677. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11678. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11679. ], BaseSlider.prototype, "isVertical", null);
  11680. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11681. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11682. ], BaseSlider.prototype, "isThumbClamped", null);
  11683. return BaseSlider;
  11684. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  11685. /***/ }),
  11686. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  11687. /*!*************************************************!*\
  11688. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  11689. \*************************************************/
  11690. /*! exports provided: ImageBasedSlider */
  11691. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11692. "use strict";
  11693. __webpack_require__.r(__webpack_exports__);
  11694. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  11695. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11696. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11697. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11698. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  11699. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  11700. /**
  11701. * Class used to create slider controls based on images
  11702. */
  11703. var ImageBasedSlider = /** @class */ (function (_super) {
  11704. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  11705. /**
  11706. * Creates a new ImageBasedSlider
  11707. * @param name defines the control name
  11708. */
  11709. function ImageBasedSlider(name) {
  11710. var _this = _super.call(this, name) || this;
  11711. _this.name = name;
  11712. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11713. return _this;
  11714. }
  11715. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  11716. get: function () {
  11717. return this._displayThumb && this.thumbImage != null;
  11718. },
  11719. set: function (value) {
  11720. if (this._displayThumb === value) {
  11721. return;
  11722. }
  11723. this._displayThumb = value;
  11724. this._markAsDirty();
  11725. },
  11726. enumerable: false,
  11727. configurable: true
  11728. });
  11729. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  11730. /**
  11731. * Gets or sets the image used to render the background
  11732. */
  11733. get: function () {
  11734. return this._backgroundImage;
  11735. },
  11736. set: function (value) {
  11737. var _this = this;
  11738. if (this._backgroundImage === value) {
  11739. return;
  11740. }
  11741. this._backgroundImage = value;
  11742. if (value && !value.isLoaded) {
  11743. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11744. }
  11745. this._markAsDirty();
  11746. },
  11747. enumerable: false,
  11748. configurable: true
  11749. });
  11750. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  11751. /**
  11752. * Gets or sets the image used to render the value bar
  11753. */
  11754. get: function () {
  11755. return this._valueBarImage;
  11756. },
  11757. set: function (value) {
  11758. var _this = this;
  11759. if (this._valueBarImage === value) {
  11760. return;
  11761. }
  11762. this._valueBarImage = value;
  11763. if (value && !value.isLoaded) {
  11764. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11765. }
  11766. this._markAsDirty();
  11767. },
  11768. enumerable: false,
  11769. configurable: true
  11770. });
  11771. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  11772. /**
  11773. * Gets or sets the image used to render the thumb
  11774. */
  11775. get: function () {
  11776. return this._thumbImage;
  11777. },
  11778. set: function (value) {
  11779. var _this = this;
  11780. if (this._thumbImage === value) {
  11781. return;
  11782. }
  11783. this._thumbImage = value;
  11784. if (value && !value.isLoaded) {
  11785. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11786. }
  11787. this._markAsDirty();
  11788. },
  11789. enumerable: false,
  11790. configurable: true
  11791. });
  11792. ImageBasedSlider.prototype._getTypeName = function () {
  11793. return "ImageBasedSlider";
  11794. };
  11795. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  11796. context.save();
  11797. this._applyStates(context);
  11798. this._prepareRenderingData("rectangle");
  11799. var thumbPosition = this._getThumbPosition();
  11800. var left = this._renderLeft;
  11801. var top = this._renderTop;
  11802. var width = this._renderWidth;
  11803. var height = this._renderHeight;
  11804. // Background
  11805. if (this._backgroundImage) {
  11806. this._tempMeasure.copyFromFloats(left, top, width, height);
  11807. if (this.isThumbClamped && this.displayThumb) {
  11808. if (this.isVertical) {
  11809. this._tempMeasure.height += this._effectiveThumbThickness;
  11810. }
  11811. else {
  11812. this._tempMeasure.width += this._effectiveThumbThickness;
  11813. }
  11814. }
  11815. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11816. this._backgroundImage._draw(context);
  11817. }
  11818. // Bar
  11819. if (this._valueBarImage) {
  11820. if (this.isVertical) {
  11821. if (this.isThumbClamped && this.displayThumb) {
  11822. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11823. }
  11824. else {
  11825. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  11826. }
  11827. }
  11828. else {
  11829. if (this.isThumbClamped && this.displayThumb) {
  11830. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  11831. }
  11832. else {
  11833. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  11834. }
  11835. }
  11836. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  11837. this._valueBarImage._draw(context);
  11838. }
  11839. // Thumb
  11840. if (this.displayThumb) {
  11841. if (this.isVertical) {
  11842. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11843. }
  11844. else {
  11845. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11846. }
  11847. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11848. this._thumbImage._draw(context);
  11849. }
  11850. context.restore();
  11851. };
  11852. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11853. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["serialize"])()
  11854. ], ImageBasedSlider.prototype, "displayThumb", null);
  11855. return ImageBasedSlider;
  11856. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11857. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  11858. /***/ }),
  11859. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  11860. /*!***********************************************!*\
  11861. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  11862. \***********************************************/
  11863. /*! exports provided: ImageScrollBar */
  11864. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11865. "use strict";
  11866. __webpack_require__.r(__webpack_exports__);
  11867. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  11868. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11869. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11870. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11871. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  11872. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__);
  11873. /**
  11874. * Class used to create slider controls
  11875. */
  11876. var ImageScrollBar = /** @class */ (function (_super) {
  11877. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  11878. /**
  11879. * Creates a new ImageScrollBar
  11880. * @param name defines the control name
  11881. */
  11882. function ImageScrollBar(name) {
  11883. var _this = _super.call(this, name) || this;
  11884. _this.name = name;
  11885. _this._thumbLength = 0.5;
  11886. _this._thumbHeight = 1;
  11887. _this._barImageHeight = 1;
  11888. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11889. /** Number of 90° rotation to apply on the images when in vertical mode */
  11890. _this.num90RotationInVerticalMode = 1;
  11891. return _this;
  11892. }
  11893. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  11894. /**
  11895. * Gets or sets the image used to render the background for horizontal bar
  11896. */
  11897. get: function () {
  11898. return this._backgroundBaseImage;
  11899. },
  11900. set: function (value) {
  11901. var _this = this;
  11902. if (this._backgroundBaseImage === value) {
  11903. return;
  11904. }
  11905. this._backgroundBaseImage = value;
  11906. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11907. if (!value.isLoaded) {
  11908. value.onImageLoadedObservable.addOnce(function () {
  11909. var rotatedValue = value._rotate90(_this.num90RotationInVerticalMode, true);
  11910. _this._backgroundImage = rotatedValue;
  11911. if (!rotatedValue.isLoaded) {
  11912. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11913. _this._markAsDirty();
  11914. });
  11915. }
  11916. _this._markAsDirty();
  11917. });
  11918. }
  11919. else {
  11920. this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);
  11921. this._markAsDirty();
  11922. }
  11923. }
  11924. else {
  11925. this._backgroundImage = value;
  11926. if (value && !value.isLoaded) {
  11927. value.onImageLoadedObservable.addOnce(function () {
  11928. _this._markAsDirty();
  11929. });
  11930. }
  11931. this._markAsDirty();
  11932. }
  11933. },
  11934. enumerable: false,
  11935. configurable: true
  11936. });
  11937. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  11938. /**
  11939. * Gets or sets the image used to render the thumb
  11940. */
  11941. get: function () {
  11942. return this._thumbBaseImage;
  11943. },
  11944. set: function (value) {
  11945. var _this = this;
  11946. if (this._thumbBaseImage === value) {
  11947. return;
  11948. }
  11949. this._thumbBaseImage = value;
  11950. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11951. if (!value.isLoaded) {
  11952. value.onImageLoadedObservable.addOnce(function () {
  11953. var rotatedValue = value._rotate90(-_this.num90RotationInVerticalMode, true);
  11954. _this._thumbImage = rotatedValue;
  11955. if (!rotatedValue.isLoaded) {
  11956. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11957. _this._markAsDirty();
  11958. });
  11959. }
  11960. _this._markAsDirty();
  11961. });
  11962. }
  11963. else {
  11964. this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);
  11965. this._markAsDirty();
  11966. }
  11967. }
  11968. else {
  11969. this._thumbImage = value;
  11970. if (value && !value.isLoaded) {
  11971. value.onImageLoadedObservable.addOnce(function () {
  11972. _this._markAsDirty();
  11973. });
  11974. }
  11975. this._markAsDirty();
  11976. }
  11977. },
  11978. enumerable: false,
  11979. configurable: true
  11980. });
  11981. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  11982. /**
  11983. * Gets or sets the length of the thumb
  11984. */
  11985. get: function () {
  11986. return this._thumbLength;
  11987. },
  11988. set: function (value) {
  11989. if (this._thumbLength === value) {
  11990. return;
  11991. }
  11992. this._thumbLength = value;
  11993. this._markAsDirty();
  11994. },
  11995. enumerable: false,
  11996. configurable: true
  11997. });
  11998. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  11999. /**
  12000. * Gets or sets the height of the thumb
  12001. */
  12002. get: function () {
  12003. return this._thumbHeight;
  12004. },
  12005. set: function (value) {
  12006. if (this._thumbLength === value) {
  12007. return;
  12008. }
  12009. this._thumbHeight = value;
  12010. this._markAsDirty();
  12011. },
  12012. enumerable: false,
  12013. configurable: true
  12014. });
  12015. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  12016. /**
  12017. * Gets or sets the height of the bar image
  12018. */
  12019. get: function () {
  12020. return this._barImageHeight;
  12021. },
  12022. set: function (value) {
  12023. if (this._barImageHeight === value) {
  12024. return;
  12025. }
  12026. this._barImageHeight = value;
  12027. this._markAsDirty();
  12028. },
  12029. enumerable: false,
  12030. configurable: true
  12031. });
  12032. ImageScrollBar.prototype._getTypeName = function () {
  12033. return "ImageScrollBar";
  12034. };
  12035. ImageScrollBar.prototype._getThumbThickness = function () {
  12036. var thumbThickness = 0;
  12037. if (this._thumbWidth.isPixel) {
  12038. thumbThickness = this._thumbWidth.getValue(this._host);
  12039. }
  12040. else {
  12041. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  12042. }
  12043. return thumbThickness;
  12044. };
  12045. ImageScrollBar.prototype._draw = function (context) {
  12046. context.save();
  12047. this._applyStates(context);
  12048. this._prepareRenderingData("rectangle");
  12049. var thumbPosition = this._getThumbPosition();
  12050. var left = this._renderLeft;
  12051. var top = this._renderTop;
  12052. var width = this._renderWidth;
  12053. var height = this._renderHeight;
  12054. // Background
  12055. if (this._backgroundImage) {
  12056. this._tempMeasure.copyFromFloats(left, top, width, height);
  12057. if (this.isVertical) {
  12058. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  12059. this._tempMeasure.height += this._effectiveThumbThickness;
  12060. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  12061. }
  12062. else {
  12063. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  12064. this._tempMeasure.width += this._effectiveThumbThickness;
  12065. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  12066. }
  12067. this._backgroundImage._draw(context);
  12068. }
  12069. // Thumb
  12070. if (this.isVertical) {
  12071. 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);
  12072. }
  12073. else {
  12074. 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);
  12075. }
  12076. if (this._thumbImage) {
  12077. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  12078. this._thumbImage._draw(context);
  12079. }
  12080. context.restore();
  12081. };
  12082. /** @hidden */
  12083. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  12084. if (this.rotation != 0) {
  12085. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  12086. x = this._transformedPosition.x;
  12087. y = this._transformedPosition.y;
  12088. }
  12089. if (this._first) {
  12090. this._first = false;
  12091. this._originX = x;
  12092. this._originY = y;
  12093. // Check if move is required
  12094. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  12095. if (this.isVertical) {
  12096. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  12097. }
  12098. else {
  12099. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  12100. }
  12101. }
  12102. }
  12103. // Delta mode
  12104. var delta = 0;
  12105. if (this.isVertical) {
  12106. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  12107. }
  12108. else {
  12109. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  12110. }
  12111. this.value += delta * (this.maximum - this.minimum);
  12112. this._originX = x;
  12113. this._originY = y;
  12114. };
  12115. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  12116. this._first = true;
  12117. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi);
  12118. };
  12119. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12120. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"])()
  12121. ], ImageScrollBar.prototype, "num90RotationInVerticalMode", void 0);
  12122. return ImageScrollBar;
  12123. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  12124. /***/ }),
  12125. /***/ "./2D/controls/sliders/scrollBar.ts":
  12126. /*!******************************************!*\
  12127. !*** ./2D/controls/sliders/scrollBar.ts ***!
  12128. \******************************************/
  12129. /*! exports provided: ScrollBar */
  12130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12131. "use strict";
  12132. __webpack_require__.r(__webpack_exports__);
  12133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  12134. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12135. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  12136. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  12137. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  12138. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__);
  12139. /**
  12140. * Class used to create slider controls
  12141. */
  12142. var ScrollBar = /** @class */ (function (_super) {
  12143. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  12144. /**
  12145. * Creates a new Slider
  12146. * @param name defines the control name
  12147. */
  12148. function ScrollBar(name) {
  12149. var _this = _super.call(this, name) || this;
  12150. _this.name = name;
  12151. _this._background = "black";
  12152. _this._borderColor = "white";
  12153. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  12154. return _this;
  12155. }
  12156. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  12157. /** Gets or sets border color */
  12158. get: function () {
  12159. return this._borderColor;
  12160. },
  12161. set: function (value) {
  12162. if (this._borderColor === value) {
  12163. return;
  12164. }
  12165. this._borderColor = value;
  12166. this._markAsDirty();
  12167. },
  12168. enumerable: false,
  12169. configurable: true
  12170. });
  12171. Object.defineProperty(ScrollBar.prototype, "background", {
  12172. /** Gets or sets background color */
  12173. get: function () {
  12174. return this._background;
  12175. },
  12176. set: function (value) {
  12177. if (this._background === value) {
  12178. return;
  12179. }
  12180. this._background = value;
  12181. this._markAsDirty();
  12182. },
  12183. enumerable: false,
  12184. configurable: true
  12185. });
  12186. ScrollBar.prototype._getTypeName = function () {
  12187. return "Scrollbar";
  12188. };
  12189. ScrollBar.prototype._getThumbThickness = function () {
  12190. var thumbThickness = 0;
  12191. if (this._thumbWidth.isPixel) {
  12192. thumbThickness = this._thumbWidth.getValue(this._host);
  12193. }
  12194. else {
  12195. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  12196. }
  12197. return thumbThickness;
  12198. };
  12199. ScrollBar.prototype._draw = function (context) {
  12200. context.save();
  12201. this._applyStates(context);
  12202. this._prepareRenderingData("rectangle");
  12203. var left = this._renderLeft;
  12204. var thumbPosition = this._getThumbPosition();
  12205. context.fillStyle = this._background;
  12206. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  12207. // Value bar
  12208. context.fillStyle = this.color;
  12209. // Thumb
  12210. if (this.isVertical) {
  12211. this._tempMeasure.left = left - this._effectiveBarOffset;
  12212. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  12213. this._tempMeasure.width = this._currentMeasure.width;
  12214. this._tempMeasure.height = this._effectiveThumbThickness;
  12215. }
  12216. else {
  12217. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  12218. this._tempMeasure.top = this._currentMeasure.top;
  12219. this._tempMeasure.width = this._effectiveThumbThickness;
  12220. this._tempMeasure.height = this._currentMeasure.height;
  12221. }
  12222. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  12223. context.restore();
  12224. };
  12225. /** @hidden */
  12226. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  12227. if (this.rotation != 0) {
  12228. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  12229. x = this._transformedPosition.x;
  12230. y = this._transformedPosition.y;
  12231. }
  12232. if (this._first) {
  12233. this._first = false;
  12234. this._originX = x;
  12235. this._originY = y;
  12236. // Check if move is required
  12237. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  12238. if (this.isVertical) {
  12239. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  12240. }
  12241. else {
  12242. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  12243. }
  12244. }
  12245. }
  12246. // Delta mode
  12247. var delta = 0;
  12248. if (this.isVertical) {
  12249. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  12250. }
  12251. else {
  12252. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  12253. }
  12254. this.value += delta * (this.maximum - this.minimum);
  12255. this._originX = x;
  12256. this._originY = y;
  12257. };
  12258. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  12259. this._first = true;
  12260. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi);
  12261. };
  12262. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12263. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"])()
  12264. ], ScrollBar.prototype, "borderColor", null);
  12265. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12266. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"])()
  12267. ], ScrollBar.prototype, "background", null);
  12268. return ScrollBar;
  12269. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  12270. /***/ }),
  12271. /***/ "./2D/controls/sliders/slider.ts":
  12272. /*!***************************************!*\
  12273. !*** ./2D/controls/sliders/slider.ts ***!
  12274. \***************************************/
  12275. /*! exports provided: Slider */
  12276. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12277. "use strict";
  12278. __webpack_require__.r(__webpack_exports__);
  12279. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  12280. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12281. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  12282. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  12283. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  12284. /**
  12285. * Class used to create slider controls
  12286. */
  12287. var Slider = /** @class */ (function (_super) {
  12288. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  12289. /**
  12290. * Creates a new Slider
  12291. * @param name defines the control name
  12292. */
  12293. function Slider(name) {
  12294. var _this = _super.call(this, name) || this;
  12295. _this.name = name;
  12296. _this._background = "black";
  12297. _this._borderColor = "white";
  12298. _this._thumbColor = "";
  12299. _this._isThumbCircle = false;
  12300. _this._displayValueBar = true;
  12301. return _this;
  12302. }
  12303. Object.defineProperty(Slider.prototype, "displayValueBar", {
  12304. /** Gets or sets a boolean indicating if the value bar must be rendered */
  12305. get: function () {
  12306. return this._displayValueBar;
  12307. },
  12308. set: function (value) {
  12309. if (this._displayValueBar === value) {
  12310. return;
  12311. }
  12312. this._displayValueBar = value;
  12313. this._markAsDirty();
  12314. },
  12315. enumerable: false,
  12316. configurable: true
  12317. });
  12318. Object.defineProperty(Slider.prototype, "borderColor", {
  12319. /** Gets or sets border color */
  12320. get: function () {
  12321. return this._borderColor;
  12322. },
  12323. set: function (value) {
  12324. if (this._borderColor === value) {
  12325. return;
  12326. }
  12327. this._borderColor = value;
  12328. this._markAsDirty();
  12329. },
  12330. enumerable: false,
  12331. configurable: true
  12332. });
  12333. Object.defineProperty(Slider.prototype, "background", {
  12334. /** Gets or sets background color */
  12335. get: function () {
  12336. return this._background;
  12337. },
  12338. set: function (value) {
  12339. if (this._background === value) {
  12340. return;
  12341. }
  12342. this._background = value;
  12343. this._markAsDirty();
  12344. },
  12345. enumerable: false,
  12346. configurable: true
  12347. });
  12348. Object.defineProperty(Slider.prototype, "thumbColor", {
  12349. /** Gets or sets thumb's color */
  12350. get: function () {
  12351. return this._thumbColor;
  12352. },
  12353. set: function (value) {
  12354. if (this._thumbColor === value) {
  12355. return;
  12356. }
  12357. this._thumbColor = value;
  12358. this._markAsDirty();
  12359. },
  12360. enumerable: false,
  12361. configurable: true
  12362. });
  12363. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  12364. /** Gets or sets a boolean indicating if the thumb should be round or square */
  12365. get: function () {
  12366. return this._isThumbCircle;
  12367. },
  12368. set: function (value) {
  12369. if (this._isThumbCircle === value) {
  12370. return;
  12371. }
  12372. this._isThumbCircle = value;
  12373. this._markAsDirty();
  12374. },
  12375. enumerable: false,
  12376. configurable: true
  12377. });
  12378. Slider.prototype._getTypeName = function () {
  12379. return "Slider";
  12380. };
  12381. Slider.prototype._draw = function (context, invalidatedRectangle) {
  12382. context.save();
  12383. this._applyStates(context);
  12384. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  12385. var left = this._renderLeft;
  12386. var top = this._renderTop;
  12387. var width = this._renderWidth;
  12388. var height = this._renderHeight;
  12389. var radius = 0;
  12390. if (this.isThumbClamped && this.isThumbCircle) {
  12391. if (this.isVertical) {
  12392. top += (this._effectiveThumbThickness / 2);
  12393. }
  12394. else {
  12395. left += (this._effectiveThumbThickness / 2);
  12396. }
  12397. radius = this._backgroundBoxThickness / 2;
  12398. }
  12399. else {
  12400. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  12401. }
  12402. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12403. context.shadowColor = this.shadowColor;
  12404. context.shadowBlur = this.shadowBlur;
  12405. context.shadowOffsetX = this.shadowOffsetX;
  12406. context.shadowOffsetY = this.shadowOffsetY;
  12407. }
  12408. var thumbPosition = this._getThumbPosition();
  12409. context.fillStyle = this._background;
  12410. if (this.isVertical) {
  12411. if (this.isThumbClamped) {
  12412. if (this.isThumbCircle) {
  12413. context.beginPath();
  12414. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  12415. context.fill();
  12416. context.fillRect(left, top, width, height);
  12417. }
  12418. else {
  12419. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  12420. }
  12421. }
  12422. else {
  12423. context.fillRect(left, top, width, height);
  12424. }
  12425. }
  12426. else {
  12427. if (this.isThumbClamped) {
  12428. if (this.isThumbCircle) {
  12429. context.beginPath();
  12430. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  12431. context.fill();
  12432. context.fillRect(left, top, width, height);
  12433. }
  12434. else {
  12435. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  12436. }
  12437. }
  12438. else {
  12439. context.fillRect(left, top, width, height);
  12440. }
  12441. }
  12442. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12443. context.shadowBlur = 0;
  12444. context.shadowOffsetX = 0;
  12445. context.shadowOffsetY = 0;
  12446. }
  12447. // Value bar
  12448. context.fillStyle = this.color;
  12449. if (this._displayValueBar) {
  12450. if (this.isVertical) {
  12451. if (this.isThumbClamped) {
  12452. if (this.isThumbCircle) {
  12453. context.beginPath();
  12454. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  12455. context.fill();
  12456. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  12457. }
  12458. else {
  12459. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  12460. }
  12461. }
  12462. else {
  12463. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  12464. }
  12465. }
  12466. else {
  12467. if (this.isThumbClamped) {
  12468. if (this.isThumbCircle) {
  12469. context.beginPath();
  12470. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  12471. context.fill();
  12472. context.fillRect(left, top, thumbPosition, height);
  12473. }
  12474. else {
  12475. context.fillRect(left, top, thumbPosition, height);
  12476. }
  12477. }
  12478. else {
  12479. context.fillRect(left, top, thumbPosition, height);
  12480. }
  12481. }
  12482. }
  12483. // Thumb
  12484. context.fillStyle = this._thumbColor || this.color;
  12485. if (this.displayThumb) {
  12486. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12487. context.shadowColor = this.shadowColor;
  12488. context.shadowBlur = this.shadowBlur;
  12489. context.shadowOffsetX = this.shadowOffsetX;
  12490. context.shadowOffsetY = this.shadowOffsetY;
  12491. }
  12492. if (this._isThumbCircle) {
  12493. context.beginPath();
  12494. if (this.isVertical) {
  12495. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  12496. }
  12497. else {
  12498. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  12499. }
  12500. context.fill();
  12501. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12502. context.shadowBlur = 0;
  12503. context.shadowOffsetX = 0;
  12504. context.shadowOffsetY = 0;
  12505. }
  12506. context.strokeStyle = this._borderColor;
  12507. context.stroke();
  12508. }
  12509. else {
  12510. if (this.isVertical) {
  12511. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  12512. }
  12513. else {
  12514. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  12515. }
  12516. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12517. context.shadowBlur = 0;
  12518. context.shadowOffsetX = 0;
  12519. context.shadowOffsetY = 0;
  12520. }
  12521. context.strokeStyle = this._borderColor;
  12522. if (this.isVertical) {
  12523. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  12524. }
  12525. else {
  12526. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  12527. }
  12528. }
  12529. }
  12530. context.restore();
  12531. };
  12532. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12533. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  12534. ], Slider.prototype, "displayValueBar", null);
  12535. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12536. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  12537. ], Slider.prototype, "borderColor", null);
  12538. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12539. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  12540. ], Slider.prototype, "background", null);
  12541. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12542. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  12543. ], Slider.prototype, "thumbColor", null);
  12544. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12545. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  12546. ], Slider.prototype, "isThumbCircle", null);
  12547. return Slider;
  12548. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  12549. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  12550. /***/ }),
  12551. /***/ "./2D/controls/stackPanel.ts":
  12552. /*!***********************************!*\
  12553. !*** ./2D/controls/stackPanel.ts ***!
  12554. \***********************************/
  12555. /*! exports provided: StackPanel */
  12556. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12557. "use strict";
  12558. __webpack_require__.r(__webpack_exports__);
  12559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  12560. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12561. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  12562. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  12563. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  12564. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12565. /**
  12566. * Class used to create a 2D stack panel container
  12567. */
  12568. var StackPanel = /** @class */ (function (_super) {
  12569. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  12570. /**
  12571. * Creates a new StackPanel
  12572. * @param name defines control name
  12573. */
  12574. function StackPanel(name) {
  12575. var _this = _super.call(this, name) || this;
  12576. _this.name = name;
  12577. _this._isVertical = true;
  12578. _this._manualWidth = false;
  12579. _this._manualHeight = false;
  12580. _this._doNotTrackManualChanges = false;
  12581. /**
  12582. * Gets or sets a boolean indicating that layou warnings should be ignored
  12583. */
  12584. _this.ignoreLayoutWarnings = false;
  12585. return _this;
  12586. }
  12587. Object.defineProperty(StackPanel.prototype, "isVertical", {
  12588. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  12589. get: function () {
  12590. return this._isVertical;
  12591. },
  12592. set: function (value) {
  12593. if (this._isVertical === value) {
  12594. return;
  12595. }
  12596. this._isVertical = value;
  12597. this._markAsDirty();
  12598. },
  12599. enumerable: false,
  12600. configurable: true
  12601. });
  12602. Object.defineProperty(StackPanel.prototype, "width", {
  12603. get: function () {
  12604. return this._width.toString(this._host);
  12605. },
  12606. /**
  12607. * Gets or sets panel width.
  12608. * This value should not be set when in horizontal mode as it will be computed automatically
  12609. */
  12610. set: function (value) {
  12611. if (!this._doNotTrackManualChanges) {
  12612. this._manualWidth = true;
  12613. }
  12614. if (this._width.toString(this._host) === value) {
  12615. return;
  12616. }
  12617. if (this._width.fromString(value)) {
  12618. this._markAsDirty();
  12619. }
  12620. },
  12621. enumerable: false,
  12622. configurable: true
  12623. });
  12624. Object.defineProperty(StackPanel.prototype, "height", {
  12625. get: function () {
  12626. return this._height.toString(this._host);
  12627. },
  12628. /**
  12629. * Gets or sets panel height.
  12630. * This value should not be set when in vertical mode as it will be computed automatically
  12631. */
  12632. set: function (value) {
  12633. if (!this._doNotTrackManualChanges) {
  12634. this._manualHeight = true;
  12635. }
  12636. if (this._height.toString(this._host) === value) {
  12637. return;
  12638. }
  12639. if (this._height.fromString(value)) {
  12640. this._markAsDirty();
  12641. }
  12642. },
  12643. enumerable: false,
  12644. configurable: true
  12645. });
  12646. StackPanel.prototype._getTypeName = function () {
  12647. return "StackPanel";
  12648. };
  12649. /** @hidden */
  12650. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  12651. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12652. var child = _a[_i];
  12653. if (this._isVertical) {
  12654. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  12655. }
  12656. else {
  12657. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  12658. }
  12659. }
  12660. _super.prototype._preMeasure.call(this, parentMeasure, context);
  12661. };
  12662. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  12663. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  12664. this._measureForChildren.copyFrom(parentMeasure);
  12665. this._measureForChildren.left = this._currentMeasure.left;
  12666. this._measureForChildren.top = this._currentMeasure.top;
  12667. if (!this.isVertical || this._manualWidth) {
  12668. this._measureForChildren.width = this._currentMeasure.width;
  12669. }
  12670. if (this.isVertical || this._manualHeight) {
  12671. this._measureForChildren.height = this._currentMeasure.height;
  12672. }
  12673. };
  12674. StackPanel.prototype._postMeasure = function () {
  12675. var stackWidth = 0;
  12676. var stackHeight = 0;
  12677. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12678. var child = _a[_i];
  12679. if (!child.isVisible || child.notRenderable) {
  12680. continue;
  12681. }
  12682. if (this._isVertical) {
  12683. if (child.top !== stackHeight + "px") {
  12684. child.top = stackHeight + "px";
  12685. this._rebuildLayout = true;
  12686. child._top.ignoreAdaptiveScaling = true;
  12687. }
  12688. if (child._height.isPercentage && !child._automaticSize) {
  12689. if (!this.ignoreLayoutWarnings) {
  12690. 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");
  12691. }
  12692. }
  12693. else {
  12694. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  12695. }
  12696. }
  12697. else {
  12698. if (child.left !== stackWidth + "px") {
  12699. child.left = stackWidth + "px";
  12700. this._rebuildLayout = true;
  12701. child._left.ignoreAdaptiveScaling = true;
  12702. }
  12703. if (child._width.isPercentage && !child._automaticSize) {
  12704. if (!this.ignoreLayoutWarnings) {
  12705. 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");
  12706. }
  12707. }
  12708. else {
  12709. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  12710. }
  12711. }
  12712. }
  12713. stackWidth += this.paddingLeftInPixels + this.paddingRightInPixels;
  12714. stackHeight += this.paddingTopInPixels + this.paddingBottomInPixels;
  12715. this._doNotTrackManualChanges = true;
  12716. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  12717. // User can now define their own height and width for stack panel.
  12718. var panelWidthChanged = false;
  12719. var panelHeightChanged = false;
  12720. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  12721. var previousHeight = this.height;
  12722. this.height = stackHeight + "px";
  12723. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  12724. }
  12725. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  12726. var previousWidth = this.width;
  12727. this.width = stackWidth + "px";
  12728. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  12729. }
  12730. if (panelHeightChanged) {
  12731. this._height.ignoreAdaptiveScaling = true;
  12732. }
  12733. if (panelWidthChanged) {
  12734. this._width.ignoreAdaptiveScaling = true;
  12735. }
  12736. this._doNotTrackManualChanges = false;
  12737. if (panelWidthChanged || panelHeightChanged) {
  12738. this._rebuildLayout = true;
  12739. }
  12740. _super.prototype._postMeasure.call(this);
  12741. };
  12742. /**
  12743. * Serializes the current control
  12744. * @param serializationObject defined the JSON serialized object
  12745. */
  12746. StackPanel.prototype.serialize = function (serializationObject) {
  12747. _super.prototype.serialize.call(this, serializationObject);
  12748. serializationObject.manualWidth = this._manualWidth;
  12749. serializationObject.manualHeight = this._manualHeight;
  12750. };
  12751. /** @hidden */
  12752. StackPanel.prototype._parseFromContent = function (serializedObject, host) {
  12753. this._manualWidth = serializedObject.manualWidth;
  12754. this._manualHeight = serializedObject.manualHeight;
  12755. _super.prototype._parseFromContent.call(this, serializedObject, host);
  12756. };
  12757. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12758. Object(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12759. ], StackPanel.prototype, "ignoreLayoutWarnings", void 0);
  12760. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12761. Object(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12762. ], StackPanel.prototype, "isVertical", null);
  12763. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12764. Object(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12765. ], StackPanel.prototype, "width", null);
  12766. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12767. Object(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12768. ], StackPanel.prototype, "height", null);
  12769. return StackPanel;
  12770. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  12771. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  12772. /***/ }),
  12773. /***/ "./2D/controls/statics.ts":
  12774. /*!********************************!*\
  12775. !*** ./2D/controls/statics.ts ***!
  12776. \********************************/
  12777. /*! exports provided: name */
  12778. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12779. "use strict";
  12780. __webpack_require__.r(__webpack_exports__);
  12781. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  12782. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12783. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12784. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  12785. /**
  12786. * Forcing an export so that this code will execute
  12787. * @hidden
  12788. */
  12789. var name = "Statics";
  12790. /**
  12791. * Creates a stack panel that can be used to render headers
  12792. * @param control defines the control to associate with the header
  12793. * @param text defines the text of the header
  12794. * @param size defines the size of the header
  12795. * @param options defines options used to configure the header
  12796. * @returns a new StackPanel
  12797. */
  12798. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  12799. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  12800. var isHorizontal = options ? options.isHorizontal : true;
  12801. var controlFirst = options ? options.controlFirst : true;
  12802. panel.isVertical = !isHorizontal;
  12803. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  12804. header.text = text;
  12805. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  12806. if (isHorizontal) {
  12807. header.width = size;
  12808. }
  12809. else {
  12810. header.height = size;
  12811. }
  12812. if (controlFirst) {
  12813. panel.addControl(control);
  12814. panel.addControl(header);
  12815. header.paddingLeft = "5px";
  12816. }
  12817. else {
  12818. panel.addControl(header);
  12819. panel.addControl(control);
  12820. header.paddingRight = "5px";
  12821. }
  12822. header.shadowBlur = control.shadowBlur;
  12823. header.shadowColor = control.shadowColor;
  12824. header.shadowOffsetX = control.shadowOffsetX;
  12825. header.shadowOffsetY = control.shadowOffsetY;
  12826. return panel;
  12827. };
  12828. /***/ }),
  12829. /***/ "./2D/controls/textBlock.ts":
  12830. /*!**********************************!*\
  12831. !*** ./2D/controls/textBlock.ts ***!
  12832. \**********************************/
  12833. /*! exports provided: TextWrapping, TextBlock */
  12834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12835. "use strict";
  12836. __webpack_require__.r(__webpack_exports__);
  12837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  12838. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  12839. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12840. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12841. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12842. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  12843. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12844. /**
  12845. * Enum that determines the text-wrapping mode to use.
  12846. */
  12847. var TextWrapping;
  12848. (function (TextWrapping) {
  12849. /**
  12850. * Clip the text when it's larger than Control.width; this is the default mode.
  12851. */
  12852. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  12853. /**
  12854. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  12855. */
  12856. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  12857. /**
  12858. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  12859. */
  12860. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  12861. })(TextWrapping || (TextWrapping = {}));
  12862. /**
  12863. * Class used to create text block control
  12864. */
  12865. var TextBlock = /** @class */ (function (_super) {
  12866. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  12867. /**
  12868. * Creates a new TextBlock object
  12869. * @param name defines the name of the control
  12870. * @param text defines the text to display (emptry string by default)
  12871. */
  12872. function TextBlock(
  12873. /**
  12874. * Defines the name of the control
  12875. */
  12876. name, text) {
  12877. if (text === void 0) { text = ""; }
  12878. var _this = _super.call(this, name) || this;
  12879. _this.name = name;
  12880. _this._text = "";
  12881. _this._textWrapping = TextWrapping.Clip;
  12882. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  12883. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  12884. _this._resizeToFit = false;
  12885. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  12886. _this._outlineWidth = 0;
  12887. _this._outlineColor = "white";
  12888. _this._underline = false;
  12889. _this._lineThrough = false;
  12890. /**
  12891. * An event triggered after the text is changed
  12892. */
  12893. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12894. /**
  12895. * An event triggered after the text was broken up into lines
  12896. */
  12897. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12898. _this.text = text;
  12899. return _this;
  12900. }
  12901. Object.defineProperty(TextBlock.prototype, "lines", {
  12902. /**
  12903. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  12904. */
  12905. get: function () {
  12906. return this._lines;
  12907. },
  12908. enumerable: false,
  12909. configurable: true
  12910. });
  12911. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  12912. /**
  12913. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12914. */
  12915. get: function () {
  12916. return this._resizeToFit;
  12917. },
  12918. /**
  12919. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12920. */
  12921. set: function (value) {
  12922. if (this._resizeToFit === value) {
  12923. return;
  12924. }
  12925. this._resizeToFit = value;
  12926. if (this._resizeToFit) {
  12927. this._width.ignoreAdaptiveScaling = true;
  12928. this._height.ignoreAdaptiveScaling = true;
  12929. }
  12930. this._markAsDirty();
  12931. },
  12932. enumerable: false,
  12933. configurable: true
  12934. });
  12935. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  12936. /**
  12937. * Gets or sets a boolean indicating if text must be wrapped
  12938. */
  12939. get: function () {
  12940. return this._textWrapping;
  12941. },
  12942. /**
  12943. * Gets or sets a boolean indicating if text must be wrapped
  12944. */
  12945. set: function (value) {
  12946. if (this._textWrapping === value) {
  12947. return;
  12948. }
  12949. this._textWrapping = +value;
  12950. this._markAsDirty();
  12951. },
  12952. enumerable: false,
  12953. configurable: true
  12954. });
  12955. Object.defineProperty(TextBlock.prototype, "text", {
  12956. /**
  12957. * Gets or sets text to display
  12958. */
  12959. get: function () {
  12960. return this._text;
  12961. },
  12962. /**
  12963. * Gets or sets text to display
  12964. */
  12965. set: function (value) {
  12966. if (this._text === value) {
  12967. return;
  12968. }
  12969. this._text = value;
  12970. this._markAsDirty();
  12971. this.onTextChangedObservable.notifyObservers(this);
  12972. },
  12973. enumerable: false,
  12974. configurable: true
  12975. });
  12976. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  12977. /**
  12978. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12979. */
  12980. get: function () {
  12981. return this._textHorizontalAlignment;
  12982. },
  12983. /**
  12984. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12985. */
  12986. set: function (value) {
  12987. if (this._textHorizontalAlignment === value) {
  12988. return;
  12989. }
  12990. this._textHorizontalAlignment = value;
  12991. this._markAsDirty();
  12992. },
  12993. enumerable: false,
  12994. configurable: true
  12995. });
  12996. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  12997. /**
  12998. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12999. */
  13000. get: function () {
  13001. return this._textVerticalAlignment;
  13002. },
  13003. /**
  13004. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  13005. */
  13006. set: function (value) {
  13007. if (this._textVerticalAlignment === value) {
  13008. return;
  13009. }
  13010. this._textVerticalAlignment = value;
  13011. this._markAsDirty();
  13012. },
  13013. enumerable: false,
  13014. configurable: true
  13015. });
  13016. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  13017. /**
  13018. * Gets or sets line spacing value
  13019. */
  13020. get: function () {
  13021. return this._lineSpacing.toString(this._host);
  13022. },
  13023. /**
  13024. * Gets or sets line spacing value
  13025. */
  13026. set: function (value) {
  13027. if (this._lineSpacing.fromString(value)) {
  13028. this._markAsDirty();
  13029. }
  13030. },
  13031. enumerable: false,
  13032. configurable: true
  13033. });
  13034. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  13035. /**
  13036. * Gets or sets outlineWidth of the text to display
  13037. */
  13038. get: function () {
  13039. return this._outlineWidth;
  13040. },
  13041. /**
  13042. * Gets or sets outlineWidth of the text to display
  13043. */
  13044. set: function (value) {
  13045. if (this._outlineWidth === value) {
  13046. return;
  13047. }
  13048. this._outlineWidth = value;
  13049. this._markAsDirty();
  13050. },
  13051. enumerable: false,
  13052. configurable: true
  13053. });
  13054. Object.defineProperty(TextBlock.prototype, "underline", {
  13055. /**
  13056. * Gets or sets a boolean indicating that text must have underline
  13057. */
  13058. get: function () {
  13059. return this._underline;
  13060. },
  13061. /**
  13062. * Gets or sets a boolean indicating that text must have underline
  13063. */
  13064. set: function (value) {
  13065. if (this._underline === value) {
  13066. return;
  13067. }
  13068. this._underline = value;
  13069. this._markAsDirty();
  13070. },
  13071. enumerable: false,
  13072. configurable: true
  13073. });
  13074. Object.defineProperty(TextBlock.prototype, "lineThrough", {
  13075. /**
  13076. * Gets or sets an boolean indicating that text must be crossed out
  13077. */
  13078. get: function () {
  13079. return this._lineThrough;
  13080. },
  13081. /**
  13082. * Gets or sets an boolean indicating that text must be crossed out
  13083. */
  13084. set: function (value) {
  13085. if (this._lineThrough === value) {
  13086. return;
  13087. }
  13088. this._lineThrough = value;
  13089. this._markAsDirty();
  13090. },
  13091. enumerable: false,
  13092. configurable: true
  13093. });
  13094. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  13095. /**
  13096. * Gets or sets outlineColor of the text to display
  13097. */
  13098. get: function () {
  13099. return this._outlineColor;
  13100. },
  13101. /**
  13102. * Gets or sets outlineColor of the text to display
  13103. */
  13104. set: function (value) {
  13105. if (this._outlineColor === value) {
  13106. return;
  13107. }
  13108. this._outlineColor = value;
  13109. this._markAsDirty();
  13110. },
  13111. enumerable: false,
  13112. configurable: true
  13113. });
  13114. TextBlock.prototype._getTypeName = function () {
  13115. return "TextBlock";
  13116. };
  13117. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  13118. if (!this._fontOffset) {
  13119. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  13120. }
  13121. _super.prototype._processMeasures.call(this, parentMeasure, context);
  13122. // Prepare lines
  13123. this._lines = this._breakLines(this._currentMeasure.width, context);
  13124. this.onLinesReadyObservable.notifyObservers(this);
  13125. var maxLineWidth = 0;
  13126. for (var i = 0; i < this._lines.length; i++) {
  13127. var line = this._lines[i];
  13128. if (line.width > maxLineWidth) {
  13129. maxLineWidth = line.width;
  13130. }
  13131. }
  13132. if (this._resizeToFit) {
  13133. if (this._textWrapping === TextWrapping.Clip) {
  13134. var newWidth = (this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth) | 0;
  13135. if (newWidth !== this._width.internalValue) {
  13136. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  13137. this._rebuildLayout = true;
  13138. }
  13139. }
  13140. var newHeight = (this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length) | 0;
  13141. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  13142. var lineSpacing = 0;
  13143. if (this._lineSpacing.isPixel) {
  13144. lineSpacing = this._lineSpacing.getValue(this._host);
  13145. }
  13146. else {
  13147. lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  13148. }
  13149. newHeight += (this._lines.length - 1) * lineSpacing;
  13150. }
  13151. if (newHeight !== this._height.internalValue) {
  13152. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  13153. this._rebuildLayout = true;
  13154. }
  13155. }
  13156. };
  13157. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  13158. var width = this._currentMeasure.width;
  13159. var x = 0;
  13160. switch (this._textHorizontalAlignment) {
  13161. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  13162. x = 0;
  13163. break;
  13164. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  13165. x = width - textWidth;
  13166. break;
  13167. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  13168. x = (width - textWidth) / 2;
  13169. break;
  13170. }
  13171. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  13172. context.shadowColor = this.shadowColor;
  13173. context.shadowBlur = this.shadowBlur;
  13174. context.shadowOffsetX = this.shadowOffsetX;
  13175. context.shadowOffsetY = this.shadowOffsetY;
  13176. }
  13177. if (this.outlineWidth) {
  13178. context.strokeText(text, this._currentMeasure.left + x, y);
  13179. }
  13180. context.fillText(text, this._currentMeasure.left + x, y);
  13181. if (this._underline) {
  13182. context.beginPath();
  13183. context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
  13184. context.moveTo(this._currentMeasure.left + x, y + 3);
  13185. context.lineTo(this._currentMeasure.left + x + textWidth, y + 3);
  13186. context.stroke();
  13187. context.closePath();
  13188. }
  13189. if (this._lineThrough) {
  13190. context.beginPath();
  13191. context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
  13192. context.moveTo(this._currentMeasure.left + x, y - this.fontSizeInPixels / 3);
  13193. context.lineTo(this._currentMeasure.left + x + textWidth, y - this.fontSizeInPixels / 3);
  13194. context.stroke();
  13195. context.closePath();
  13196. }
  13197. };
  13198. /** @hidden */
  13199. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  13200. context.save();
  13201. this._applyStates(context);
  13202. // Render lines
  13203. this._renderLines(context);
  13204. context.restore();
  13205. };
  13206. TextBlock.prototype._applyStates = function (context) {
  13207. _super.prototype._applyStates.call(this, context);
  13208. if (this.outlineWidth) {
  13209. context.lineWidth = this.outlineWidth;
  13210. context.strokeStyle = this.outlineColor;
  13211. context.lineJoin = 'miter';
  13212. context.miterLimit = 2;
  13213. }
  13214. };
  13215. TextBlock.prototype._breakLines = function (refWidth, context) {
  13216. var lines = [];
  13217. var _lines = this.text.split("\n");
  13218. if (this._textWrapping === TextWrapping.Ellipsis) {
  13219. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  13220. var _line = _lines_1[_i];
  13221. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  13222. }
  13223. }
  13224. else if (this._textWrapping === TextWrapping.WordWrap) {
  13225. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  13226. var _line = _lines_2[_a];
  13227. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  13228. }
  13229. }
  13230. else {
  13231. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  13232. var _line = _lines_3[_b];
  13233. lines.push(this._parseLine(_line, context));
  13234. }
  13235. }
  13236. return lines;
  13237. };
  13238. TextBlock.prototype._parseLine = function (line, context) {
  13239. if (line === void 0) { line = ""; }
  13240. return { text: line, width: context.measureText(line).width };
  13241. };
  13242. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  13243. if (line === void 0) { line = ""; }
  13244. var lineWidth = context.measureText(line).width;
  13245. if (lineWidth > width) {
  13246. line += "…";
  13247. }
  13248. // unicode support. split('') does not work with unicode!
  13249. // make sure Array.from is available
  13250. var characters = Array.from && Array.from(line);
  13251. if (!characters) {
  13252. // no array.from, use the old method
  13253. while (line.length > 2 && lineWidth > width) {
  13254. line = line.slice(0, -2) + "…";
  13255. lineWidth = context.measureText(line).width;
  13256. }
  13257. }
  13258. else {
  13259. while (characters.length && lineWidth > width) {
  13260. characters.pop();
  13261. line = characters.join("") + "...";
  13262. lineWidth = context.measureText(line).width;
  13263. }
  13264. }
  13265. return { text: line, width: lineWidth };
  13266. };
  13267. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  13268. if (line === void 0) { line = ""; }
  13269. var lines = [];
  13270. var words = this.wordSplittingFunction ? this.wordSplittingFunction(line) : line.split(" ");
  13271. var lineWidth = 0;
  13272. for (var n = 0; n < words.length; n++) {
  13273. var testLine = n > 0 ? line + " " + words[n] : words[0];
  13274. var metrics = context.measureText(testLine);
  13275. var testWidth = metrics.width;
  13276. if (testWidth > width && n > 0) {
  13277. lines.push({ text: line, width: lineWidth });
  13278. line = words[n];
  13279. lineWidth = context.measureText(line).width;
  13280. }
  13281. else {
  13282. lineWidth = testWidth;
  13283. line = testLine;
  13284. }
  13285. }
  13286. lines.push({ text: line, width: lineWidth });
  13287. return lines;
  13288. };
  13289. TextBlock.prototype._renderLines = function (context) {
  13290. var height = this._currentMeasure.height;
  13291. var rootY = 0;
  13292. switch (this._textVerticalAlignment) {
  13293. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  13294. rootY = this._fontOffset.ascent;
  13295. break;
  13296. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  13297. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  13298. break;
  13299. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  13300. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  13301. break;
  13302. }
  13303. rootY += this._currentMeasure.top;
  13304. for (var i = 0; i < this._lines.length; i++) {
  13305. var line = this._lines[i];
  13306. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  13307. if (this._lineSpacing.isPixel) {
  13308. rootY += this._lineSpacing.getValue(this._host);
  13309. }
  13310. else {
  13311. rootY = rootY + this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  13312. }
  13313. }
  13314. this._drawText(line.text, line.width, rootY, context);
  13315. rootY += this._fontOffset.height;
  13316. }
  13317. };
  13318. /**
  13319. * Given a width constraint applied on the text block, find the expected height
  13320. * @returns expected height
  13321. */
  13322. TextBlock.prototype.computeExpectedHeight = function () {
  13323. if (this.text && this.widthInPixels) {
  13324. var context_1 = document.createElement("canvas").getContext("2d");
  13325. if (context_1) {
  13326. this._applyStates(context_1);
  13327. if (!this._fontOffset) {
  13328. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  13329. }
  13330. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  13331. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  13332. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  13333. var lineSpacing = 0;
  13334. if (this._lineSpacing.isPixel) {
  13335. lineSpacing = this._lineSpacing.getValue(this._host);
  13336. }
  13337. else {
  13338. lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  13339. }
  13340. newHeight += (lines.length - 1) * lineSpacing;
  13341. }
  13342. return newHeight;
  13343. }
  13344. }
  13345. return 0;
  13346. };
  13347. TextBlock.prototype.dispose = function () {
  13348. _super.prototype.dispose.call(this);
  13349. this.onTextChangedObservable.clear();
  13350. };
  13351. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13352. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13353. ], TextBlock.prototype, "resizeToFit", null);
  13354. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13355. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13356. ], TextBlock.prototype, "textWrapping", null);
  13357. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13358. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13359. ], TextBlock.prototype, "text", null);
  13360. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13361. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13362. ], TextBlock.prototype, "textHorizontalAlignment", null);
  13363. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13364. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13365. ], TextBlock.prototype, "textVerticalAlignment", null);
  13366. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13367. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13368. ], TextBlock.prototype, "lineSpacing", null);
  13369. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13370. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13371. ], TextBlock.prototype, "outlineWidth", null);
  13372. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13373. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13374. ], TextBlock.prototype, "underline", null);
  13375. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13376. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13377. ], TextBlock.prototype, "lineThrough", null);
  13378. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13379. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13380. ], TextBlock.prototype, "outlineColor", null);
  13381. return TextBlock;
  13382. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  13383. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  13384. /***/ }),
  13385. /***/ "./2D/controls/textWrapper.ts":
  13386. /*!************************************!*\
  13387. !*** ./2D/controls/textWrapper.ts ***!
  13388. \************************************/
  13389. /*! exports provided: TextWrapper */
  13390. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13391. "use strict";
  13392. __webpack_require__.r(__webpack_exports__);
  13393. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return TextWrapper; });
  13394. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13395. /** @hidden */
  13396. var TextWrapper = /** @class */ (function () {
  13397. function TextWrapper() {
  13398. }
  13399. Object.defineProperty(TextWrapper.prototype, "text", {
  13400. get: function () {
  13401. return this._characters ? this._characters.join("") : this._text;
  13402. },
  13403. set: function (txt) {
  13404. this._text = txt;
  13405. this._characters = Array.from && Array.from(txt);
  13406. },
  13407. enumerable: false,
  13408. configurable: true
  13409. });
  13410. Object.defineProperty(TextWrapper.prototype, "length", {
  13411. get: function () {
  13412. return this._characters ? this._characters.length : this._text.length;
  13413. },
  13414. enumerable: false,
  13415. configurable: true
  13416. });
  13417. TextWrapper.prototype.removePart = function (idxStart, idxEnd, insertTxt) {
  13418. var _a;
  13419. this._text = this._text.slice(0, idxStart) + (insertTxt ? insertTxt : "") + this._text.slice(idxEnd);
  13420. if (this._characters) {
  13421. var newCharacters = insertTxt ? Array.from(insertTxt) : [];
  13422. (_a = this._characters).splice.apply(_a, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spreadArrays"])([idxStart, idxEnd - idxStart], newCharacters));
  13423. }
  13424. };
  13425. TextWrapper.prototype.charAt = function (idx) {
  13426. return this._characters ? this._characters[idx] : this._text.charAt(idx);
  13427. };
  13428. TextWrapper.prototype.substr = function (from, length) {
  13429. if (this._characters) {
  13430. if (isNaN(from)) {
  13431. from = 0;
  13432. }
  13433. else if (from >= 0) {
  13434. from = Math.min(from, this._characters.length);
  13435. }
  13436. else {
  13437. from = this._characters.length + Math.max(from, -this._characters.length);
  13438. }
  13439. if (length === undefined) {
  13440. length = this._characters.length - from;
  13441. }
  13442. else if (isNaN(length)) {
  13443. length = 0;
  13444. }
  13445. else if (length < 0) {
  13446. length = 0;
  13447. }
  13448. var temp = [];
  13449. while (--length >= 0) {
  13450. temp[length] = this._characters[from + length];
  13451. }
  13452. return temp.join("");
  13453. }
  13454. return this._text.substr(from, length);
  13455. };
  13456. TextWrapper.prototype.substring = function (from, to) {
  13457. if (this._characters) {
  13458. if (isNaN(from)) {
  13459. from = 0;
  13460. }
  13461. else if (from > this._characters.length) {
  13462. from = this._characters.length;
  13463. }
  13464. else if (from < 0) {
  13465. from = 0;
  13466. }
  13467. if (to === undefined) {
  13468. to = this._characters.length;
  13469. }
  13470. else if (isNaN(to)) {
  13471. to = 0;
  13472. }
  13473. else if (to > this._characters.length) {
  13474. to = this._characters.length;
  13475. }
  13476. else if (to < 0) {
  13477. to = 0;
  13478. }
  13479. var temp = [];
  13480. var idx = 0;
  13481. while (from < to) {
  13482. temp[idx++] = this._characters[from++];
  13483. }
  13484. return temp.join("");
  13485. }
  13486. return this._text.substring(from, to);
  13487. };
  13488. TextWrapper.prototype.isWord = function (index) {
  13489. var rWord = /\w/g;
  13490. return this._characters ? this._characters[index].search(rWord) !== -1 : this._text.search(rWord) !== -1;
  13491. };
  13492. return TextWrapper;
  13493. }());
  13494. /***/ }),
  13495. /***/ "./2D/controls/toggleButton.ts":
  13496. /*!*************************************!*\
  13497. !*** ./2D/controls/toggleButton.ts ***!
  13498. \*************************************/
  13499. /*! exports provided: ToggleButton */
  13500. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13501. "use strict";
  13502. __webpack_require__.r(__webpack_exports__);
  13503. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return ToggleButton; });
  13504. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13505. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  13506. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  13507. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  13508. /**
  13509. * Class used to create toggle buttons
  13510. */
  13511. var ToggleButton = /** @class */ (function (_super) {
  13512. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ToggleButton, _super);
  13513. /**
  13514. * Creates a new ToggleButton
  13515. * @param name defines the control name
  13516. * @param group defines the toggle group this toggle belongs to
  13517. */
  13518. function ToggleButton(name, group) {
  13519. var _this = _super.call(this, name) || this;
  13520. _this.name = name;
  13521. /** Observable raised when isActive is changed */
  13522. _this.onIsActiveChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  13523. /**
  13524. * Gets or sets a boolean indicating that the toggle button will let internal controls handle picking instead of doing it directly using its bounding info
  13525. */
  13526. _this.delegatePickingToChildren = false;
  13527. _this._isActive = false;
  13528. _this.group = group !== null && group !== void 0 ? group : "";
  13529. _this.thickness = 0;
  13530. _this.isPointerBlocker = true;
  13531. var alphaStore = null;
  13532. _this.toActiveAnimation = function () {
  13533. _this.thickness = 1;
  13534. };
  13535. _this.toInactiveAnimation = function () {
  13536. _this.thickness = 0;
  13537. };
  13538. _this.pointerEnterActiveAnimation = function () {
  13539. alphaStore = _this.alpha;
  13540. _this.alpha -= 0.1;
  13541. };
  13542. _this.pointerOutActiveAnimation = function () {
  13543. if (alphaStore !== null) {
  13544. _this.alpha = alphaStore;
  13545. }
  13546. };
  13547. _this.pointerDownActiveAnimation = function () {
  13548. _this.scaleX -= 0.05;
  13549. _this.scaleY -= 0.05;
  13550. };
  13551. _this.pointerUpActiveAnimation = function () {
  13552. _this.scaleX += 0.05;
  13553. _this.scaleY += 0.05;
  13554. };
  13555. _this.pointerEnterInactiveAnimation = function () {
  13556. alphaStore = _this.alpha;
  13557. _this.alpha -= 0.1;
  13558. };
  13559. _this.pointerOutInactiveAnimation = function () {
  13560. if (alphaStore !== null) {
  13561. _this.alpha = alphaStore;
  13562. }
  13563. };
  13564. _this.pointerDownInactiveAnimation = function () {
  13565. _this.scaleX -= 0.05;
  13566. _this.scaleY -= 0.05;
  13567. };
  13568. _this.pointerUpInactiveAnimation = function () {
  13569. _this.scaleX += 0.05;
  13570. _this.scaleY += 0.05;
  13571. };
  13572. return _this;
  13573. }
  13574. Object.defineProperty(ToggleButton.prototype, "image", {
  13575. /**
  13576. * Returns the ToggleButton's image control if it exists
  13577. */
  13578. get: function () {
  13579. return this._image;
  13580. },
  13581. enumerable: false,
  13582. configurable: true
  13583. });
  13584. Object.defineProperty(ToggleButton.prototype, "textBlock", {
  13585. /**
  13586. * Returns the ToggleButton's child TextBlock control if it exists
  13587. */
  13588. get: function () {
  13589. return this._textBlock;
  13590. },
  13591. enumerable: false,
  13592. configurable: true
  13593. });
  13594. Object.defineProperty(ToggleButton.prototype, "group", {
  13595. /** Gets or sets group name this toggle button belongs to */
  13596. get: function () {
  13597. return this._group;
  13598. },
  13599. set: function (value) {
  13600. if (this._group === value) {
  13601. return;
  13602. }
  13603. this._group = value;
  13604. },
  13605. enumerable: false,
  13606. configurable: true
  13607. });
  13608. Object.defineProperty(ToggleButton.prototype, "isActive", {
  13609. /** Gets or sets a boolean indicating if the toogle button is active or not */
  13610. get: function () {
  13611. return this._isActive;
  13612. },
  13613. set: function (value) {
  13614. var _this = this;
  13615. var _a, _b;
  13616. // Function modeled after radioButton.ts
  13617. if (this._isActive === value) {
  13618. return;
  13619. }
  13620. this._isActive = value;
  13621. // Update the visual state based on the new value
  13622. if (this._isActive) {
  13623. (_a = this.toActiveAnimation) === null || _a === void 0 ? void 0 : _a.call(this);
  13624. }
  13625. else {
  13626. (_b = this.toInactiveAnimation) === null || _b === void 0 ? void 0 : _b.call(this);
  13627. }
  13628. this._markAsDirty();
  13629. this.onIsActiveChangedObservable.notifyObservers(value);
  13630. if (this._isActive && this._host && this._group) {
  13631. // A toggle button in a group can only have 1 active element at a given time.
  13632. // If this toggle button has a group, set other toggle buttons in the group to inactive.
  13633. this._host.executeOnAllControls(function (control) {
  13634. // Check for control type ToggleButton
  13635. if (control.typeName === "ToggleButton") {
  13636. // Don't do anything to this toggle button
  13637. if (control === _this) {
  13638. return;
  13639. }
  13640. var childToggle = control;
  13641. // If toggle button is in same group, set isActive to false
  13642. if (childToggle.group === _this.group) {
  13643. childToggle.isActive = false;
  13644. }
  13645. }
  13646. });
  13647. }
  13648. },
  13649. enumerable: false,
  13650. configurable: true
  13651. });
  13652. ToggleButton.prototype._getTypeName = function () {
  13653. return "ToggleButton";
  13654. };
  13655. // While being a container, the toggle button behaves like a control.
  13656. /** @hidden */
  13657. ToggleButton.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  13658. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  13659. return false;
  13660. }
  13661. if (!_super.prototype.contains.call(this, x, y)) {
  13662. return false;
  13663. }
  13664. if (this.delegatePickingToChildren) {
  13665. var contains = false;
  13666. for (var index = this._children.length - 1; index >= 0; index--) {
  13667. var child = this._children[index];
  13668. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  13669. contains = true;
  13670. break;
  13671. }
  13672. }
  13673. if (!contains) {
  13674. return false;
  13675. }
  13676. }
  13677. this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  13678. return true;
  13679. };
  13680. /** @hidden */
  13681. ToggleButton.prototype._onPointerEnter = function (target, pi) {
  13682. if (!_super.prototype._onPointerEnter.call(this, target, pi)) {
  13683. return false;
  13684. }
  13685. if (this._isActive) {
  13686. if (this.pointerEnterActiveAnimation) {
  13687. this.pointerEnterActiveAnimation();
  13688. }
  13689. }
  13690. else {
  13691. if (this.pointerEnterInactiveAnimation) {
  13692. this.pointerEnterInactiveAnimation();
  13693. }
  13694. }
  13695. return true;
  13696. };
  13697. /** @hidden */
  13698. ToggleButton.prototype._onPointerOut = function (target, pi, force) {
  13699. if (force === void 0) { force = false; }
  13700. if (this._isActive) {
  13701. if (this.pointerOutActiveAnimation) {
  13702. this.pointerOutActiveAnimation();
  13703. }
  13704. }
  13705. else {
  13706. if (this.pointerOutInactiveAnimation) {
  13707. this.pointerOutInactiveAnimation();
  13708. }
  13709. }
  13710. _super.prototype._onPointerOut.call(this, target, pi, force);
  13711. };
  13712. /** @hidden */
  13713. ToggleButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  13714. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  13715. return false;
  13716. }
  13717. if (this._isActive) {
  13718. if (this.pointerDownActiveAnimation) {
  13719. this.pointerDownActiveAnimation();
  13720. }
  13721. }
  13722. else {
  13723. if (this.pointerDownInactiveAnimation) {
  13724. this.pointerDownInactiveAnimation();
  13725. }
  13726. }
  13727. return true;
  13728. };
  13729. /** @hidden */
  13730. ToggleButton.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  13731. if (this._isActive) {
  13732. if (this.pointerUpActiveAnimation) {
  13733. this.pointerUpActiveAnimation();
  13734. }
  13735. }
  13736. else {
  13737. if (this.pointerUpInactiveAnimation) {
  13738. this.pointerUpInactiveAnimation();
  13739. }
  13740. }
  13741. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick, pi);
  13742. };
  13743. return ToggleButton;
  13744. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  13745. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ToggleButton"] = ToggleButton;
  13746. /***/ }),
  13747. /***/ "./2D/controls/virtualKeyboard.ts":
  13748. /*!****************************************!*\
  13749. !*** ./2D/controls/virtualKeyboard.ts ***!
  13750. \****************************************/
  13751. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  13752. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13753. "use strict";
  13754. __webpack_require__.r(__webpack_exports__);
  13755. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  13756. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  13757. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13758. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  13759. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  13760. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  13761. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  13762. /**
  13763. * Class used to store key control properties
  13764. */
  13765. var KeyPropertySet = /** @class */ (function () {
  13766. function KeyPropertySet() {
  13767. }
  13768. return KeyPropertySet;
  13769. }());
  13770. /**
  13771. * Class used to create virtual keyboard
  13772. */
  13773. var VirtualKeyboard = /** @class */ (function (_super) {
  13774. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  13775. function VirtualKeyboard() {
  13776. var _this = _super !== null && _super.apply(this, arguments) || this;
  13777. /** Observable raised when a key is pressed */
  13778. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  13779. /** Gets or sets default key button width */
  13780. _this.defaultButtonWidth = "40px";
  13781. /** Gets or sets default key button height */
  13782. _this.defaultButtonHeight = "40px";
  13783. /** Gets or sets default key button left padding */
  13784. _this.defaultButtonPaddingLeft = "2px";
  13785. /** Gets or sets default key button right padding */
  13786. _this.defaultButtonPaddingRight = "2px";
  13787. /** Gets or sets default key button top padding */
  13788. _this.defaultButtonPaddingTop = "2px";
  13789. /** Gets or sets default key button bottom padding */
  13790. _this.defaultButtonPaddingBottom = "2px";
  13791. /** Gets or sets default key button foreground color */
  13792. _this.defaultButtonColor = "#DDD";
  13793. /** Gets or sets default key button background color */
  13794. _this.defaultButtonBackground = "#070707";
  13795. /** Gets or sets shift button foreground color */
  13796. _this.shiftButtonColor = "#7799FF";
  13797. /** Gets or sets shift button thickness*/
  13798. _this.selectedShiftThickness = 1;
  13799. /** Gets shift key state */
  13800. _this.shiftState = 0;
  13801. _this._currentlyConnectedInputText = null;
  13802. _this._connectedInputTexts = [];
  13803. _this._onKeyPressObserver = null;
  13804. return _this;
  13805. }
  13806. VirtualKeyboard.prototype._getTypeName = function () {
  13807. return "VirtualKeyboard";
  13808. };
  13809. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  13810. var _this = this;
  13811. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  13812. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  13813. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  13814. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  13815. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  13816. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  13817. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  13818. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  13819. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  13820. button.thickness = 0;
  13821. button.isFocusInvisible = true;
  13822. button.shadowColor = this.shadowColor;
  13823. button.shadowBlur = this.shadowBlur;
  13824. button.shadowOffsetX = this.shadowOffsetX;
  13825. button.shadowOffsetY = this.shadowOffsetY;
  13826. button.onPointerUpObservable.add(function () {
  13827. _this.onKeyPressObservable.notifyObservers(key);
  13828. });
  13829. return button;
  13830. };
  13831. /**
  13832. * Adds a new row of keys
  13833. * @param keys defines the list of keys to add
  13834. * @param propertySets defines the associated property sets
  13835. */
  13836. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  13837. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  13838. panel.isVertical = false;
  13839. panel.isFocusInvisible = true;
  13840. var maxKey = null;
  13841. for (var i = 0; i < keys.length; i++) {
  13842. var properties = null;
  13843. if (propertySets && propertySets.length === keys.length) {
  13844. properties = propertySets[i];
  13845. }
  13846. var key = this._createKey(keys[i], properties);
  13847. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  13848. maxKey = key;
  13849. }
  13850. panel.addControl(key);
  13851. }
  13852. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  13853. this.addControl(panel);
  13854. };
  13855. /**
  13856. * Set the shift key to a specific state
  13857. * @param shiftState defines the new shift state
  13858. */
  13859. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  13860. if (!this.children) {
  13861. return;
  13862. }
  13863. for (var i = 0; i < this.children.length; i++) {
  13864. var row = this.children[i];
  13865. if (!row || !row.children) {
  13866. continue;
  13867. }
  13868. var rowContainer = row;
  13869. for (var j = 0; j < rowContainer.children.length; j++) {
  13870. var button = rowContainer.children[j];
  13871. if (!button || !button.children[0]) {
  13872. continue;
  13873. }
  13874. var button_tblock = button.children[0];
  13875. if (button_tblock.text === "\u21E7") {
  13876. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  13877. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  13878. }
  13879. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  13880. }
  13881. }
  13882. };
  13883. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  13884. /** Gets the input text control currently attached to the keyboard */
  13885. get: function () {
  13886. return this._currentlyConnectedInputText;
  13887. },
  13888. enumerable: false,
  13889. configurable: true
  13890. });
  13891. /**
  13892. * Connects the keyboard with an input text control
  13893. *
  13894. * @param input defines the target control
  13895. */
  13896. VirtualKeyboard.prototype.connect = function (input) {
  13897. var _this = this;
  13898. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  13899. if (inputTextAlreadyConnected) {
  13900. return;
  13901. }
  13902. if (this._onKeyPressObserver === null) {
  13903. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  13904. if (!_this._currentlyConnectedInputText) {
  13905. return;
  13906. }
  13907. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  13908. switch (key) {
  13909. case "\u21E7":
  13910. _this.shiftState++;
  13911. if (_this.shiftState > 2) {
  13912. _this.shiftState = 0;
  13913. }
  13914. _this.applyShiftState(_this.shiftState);
  13915. return;
  13916. case "\u2190":
  13917. _this._currentlyConnectedInputText.processKey(8);
  13918. return;
  13919. case "\u21B5":
  13920. _this._currentlyConnectedInputText.processKey(13);
  13921. return;
  13922. }
  13923. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  13924. if (_this.shiftState === 1) {
  13925. _this.shiftState = 0;
  13926. _this.applyShiftState(_this.shiftState);
  13927. }
  13928. });
  13929. }
  13930. this.isVisible = false;
  13931. this._currentlyConnectedInputText = input;
  13932. input._connectedVirtualKeyboard = this;
  13933. // Events hooking
  13934. var onFocusObserver = input.onFocusObservable.add(function () {
  13935. _this._currentlyConnectedInputText = input;
  13936. input._connectedVirtualKeyboard = _this;
  13937. _this.isVisible = true;
  13938. });
  13939. var onBlurObserver = input.onBlurObservable.add(function () {
  13940. input._connectedVirtualKeyboard = null;
  13941. _this._currentlyConnectedInputText = null;
  13942. _this.isVisible = false;
  13943. });
  13944. this._connectedInputTexts.push({
  13945. input: input,
  13946. onBlurObserver: onBlurObserver,
  13947. onFocusObserver: onFocusObserver
  13948. });
  13949. };
  13950. /**
  13951. * Disconnects the keyboard from connected InputText controls
  13952. *
  13953. * @param input optionally defines a target control, otherwise all are disconnected
  13954. */
  13955. VirtualKeyboard.prototype.disconnect = function (input) {
  13956. var _this = this;
  13957. if (input) {
  13958. // .find not available on IE
  13959. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  13960. if (filtered.length === 1) {
  13961. this._removeConnectedInputObservables(filtered[0]);
  13962. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  13963. if (this._currentlyConnectedInputText === input) {
  13964. this._currentlyConnectedInputText = null;
  13965. }
  13966. }
  13967. }
  13968. else {
  13969. this._connectedInputTexts.forEach(function (connectedInputText) {
  13970. _this._removeConnectedInputObservables(connectedInputText);
  13971. });
  13972. this._connectedInputTexts = [];
  13973. }
  13974. if (this._connectedInputTexts.length === 0) {
  13975. this._currentlyConnectedInputText = null;
  13976. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  13977. this._onKeyPressObserver = null;
  13978. }
  13979. };
  13980. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  13981. connectedInputText.input._connectedVirtualKeyboard = null;
  13982. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  13983. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  13984. };
  13985. /**
  13986. * Release all resources
  13987. */
  13988. VirtualKeyboard.prototype.dispose = function () {
  13989. _super.prototype.dispose.call(this);
  13990. this.disconnect();
  13991. };
  13992. // Statics
  13993. /**
  13994. * Creates a new keyboard using a default layout
  13995. *
  13996. * @param name defines control name
  13997. * @returns a new VirtualKeyboard
  13998. */
  13999. VirtualKeyboard.CreateDefaultLayout = function (name) {
  14000. var returnValue = new VirtualKeyboard(name);
  14001. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  14002. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  14003. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  14004. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  14005. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  14006. return returnValue;
  14007. };
  14008. return VirtualKeyboard;
  14009. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  14010. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  14011. /***/ }),
  14012. /***/ "./2D/index.ts":
  14013. /*!*********************!*\
  14014. !*** ./2D/index.ts ***!
  14015. \*********************/
  14016. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, FocusableButton, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, TextWrapper, ToggleButton, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader */
  14017. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14018. "use strict";
  14019. __webpack_require__.r(__webpack_exports__);
  14020. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  14021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["FocusableButton"]; });
  14028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapper"]; });
  14045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ToggleButton"]; });
  14046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  14055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14056. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  14058. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  14059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  14060. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  14061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  14062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  14063. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  14064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  14065. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  14066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  14067. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  14068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  14069. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  14070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  14071. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  14072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  14073. /***/ }),
  14074. /***/ "./2D/math2D.ts":
  14075. /*!**********************!*\
  14076. !*** ./2D/math2D.ts ***!
  14077. \**********************/
  14078. /*! exports provided: Vector2WithInfo, Matrix2D */
  14079. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14080. "use strict";
  14081. __webpack_require__.r(__webpack_exports__);
  14082. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  14083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  14084. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14085. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  14086. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  14087. /**
  14088. * Class used to transport Vector2 information for pointer events
  14089. */
  14090. var Vector2WithInfo = /** @class */ (function (_super) {
  14091. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  14092. /**
  14093. * Creates a new Vector2WithInfo
  14094. * @param source defines the vector2 data to transport
  14095. * @param buttonIndex defines the current mouse button index
  14096. */
  14097. function Vector2WithInfo(source,
  14098. /** defines the current mouse button index */
  14099. buttonIndex) {
  14100. if (buttonIndex === void 0) { buttonIndex = 0; }
  14101. var _this = _super.call(this, source.x, source.y) || this;
  14102. _this.buttonIndex = buttonIndex;
  14103. return _this;
  14104. }
  14105. return Vector2WithInfo;
  14106. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  14107. /** Class used to provide 2D matrix features */
  14108. var Matrix2D = /** @class */ (function () {
  14109. /**
  14110. * Creates a new matrix
  14111. * @param m00 defines value for (0, 0)
  14112. * @param m01 defines value for (0, 1)
  14113. * @param m10 defines value for (1, 0)
  14114. * @param m11 defines value for (1, 1)
  14115. * @param m20 defines value for (2, 0)
  14116. * @param m21 defines value for (2, 1)
  14117. */
  14118. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  14119. /** Gets the internal array of 6 floats used to store matrix data */
  14120. this.m = new Float32Array(6);
  14121. this.fromValues(m00, m01, m10, m11, m20, m21);
  14122. }
  14123. /**
  14124. * Fills the matrix from direct values
  14125. * @param m00 defines value for (0, 0)
  14126. * @param m01 defines value for (0, 1)
  14127. * @param m10 defines value for (1, 0)
  14128. * @param m11 defines value for (1, 1)
  14129. * @param m20 defines value for (2, 0)
  14130. * @param m21 defines value for (2, 1)
  14131. * @returns the current modified matrix
  14132. */
  14133. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  14134. this.m[0] = m00;
  14135. this.m[1] = m01;
  14136. this.m[2] = m10;
  14137. this.m[3] = m11;
  14138. this.m[4] = m20;
  14139. this.m[5] = m21;
  14140. return this;
  14141. };
  14142. /**
  14143. * Gets matrix determinant
  14144. * @returns the determinant
  14145. */
  14146. Matrix2D.prototype.determinant = function () {
  14147. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  14148. };
  14149. /**
  14150. * Inverses the matrix and stores it in a target matrix
  14151. * @param result defines the target matrix
  14152. * @returns the current matrix
  14153. */
  14154. Matrix2D.prototype.invertToRef = function (result) {
  14155. var l0 = this.m[0];
  14156. var l1 = this.m[1];
  14157. var l2 = this.m[2];
  14158. var l3 = this.m[3];
  14159. var l4 = this.m[4];
  14160. var l5 = this.m[5];
  14161. var det = this.determinant();
  14162. if (det < (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  14163. result.m[0] = 0;
  14164. result.m[1] = 0;
  14165. result.m[2] = 0;
  14166. result.m[3] = 0;
  14167. result.m[4] = 0;
  14168. result.m[5] = 0;
  14169. return this;
  14170. }
  14171. var detDiv = 1 / det;
  14172. var det4 = l2 * l5 - l3 * l4;
  14173. var det5 = l1 * l4 - l0 * l5;
  14174. result.m[0] = l3 * detDiv;
  14175. result.m[1] = -l1 * detDiv;
  14176. result.m[2] = -l2 * detDiv;
  14177. result.m[3] = l0 * detDiv;
  14178. result.m[4] = det4 * detDiv;
  14179. result.m[5] = det5 * detDiv;
  14180. return this;
  14181. };
  14182. /**
  14183. * Multiplies the current matrix with another one
  14184. * @param other defines the second operand
  14185. * @param result defines the target matrix
  14186. * @returns the current matrix
  14187. */
  14188. Matrix2D.prototype.multiplyToRef = function (other, result) {
  14189. var l0 = this.m[0];
  14190. var l1 = this.m[1];
  14191. var l2 = this.m[2];
  14192. var l3 = this.m[3];
  14193. var l4 = this.m[4];
  14194. var l5 = this.m[5];
  14195. var r0 = other.m[0];
  14196. var r1 = other.m[1];
  14197. var r2 = other.m[2];
  14198. var r3 = other.m[3];
  14199. var r4 = other.m[4];
  14200. var r5 = other.m[5];
  14201. result.m[0] = l0 * r0 + l1 * r2;
  14202. result.m[1] = l0 * r1 + l1 * r3;
  14203. result.m[2] = l2 * r0 + l3 * r2;
  14204. result.m[3] = l2 * r1 + l3 * r3;
  14205. result.m[4] = l4 * r0 + l5 * r2 + r4;
  14206. result.m[5] = l4 * r1 + l5 * r3 + r5;
  14207. return this;
  14208. };
  14209. /**
  14210. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  14211. * @param x defines the x coordinate to transform
  14212. * @param y defines the x coordinate to transform
  14213. * @param result defines the target vector2
  14214. * @returns the current matrix
  14215. */
  14216. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  14217. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  14218. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  14219. return this;
  14220. };
  14221. // Statics
  14222. /**
  14223. * Creates an identity matrix
  14224. * @returns a new matrix
  14225. */
  14226. Matrix2D.Identity = function () {
  14227. return new Matrix2D(1, 0, 0, 1, 0, 0);
  14228. };
  14229. /**
  14230. * Creates a translation matrix and stores it in a target matrix
  14231. * @param x defines the x coordinate of the translation
  14232. * @param y defines the y coordinate of the translation
  14233. * @param result defines the target matrix
  14234. */
  14235. Matrix2D.TranslationToRef = function (x, y, result) {
  14236. result.fromValues(1, 0, 0, 1, x, y);
  14237. };
  14238. /**
  14239. * Creates a scaling matrix and stores it in a target matrix
  14240. * @param x defines the x coordinate of the scaling
  14241. * @param y defines the y coordinate of the scaling
  14242. * @param result defines the target matrix
  14243. */
  14244. Matrix2D.ScalingToRef = function (x, y, result) {
  14245. result.fromValues(x, 0, 0, y, 0, 0);
  14246. };
  14247. /**
  14248. * Creates a rotation matrix and stores it in a target matrix
  14249. * @param angle defines the rotation angle
  14250. * @param result defines the target matrix
  14251. */
  14252. Matrix2D.RotationToRef = function (angle, result) {
  14253. var s = Math.sin(angle);
  14254. var c = Math.cos(angle);
  14255. result.fromValues(c, s, -s, c, 0, 0);
  14256. };
  14257. /**
  14258. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  14259. * @param tx defines the x coordinate of the translation
  14260. * @param ty defines the y coordinate of the translation
  14261. * @param angle defines the rotation angle
  14262. * @param scaleX defines the x coordinate of the scaling
  14263. * @param scaleY defines the y coordinate of the scaling
  14264. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  14265. * @param result defines the target matrix
  14266. */
  14267. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  14268. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  14269. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  14270. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  14271. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  14272. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  14273. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  14274. if (parentMatrix) {
  14275. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  14276. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  14277. }
  14278. else {
  14279. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  14280. }
  14281. };
  14282. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  14283. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  14284. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  14285. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  14286. Matrix2D._TempCompose0 = Matrix2D.Identity();
  14287. Matrix2D._TempCompose1 = Matrix2D.Identity();
  14288. Matrix2D._TempCompose2 = Matrix2D.Identity();
  14289. return Matrix2D;
  14290. }());
  14291. /***/ }),
  14292. /***/ "./2D/measure.ts":
  14293. /*!***********************!*\
  14294. !*** ./2D/measure.ts ***!
  14295. \***********************/
  14296. /*! exports provided: Measure */
  14297. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14298. "use strict";
  14299. __webpack_require__.r(__webpack_exports__);
  14300. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  14301. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  14302. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  14303. var tmpRect = [
  14304. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14305. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14306. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14307. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14308. ];
  14309. var tmpRect2 = [
  14310. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14311. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14312. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14313. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14314. ];
  14315. var tmpV1 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  14316. var tmpV2 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  14317. /**
  14318. * Class used to store 2D control sizes
  14319. */
  14320. var Measure = /** @class */ (function () {
  14321. /**
  14322. * Creates a new measure
  14323. * @param left defines left coordinate
  14324. * @param top defines top coordinate
  14325. * @param width defines width dimension
  14326. * @param height defines height dimension
  14327. */
  14328. function Measure(
  14329. /** defines left coordinate */
  14330. left,
  14331. /** defines top coordinate */
  14332. top,
  14333. /** defines width dimension */
  14334. width,
  14335. /** defines height dimension */
  14336. height) {
  14337. this.left = left;
  14338. this.top = top;
  14339. this.width = width;
  14340. this.height = height;
  14341. }
  14342. /**
  14343. * Copy from another measure
  14344. * @param other defines the other measure to copy from
  14345. */
  14346. Measure.prototype.copyFrom = function (other) {
  14347. this.left = other.left;
  14348. this.top = other.top;
  14349. this.width = other.width;
  14350. this.height = other.height;
  14351. };
  14352. /**
  14353. * Copy from a group of 4 floats
  14354. * @param left defines left coordinate
  14355. * @param top defines top coordinate
  14356. * @param width defines width dimension
  14357. * @param height defines height dimension
  14358. */
  14359. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  14360. this.left = left;
  14361. this.top = top;
  14362. this.width = width;
  14363. this.height = height;
  14364. };
  14365. /**
  14366. * Computes the axis aligned bounding box measure for two given measures
  14367. * @param a Input measure
  14368. * @param b Input measure
  14369. * @param result the resulting bounding measure
  14370. */
  14371. Measure.CombineToRef = function (a, b, result) {
  14372. var left = Math.min(a.left, b.left);
  14373. var top = Math.min(a.top, b.top);
  14374. var right = Math.max(a.left + a.width, b.left + b.width);
  14375. var bottom = Math.max(a.top + a.height, b.top + b.height);
  14376. result.left = left;
  14377. result.top = top;
  14378. result.width = right - left;
  14379. result.height = bottom - top;
  14380. };
  14381. /**
  14382. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  14383. * @param transform the matrix to transform the measure before computing the AABB
  14384. * @param addX number to add to left
  14385. * @param addY number to add to top
  14386. * @param addWidth number to add to width
  14387. * @param addHeight number to add to height
  14388. * @param result the resulting AABB
  14389. */
  14390. Measure.prototype.addAndTransformToRef = function (transform, addX, addY, addWidth, addHeight, result) {
  14391. var left = this.left + addX;
  14392. var top = this.top + addY;
  14393. var width = this.width + addWidth;
  14394. var height = this.height + addHeight;
  14395. tmpRect[0].copyFromFloats(left, top);
  14396. tmpRect[1].copyFromFloats(left + width, top);
  14397. tmpRect[2].copyFromFloats(left + width, top + height);
  14398. tmpRect[3].copyFromFloats(left, top + height);
  14399. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  14400. tmpV2.copyFromFloats(0, 0);
  14401. for (var i = 0; i < 4; i++) {
  14402. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  14403. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  14404. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  14405. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  14406. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  14407. }
  14408. result.left = tmpV1.x;
  14409. result.top = tmpV1.y;
  14410. result.width = tmpV2.x - tmpV1.x;
  14411. result.height = tmpV2.y - tmpV1.y;
  14412. };
  14413. /**
  14414. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  14415. * @param transform the matrix to transform the measure before computing the AABB
  14416. * @param result the resulting AABB
  14417. */
  14418. Measure.prototype.transformToRef = function (transform, result) {
  14419. this.addAndTransformToRef(transform, 0, 0, 0, 0, result);
  14420. };
  14421. /**
  14422. * Check equality between this measure and another one
  14423. * @param other defines the other measures
  14424. * @returns true if both measures are equals
  14425. */
  14426. Measure.prototype.isEqualsTo = function (other) {
  14427. if (this.left !== other.left) {
  14428. return false;
  14429. }
  14430. if (this.top !== other.top) {
  14431. return false;
  14432. }
  14433. if (this.width !== other.width) {
  14434. return false;
  14435. }
  14436. if (this.height !== other.height) {
  14437. return false;
  14438. }
  14439. return true;
  14440. };
  14441. /**
  14442. * Creates an empty measure
  14443. * @returns a new measure
  14444. */
  14445. Measure.Empty = function () {
  14446. return new Measure(0, 0, 0, 0);
  14447. };
  14448. return Measure;
  14449. }());
  14450. /***/ }),
  14451. /***/ "./2D/multiLinePoint.ts":
  14452. /*!******************************!*\
  14453. !*** ./2D/multiLinePoint.ts ***!
  14454. \******************************/
  14455. /*! exports provided: MultiLinePoint */
  14456. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14457. "use strict";
  14458. __webpack_require__.r(__webpack_exports__);
  14459. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  14460. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  14461. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  14462. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  14463. /**
  14464. * Class used to store a point for a MultiLine object.
  14465. * The point can be pure 2D coordinates, a mesh or a control
  14466. */
  14467. var MultiLinePoint = /** @class */ (function () {
  14468. /**
  14469. * Creates a new MultiLinePoint
  14470. * @param multiLine defines the source MultiLine object
  14471. */
  14472. function MultiLinePoint(multiLine) {
  14473. this._multiLine = multiLine;
  14474. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  14475. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  14476. this._point = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  14477. }
  14478. Object.defineProperty(MultiLinePoint.prototype, "x", {
  14479. /** Gets or sets x coordinate */
  14480. get: function () {
  14481. return this._x.toString(this._multiLine._host);
  14482. },
  14483. set: function (value) {
  14484. if (this._x.toString(this._multiLine._host) === value) {
  14485. return;
  14486. }
  14487. if (this._x.fromString(value)) {
  14488. this._multiLine._markAsDirty();
  14489. }
  14490. },
  14491. enumerable: false,
  14492. configurable: true
  14493. });
  14494. Object.defineProperty(MultiLinePoint.prototype, "y", {
  14495. /** Gets or sets y coordinate */
  14496. get: function () {
  14497. return this._y.toString(this._multiLine._host);
  14498. },
  14499. set: function (value) {
  14500. if (this._y.toString(this._multiLine._host) === value) {
  14501. return;
  14502. }
  14503. if (this._y.fromString(value)) {
  14504. this._multiLine._markAsDirty();
  14505. }
  14506. },
  14507. enumerable: false,
  14508. configurable: true
  14509. });
  14510. Object.defineProperty(MultiLinePoint.prototype, "control", {
  14511. /** Gets or sets the control associated with this point */
  14512. get: function () {
  14513. return this._control;
  14514. },
  14515. set: function (value) {
  14516. if (this._control === value) {
  14517. return;
  14518. }
  14519. if (this._control && this._controlObserver) {
  14520. this._control.onDirtyObservable.remove(this._controlObserver);
  14521. this._controlObserver = null;
  14522. }
  14523. this._control = value;
  14524. if (this._control) {
  14525. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  14526. }
  14527. this._multiLine._markAsDirty();
  14528. },
  14529. enumerable: false,
  14530. configurable: true
  14531. });
  14532. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  14533. /** Gets or sets the mesh associated with this point */
  14534. get: function () {
  14535. return this._mesh;
  14536. },
  14537. set: function (value) {
  14538. if (this._mesh === value) {
  14539. return;
  14540. }
  14541. if (this._mesh && this._meshObserver) {
  14542. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  14543. }
  14544. this._mesh = value;
  14545. if (this._mesh) {
  14546. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  14547. }
  14548. this._multiLine._markAsDirty();
  14549. },
  14550. enumerable: false,
  14551. configurable: true
  14552. });
  14553. /** Resets links */
  14554. MultiLinePoint.prototype.resetLinks = function () {
  14555. this.control = null;
  14556. this.mesh = null;
  14557. };
  14558. /**
  14559. * Gets a translation vector with Z component
  14560. * @returns the translation vector
  14561. */
  14562. MultiLinePoint.prototype.translate = function () {
  14563. this._point = this._translatePoint();
  14564. return this._point;
  14565. };
  14566. MultiLinePoint.prototype._translatePoint = function () {
  14567. if (this._mesh != null) {
  14568. return this._multiLine._host.getProjectedPositionWithZ(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  14569. }
  14570. else if (this._control != null) {
  14571. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](this._control.centerX, this._control.centerY, 1. - babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]);
  14572. }
  14573. else {
  14574. var host = this._multiLine._host;
  14575. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  14576. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  14577. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](xValue, yValue, 1. - babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]);
  14578. }
  14579. };
  14580. /** Release associated resources */
  14581. MultiLinePoint.prototype.dispose = function () {
  14582. this.resetLinks();
  14583. };
  14584. return MultiLinePoint;
  14585. }());
  14586. /***/ }),
  14587. /***/ "./2D/style.ts":
  14588. /*!*********************!*\
  14589. !*** ./2D/style.ts ***!
  14590. \*********************/
  14591. /*! exports provided: Style */
  14592. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14593. "use strict";
  14594. __webpack_require__.r(__webpack_exports__);
  14595. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  14596. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  14597. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14598. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  14599. /**
  14600. * Define a style used by control to automatically setup properties based on a template.
  14601. * Only support font related properties so far
  14602. */
  14603. var Style = /** @class */ (function () {
  14604. /**
  14605. * Creates a new style object
  14606. * @param host defines the AdvancedDynamicTexture which hosts this style
  14607. */
  14608. function Style(host) {
  14609. this._fontFamily = "Arial";
  14610. this._fontStyle = "";
  14611. this._fontWeight = "";
  14612. /** @hidden */
  14613. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  14614. /**
  14615. * Observable raised when the style values are changed
  14616. */
  14617. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14618. this._host = host;
  14619. }
  14620. Object.defineProperty(Style.prototype, "fontSize", {
  14621. /**
  14622. * Gets or sets the font size
  14623. */
  14624. get: function () {
  14625. return this._fontSize.toString(this._host);
  14626. },
  14627. set: function (value) {
  14628. if (this._fontSize.toString(this._host) === value) {
  14629. return;
  14630. }
  14631. if (this._fontSize.fromString(value)) {
  14632. this.onChangedObservable.notifyObservers(this);
  14633. }
  14634. },
  14635. enumerable: false,
  14636. configurable: true
  14637. });
  14638. Object.defineProperty(Style.prototype, "fontFamily", {
  14639. /**
  14640. * Gets or sets the font family
  14641. */
  14642. get: function () {
  14643. return this._fontFamily;
  14644. },
  14645. set: function (value) {
  14646. if (this._fontFamily === value) {
  14647. return;
  14648. }
  14649. this._fontFamily = value;
  14650. this.onChangedObservable.notifyObservers(this);
  14651. },
  14652. enumerable: false,
  14653. configurable: true
  14654. });
  14655. Object.defineProperty(Style.prototype, "fontStyle", {
  14656. /**
  14657. * Gets or sets the font style
  14658. */
  14659. get: function () {
  14660. return this._fontStyle;
  14661. },
  14662. set: function (value) {
  14663. if (this._fontStyle === value) {
  14664. return;
  14665. }
  14666. this._fontStyle = value;
  14667. this.onChangedObservable.notifyObservers(this);
  14668. },
  14669. enumerable: false,
  14670. configurable: true
  14671. });
  14672. Object.defineProperty(Style.prototype, "fontWeight", {
  14673. /** Gets or sets font weight */
  14674. get: function () {
  14675. return this._fontWeight;
  14676. },
  14677. set: function (value) {
  14678. if (this._fontWeight === value) {
  14679. return;
  14680. }
  14681. this._fontWeight = value;
  14682. this.onChangedObservable.notifyObservers(this);
  14683. },
  14684. enumerable: false,
  14685. configurable: true
  14686. });
  14687. /** Dispose all associated resources */
  14688. Style.prototype.dispose = function () {
  14689. this.onChangedObservable.clear();
  14690. };
  14691. return Style;
  14692. }());
  14693. /***/ }),
  14694. /***/ "./2D/valueAndUnit.ts":
  14695. /*!****************************!*\
  14696. !*** ./2D/valueAndUnit.ts ***!
  14697. \****************************/
  14698. /*! exports provided: ValueAndUnit */
  14699. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14700. "use strict";
  14701. __webpack_require__.r(__webpack_exports__);
  14702. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  14703. /**
  14704. * Class used to specific a value and its associated unit
  14705. */
  14706. var ValueAndUnit = /** @class */ (function () {
  14707. /**
  14708. * Creates a new ValueAndUnit
  14709. * @param value defines the value to store
  14710. * @param unit defines the unit to store
  14711. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  14712. */
  14713. function ValueAndUnit(value,
  14714. /** defines the unit to store */
  14715. unit,
  14716. /** defines a boolean indicating if the value can be negative */
  14717. negativeValueAllowed) {
  14718. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  14719. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  14720. this.unit = unit;
  14721. this.negativeValueAllowed = negativeValueAllowed;
  14722. this._value = 1;
  14723. /**
  14724. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  14725. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  14726. */
  14727. this.ignoreAdaptiveScaling = false;
  14728. this._value = value;
  14729. this._originalUnit = unit;
  14730. }
  14731. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  14732. /** Gets a boolean indicating if the value is a percentage */
  14733. get: function () {
  14734. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  14735. },
  14736. enumerable: false,
  14737. configurable: true
  14738. });
  14739. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  14740. /** Gets a boolean indicating if the value is store as pixel */
  14741. get: function () {
  14742. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  14743. },
  14744. enumerable: false,
  14745. configurable: true
  14746. });
  14747. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  14748. /** Gets direct internal value */
  14749. get: function () {
  14750. return this._value;
  14751. },
  14752. enumerable: false,
  14753. configurable: true
  14754. });
  14755. /**
  14756. * Gets value as pixel
  14757. * @param host defines the root host
  14758. * @param refValue defines the reference value for percentages
  14759. * @returns the value as pixel
  14760. */
  14761. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  14762. if (this.isPixel) {
  14763. return this.getValue(host);
  14764. }
  14765. return this.getValue(host) * refValue;
  14766. };
  14767. /**
  14768. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  14769. * @param value defines the value to store
  14770. * @param unit defines the unit to store
  14771. * @returns the current ValueAndUnit
  14772. */
  14773. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  14774. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  14775. this._value = value;
  14776. this.unit = unit;
  14777. return this;
  14778. };
  14779. /**
  14780. * Gets the value accordingly to its unit
  14781. * @param host defines the root host
  14782. * @returns the value
  14783. */
  14784. ValueAndUnit.prototype.getValue = function (host) {
  14785. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  14786. var width = 0;
  14787. var height = 0;
  14788. if (host.idealWidth) {
  14789. width = (this._value * host.getSize().width) / host.idealWidth;
  14790. }
  14791. if (host.idealHeight) {
  14792. height = (this._value * host.getSize().height) / host.idealHeight;
  14793. }
  14794. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  14795. return window.innerWidth < window.innerHeight ? width : height;
  14796. }
  14797. if (host.idealWidth) { // horizontal
  14798. return width;
  14799. }
  14800. if (host.idealHeight) { // vertical
  14801. return height;
  14802. }
  14803. }
  14804. return this._value;
  14805. };
  14806. /**
  14807. * Gets a string representation of the value
  14808. * @param host defines the root host
  14809. * @param decimals defines an optional number of decimals to display
  14810. * @returns a string
  14811. */
  14812. ValueAndUnit.prototype.toString = function (host, decimals) {
  14813. switch (this.unit) {
  14814. case ValueAndUnit.UNITMODE_PERCENTAGE:
  14815. var percentage = this.getValue(host) * 100;
  14816. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  14817. case ValueAndUnit.UNITMODE_PIXEL:
  14818. var pixels = this.getValue(host);
  14819. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  14820. }
  14821. return this.unit.toString();
  14822. };
  14823. /**
  14824. * Store a value parsed from a string
  14825. * @param source defines the source string
  14826. * @returns true if the value was successfully parsed
  14827. */
  14828. ValueAndUnit.prototype.fromString = function (source) {
  14829. var match = ValueAndUnit._Regex.exec(source.toString());
  14830. if (!match || match.length === 0) {
  14831. return false;
  14832. }
  14833. var sourceValue = parseFloat(match[1]);
  14834. var sourceUnit = this._originalUnit;
  14835. if (!this.negativeValueAllowed) {
  14836. if (sourceValue < 0) {
  14837. sourceValue = 0;
  14838. }
  14839. }
  14840. if (match.length === 4) {
  14841. switch (match[3]) {
  14842. case "px":
  14843. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  14844. break;
  14845. case "%":
  14846. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  14847. sourceValue /= 100.0;
  14848. break;
  14849. }
  14850. }
  14851. if (sourceValue === this._value && sourceUnit === this.unit) {
  14852. return false;
  14853. }
  14854. this._value = sourceValue;
  14855. this.unit = sourceUnit;
  14856. return true;
  14857. };
  14858. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  14859. /** UNITMODE_PERCENTAGE */
  14860. get: function () {
  14861. return ValueAndUnit._UNITMODE_PERCENTAGE;
  14862. },
  14863. enumerable: false,
  14864. configurable: true
  14865. });
  14866. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  14867. /** UNITMODE_PIXEL */
  14868. get: function () {
  14869. return ValueAndUnit._UNITMODE_PIXEL;
  14870. },
  14871. enumerable: false,
  14872. configurable: true
  14873. });
  14874. // Static
  14875. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  14876. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  14877. ValueAndUnit._UNITMODE_PIXEL = 1;
  14878. return ValueAndUnit;
  14879. }());
  14880. /***/ }),
  14881. /***/ "./2D/xmlLoader.ts":
  14882. /*!*************************!*\
  14883. !*** ./2D/xmlLoader.ts ***!
  14884. \*************************/
  14885. /*! exports provided: XmlLoader */
  14886. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14887. "use strict";
  14888. __webpack_require__.r(__webpack_exports__);
  14889. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  14890. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  14891. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  14892. /**
  14893. * Class used to load GUI via XML.
  14894. */
  14895. var XmlLoader = /** @class */ (function () {
  14896. /**
  14897. * Create a new xml loader
  14898. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  14899. */
  14900. function XmlLoader(parentClass) {
  14901. if (parentClass === void 0) { parentClass = null; }
  14902. this._nodes = {};
  14903. this._nodeTypes = {
  14904. element: 1,
  14905. attribute: 2,
  14906. text: 3
  14907. };
  14908. this._isLoaded = false;
  14909. this._objectAttributes = {
  14910. "textHorizontalAlignment": 1,
  14911. "textVerticalAlignment": 2,
  14912. "horizontalAlignment": 3,
  14913. "verticalAlignment": 4,
  14914. "stretch": 5,
  14915. };
  14916. if (parentClass) {
  14917. this._parentClass = parentClass;
  14918. }
  14919. }
  14920. XmlLoader.prototype._getChainElement = function (attributeValue) {
  14921. var element = window;
  14922. if (this._parentClass) {
  14923. element = this._parentClass;
  14924. }
  14925. var value = attributeValue;
  14926. value = value.split(".");
  14927. for (var i = 0; i < value.length; i++) {
  14928. element = element[value[i]];
  14929. }
  14930. return element;
  14931. };
  14932. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  14933. var attribute = attributeName.split(".");
  14934. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  14935. return className[attribute[1]];
  14936. };
  14937. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  14938. if (linkParent === void 0) { linkParent = true; }
  14939. try {
  14940. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  14941. var guiNode = new className();
  14942. if (parent && linkParent) {
  14943. parent.addControl(guiNode);
  14944. }
  14945. for (var i = 0; i < node.attributes.length; i++) {
  14946. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  14947. continue;
  14948. }
  14949. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  14950. var element = this._getChainElement(node.attributes[i].value);
  14951. guiNode[node.attributes[i].name].add(element);
  14952. continue;
  14953. }
  14954. else if (node.attributes[i].name == "linkWithMesh") {
  14955. if (this._parentClass) {
  14956. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  14957. }
  14958. else {
  14959. guiNode.linkWithMesh(window[node.attributes[i].value]);
  14960. }
  14961. }
  14962. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  14963. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  14964. guiNode[node.attributes[i].name] = element;
  14965. }
  14966. else if (!this._objectAttributes[node.attributes[i].name]) {
  14967. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  14968. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  14969. }
  14970. else {
  14971. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  14972. }
  14973. }
  14974. else {
  14975. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  14976. }
  14977. }
  14978. if (!node.attributes.getNamedItem("id")) {
  14979. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  14980. return guiNode;
  14981. }
  14982. var id = node.attributes.getNamedItem("id").value;
  14983. if (id.startsWith("{{") && id.endsWith("}}")) {
  14984. id = this._getChainElement(id.substring(2, id.length - 2));
  14985. }
  14986. if (!this._nodes[id]) {
  14987. this._nodes[id] = guiNode;
  14988. }
  14989. else {
  14990. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  14991. }
  14992. return guiNode;
  14993. }
  14994. catch (e) {
  14995. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  14996. }
  14997. };
  14998. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  14999. var width;
  15000. var height;
  15001. var columns;
  15002. var rows = node.children;
  15003. var cells;
  15004. var isPixel = false;
  15005. var cellNode;
  15006. var rowNumber = -1;
  15007. var columnNumber = -1;
  15008. var totalColumnsNumber = 0;
  15009. for (var i = 0; i < rows.length; i++) {
  15010. if (rows[i].nodeType != this._nodeTypes.element) {
  15011. continue;
  15012. }
  15013. if (rows[i].nodeName != "Row") {
  15014. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  15015. }
  15016. rowNumber += 1;
  15017. columns = rows[i].children;
  15018. if (!rows[i].attributes.getNamedItem("height")) {
  15019. throw "XmlLoader Exception : Height must be defined for grid rows";
  15020. }
  15021. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  15022. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  15023. guiNode.addRowDefinition(height, isPixel);
  15024. for (var j = 0; j < columns.length; j++) {
  15025. if (columns[j].nodeType != this._nodeTypes.element) {
  15026. continue;
  15027. }
  15028. if (columns[j].nodeName != "Column") {
  15029. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  15030. }
  15031. columnNumber += 1;
  15032. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  15033. 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.";
  15034. }
  15035. if (rowNumber == 0) {
  15036. if (!columns[j].attributes.getNamedItem("width")) {
  15037. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  15038. }
  15039. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  15040. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  15041. guiNode.addColumnDefinition(width, isPixel);
  15042. }
  15043. cells = columns[j].children;
  15044. for (var k = 0; k < cells.length; k++) {
  15045. if (cells[k].nodeType != this._nodeTypes.element) {
  15046. continue;
  15047. }
  15048. cellNode = this._createGuiElement(cells[k], guiNode, false);
  15049. guiNode.addControl(cellNode, rowNumber, columnNumber);
  15050. if (cells[k].firstChild) {
  15051. this._parseXml(cells[k].firstChild, cellNode);
  15052. }
  15053. }
  15054. }
  15055. if (rowNumber == 0) {
  15056. totalColumnsNumber = columnNumber;
  15057. }
  15058. columnNumber = -1;
  15059. }
  15060. if (node.nextSibling) {
  15061. this._parseXml(node.nextSibling, parent);
  15062. }
  15063. };
  15064. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  15065. if (node.firstChild) {
  15066. this._parseXml(node.firstChild, guiNode);
  15067. }
  15068. if (node.nextSibling) {
  15069. this._parseXml(node.nextSibling, parent);
  15070. }
  15071. };
  15072. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  15073. if (this._parentClass) {
  15074. this._parentClass[variable] = source[iterator];
  15075. }
  15076. else {
  15077. window[variable] = source[iterator];
  15078. }
  15079. if (node.firstChild) {
  15080. this._parseXml(node.firstChild, guiNode, true);
  15081. }
  15082. };
  15083. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  15084. var dataSource = node.attributes.getNamedItem("dataSource").value;
  15085. if (!dataSource.includes(" in ")) {
  15086. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  15087. }
  15088. else {
  15089. var isArray = true;
  15090. var splittedSource = dataSource.split(" in ");
  15091. if (splittedSource.length < 2) {
  15092. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  15093. }
  15094. var source = splittedSource[1];
  15095. if (source.startsWith("{") && source.endsWith("}")) {
  15096. isArray = false;
  15097. }
  15098. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  15099. source = source.substring(1, source.length - 1);
  15100. }
  15101. if (this._parentClass) {
  15102. source = this._parentClass[source];
  15103. }
  15104. else {
  15105. source = window[source];
  15106. }
  15107. if (isArray) {
  15108. for (var i = 0; i < source.length; i++) {
  15109. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  15110. }
  15111. }
  15112. else {
  15113. for (var i in source) {
  15114. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  15115. }
  15116. }
  15117. if (node.nextSibling) {
  15118. this._parseXml(node.nextSibling, parent);
  15119. }
  15120. }
  15121. };
  15122. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  15123. if (generated === void 0) { generated = false; }
  15124. if (node.nodeType != this._nodeTypes.element) {
  15125. if (node.nextSibling) {
  15126. this._parseXml(node.nextSibling, parent, generated);
  15127. }
  15128. return;
  15129. }
  15130. if (generated) {
  15131. node.setAttribute("id", parent.id + (parent._children.length + 1));
  15132. }
  15133. var guiNode = this._createGuiElement(node, parent);
  15134. if (node.nodeName == "Grid") {
  15135. this._parseGrid(node, guiNode, parent);
  15136. }
  15137. else if (!node.attributes.getNamedItem("dataSource")) {
  15138. this._parseElement(node, guiNode, parent);
  15139. }
  15140. else {
  15141. this._parseElementsFromSource(node, guiNode, parent);
  15142. }
  15143. };
  15144. /**
  15145. * Gets if the loading has finished.
  15146. * @returns whether the loading has finished or not
  15147. */
  15148. XmlLoader.prototype.isLoaded = function () {
  15149. return this._isLoaded;
  15150. };
  15151. /**
  15152. * Gets a loaded node / control by id.
  15153. * @param id the Controls id set in the xml
  15154. * @returns element of type Control
  15155. */
  15156. XmlLoader.prototype.getNodeById = function (id) {
  15157. return this._nodes[id];
  15158. };
  15159. /**
  15160. * Gets all loaded nodes / controls
  15161. * @returns Array of controls
  15162. */
  15163. XmlLoader.prototype.getNodes = function () {
  15164. return this._nodes;
  15165. };
  15166. /**
  15167. * Initiates the xml layout loading
  15168. * @param xmlFile defines the xml layout to load
  15169. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  15170. * @param callback defines the callback called on layout load.
  15171. */
  15172. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  15173. var xhttp = new XMLHttpRequest();
  15174. xhttp.onreadystatechange = function () {
  15175. if (xhttp.readyState == 4 && xhttp.status == 200) {
  15176. if (!xhttp.responseXML) {
  15177. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  15178. }
  15179. var xmlDoc = xhttp.responseXML.documentElement;
  15180. this._parseXml(xmlDoc.firstChild, rootNode);
  15181. this._isLoaded = true;
  15182. if (callback) {
  15183. callback();
  15184. }
  15185. }
  15186. }.bind(this);
  15187. xhttp.open("GET", xmlFile, true);
  15188. xhttp.send();
  15189. };
  15190. return XmlLoader;
  15191. }());
  15192. /***/ }),
  15193. /***/ "./3D/controls/abstractButton3D.ts":
  15194. /*!*****************************************!*\
  15195. !*** ./3D/controls/abstractButton3D.ts ***!
  15196. \*****************************************/
  15197. /*! exports provided: AbstractButton3D */
  15198. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15199. "use strict";
  15200. __webpack_require__.r(__webpack_exports__);
  15201. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  15202. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15203. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  15204. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  15205. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  15206. /**
  15207. * Class used as a root to all buttons
  15208. */
  15209. var AbstractButton3D = /** @class */ (function (_super) {
  15210. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  15211. /**
  15212. * Creates a new button
  15213. * @param name defines the control name
  15214. */
  15215. function AbstractButton3D(name) {
  15216. return _super.call(this, name) || this;
  15217. }
  15218. AbstractButton3D.prototype._getTypeName = function () {
  15219. return "AbstractButton3D";
  15220. };
  15221. // Mesh association
  15222. AbstractButton3D.prototype._createNode = function (scene) {
  15223. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  15224. };
  15225. return AbstractButton3D;
  15226. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  15227. /***/ }),
  15228. /***/ "./3D/controls/button3D.ts":
  15229. /*!*********************************!*\
  15230. !*** ./3D/controls/button3D.ts ***!
  15231. \*********************************/
  15232. /*! exports provided: Button3D */
  15233. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15234. "use strict";
  15235. __webpack_require__.r(__webpack_exports__);
  15236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  15237. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15238. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  15239. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  15240. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  15241. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  15242. /**
  15243. * Class used to create a button in 3D
  15244. */
  15245. var Button3D = /** @class */ (function (_super) {
  15246. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  15247. /**
  15248. * Creates a new button
  15249. * @param name defines the control name
  15250. */
  15251. function Button3D(name) {
  15252. var _this = _super.call(this, name) || this;
  15253. _this._contentResolution = 512;
  15254. _this._contentScaleRatio = 2;
  15255. // Default animations
  15256. _this.pointerEnterAnimation = function () {
  15257. if (!_this.mesh) {
  15258. return;
  15259. }
  15260. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  15261. };
  15262. _this.pointerOutAnimation = function () {
  15263. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  15264. };
  15265. _this.pointerDownAnimation = function () {
  15266. if (!_this.mesh) {
  15267. return;
  15268. }
  15269. _this.mesh.scaling.scaleInPlace(0.95);
  15270. };
  15271. _this.pointerUpAnimation = function () {
  15272. if (!_this.mesh) {
  15273. return;
  15274. }
  15275. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  15276. };
  15277. return _this;
  15278. }
  15279. Object.defineProperty(Button3D.prototype, "contentResolution", {
  15280. /**
  15281. * Gets or sets the texture resolution used to render content (512 by default)
  15282. */
  15283. get: function () {
  15284. return this._contentResolution;
  15285. },
  15286. set: function (value) {
  15287. if (this._contentResolution === value) {
  15288. return;
  15289. }
  15290. this._contentResolution = value;
  15291. this._resetContent();
  15292. },
  15293. enumerable: false,
  15294. configurable: true
  15295. });
  15296. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  15297. /**
  15298. * Gets or sets the texture scale ratio used to render content (2 by default)
  15299. */
  15300. get: function () {
  15301. return this._contentScaleRatio;
  15302. },
  15303. set: function (value) {
  15304. if (this._contentScaleRatio === value) {
  15305. return;
  15306. }
  15307. this._contentScaleRatio = value;
  15308. this._resetContent();
  15309. },
  15310. enumerable: false,
  15311. configurable: true
  15312. });
  15313. Button3D.prototype._disposeFacadeTexture = function () {
  15314. if (this._facadeTexture) {
  15315. this._facadeTexture.dispose();
  15316. this._facadeTexture = null;
  15317. }
  15318. };
  15319. Button3D.prototype._resetContent = function () {
  15320. this._disposeFacadeTexture();
  15321. this.content = this._content;
  15322. };
  15323. Object.defineProperty(Button3D.prototype, "content", {
  15324. /**
  15325. * Gets or sets the GUI 2D content used to display the button's facade
  15326. */
  15327. get: function () {
  15328. return this._content;
  15329. },
  15330. set: function (value) {
  15331. this._content = value;
  15332. if (!this._host || !this._host.utilityLayer) {
  15333. return;
  15334. }
  15335. if (!this._facadeTexture) {
  15336. this._facadeTexture = new _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__["AdvancedDynamicTexture"]("Facade", this._contentResolution, this._contentResolution, this._host.utilityLayer.utilityLayerScene, true, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  15337. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  15338. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  15339. this._facadeTexture.premulAlpha = true;
  15340. }
  15341. else {
  15342. this._facadeTexture.rootContainer.clearControls();
  15343. }
  15344. this._facadeTexture.addControl(value);
  15345. this._applyFacade(this._facadeTexture);
  15346. },
  15347. enumerable: false,
  15348. configurable: true
  15349. });
  15350. /**
  15351. * Apply the facade texture (created from the content property).
  15352. * This function can be overloaded by child classes
  15353. * @param facadeTexture defines the AdvancedDynamicTexture to use
  15354. */
  15355. Button3D.prototype._applyFacade = function (facadeTexture) {
  15356. this._currentMaterial.emissiveTexture = facadeTexture;
  15357. };
  15358. Button3D.prototype._getTypeName = function () {
  15359. return "Button3D";
  15360. };
  15361. // Mesh association
  15362. Button3D.prototype._createNode = function (scene) {
  15363. var faceUV = new Array(6);
  15364. for (var i = 0; i < 6; i++) {
  15365. faceUV[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  15366. }
  15367. faceUV[1] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  15368. var mesh = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  15369. width: 1.0,
  15370. height: 1.0,
  15371. depth: 0.08,
  15372. faceUV: faceUV
  15373. }, scene);
  15374. return mesh;
  15375. };
  15376. Button3D.prototype._affectMaterial = function (mesh) {
  15377. var material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  15378. material.specularColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  15379. mesh.material = material;
  15380. this._currentMaterial = material;
  15381. this._resetContent();
  15382. };
  15383. /**
  15384. * Releases all associated resources
  15385. */
  15386. Button3D.prototype.dispose = function () {
  15387. _super.prototype.dispose.call(this);
  15388. this._disposeFacadeTexture();
  15389. if (this._currentMaterial) {
  15390. this._currentMaterial.dispose();
  15391. }
  15392. };
  15393. return Button3D;
  15394. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  15395. /***/ }),
  15396. /***/ "./3D/controls/container3D.ts":
  15397. /*!************************************!*\
  15398. !*** ./3D/controls/container3D.ts ***!
  15399. \************************************/
  15400. /*! exports provided: Container3D */
  15401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15402. "use strict";
  15403. __webpack_require__.r(__webpack_exports__);
  15404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  15405. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15406. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  15407. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  15408. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  15409. /**
  15410. * Class used to create containers for controls
  15411. */
  15412. var Container3D = /** @class */ (function (_super) {
  15413. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  15414. /**
  15415. * Creates a new container
  15416. * @param name defines the container name
  15417. */
  15418. function Container3D(name) {
  15419. var _this = _super.call(this, name) || this;
  15420. _this._blockLayout = false;
  15421. /**
  15422. * Gets the list of child controls
  15423. */
  15424. _this._children = new Array();
  15425. return _this;
  15426. }
  15427. Object.defineProperty(Container3D.prototype, "children", {
  15428. /**
  15429. * Gets the list of child controls
  15430. */
  15431. get: function () {
  15432. return this._children;
  15433. },
  15434. enumerable: false,
  15435. configurable: true
  15436. });
  15437. Object.defineProperty(Container3D.prototype, "blockLayout", {
  15438. /**
  15439. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  15440. * This is helpful to optimize layout operation when adding multiple children in a row
  15441. */
  15442. get: function () {
  15443. return this._blockLayout;
  15444. },
  15445. set: function (value) {
  15446. if (this._blockLayout === value) {
  15447. return;
  15448. }
  15449. this._blockLayout = value;
  15450. if (!this._blockLayout) {
  15451. this._arrangeChildren();
  15452. }
  15453. },
  15454. enumerable: false,
  15455. configurable: true
  15456. });
  15457. /**
  15458. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  15459. * @returns the current container
  15460. */
  15461. Container3D.prototype.updateLayout = function () {
  15462. this._arrangeChildren();
  15463. return this;
  15464. };
  15465. /**
  15466. * Gets a boolean indicating if the given control is in the children of this control
  15467. * @param control defines the control to check
  15468. * @returns true if the control is in the child list
  15469. */
  15470. Container3D.prototype.containsControl = function (control) {
  15471. return this._children.indexOf(control) !== -1;
  15472. };
  15473. /**
  15474. * Adds a control to the children of this control
  15475. * @param control defines the control to add
  15476. * @returns the current container
  15477. */
  15478. Container3D.prototype.addControl = function (control) {
  15479. var index = this._children.indexOf(control);
  15480. if (index !== -1) {
  15481. return this;
  15482. }
  15483. control.parent = this;
  15484. control._host = this._host;
  15485. this._children.push(control);
  15486. if (this._host.utilityLayer) {
  15487. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  15488. if (control.node) {
  15489. control.node.parent = this.node;
  15490. }
  15491. if (!this.blockLayout) {
  15492. this._arrangeChildren();
  15493. }
  15494. }
  15495. return this;
  15496. };
  15497. /**
  15498. * This function will be called everytime a new control is added
  15499. */
  15500. Container3D.prototype._arrangeChildren = function () {
  15501. };
  15502. Container3D.prototype._createNode = function (scene) {
  15503. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  15504. };
  15505. /**
  15506. * Removes a control from the children of this control
  15507. * @param control defines the control to remove
  15508. * @returns the current container
  15509. */
  15510. Container3D.prototype.removeControl = function (control) {
  15511. var index = this._children.indexOf(control);
  15512. if (index !== -1) {
  15513. this._children.splice(index, 1);
  15514. control.parent = null;
  15515. control._disposeNode();
  15516. }
  15517. return this;
  15518. };
  15519. Container3D.prototype._getTypeName = function () {
  15520. return "Container3D";
  15521. };
  15522. /**
  15523. * Releases all associated resources
  15524. */
  15525. Container3D.prototype.dispose = function () {
  15526. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15527. var control = _a[_i];
  15528. control.dispose();
  15529. }
  15530. this._children = [];
  15531. _super.prototype.dispose.call(this);
  15532. };
  15533. /** Control rotation will remain unchanged */
  15534. Container3D.UNSET_ORIENTATION = 0;
  15535. /** Control will rotate to make it look at sphere central axis */
  15536. Container3D.FACEORIGIN_ORIENTATION = 1;
  15537. /** Control will rotate to make it look back at sphere central axis */
  15538. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  15539. /** Control will rotate to look at z axis (0, 0, 1) */
  15540. Container3D.FACEFORWARD_ORIENTATION = 3;
  15541. /** Control will rotate to look at negative z axis (0, 0, -1) */
  15542. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  15543. return Container3D;
  15544. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  15545. /***/ }),
  15546. /***/ "./3D/controls/control3D.ts":
  15547. /*!**********************************!*\
  15548. !*** ./3D/controls/control3D.ts ***!
  15549. \**********************************/
  15550. /*! exports provided: Control3D */
  15551. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15552. "use strict";
  15553. __webpack_require__.r(__webpack_exports__);
  15554. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  15555. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  15556. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15557. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  15558. /**
  15559. * Class used as base class for controls
  15560. */
  15561. var Control3D = /** @class */ (function () {
  15562. /**
  15563. * Creates a new control
  15564. * @param name defines the control name
  15565. */
  15566. function Control3D(
  15567. /** Defines the control name */
  15568. name) {
  15569. this.name = name;
  15570. this._downCount = 0;
  15571. this._enterCount = -1;
  15572. this._downPointerIds = {};
  15573. this._isVisible = true;
  15574. /**
  15575. * An event triggered when the pointer move over the control
  15576. */
  15577. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15578. /**
  15579. * An event triggered when the pointer move out of the control
  15580. */
  15581. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15582. /**
  15583. * An event triggered when the pointer taps the control
  15584. */
  15585. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15586. /**
  15587. * An event triggered when pointer is up
  15588. */
  15589. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15590. /**
  15591. * An event triggered when a control is clicked on (with a mouse)
  15592. */
  15593. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15594. /**
  15595. * An event triggered when pointer enters the control
  15596. */
  15597. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15598. // Behaviors
  15599. this._behaviors = new Array();
  15600. }
  15601. Object.defineProperty(Control3D.prototype, "position", {
  15602. /** Gets or sets the control position in world space */
  15603. get: function () {
  15604. if (!this._node) {
  15605. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  15606. }
  15607. return this._node.position;
  15608. },
  15609. set: function (value) {
  15610. if (!this._node) {
  15611. return;
  15612. }
  15613. this._node.position = value;
  15614. },
  15615. enumerable: false,
  15616. configurable: true
  15617. });
  15618. Object.defineProperty(Control3D.prototype, "scaling", {
  15619. /** Gets or sets the control scaling in world space */
  15620. get: function () {
  15621. if (!this._node) {
  15622. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  15623. }
  15624. return this._node.scaling;
  15625. },
  15626. set: function (value) {
  15627. if (!this._node) {
  15628. return;
  15629. }
  15630. this._node.scaling = value;
  15631. },
  15632. enumerable: false,
  15633. configurable: true
  15634. });
  15635. Object.defineProperty(Control3D.prototype, "behaviors", {
  15636. /**
  15637. * Gets the list of attached behaviors
  15638. * @see https://doc.babylonjs.com/features/behaviour
  15639. */
  15640. get: function () {
  15641. return this._behaviors;
  15642. },
  15643. enumerable: false,
  15644. configurable: true
  15645. });
  15646. /**
  15647. * Attach a behavior to the control
  15648. * @see https://doc.babylonjs.com/features/behaviour
  15649. * @param behavior defines the behavior to attach
  15650. * @returns the current control
  15651. */
  15652. Control3D.prototype.addBehavior = function (behavior) {
  15653. var _this = this;
  15654. var index = this._behaviors.indexOf(behavior);
  15655. if (index !== -1) {
  15656. return this;
  15657. }
  15658. behavior.init();
  15659. var scene = this._host.scene;
  15660. if (scene.isLoading) {
  15661. // We defer the attach when the scene will be loaded
  15662. scene.onDataLoadedObservable.addOnce(function () {
  15663. behavior.attach(_this);
  15664. });
  15665. }
  15666. else {
  15667. behavior.attach(this);
  15668. }
  15669. this._behaviors.push(behavior);
  15670. return this;
  15671. };
  15672. /**
  15673. * Remove an attached behavior
  15674. * @see https://doc.babylonjs.com/features/behaviour
  15675. * @param behavior defines the behavior to attach
  15676. * @returns the current control
  15677. */
  15678. Control3D.prototype.removeBehavior = function (behavior) {
  15679. var index = this._behaviors.indexOf(behavior);
  15680. if (index === -1) {
  15681. return this;
  15682. }
  15683. this._behaviors[index].detach();
  15684. this._behaviors.splice(index, 1);
  15685. return this;
  15686. };
  15687. /**
  15688. * Gets an attached behavior by name
  15689. * @param name defines the name of the behavior to look for
  15690. * @see https://doc.babylonjs.com/features/behaviour
  15691. * @returns null if behavior was not found else the requested behavior
  15692. */
  15693. Control3D.prototype.getBehaviorByName = function (name) {
  15694. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  15695. var behavior = _a[_i];
  15696. if (behavior.name === name) {
  15697. return behavior;
  15698. }
  15699. }
  15700. return null;
  15701. };
  15702. Object.defineProperty(Control3D.prototype, "isVisible", {
  15703. /** Gets or sets a boolean indicating if the control is visible */
  15704. get: function () {
  15705. return this._isVisible;
  15706. },
  15707. set: function (value) {
  15708. if (this._isVisible === value) {
  15709. return;
  15710. }
  15711. this._isVisible = value;
  15712. var mesh = this.mesh;
  15713. if (mesh) {
  15714. mesh.setEnabled(value);
  15715. }
  15716. },
  15717. enumerable: false,
  15718. configurable: true
  15719. });
  15720. Object.defineProperty(Control3D.prototype, "typeName", {
  15721. /**
  15722. * Gets a string representing the class name
  15723. */
  15724. get: function () {
  15725. return this._getTypeName();
  15726. },
  15727. enumerable: false,
  15728. configurable: true
  15729. });
  15730. /**
  15731. * Get the current class name of the control.
  15732. * @returns current class name
  15733. */
  15734. Control3D.prototype.getClassName = function () {
  15735. return this._getTypeName();
  15736. };
  15737. Control3D.prototype._getTypeName = function () {
  15738. return "Control3D";
  15739. };
  15740. Object.defineProperty(Control3D.prototype, "node", {
  15741. /**
  15742. * Gets the transform node used by this control
  15743. */
  15744. get: function () {
  15745. return this._node;
  15746. },
  15747. enumerable: false,
  15748. configurable: true
  15749. });
  15750. Object.defineProperty(Control3D.prototype, "mesh", {
  15751. /**
  15752. * Gets the mesh used to render this control
  15753. */
  15754. get: function () {
  15755. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  15756. return this._node;
  15757. }
  15758. return null;
  15759. },
  15760. enumerable: false,
  15761. configurable: true
  15762. });
  15763. /**
  15764. * Link the control as child of the given node
  15765. * @param node defines the node to link to. Use null to unlink the control
  15766. * @returns the current control
  15767. */
  15768. Control3D.prototype.linkToTransformNode = function (node) {
  15769. if (this._node) {
  15770. this._node.parent = node;
  15771. }
  15772. return this;
  15773. };
  15774. /** @hidden **/
  15775. Control3D.prototype._prepareNode = function (scene) {
  15776. if (!this._node) {
  15777. this._node = this._createNode(scene);
  15778. if (!this.node) {
  15779. return;
  15780. }
  15781. this._injectGUI3DMetadata(this._node).control = this; // Store the control on the metadata field in order to get it when picking
  15782. this._node.position = this.position;
  15783. this._node.scaling = this.scaling;
  15784. var mesh = this.mesh;
  15785. if (mesh) {
  15786. mesh.isPickable = true;
  15787. this._affectMaterial(mesh);
  15788. }
  15789. }
  15790. };
  15791. Control3D.prototype._injectGUI3DMetadata = function (node) {
  15792. var _a, _b;
  15793. node.metadata = (_a = node.metadata) !== null && _a !== void 0 ? _a : {};
  15794. node.metadata.GUI3D = (_b = node.metadata.GUI3D) !== null && _b !== void 0 ? _b : {};
  15795. return node.metadata.GUI3D;
  15796. };
  15797. /**
  15798. * Node creation.
  15799. * Can be overriden by children
  15800. * @param scene defines the scene where the node must be attached
  15801. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  15802. */
  15803. Control3D.prototype._createNode = function (scene) {
  15804. // Do nothing by default
  15805. return null;
  15806. };
  15807. /**
  15808. * Affect a material to the given mesh
  15809. * @param mesh defines the mesh which will represent the control
  15810. */
  15811. Control3D.prototype._affectMaterial = function (mesh) {
  15812. mesh.material = null;
  15813. };
  15814. // Pointers
  15815. /** @hidden */
  15816. Control3D.prototype._onPointerMove = function (target, coordinates) {
  15817. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  15818. };
  15819. /** @hidden */
  15820. Control3D.prototype._onPointerEnter = function (target) {
  15821. if (this._enterCount > 0) {
  15822. return false;
  15823. }
  15824. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  15825. this._enterCount = 0;
  15826. }
  15827. this._enterCount++;
  15828. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  15829. if (this.pointerEnterAnimation) {
  15830. this.pointerEnterAnimation();
  15831. }
  15832. return true;
  15833. };
  15834. /** @hidden */
  15835. Control3D.prototype._onPointerOut = function (target) {
  15836. this._enterCount = 0;
  15837. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  15838. if (this.pointerOutAnimation) {
  15839. this.pointerOutAnimation();
  15840. }
  15841. };
  15842. /** @hidden */
  15843. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  15844. if (this._downCount !== 0) {
  15845. this._downCount++;
  15846. return false;
  15847. }
  15848. this._downCount++;
  15849. this._downPointerIds[pointerId] = true;
  15850. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  15851. if (this.pointerDownAnimation) {
  15852. this.pointerDownAnimation();
  15853. }
  15854. return true;
  15855. };
  15856. /** @hidden */
  15857. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  15858. this._downCount--;
  15859. delete this._downPointerIds[pointerId];
  15860. if (this._downCount < 0) {
  15861. // Handle if forcePointerUp was called prior to this
  15862. this._downCount = 0;
  15863. return;
  15864. }
  15865. if (this._downCount == 0) {
  15866. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  15867. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  15868. }
  15869. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  15870. if (this.pointerUpAnimation) {
  15871. this.pointerUpAnimation();
  15872. }
  15873. }
  15874. };
  15875. /** @hidden */
  15876. Control3D.prototype.forcePointerUp = function (pointerId) {
  15877. if (pointerId === void 0) { pointerId = null; }
  15878. if (pointerId !== null) {
  15879. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  15880. }
  15881. else {
  15882. for (var key in this._downPointerIds) {
  15883. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  15884. }
  15885. if (this._downCount > 0) {
  15886. this._downCount = 1;
  15887. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  15888. }
  15889. }
  15890. };
  15891. /** @hidden */
  15892. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  15893. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15894. this._onPointerMove(this, pickedPoint);
  15895. var previousControlOver = this._host._lastControlOver[pointerId];
  15896. if (previousControlOver && previousControlOver !== this) {
  15897. previousControlOver._onPointerOut(this);
  15898. }
  15899. if (previousControlOver !== this) {
  15900. this._onPointerEnter(this);
  15901. }
  15902. this._host._lastControlOver[pointerId] = this;
  15903. return true;
  15904. }
  15905. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  15906. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  15907. this._host._lastControlDown[pointerId] = this;
  15908. this._host._lastPickedControl = this;
  15909. return true;
  15910. }
  15911. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP || type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP) {
  15912. if (this._host._lastControlDown[pointerId]) {
  15913. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  15914. }
  15915. delete this._host._lastControlDown[pointerId];
  15916. return true;
  15917. }
  15918. return false;
  15919. };
  15920. /** @hidden */
  15921. Control3D.prototype._disposeNode = function () {
  15922. if (this._node) {
  15923. this._node.dispose();
  15924. this._node = null;
  15925. }
  15926. };
  15927. /**
  15928. * Releases all associated resources
  15929. */
  15930. Control3D.prototype.dispose = function () {
  15931. this.onPointerDownObservable.clear();
  15932. this.onPointerEnterObservable.clear();
  15933. this.onPointerMoveObservable.clear();
  15934. this.onPointerOutObservable.clear();
  15935. this.onPointerUpObservable.clear();
  15936. this.onPointerClickObservable.clear();
  15937. this._disposeNode();
  15938. // Behaviors
  15939. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  15940. var behavior = _a[_i];
  15941. behavior.detach();
  15942. }
  15943. };
  15944. return Control3D;
  15945. }());
  15946. /***/ }),
  15947. /***/ "./3D/controls/cylinderPanel.ts":
  15948. /*!**************************************!*\
  15949. !*** ./3D/controls/cylinderPanel.ts ***!
  15950. \**************************************/
  15951. /*! exports provided: CylinderPanel */
  15952. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15953. "use strict";
  15954. __webpack_require__.r(__webpack_exports__);
  15955. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  15956. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15957. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15958. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15959. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15960. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15961. /**
  15962. * Class used to create a container panel deployed on the surface of a cylinder
  15963. */
  15964. var CylinderPanel = /** @class */ (function (_super) {
  15965. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  15966. function CylinderPanel() {
  15967. var _this = _super !== null && _super.apply(this, arguments) || this;
  15968. _this._radius = 5.0;
  15969. return _this;
  15970. }
  15971. Object.defineProperty(CylinderPanel.prototype, "radius", {
  15972. /**
  15973. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  15974. */
  15975. get: function () {
  15976. return this._radius;
  15977. },
  15978. set: function (value) {
  15979. var _this = this;
  15980. if (this._radius === value) {
  15981. return;
  15982. }
  15983. this._radius = value;
  15984. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15985. _this._arrangeChildren();
  15986. });
  15987. },
  15988. enumerable: false,
  15989. configurable: true
  15990. });
  15991. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  15992. var mesh = control.mesh;
  15993. if (!mesh) {
  15994. return;
  15995. }
  15996. var newPos = this._cylindricalMapping(nodePosition);
  15997. control.position = newPos;
  15998. switch (this.orientation) {
  15999. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  16000. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  16001. break;
  16002. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  16003. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  16004. break;
  16005. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  16006. break;
  16007. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  16008. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  16009. break;
  16010. }
  16011. };
  16012. CylinderPanel.prototype._cylindricalMapping = function (source) {
  16013. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  16014. var yAngle = (source.x / this._radius);
  16015. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16016. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16017. };
  16018. return CylinderPanel;
  16019. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  16020. /***/ }),
  16021. /***/ "./3D/controls/holographicButton.ts":
  16022. /*!******************************************!*\
  16023. !*** ./3D/controls/holographicButton.ts ***!
  16024. \******************************************/
  16025. /*! exports provided: HolographicButton */
  16026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16027. "use strict";
  16028. __webpack_require__.r(__webpack_exports__);
  16029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  16030. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16031. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  16032. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Materials/standardMaterial */ "babylonjs/Misc/perfCounter");
  16033. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__);
  16034. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  16035. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  16036. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  16037. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  16038. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  16039. /**
  16040. * Class used to create a holographic button in 3D
  16041. */
  16042. var HolographicButton = /** @class */ (function (_super) {
  16043. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  16044. /**
  16045. * Creates a new button
  16046. * @param name defines the control name
  16047. */
  16048. function HolographicButton(name, shareMaterials) {
  16049. if (shareMaterials === void 0) { shareMaterials = true; }
  16050. var _this = _super.call(this, name) || this;
  16051. _this._shareMaterials = true;
  16052. _this._shareMaterials = shareMaterials;
  16053. // Default animations
  16054. _this.pointerEnterAnimation = function () {
  16055. if (!_this.mesh) {
  16056. return;
  16057. }
  16058. _this._frontPlate.setEnabled(true);
  16059. };
  16060. _this.pointerOutAnimation = function () {
  16061. if (!_this.mesh) {
  16062. return;
  16063. }
  16064. _this._frontPlate.setEnabled(false);
  16065. };
  16066. return _this;
  16067. }
  16068. HolographicButton.prototype._disposeTooltip = function () {
  16069. this._tooltipFade = null;
  16070. if (this._tooltipTextBlock) {
  16071. this._tooltipTextBlock.dispose();
  16072. }
  16073. if (this._tooltipTexture) {
  16074. this._tooltipTexture.dispose();
  16075. }
  16076. if (this._tooltipMesh) {
  16077. this._tooltipMesh.dispose();
  16078. }
  16079. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  16080. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  16081. };
  16082. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  16083. get: function () {
  16084. return this._backPlate.renderingGroupId;
  16085. },
  16086. /**
  16087. * Rendering ground id of all the mesh in the button
  16088. */
  16089. set: function (id) {
  16090. this._backPlate.renderingGroupId = id;
  16091. this._textPlate.renderingGroupId = id;
  16092. this._frontPlate.renderingGroupId = id;
  16093. if (this._tooltipMesh) {
  16094. this._tooltipMesh.renderingGroupId = id;
  16095. }
  16096. },
  16097. enumerable: false,
  16098. configurable: true
  16099. });
  16100. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  16101. get: function () {
  16102. if (this._tooltipTextBlock) {
  16103. return this._tooltipTextBlock.text;
  16104. }
  16105. return null;
  16106. },
  16107. /**
  16108. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  16109. */
  16110. set: function (text) {
  16111. var _this = this;
  16112. if (!text) {
  16113. this._disposeTooltip();
  16114. return;
  16115. }
  16116. if (!this._tooltipFade) {
  16117. // Create tooltip with mesh and text
  16118. this._tooltipMesh = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  16119. var tooltipBackground = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1, sideOrientation: babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Mesh"].DOUBLESIDE }, this._backPlate._scene);
  16120. var mat = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  16121. mat.diffuseColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  16122. tooltipBackground.material = mat;
  16123. tooltipBackground.isPickable = false;
  16124. this._tooltipMesh.addChild(tooltipBackground);
  16125. tooltipBackground.position.z = 0.05;
  16126. this._tooltipMesh.scaling.y = 1 / 3;
  16127. this._tooltipMesh.position.y = 0.7;
  16128. this._tooltipMesh.position.z = -0.15;
  16129. this._tooltipMesh.isPickable = false;
  16130. this._tooltipMesh.parent = this._backPlate;
  16131. // Create text texture for the tooltip
  16132. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  16133. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  16134. this._tooltipTextBlock.scaleY = 3;
  16135. this._tooltipTextBlock.color = "white";
  16136. this._tooltipTextBlock.fontSize = 130;
  16137. this._tooltipTexture.addControl(this._tooltipTextBlock);
  16138. // Add hover action to tooltip
  16139. this._tooltipFade = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  16140. this._tooltipFade.delay = 500;
  16141. this._tooltipMesh.addBehavior(this._tooltipFade);
  16142. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  16143. if (_this._tooltipFade) {
  16144. _this._tooltipFade.fadeIn(true);
  16145. }
  16146. });
  16147. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  16148. if (_this._tooltipFade) {
  16149. _this._tooltipFade.fadeIn(false);
  16150. }
  16151. });
  16152. }
  16153. if (this._tooltipTextBlock) {
  16154. this._tooltipTextBlock.text = text;
  16155. }
  16156. },
  16157. enumerable: false,
  16158. configurable: true
  16159. });
  16160. Object.defineProperty(HolographicButton.prototype, "text", {
  16161. /**
  16162. * Gets or sets text for the button
  16163. */
  16164. get: function () {
  16165. return this._text;
  16166. },
  16167. set: function (value) {
  16168. if (this._text === value) {
  16169. return;
  16170. }
  16171. this._text = value;
  16172. this._rebuildContent();
  16173. },
  16174. enumerable: false,
  16175. configurable: true
  16176. });
  16177. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  16178. /**
  16179. * Gets or sets the image url for the button
  16180. */
  16181. get: function () {
  16182. return this._imageUrl;
  16183. },
  16184. set: function (value) {
  16185. if (this._imageUrl === value) {
  16186. return;
  16187. }
  16188. this._imageUrl = value;
  16189. this._rebuildContent();
  16190. },
  16191. enumerable: false,
  16192. configurable: true
  16193. });
  16194. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  16195. /**
  16196. * Gets the back material used by this button
  16197. */
  16198. get: function () {
  16199. return this._backMaterial;
  16200. },
  16201. enumerable: false,
  16202. configurable: true
  16203. });
  16204. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  16205. /**
  16206. * Gets the front material used by this button
  16207. */
  16208. get: function () {
  16209. return this._frontMaterial;
  16210. },
  16211. enumerable: false,
  16212. configurable: true
  16213. });
  16214. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  16215. /**
  16216. * Gets the plate material used by this button
  16217. */
  16218. get: function () {
  16219. return this._plateMaterial;
  16220. },
  16221. enumerable: false,
  16222. configurable: true
  16223. });
  16224. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  16225. /**
  16226. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  16227. */
  16228. get: function () {
  16229. return this._shareMaterials;
  16230. },
  16231. enumerable: false,
  16232. configurable: true
  16233. });
  16234. HolographicButton.prototype._getTypeName = function () {
  16235. return "HolographicButton";
  16236. };
  16237. HolographicButton.prototype._rebuildContent = function () {
  16238. this._disposeFacadeTexture();
  16239. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  16240. panel.isVertical = true;
  16241. if (this._imageUrl) {
  16242. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  16243. image.source = this._imageUrl;
  16244. image.paddingTop = "40px";
  16245. image.height = "180px";
  16246. image.width = "100px";
  16247. image.paddingBottom = "40px";
  16248. panel.addControl(image);
  16249. }
  16250. if (this._text) {
  16251. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  16252. text.text = this._text;
  16253. text.color = "white";
  16254. text.height = "30px";
  16255. text.fontSize = 24;
  16256. panel.addControl(text);
  16257. }
  16258. if (this._frontPlate) {
  16259. this.content = panel;
  16260. }
  16261. };
  16262. // Mesh association
  16263. HolographicButton.prototype._createNode = function (scene) {
  16264. this._backPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  16265. width: 1.0,
  16266. height: 1.0,
  16267. depth: 0.08
  16268. }, scene);
  16269. this._frontPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  16270. width: 1.0,
  16271. height: 1.0,
  16272. depth: 0.08
  16273. }, scene);
  16274. this._frontPlate.parent = this._backPlate;
  16275. this._frontPlate.position.z = -0.08;
  16276. this._frontPlate.isPickable = false;
  16277. this._frontPlate.setEnabled(false);
  16278. this._textPlate = _super.prototype._createNode.call(this, scene);
  16279. this._textPlate.parent = this._backPlate;
  16280. this._textPlate.position.z = -0.08;
  16281. this._textPlate.isPickable = false;
  16282. return this._backPlate;
  16283. };
  16284. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  16285. this._plateMaterial.emissiveTexture = facadeTexture;
  16286. this._plateMaterial.opacityTexture = facadeTexture;
  16287. };
  16288. HolographicButton.prototype._createBackMaterial = function (mesh) {
  16289. var _this = this;
  16290. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  16291. this._backMaterial.renderHoverLight = true;
  16292. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  16293. if (pickedPoint) {
  16294. _this._backMaterial.hoverPosition = pickedPoint;
  16295. _this._backMaterial.hoverColor.a = 1.0;
  16296. }
  16297. else {
  16298. _this._backMaterial.hoverColor.a = 0;
  16299. }
  16300. });
  16301. };
  16302. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  16303. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  16304. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  16305. this._frontMaterial.alpha = 0.5; // Additive
  16306. this._frontMaterial.renderBorders = true;
  16307. };
  16308. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  16309. this._plateMaterial = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  16310. this._plateMaterial.specularColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  16311. };
  16312. HolographicButton.prototype._affectMaterial = function (mesh) {
  16313. // Back
  16314. if (this._shareMaterials) {
  16315. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  16316. this._createBackMaterial(mesh);
  16317. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  16318. }
  16319. else {
  16320. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  16321. }
  16322. // Front
  16323. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  16324. this._createFrontMaterial(mesh);
  16325. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  16326. }
  16327. else {
  16328. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  16329. }
  16330. }
  16331. else {
  16332. this._createBackMaterial(mesh);
  16333. this._createFrontMaterial(mesh);
  16334. }
  16335. this._createPlateMaterial(mesh);
  16336. this._backPlate.material = this._backMaterial;
  16337. this._frontPlate.material = this._frontMaterial;
  16338. this._textPlate.material = this._plateMaterial;
  16339. this._rebuildContent();
  16340. };
  16341. /**
  16342. * Releases all associated resources
  16343. */
  16344. HolographicButton.prototype.dispose = function () {
  16345. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  16346. this._disposeTooltip();
  16347. if (!this.shareMaterials) {
  16348. this._backMaterial.dispose();
  16349. this._frontMaterial.dispose();
  16350. this._plateMaterial.dispose();
  16351. if (this._pickedPointObserver) {
  16352. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  16353. this._pickedPointObserver = null;
  16354. }
  16355. }
  16356. };
  16357. return HolographicButton;
  16358. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  16359. /***/ }),
  16360. /***/ "./3D/controls/index.ts":
  16361. /*!******************************!*\
  16362. !*** ./3D/controls/index.ts ***!
  16363. \******************************/
  16364. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  16365. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16366. "use strict";
  16367. __webpack_require__.r(__webpack_exports__);
  16368. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  16369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16370. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  16371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  16372. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  16374. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  16375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  16376. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  16377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  16378. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  16379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  16380. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  16381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  16382. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  16383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  16384. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  16385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  16386. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  16387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  16388. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  16389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  16390. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  16391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  16392. /***/ }),
  16393. /***/ "./3D/controls/meshButton3D.ts":
  16394. /*!*************************************!*\
  16395. !*** ./3D/controls/meshButton3D.ts ***!
  16396. \*************************************/
  16397. /*! exports provided: MeshButton3D */
  16398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16399. "use strict";
  16400. __webpack_require__.r(__webpack_exports__);
  16401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  16402. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16403. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  16404. /**
  16405. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  16406. */
  16407. var MeshButton3D = /** @class */ (function (_super) {
  16408. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  16409. /**
  16410. * Creates a new 3D button based on a mesh
  16411. * @param mesh mesh to become a 3D button
  16412. * @param name defines the control name
  16413. */
  16414. function MeshButton3D(mesh, name) {
  16415. var _this = _super.call(this, name) || this;
  16416. _this._currentMesh = mesh;
  16417. /**
  16418. * Provides a default behavior on hover/out & up/down
  16419. * Override those function to create your own desired behavior specific to your mesh
  16420. */
  16421. _this.pointerEnterAnimation = function () {
  16422. if (!_this.mesh) {
  16423. return;
  16424. }
  16425. _this.mesh.scaling.scaleInPlace(1.1);
  16426. };
  16427. _this.pointerOutAnimation = function () {
  16428. if (!_this.mesh) {
  16429. return;
  16430. }
  16431. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  16432. };
  16433. _this.pointerDownAnimation = function () {
  16434. if (!_this.mesh) {
  16435. return;
  16436. }
  16437. _this.mesh.scaling.scaleInPlace(0.95);
  16438. };
  16439. _this.pointerUpAnimation = function () {
  16440. if (!_this.mesh) {
  16441. return;
  16442. }
  16443. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  16444. };
  16445. return _this;
  16446. }
  16447. MeshButton3D.prototype._getTypeName = function () {
  16448. return "MeshButton3D";
  16449. };
  16450. // Mesh association
  16451. MeshButton3D.prototype._createNode = function (scene) {
  16452. var _this = this;
  16453. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  16454. _this._injectGUI3DMetadata(mesh).control = _this;
  16455. });
  16456. return this._currentMesh;
  16457. };
  16458. MeshButton3D.prototype._affectMaterial = function (mesh) {
  16459. };
  16460. return MeshButton3D;
  16461. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  16462. /***/ }),
  16463. /***/ "./3D/controls/planePanel.ts":
  16464. /*!***********************************!*\
  16465. !*** ./3D/controls/planePanel.ts ***!
  16466. \***********************************/
  16467. /*! exports provided: PlanePanel */
  16468. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16469. "use strict";
  16470. __webpack_require__.r(__webpack_exports__);
  16471. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  16472. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16473. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  16474. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  16475. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16476. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  16477. /**
  16478. * Class used to create a container panel deployed on the surface of a plane
  16479. */
  16480. var PlanePanel = /** @class */ (function (_super) {
  16481. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  16482. function PlanePanel() {
  16483. return _super !== null && _super.apply(this, arguments) || this;
  16484. }
  16485. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  16486. var mesh = control.mesh;
  16487. if (!mesh) {
  16488. return;
  16489. }
  16490. control.position = nodePosition.clone();
  16491. var target = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  16492. target.copyFrom(nodePosition);
  16493. switch (this.orientation) {
  16494. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  16495. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  16496. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  16497. mesh.lookAt(target);
  16498. break;
  16499. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  16500. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  16501. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  16502. mesh.lookAt(target);
  16503. break;
  16504. }
  16505. };
  16506. return PlanePanel;
  16507. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  16508. /***/ }),
  16509. /***/ "./3D/controls/scatterPanel.ts":
  16510. /*!*************************************!*\
  16511. !*** ./3D/controls/scatterPanel.ts ***!
  16512. \*************************************/
  16513. /*! exports provided: ScatterPanel */
  16514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16515. "use strict";
  16516. __webpack_require__.r(__webpack_exports__);
  16517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  16518. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16519. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  16520. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  16521. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  16522. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16523. /**
  16524. * Class used to create a container panel where items get randomized planar mapping
  16525. */
  16526. var ScatterPanel = /** @class */ (function (_super) {
  16527. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  16528. function ScatterPanel() {
  16529. var _this = _super !== null && _super.apply(this, arguments) || this;
  16530. _this._iteration = 100.0;
  16531. return _this;
  16532. }
  16533. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  16534. /**
  16535. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  16536. */
  16537. get: function () {
  16538. return this._iteration;
  16539. },
  16540. set: function (value) {
  16541. var _this = this;
  16542. if (this._iteration === value) {
  16543. return;
  16544. }
  16545. this._iteration = value;
  16546. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16547. _this._arrangeChildren();
  16548. });
  16549. },
  16550. enumerable: false,
  16551. configurable: true
  16552. });
  16553. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  16554. var mesh = control.mesh;
  16555. var newPos = this._scatterMapping(nodePosition);
  16556. if (!mesh) {
  16557. return;
  16558. }
  16559. switch (this.orientation) {
  16560. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  16561. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  16562. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  16563. break;
  16564. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  16565. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  16566. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  16567. break;
  16568. }
  16569. control.position = newPos;
  16570. };
  16571. ScatterPanel.prototype._scatterMapping = function (source) {
  16572. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  16573. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  16574. return source;
  16575. };
  16576. ScatterPanel.prototype._finalProcessing = function () {
  16577. var meshes = [];
  16578. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  16579. var child = _a[_i];
  16580. if (!child.mesh) {
  16581. continue;
  16582. }
  16583. meshes.push(child.mesh);
  16584. }
  16585. for (var count = 0; count < this._iteration; count++) {
  16586. meshes.sort(function (a, b) {
  16587. var distance1 = a.position.lengthSquared();
  16588. var distance2 = b.position.lengthSquared();
  16589. if (distance1 < distance2) {
  16590. return 1;
  16591. }
  16592. else if (distance1 > distance2) {
  16593. return -1;
  16594. }
  16595. return 0;
  16596. });
  16597. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  16598. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  16599. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  16600. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  16601. for (var i = 0; i < meshes.length - 1; i++) {
  16602. for (var j = i + 1; j < meshes.length; j++) {
  16603. if (i != j) {
  16604. meshes[j].position.subtractToRef(meshes[i].position, difference);
  16605. // Ignore Z axis
  16606. difference2D.x = difference.x;
  16607. difference2D.y = difference.y;
  16608. var combinedRadius = cellSize;
  16609. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  16610. var minSeparation = Math.min(distance, radiusPaddingSquared);
  16611. distance -= minSeparation;
  16612. if (distance < (Math.pow(combinedRadius, 2.0))) {
  16613. difference2D.normalize();
  16614. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  16615. meshes[j].position.addInPlace(difference);
  16616. meshes[i].position.subtractInPlace(difference);
  16617. }
  16618. }
  16619. }
  16620. }
  16621. }
  16622. };
  16623. return ScatterPanel;
  16624. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  16625. /***/ }),
  16626. /***/ "./3D/controls/spherePanel.ts":
  16627. /*!************************************!*\
  16628. !*** ./3D/controls/spherePanel.ts ***!
  16629. \************************************/
  16630. /*! exports provided: SpherePanel */
  16631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16632. "use strict";
  16633. __webpack_require__.r(__webpack_exports__);
  16634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  16635. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16636. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  16637. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  16638. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  16639. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16640. /**
  16641. * Class used to create a container panel deployed on the surface of a sphere
  16642. */
  16643. var SpherePanel = /** @class */ (function (_super) {
  16644. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  16645. function SpherePanel() {
  16646. var _this = _super !== null && _super.apply(this, arguments) || this;
  16647. _this._radius = 5.0;
  16648. return _this;
  16649. }
  16650. Object.defineProperty(SpherePanel.prototype, "radius", {
  16651. /**
  16652. * Gets or sets the radius of the sphere where to project controls (5 by default)
  16653. */
  16654. get: function () {
  16655. return this._radius;
  16656. },
  16657. set: function (value) {
  16658. var _this = this;
  16659. if (this._radius === value) {
  16660. return;
  16661. }
  16662. this._radius = value;
  16663. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16664. _this._arrangeChildren();
  16665. });
  16666. },
  16667. enumerable: false,
  16668. configurable: true
  16669. });
  16670. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  16671. var mesh = control.mesh;
  16672. if (!mesh) {
  16673. return;
  16674. }
  16675. var newPos = this._sphericalMapping(nodePosition);
  16676. control.position = newPos;
  16677. switch (this.orientation) {
  16678. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  16679. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  16680. break;
  16681. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  16682. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  16683. break;
  16684. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  16685. break;
  16686. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  16687. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  16688. break;
  16689. }
  16690. };
  16691. SpherePanel.prototype._sphericalMapping = function (source) {
  16692. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  16693. var xAngle = (source.y / this._radius);
  16694. var yAngle = -(source.x / this._radius);
  16695. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16696. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16697. };
  16698. return SpherePanel;
  16699. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  16700. /***/ }),
  16701. /***/ "./3D/controls/stackPanel3D.ts":
  16702. /*!*************************************!*\
  16703. !*** ./3D/controls/stackPanel3D.ts ***!
  16704. \*************************************/
  16705. /*! exports provided: StackPanel3D */
  16706. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16707. "use strict";
  16708. __webpack_require__.r(__webpack_exports__);
  16709. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  16710. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16711. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  16712. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  16713. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16714. /**
  16715. * Class used to create a stack panel in 3D on XY plane
  16716. */
  16717. var StackPanel3D = /** @class */ (function (_super) {
  16718. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  16719. /**
  16720. * Creates new StackPanel
  16721. * @param isVertical
  16722. */
  16723. function StackPanel3D(isVertical) {
  16724. if (isVertical === void 0) { isVertical = false; }
  16725. var _this = _super.call(this) || this;
  16726. _this._isVertical = false;
  16727. /**
  16728. * Gets or sets the distance between elements
  16729. */
  16730. _this.margin = 0.1;
  16731. _this._isVertical = isVertical;
  16732. return _this;
  16733. }
  16734. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  16735. /**
  16736. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  16737. */
  16738. get: function () {
  16739. return this._isVertical;
  16740. },
  16741. set: function (value) {
  16742. var _this = this;
  16743. if (this._isVertical === value) {
  16744. return;
  16745. }
  16746. this._isVertical = value;
  16747. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16748. _this._arrangeChildren();
  16749. });
  16750. },
  16751. enumerable: false,
  16752. configurable: true
  16753. });
  16754. StackPanel3D.prototype._arrangeChildren = function () {
  16755. var width = 0;
  16756. var height = 0;
  16757. var controlCount = 0;
  16758. var extendSizes = [];
  16759. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  16760. // Measure
  16761. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  16762. var child = _a[_i];
  16763. if (!child.mesh) {
  16764. continue;
  16765. }
  16766. controlCount++;
  16767. child.mesh.computeWorldMatrix(true);
  16768. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16769. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  16770. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16771. extendSizes.push(extendSize);
  16772. if (this._isVertical) {
  16773. height += extendSize.y;
  16774. }
  16775. else {
  16776. width += extendSize.x;
  16777. }
  16778. }
  16779. if (this._isVertical) {
  16780. height += (controlCount - 1) * this.margin / 2;
  16781. }
  16782. else {
  16783. width += (controlCount - 1) * this.margin / 2;
  16784. }
  16785. // Arrange
  16786. var offset;
  16787. if (this._isVertical) {
  16788. offset = -height;
  16789. }
  16790. else {
  16791. offset = -width;
  16792. }
  16793. var index = 0;
  16794. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  16795. var child = _c[_b];
  16796. if (!child.mesh) {
  16797. continue;
  16798. }
  16799. controlCount--;
  16800. var extendSize = extendSizes[index++];
  16801. if (this._isVertical) {
  16802. child.position.y = offset + extendSize.y;
  16803. child.position.x = 0;
  16804. offset += extendSize.y * 2;
  16805. }
  16806. else {
  16807. child.position.x = offset + extendSize.x;
  16808. child.position.y = 0;
  16809. offset += extendSize.x * 2;
  16810. }
  16811. offset += (controlCount > 0 ? this.margin : 0);
  16812. }
  16813. };
  16814. return StackPanel3D;
  16815. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  16816. /***/ }),
  16817. /***/ "./3D/controls/volumeBasedPanel.ts":
  16818. /*!*****************************************!*\
  16819. !*** ./3D/controls/volumeBasedPanel.ts ***!
  16820. \*****************************************/
  16821. /*! exports provided: VolumeBasedPanel */
  16822. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16823. "use strict";
  16824. __webpack_require__.r(__webpack_exports__);
  16825. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  16826. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16827. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  16828. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  16829. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16830. /**
  16831. * Abstract class used to create a container panel deployed on the surface of a volume
  16832. */
  16833. var VolumeBasedPanel = /** @class */ (function (_super) {
  16834. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  16835. /**
  16836. * Creates new VolumeBasedPanel
  16837. */
  16838. function VolumeBasedPanel() {
  16839. var _this = _super.call(this) || this;
  16840. _this._columns = 10;
  16841. _this._rows = 0;
  16842. _this._rowThenColum = true;
  16843. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  16844. /**
  16845. * Gets or sets the distance between elements
  16846. */
  16847. _this.margin = 0;
  16848. return _this;
  16849. }
  16850. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  16851. /**
  16852. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  16853. * | Value | Type | Description |
  16854. * | ----- | ----------------------------------- | ----------- |
  16855. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  16856. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  16857. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  16858. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  16859. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  16860. */
  16861. get: function () {
  16862. return this._orientation;
  16863. },
  16864. set: function (value) {
  16865. var _this = this;
  16866. if (this._orientation === value) {
  16867. return;
  16868. }
  16869. this._orientation = value;
  16870. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16871. _this._arrangeChildren();
  16872. });
  16873. },
  16874. enumerable: false,
  16875. configurable: true
  16876. });
  16877. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  16878. /**
  16879. * Gets or sets the number of columns requested (10 by default).
  16880. * The panel will automatically compute the number of rows based on number of child controls.
  16881. */
  16882. get: function () {
  16883. return this._columns;
  16884. },
  16885. set: function (value) {
  16886. var _this = this;
  16887. if (this._columns === value) {
  16888. return;
  16889. }
  16890. this._columns = value;
  16891. this._rowThenColum = true;
  16892. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16893. _this._arrangeChildren();
  16894. });
  16895. },
  16896. enumerable: false,
  16897. configurable: true
  16898. });
  16899. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  16900. /**
  16901. * Gets or sets a the number of rows requested.
  16902. * The panel will automatically compute the number of columns based on number of child controls.
  16903. */
  16904. get: function () {
  16905. return this._rows;
  16906. },
  16907. set: function (value) {
  16908. var _this = this;
  16909. if (this._rows === value) {
  16910. return;
  16911. }
  16912. this._rows = value;
  16913. this._rowThenColum = false;
  16914. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16915. _this._arrangeChildren();
  16916. });
  16917. },
  16918. enumerable: false,
  16919. configurable: true
  16920. });
  16921. VolumeBasedPanel.prototype._arrangeChildren = function () {
  16922. this._cellWidth = 0;
  16923. this._cellHeight = 0;
  16924. var rows = 0;
  16925. var columns = 0;
  16926. var controlCount = 0;
  16927. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  16928. // Measure
  16929. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  16930. var child = _a[_i];
  16931. if (!child.mesh) {
  16932. continue;
  16933. }
  16934. controlCount++;
  16935. child.mesh.computeWorldMatrix(true);
  16936. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  16937. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  16938. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  16939. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  16940. boundingBox.max.subtractToRef(boundingBox.min, diff);
  16941. diff.scaleInPlace(0.5);
  16942. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  16943. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  16944. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  16945. }
  16946. this._cellWidth += this.margin * 2;
  16947. this._cellHeight += this.margin * 2;
  16948. // Arrange
  16949. if (this._rowThenColum) {
  16950. columns = this._columns;
  16951. rows = Math.ceil(controlCount / this._columns);
  16952. }
  16953. else {
  16954. rows = this._rows;
  16955. columns = Math.ceil(controlCount / this._rows);
  16956. }
  16957. var startOffsetX = (columns * 0.5) * this._cellWidth;
  16958. var startOffsetY = (rows * 0.5) * this._cellHeight;
  16959. var nodeGrid = [];
  16960. var cellCounter = 0;
  16961. if (this._rowThenColum) {
  16962. for (var r = 0; r < rows; r++) {
  16963. for (var c = 0; c < columns; c++) {
  16964. 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));
  16965. cellCounter++;
  16966. if (cellCounter > controlCount) {
  16967. break;
  16968. }
  16969. }
  16970. }
  16971. }
  16972. else {
  16973. for (var c = 0; c < columns; c++) {
  16974. for (var r = 0; r < rows; r++) {
  16975. 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));
  16976. cellCounter++;
  16977. if (cellCounter > controlCount) {
  16978. break;
  16979. }
  16980. }
  16981. }
  16982. }
  16983. cellCounter = 0;
  16984. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  16985. var child = _c[_b];
  16986. if (!child.mesh) {
  16987. continue;
  16988. }
  16989. this._mapGridNode(child, nodeGrid[cellCounter]);
  16990. cellCounter++;
  16991. }
  16992. this._finalProcessing();
  16993. };
  16994. /** Child classes can implement this function to provide additional processing */
  16995. VolumeBasedPanel.prototype._finalProcessing = function () {
  16996. };
  16997. return VolumeBasedPanel;
  16998. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  16999. /***/ }),
  17000. /***/ "./3D/gui3DManager.ts":
  17001. /*!****************************!*\
  17002. !*** ./3D/gui3DManager.ts ***!
  17003. \****************************/
  17004. /*! exports provided: GUI3DManager */
  17005. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17006. "use strict";
  17007. __webpack_require__.r(__webpack_exports__);
  17008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  17009. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  17010. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  17011. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  17012. /**
  17013. * Class used to manage 3D user interface
  17014. * @see https://doc.babylonjs.com/how_to/gui3d
  17015. */
  17016. var GUI3DManager = /** @class */ (function () {
  17017. /**
  17018. * Creates a new GUI3DManager
  17019. * @param scene
  17020. */
  17021. function GUI3DManager(scene) {
  17022. var _this = this;
  17023. /** @hidden */
  17024. this._lastControlOver = {};
  17025. /** @hidden */
  17026. this._lastControlDown = {};
  17027. /**
  17028. * Observable raised when the point picked by the pointer events changed
  17029. */
  17030. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  17031. // Shared resources
  17032. /** @hidden */
  17033. this._sharedMaterials = {};
  17034. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  17035. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  17036. _this._sceneDisposeObserver = null;
  17037. _this._utilityLayer = null;
  17038. _this.dispose();
  17039. });
  17040. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  17041. this._utilityLayer.onlyCheckPointerDownEvents = false;
  17042. this._utilityLayer.pickUtilitySceneFirst = false;
  17043. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  17044. var _a, _b, _c;
  17045. return mesh && ((_c = (_b = (_a = mesh.metadata) === null || _a === void 0 ? void 0 : _a.GUI3D) === null || _b === void 0 ? void 0 : _b.control) === null || _c === void 0 ? void 0 : _c._node);
  17046. };
  17047. // Root
  17048. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  17049. this._rootContainer._host = this;
  17050. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  17051. // Events
  17052. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  17053. _this._handlePointerOut(pointerId, true);
  17054. });
  17055. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  17056. _this._doPicking(pi);
  17057. });
  17058. // Scene
  17059. this._utilityLayer.utilityLayerScene.autoClear = false;
  17060. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  17061. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  17062. }
  17063. Object.defineProperty(GUI3DManager.prototype, "scene", {
  17064. /** Gets the hosting scene */
  17065. get: function () {
  17066. return this._scene;
  17067. },
  17068. enumerable: false,
  17069. configurable: true
  17070. });
  17071. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  17072. /** Gets associated utility layer */
  17073. get: function () {
  17074. return this._utilityLayer;
  17075. },
  17076. enumerable: false,
  17077. configurable: true
  17078. });
  17079. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  17080. var previousControlOver = this._lastControlOver[pointerId];
  17081. if (previousControlOver) {
  17082. previousControlOver._onPointerOut(previousControlOver);
  17083. delete this._lastControlOver[pointerId];
  17084. }
  17085. if (isPointerUp) {
  17086. if (this._lastControlDown[pointerId]) {
  17087. this._lastControlDown[pointerId].forcePointerUp();
  17088. delete this._lastControlDown[pointerId];
  17089. }
  17090. }
  17091. this.onPickedPointChangedObservable.notifyObservers(null);
  17092. };
  17093. GUI3DManager.prototype._doPicking = function (pi) {
  17094. var _a, _b;
  17095. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  17096. return false;
  17097. }
  17098. var pointerEvent = (pi.event);
  17099. var pointerId = pointerEvent.pointerId || 0;
  17100. var buttonIndex = pointerEvent.button;
  17101. var pickingInfo = pi.pickInfo;
  17102. if (!pickingInfo || !pickingInfo.hit) {
  17103. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  17104. return false;
  17105. }
  17106. var control = ((_b = (_a = pickingInfo.pickedMesh.metadata) === null || _a === void 0 ? void 0 : _a.GUI3D) === null || _b === void 0 ? void 0 : _b.control);
  17107. if (pickingInfo.pickedPoint) {
  17108. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  17109. }
  17110. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  17111. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  17112. if (this._lastControlOver[pointerId]) {
  17113. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  17114. }
  17115. delete this._lastControlOver[pointerId];
  17116. }
  17117. }
  17118. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  17119. if (this._lastControlDown[pointerEvent.pointerId]) {
  17120. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  17121. delete this._lastControlDown[pointerEvent.pointerId];
  17122. }
  17123. if (pointerEvent.pointerType === "touch") {
  17124. this._handlePointerOut(pointerId, false);
  17125. }
  17126. }
  17127. return true;
  17128. };
  17129. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  17130. /**
  17131. * Gets the root container
  17132. */
  17133. get: function () {
  17134. return this._rootContainer;
  17135. },
  17136. enumerable: false,
  17137. configurable: true
  17138. });
  17139. /**
  17140. * Gets a boolean indicating if the given control is in the root child list
  17141. * @param control defines the control to check
  17142. * @returns true if the control is in the root child list
  17143. */
  17144. GUI3DManager.prototype.containsControl = function (control) {
  17145. return this._rootContainer.containsControl(control);
  17146. };
  17147. /**
  17148. * Adds a control to the root child list
  17149. * @param control defines the control to add
  17150. * @returns the current manager
  17151. */
  17152. GUI3DManager.prototype.addControl = function (control) {
  17153. this._rootContainer.addControl(control);
  17154. return this;
  17155. };
  17156. /**
  17157. * Removes a control from the root child list
  17158. * @param control defines the control to remove
  17159. * @returns the current container
  17160. */
  17161. GUI3DManager.prototype.removeControl = function (control) {
  17162. this._rootContainer.removeControl(control);
  17163. return this;
  17164. };
  17165. /**
  17166. * Releases all associated resources
  17167. */
  17168. GUI3DManager.prototype.dispose = function () {
  17169. this._rootContainer.dispose();
  17170. for (var materialName in this._sharedMaterials) {
  17171. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  17172. continue;
  17173. }
  17174. this._sharedMaterials[materialName].dispose();
  17175. }
  17176. this._sharedMaterials = {};
  17177. if (this._pointerOutObserver && this._utilityLayer) {
  17178. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  17179. this._pointerOutObserver = null;
  17180. }
  17181. this.onPickedPointChangedObservable.clear();
  17182. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  17183. if (utilityLayerScene) {
  17184. if (this._pointerObserver) {
  17185. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  17186. this._pointerObserver = null;
  17187. }
  17188. }
  17189. if (this._scene) {
  17190. if (this._sceneDisposeObserver) {
  17191. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  17192. this._sceneDisposeObserver = null;
  17193. }
  17194. }
  17195. if (this._utilityLayer) {
  17196. this._utilityLayer.dispose();
  17197. }
  17198. };
  17199. return GUI3DManager;
  17200. }());
  17201. /***/ }),
  17202. /***/ "./3D/index.ts":
  17203. /*!*********************!*\
  17204. !*** ./3D/index.ts ***!
  17205. \*********************/
  17206. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  17207. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17208. "use strict";
  17209. __webpack_require__.r(__webpack_exports__);
  17210. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  17211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  17212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  17213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  17214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  17215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  17216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  17217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  17218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  17219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  17220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  17221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  17222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  17223. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  17224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  17225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  17226. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  17227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  17228. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  17229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  17230. /***/ }),
  17231. /***/ "./3D/materials/fluentMaterial.ts":
  17232. /*!****************************************!*\
  17233. !*** ./3D/materials/fluentMaterial.ts ***!
  17234. \****************************************/
  17235. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  17236. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17237. "use strict";
  17238. __webpack_require__.r(__webpack_exports__);
  17239. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  17240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  17241. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  17242. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  17243. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  17244. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  17245. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  17246. /** @hidden */
  17247. var FluentMaterialDefines = /** @class */ (function (_super) {
  17248. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  17249. function FluentMaterialDefines() {
  17250. var _this = _super.call(this) || this;
  17251. _this.INNERGLOW = false;
  17252. _this.BORDER = false;
  17253. _this.HOVERLIGHT = false;
  17254. _this.TEXTURE = false;
  17255. _this.rebuild();
  17256. return _this;
  17257. }
  17258. return FluentMaterialDefines;
  17259. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  17260. /**
  17261. * Class used to render controls with fluent desgin
  17262. */
  17263. var FluentMaterial = /** @class */ (function (_super) {
  17264. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  17265. /**
  17266. * Creates a new Fluent material
  17267. * @param name defines the name of the material
  17268. * @param scene defines the hosting scene
  17269. */
  17270. function FluentMaterial(name, scene) {
  17271. var _this = _super.call(this, name, scene) || this;
  17272. /**
  17273. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  17274. */
  17275. _this.innerGlowColorIntensity = 0.5;
  17276. /**
  17277. * Gets or sets the inner glow color (white by default)
  17278. */
  17279. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  17280. /**
  17281. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  17282. */
  17283. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  17284. /**
  17285. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  17286. */
  17287. _this.renderBorders = false;
  17288. /**
  17289. * Gets or sets border width (default is 0.5)
  17290. */
  17291. _this.borderWidth = 0.5;
  17292. /**
  17293. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  17294. */
  17295. _this.edgeSmoothingValue = 0.02;
  17296. /**
  17297. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  17298. */
  17299. _this.borderMinValue = 0.1;
  17300. /**
  17301. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  17302. */
  17303. _this.renderHoverLight = false;
  17304. /**
  17305. * Gets or sets the radius used to render the hover light (default is 1.0)
  17306. */
  17307. _this.hoverRadius = 1.0;
  17308. /**
  17309. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  17310. */
  17311. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  17312. /**
  17313. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  17314. */
  17315. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  17316. return _this;
  17317. }
  17318. FluentMaterial.prototype.needAlphaBlending = function () {
  17319. return this.alpha !== 1.0;
  17320. };
  17321. FluentMaterial.prototype.needAlphaTesting = function () {
  17322. return false;
  17323. };
  17324. FluentMaterial.prototype.getAlphaTestTexture = function () {
  17325. return null;
  17326. };
  17327. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  17328. if (this.isFrozen) {
  17329. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  17330. return true;
  17331. }
  17332. }
  17333. if (!subMesh._materialDefines) {
  17334. subMesh._materialDefines = new FluentMaterialDefines();
  17335. }
  17336. var scene = this.getScene();
  17337. var defines = subMesh._materialDefines;
  17338. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  17339. if (defines._renderId === scene.getRenderId()) {
  17340. return true;
  17341. }
  17342. }
  17343. if (defines._areTexturesDirty) {
  17344. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  17345. defines.BORDER = this.renderBorders;
  17346. defines.HOVERLIGHT = this.renderHoverLight;
  17347. if (this._albedoTexture) {
  17348. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  17349. return false;
  17350. }
  17351. else {
  17352. defines.TEXTURE = true;
  17353. }
  17354. }
  17355. else {
  17356. defines.TEXTURE = false;
  17357. }
  17358. }
  17359. var engine = scene.getEngine();
  17360. // Get correct effect
  17361. if (defines.isDirty) {
  17362. defines.markAsProcessed();
  17363. scene.resetCachedMaterial();
  17364. //Attributes
  17365. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  17366. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  17367. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  17368. var shaderName = "fluent";
  17369. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  17370. "hoverColor", "hoverPosition", "hoverRadius"
  17371. ];
  17372. var samplers = ["albedoSampler"];
  17373. var uniformBuffers = new Array();
  17374. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  17375. uniformsNames: uniforms,
  17376. uniformBuffersNames: uniformBuffers,
  17377. samplers: samplers,
  17378. defines: defines,
  17379. maxSimultaneousLights: 4
  17380. });
  17381. var join = defines.toString();
  17382. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  17383. attributes: attribs,
  17384. uniformsNames: uniforms,
  17385. uniformBuffersNames: uniformBuffers,
  17386. samplers: samplers,
  17387. defines: join,
  17388. fallbacks: null,
  17389. onCompiled: this.onCompiled,
  17390. onError: this.onError,
  17391. indexParameters: { maxSimultaneousLights: 4 }
  17392. }, engine));
  17393. }
  17394. if (!subMesh.effect || !subMesh.effect.isReady()) {
  17395. return false;
  17396. }
  17397. defines._renderId = scene.getRenderId();
  17398. subMesh.effect._wasPreviouslyReady = true;
  17399. return true;
  17400. };
  17401. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  17402. var scene = this.getScene();
  17403. var defines = subMesh._materialDefines;
  17404. if (!defines) {
  17405. return;
  17406. }
  17407. var effect = subMesh.effect;
  17408. if (!effect) {
  17409. return;
  17410. }
  17411. this._activeEffect = effect;
  17412. // Matrices
  17413. this.bindOnlyWorldMatrix(world);
  17414. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  17415. if (this._mustRebind(scene, effect)) {
  17416. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  17417. if (defines.INNERGLOW) {
  17418. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  17419. }
  17420. if (defines.BORDER) {
  17421. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  17422. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  17423. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  17424. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  17425. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  17426. }
  17427. if (defines.HOVERLIGHT) {
  17428. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  17429. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  17430. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  17431. }
  17432. if (defines.TEXTURE) {
  17433. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  17434. }
  17435. }
  17436. this._afterBind(mesh, this._activeEffect);
  17437. };
  17438. FluentMaterial.prototype.getActiveTextures = function () {
  17439. var activeTextures = _super.prototype.getActiveTextures.call(this);
  17440. return activeTextures;
  17441. };
  17442. FluentMaterial.prototype.hasTexture = function (texture) {
  17443. if (_super.prototype.hasTexture.call(this, texture)) {
  17444. return true;
  17445. }
  17446. return false;
  17447. };
  17448. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  17449. _super.prototype.dispose.call(this, forceDisposeEffect);
  17450. };
  17451. FluentMaterial.prototype.clone = function (name) {
  17452. var _this = this;
  17453. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  17454. };
  17455. FluentMaterial.prototype.serialize = function () {
  17456. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  17457. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  17458. return serializationObject;
  17459. };
  17460. FluentMaterial.prototype.getClassName = function () {
  17461. return "FluentMaterial";
  17462. };
  17463. // Statics
  17464. FluentMaterial.Parse = function (source, scene, rootUrl) {
  17465. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  17466. };
  17467. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17468. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  17469. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  17470. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  17471. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17472. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  17473. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  17474. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17475. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  17476. ], FluentMaterial.prototype, "albedoColor", void 0);
  17477. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17478. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  17479. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  17480. ], FluentMaterial.prototype, "renderBorders", void 0);
  17481. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17482. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  17483. ], FluentMaterial.prototype, "borderWidth", void 0);
  17484. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17485. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  17486. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  17487. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17488. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  17489. ], FluentMaterial.prototype, "borderMinValue", void 0);
  17490. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17491. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  17492. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  17493. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  17494. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17495. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  17496. ], FluentMaterial.prototype, "hoverRadius", void 0);
  17497. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17498. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  17499. ], FluentMaterial.prototype, "hoverColor", void 0);
  17500. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17501. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  17502. ], FluentMaterial.prototype, "hoverPosition", void 0);
  17503. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17504. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  17505. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  17506. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17507. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  17508. ], FluentMaterial.prototype, "albedoTexture", void 0);
  17509. return FluentMaterial;
  17510. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  17511. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  17512. /***/ }),
  17513. /***/ "./3D/materials/index.ts":
  17514. /*!*******************************!*\
  17515. !*** ./3D/materials/index.ts ***!
  17516. \*******************************/
  17517. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  17518. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17519. "use strict";
  17520. __webpack_require__.r(__webpack_exports__);
  17521. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  17522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  17523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  17524. /***/ }),
  17525. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  17526. /*!*************************************************!*\
  17527. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  17528. \*************************************************/
  17529. /*! exports provided: fluentPixelShader */
  17530. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17531. "use strict";
  17532. __webpack_require__.r(__webpack_exports__);
  17533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  17534. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  17535. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  17536. var name = 'fluentPixelShader';
  17537. 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}";
  17538. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  17539. /** @hidden */
  17540. var fluentPixelShader = { name: name, shader: shader };
  17541. /***/ }),
  17542. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  17543. /*!***********************************************!*\
  17544. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  17545. \***********************************************/
  17546. /*! exports provided: fluentVertexShader */
  17547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17548. "use strict";
  17549. __webpack_require__.r(__webpack_exports__);
  17550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  17551. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  17552. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  17553. var name = 'fluentVertexShader';
  17554. 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";
  17555. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  17556. /** @hidden */
  17557. var fluentVertexShader = { name: name, shader: shader };
  17558. /***/ }),
  17559. /***/ "./3D/vector3WithInfo.ts":
  17560. /*!*******************************!*\
  17561. !*** ./3D/vector3WithInfo.ts ***!
  17562. \*******************************/
  17563. /*! exports provided: Vector3WithInfo */
  17564. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17565. "use strict";
  17566. __webpack_require__.r(__webpack_exports__);
  17567. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  17568. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  17569. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  17570. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  17571. /**
  17572. * Class used to transport Vector3 information for pointer events
  17573. */
  17574. var Vector3WithInfo = /** @class */ (function (_super) {
  17575. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  17576. /**
  17577. * Creates a new Vector3WithInfo
  17578. * @param source defines the vector3 data to transport
  17579. * @param buttonIndex defines the current mouse button index
  17580. */
  17581. function Vector3WithInfo(source,
  17582. /** defines the current mouse button index */
  17583. buttonIndex) {
  17584. if (buttonIndex === void 0) { buttonIndex = 0; }
  17585. var _this = _super.call(this, source.x, source.y, source.z) || this;
  17586. _this.buttonIndex = buttonIndex;
  17587. return _this;
  17588. }
  17589. return Vector3WithInfo;
  17590. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  17591. /***/ }),
  17592. /***/ "./index.ts":
  17593. /*!******************!*\
  17594. !*** ./index.ts ***!
  17595. \******************/
  17596. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, FocusableButton, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, TextWrapper, ToggleButton, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  17597. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17598. "use strict";
  17599. __webpack_require__.r(__webpack_exports__);
  17600. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  17601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  17602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  17603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  17604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  17605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  17606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  17607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["FocusableButton"]; });
  17608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  17609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  17610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  17611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  17612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  17613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  17614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  17615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  17616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  17617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  17618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  17619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  17620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  17621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  17622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  17623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  17624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapper"]; });
  17625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ToggleButton"]; });
  17626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  17627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  17628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  17629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  17630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  17631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  17632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  17633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  17634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  17635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  17636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  17637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  17638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  17639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  17640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  17641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  17642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  17643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  17644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  17645. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  17646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  17647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  17648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  17649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  17650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  17651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  17652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  17653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  17654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  17655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  17656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  17657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  17658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  17659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  17660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  17661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  17662. /***/ }),
  17663. /***/ "./legacy/legacy.ts":
  17664. /*!**************************!*\
  17665. !*** ./legacy/legacy.ts ***!
  17666. \**************************/
  17667. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, FocusableButton, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, TextWrapper, ToggleButton, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  17668. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17669. "use strict";
  17670. __webpack_require__.r(__webpack_exports__);
  17671. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  17672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  17673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  17674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  17675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  17676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  17677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  17678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FocusableButton"]; });
  17679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  17680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  17681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  17682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  17683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  17684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  17685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  17686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  17687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  17688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  17689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  17690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  17691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  17692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  17693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  17694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  17695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapper"]; });
  17696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToggleButton"]; });
  17697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  17698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  17699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  17700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  17701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  17702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  17703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  17704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  17705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  17706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  17707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  17708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  17709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  17710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  17711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  17712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  17713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  17714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  17715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  17716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  17717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  17718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  17719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  17720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  17721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  17722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  17723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  17724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  17725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  17726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  17727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  17728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  17729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  17730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  17731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  17732. /**
  17733. * Legacy support, defining window.BABYLON.GUI (global variable).
  17734. *
  17735. * This is the entry point for the UMD module.
  17736. * The entry point for a future ESM package should be index.ts
  17737. */
  17738. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  17739. if (typeof globalObject !== "undefined") {
  17740. globalObject.BABYLON = globalObject.BABYLON || {};
  17741. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  17742. }
  17743. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  17744. /***/ }),
  17745. /***/ "babylonjs/Misc/perfCounter":
  17746. /*!****************************************************************************************************!*\
  17747. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  17748. \****************************************************************************************************/
  17749. /*! no static exports found */
  17750. /***/ (function(module, exports) {
  17751. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__;
  17752. /***/ })
  17753. /******/ });
  17754. });
  17755. //# sourceMappingURL=babylon.gui.js.map