babylon.gui.js 821 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640
  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. // Statics
  1429. /**
  1430. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1431. * @param mesh defines the mesh which will receive the texture
  1432. * @param width defines the texture width (1024 by default)
  1433. * @param height defines the texture height (1024 by default)
  1434. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1435. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1436. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  1437. * @returns a new AdvancedDynamicTexture
  1438. */
  1439. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting, invertY) {
  1440. if (width === void 0) { width = 1024; }
  1441. if (height === void 0) { height = 1024; }
  1442. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1443. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1444. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, invertY);
  1445. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1446. material.backFaceCulling = false;
  1447. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1448. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1449. if (onlyAlphaTesting) {
  1450. material.diffuseTexture = result;
  1451. material.emissiveTexture = result;
  1452. result.hasAlpha = true;
  1453. }
  1454. else {
  1455. material.emissiveTexture = result;
  1456. material.opacityTexture = result;
  1457. }
  1458. mesh.material = material;
  1459. result.attachToMesh(mesh, supportPointerMove);
  1460. return result;
  1461. };
  1462. /**
  1463. * 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
  1464. * @param mesh defines the mesh which will receive the texture
  1465. * @param width defines the texture width (1024 by default)
  1466. * @param height defines the texture height (1024 by default)
  1467. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1468. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  1469. * @returns a new AdvancedDynamicTexture
  1470. */
  1471. AdvancedDynamicTexture.CreateForMeshTexture = function (mesh, width, height, supportPointerMove, invertY) {
  1472. if (width === void 0) { width = 1024; }
  1473. if (height === void 0) { height = 1024; }
  1474. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1475. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, invertY);
  1476. result.attachToMesh(mesh, supportPointerMove);
  1477. return result;
  1478. };
  1479. /**
  1480. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1481. * In this mode the texture will rely on a layer for its rendering.
  1482. * This allows it to be treated like any other layer.
  1483. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1484. * LayerMask is set through advancedTexture.layer.layerMask
  1485. * @param name defines name for the texture
  1486. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1487. * @param scene defines the hsoting scene
  1488. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1489. * @returns a new AdvancedDynamicTexture
  1490. */
  1491. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1492. if (foreground === void 0) { foreground = true; }
  1493. if (scene === void 0) { scene = null; }
  1494. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1495. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1496. // Display
  1497. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1498. layer.texture = result;
  1499. result._layerToDispose = layer;
  1500. result._isFullscreen = true;
  1501. // Attach
  1502. result.attach();
  1503. return result;
  1504. };
  1505. return AdvancedDynamicTexture;
  1506. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1507. /***/ }),
  1508. /***/ "./2D/controls/button.ts":
  1509. /*!*******************************!*\
  1510. !*** ./2D/controls/button.ts ***!
  1511. \*******************************/
  1512. /*! exports provided: Button */
  1513. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1514. "use strict";
  1515. __webpack_require__.r(__webpack_exports__);
  1516. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1517. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1518. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1519. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1520. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1521. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1522. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  1523. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1524. /**
  1525. * Class used to create 2D buttons
  1526. */
  1527. var Button = /** @class */ (function (_super) {
  1528. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1529. /**
  1530. * Creates a new Button
  1531. * @param name defines the name of the button
  1532. */
  1533. function Button(name) {
  1534. var _this = _super.call(this, name) || this;
  1535. _this.name = name;
  1536. /**
  1537. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1538. */
  1539. _this.delegatePickingToChildren = false;
  1540. _this.thickness = 1;
  1541. _this.isPointerBlocker = true;
  1542. var alphaStore = null;
  1543. _this.pointerEnterAnimation = function () {
  1544. alphaStore = _this.alpha;
  1545. _this.alpha -= 0.1;
  1546. };
  1547. _this.pointerOutAnimation = function () {
  1548. if (alphaStore !== null) {
  1549. _this.alpha = alphaStore;
  1550. }
  1551. };
  1552. _this.pointerDownAnimation = function () {
  1553. _this.scaleX -= 0.05;
  1554. _this.scaleY -= 0.05;
  1555. };
  1556. _this.pointerUpAnimation = function () {
  1557. _this.scaleX += 0.05;
  1558. _this.scaleY += 0.05;
  1559. };
  1560. return _this;
  1561. }
  1562. Object.defineProperty(Button.prototype, "image", {
  1563. /**
  1564. * Returns the image part of the button (if any)
  1565. */
  1566. get: function () {
  1567. return this._image;
  1568. },
  1569. enumerable: false,
  1570. configurable: true
  1571. });
  1572. Object.defineProperty(Button.prototype, "textBlock", {
  1573. /**
  1574. * Returns the image part of the button (if any)
  1575. */
  1576. get: function () {
  1577. return this._textBlock;
  1578. },
  1579. enumerable: false,
  1580. configurable: true
  1581. });
  1582. Button.prototype._getTypeName = function () {
  1583. return "Button";
  1584. };
  1585. // While being a container, the button behaves like a control.
  1586. /** @hidden */
  1587. Button.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  1588. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1589. return false;
  1590. }
  1591. if (!_super.prototype.contains.call(this, x, y)) {
  1592. return false;
  1593. }
  1594. if (this.delegatePickingToChildren) {
  1595. var contains = false;
  1596. for (var index = this._children.length - 1; index >= 0; index--) {
  1597. var child = this._children[index];
  1598. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1599. contains = true;
  1600. break;
  1601. }
  1602. }
  1603. if (!contains) {
  1604. return false;
  1605. }
  1606. }
  1607. this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  1608. return true;
  1609. };
  1610. /** @hidden */
  1611. Button.prototype._onPointerEnter = function (target, pi) {
  1612. if (!_super.prototype._onPointerEnter.call(this, target, pi)) {
  1613. return false;
  1614. }
  1615. if (this.pointerEnterAnimation) {
  1616. this.pointerEnterAnimation();
  1617. }
  1618. return true;
  1619. };
  1620. /** @hidden */
  1621. Button.prototype._onPointerOut = function (target, pi, force) {
  1622. if (force === void 0) { force = false; }
  1623. if (this.pointerOutAnimation) {
  1624. this.pointerOutAnimation();
  1625. }
  1626. _super.prototype._onPointerOut.call(this, target, pi, force);
  1627. };
  1628. /** @hidden */
  1629. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  1630. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  1631. return false;
  1632. }
  1633. if (this.pointerDownAnimation) {
  1634. this.pointerDownAnimation();
  1635. }
  1636. return true;
  1637. };
  1638. /** @hidden */
  1639. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  1640. if (this.pointerUpAnimation) {
  1641. this.pointerUpAnimation();
  1642. }
  1643. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick, pi);
  1644. };
  1645. // Statics
  1646. /**
  1647. * Creates a new button made with an image and a text
  1648. * @param name defines the name of the button
  1649. * @param text defines the text of the button
  1650. * @param imageUrl defines the url of the image
  1651. * @returns a new Button
  1652. */
  1653. Button.CreateImageButton = function (name, text, imageUrl) {
  1654. var result = new this(name);
  1655. // Adding text
  1656. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1657. textBlock.textWrapping = true;
  1658. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1659. textBlock.paddingLeft = "20%";
  1660. result.addControl(textBlock);
  1661. // Adding image
  1662. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1663. iconImage.width = "20%";
  1664. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1665. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1666. result.addControl(iconImage);
  1667. // Store
  1668. result._image = iconImage;
  1669. result._textBlock = textBlock;
  1670. return result;
  1671. };
  1672. /**
  1673. * Creates a new button made with an image
  1674. * @param name defines the name of the button
  1675. * @param imageUrl defines the url of the image
  1676. * @returns a new Button
  1677. */
  1678. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1679. var result = new this(name);
  1680. // Adding image
  1681. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1682. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1683. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1684. result.addControl(iconImage);
  1685. // Store
  1686. result._image = iconImage;
  1687. return result;
  1688. };
  1689. /**
  1690. * Creates a new button made with a text
  1691. * @param name defines the name of the button
  1692. * @param text defines the text of the button
  1693. * @returns a new Button
  1694. */
  1695. Button.CreateSimpleButton = function (name, text) {
  1696. var result = new this(name);
  1697. // Adding text
  1698. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1699. textBlock.textWrapping = true;
  1700. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1701. result.addControl(textBlock);
  1702. // Store
  1703. result._textBlock = textBlock;
  1704. return result;
  1705. };
  1706. /**
  1707. * Creates a new button made with an image and a centered text
  1708. * @param name defines the name of the button
  1709. * @param text defines the text of the button
  1710. * @param imageUrl defines the url of the image
  1711. * @returns a new Button
  1712. */
  1713. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1714. var result = new this(name);
  1715. // Adding image
  1716. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1717. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1718. result.addControl(iconImage);
  1719. // Adding text
  1720. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1721. textBlock.textWrapping = true;
  1722. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1723. result.addControl(textBlock);
  1724. // Store
  1725. result._image = iconImage;
  1726. result._textBlock = textBlock;
  1727. return result;
  1728. };
  1729. return Button;
  1730. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1731. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1732. /***/ }),
  1733. /***/ "./2D/controls/checkbox.ts":
  1734. /*!*********************************!*\
  1735. !*** ./2D/controls/checkbox.ts ***!
  1736. \*********************************/
  1737. /*! exports provided: Checkbox */
  1738. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1739. "use strict";
  1740. __webpack_require__.r(__webpack_exports__);
  1741. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1742. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1743. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1744. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1745. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1746. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1747. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1748. /**
  1749. * Class used to represent a 2D checkbox
  1750. */
  1751. var Checkbox = /** @class */ (function (_super) {
  1752. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1753. /**
  1754. * Creates a new CheckBox
  1755. * @param name defines the control name
  1756. */
  1757. function Checkbox(name) {
  1758. var _this = _super.call(this, name) || this;
  1759. _this.name = name;
  1760. _this._isChecked = false;
  1761. _this._background = "black";
  1762. _this._checkSizeRatio = 0.8;
  1763. _this._thickness = 1;
  1764. /**
  1765. * Observable raised when isChecked property changes
  1766. */
  1767. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1768. _this.isPointerBlocker = true;
  1769. return _this;
  1770. }
  1771. Object.defineProperty(Checkbox.prototype, "thickness", {
  1772. /** Gets or sets border thickness */
  1773. get: function () {
  1774. return this._thickness;
  1775. },
  1776. set: function (value) {
  1777. if (this._thickness === value) {
  1778. return;
  1779. }
  1780. this._thickness = value;
  1781. this._markAsDirty();
  1782. },
  1783. enumerable: false,
  1784. configurable: true
  1785. });
  1786. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1787. /** Gets or sets a value indicating the ratio between overall size and check size */
  1788. get: function () {
  1789. return this._checkSizeRatio;
  1790. },
  1791. set: function (value) {
  1792. value = Math.max(Math.min(1, value), 0);
  1793. if (this._checkSizeRatio === value) {
  1794. return;
  1795. }
  1796. this._checkSizeRatio = value;
  1797. this._markAsDirty();
  1798. },
  1799. enumerable: false,
  1800. configurable: true
  1801. });
  1802. Object.defineProperty(Checkbox.prototype, "background", {
  1803. /** Gets or sets background color */
  1804. get: function () {
  1805. return this._background;
  1806. },
  1807. set: function (value) {
  1808. if (this._background === value) {
  1809. return;
  1810. }
  1811. this._background = value;
  1812. this._markAsDirty();
  1813. },
  1814. enumerable: false,
  1815. configurable: true
  1816. });
  1817. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1818. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1819. get: function () {
  1820. return this._isChecked;
  1821. },
  1822. set: function (value) {
  1823. if (this._isChecked === value) {
  1824. return;
  1825. }
  1826. this._isChecked = value;
  1827. this._markAsDirty();
  1828. this.onIsCheckedChangedObservable.notifyObservers(value);
  1829. },
  1830. enumerable: false,
  1831. configurable: true
  1832. });
  1833. Checkbox.prototype._getTypeName = function () {
  1834. return "Checkbox";
  1835. };
  1836. /** @hidden */
  1837. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1838. context.save();
  1839. this._applyStates(context);
  1840. var actualWidth = this._currentMeasure.width - this._thickness;
  1841. var actualHeight = this._currentMeasure.height - this._thickness;
  1842. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1843. context.shadowColor = this.shadowColor;
  1844. context.shadowBlur = this.shadowBlur;
  1845. context.shadowOffsetX = this.shadowOffsetX;
  1846. context.shadowOffsetY = this.shadowOffsetY;
  1847. }
  1848. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1849. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1850. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1851. context.shadowBlur = 0;
  1852. context.shadowOffsetX = 0;
  1853. context.shadowOffsetY = 0;
  1854. }
  1855. if (this._isChecked) {
  1856. context.fillStyle = this._isEnabled ? this.color : this._disabledColorItem;
  1857. var offsetWidth = actualWidth * this._checkSizeRatio;
  1858. var offseHeight = actualHeight * this._checkSizeRatio;
  1859. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1860. }
  1861. context.strokeStyle = this.color;
  1862. context.lineWidth = this._thickness;
  1863. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1864. context.restore();
  1865. };
  1866. // Events
  1867. /** @hidden */
  1868. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  1869. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  1870. return false;
  1871. }
  1872. this.isChecked = !this.isChecked;
  1873. return true;
  1874. };
  1875. /**
  1876. * Utility function to easily create a checkbox with a header
  1877. * @param title defines the label to use for the header
  1878. * @param onValueChanged defines the callback to call when value changes
  1879. * @returns a StackPanel containing the checkbox and a textBlock
  1880. */
  1881. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1882. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1883. panel.isVertical = false;
  1884. panel.height = "30px";
  1885. var checkbox = new Checkbox();
  1886. checkbox.width = "20px";
  1887. checkbox.height = "20px";
  1888. checkbox.isChecked = true;
  1889. checkbox.color = "green";
  1890. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1891. panel.addControl(checkbox);
  1892. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1893. header.text = title;
  1894. header.width = "180px";
  1895. header.paddingLeft = "5px";
  1896. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1897. header.color = "white";
  1898. panel.addControl(header);
  1899. return panel;
  1900. };
  1901. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  1902. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  1903. ], Checkbox.prototype, "thickness", null);
  1904. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  1905. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  1906. ], Checkbox.prototype, "checkSizeRatio", null);
  1907. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  1908. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  1909. ], Checkbox.prototype, "background", null);
  1910. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  1911. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  1912. ], Checkbox.prototype, "isChecked", null);
  1913. return Checkbox;
  1914. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1915. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1916. /***/ }),
  1917. /***/ "./2D/controls/colorpicker.ts":
  1918. /*!************************************!*\
  1919. !*** ./2D/controls/colorpicker.ts ***!
  1920. \************************************/
  1921. /*! exports provided: ColorPicker */
  1922. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1923. "use strict";
  1924. __webpack_require__.r(__webpack_exports__);
  1925. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1926. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1927. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1928. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1929. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1930. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1931. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1932. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1933. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1934. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1935. /** Class used to create color pickers */
  1936. var ColorPicker = /** @class */ (function (_super) {
  1937. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1938. /**
  1939. * Creates a new ColorPicker
  1940. * @param name defines the control name
  1941. */
  1942. function ColorPicker(name) {
  1943. var _this = _super.call(this, name) || this;
  1944. _this.name = name;
  1945. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1946. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1947. _this._pointerStartedOnSquare = false;
  1948. _this._pointerStartedOnWheel = false;
  1949. _this._squareLeft = 0;
  1950. _this._squareTop = 0;
  1951. _this._squareSize = 0;
  1952. _this._h = 360;
  1953. _this._s = 1;
  1954. _this._v = 1;
  1955. _this._lastPointerDownID = -1;
  1956. /**
  1957. * Observable raised when the value changes
  1958. */
  1959. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1960. // Events
  1961. _this._pointerIsDown = false;
  1962. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1963. _this.size = "200px";
  1964. _this.isPointerBlocker = true;
  1965. return _this;
  1966. }
  1967. Object.defineProperty(ColorPicker.prototype, "value", {
  1968. /** Gets or sets the color of the color picker */
  1969. get: function () {
  1970. return this._value;
  1971. },
  1972. set: function (value) {
  1973. if (this._value.equals(value)) {
  1974. return;
  1975. }
  1976. this._value.copyFrom(value);
  1977. this._value.toHSVToRef(this._tmpColor);
  1978. this._h = this._tmpColor.r;
  1979. this._s = Math.max(this._tmpColor.g, 0.00001);
  1980. this._v = Math.max(this._tmpColor.b, 0.00001);
  1981. this._markAsDirty();
  1982. if (this._value.r <= ColorPicker._Epsilon) {
  1983. this._value.r = 0;
  1984. }
  1985. if (this._value.g <= ColorPicker._Epsilon) {
  1986. this._value.g = 0;
  1987. }
  1988. if (this._value.b <= ColorPicker._Epsilon) {
  1989. this._value.b = 0;
  1990. }
  1991. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1992. this._value.r = 1.0;
  1993. }
  1994. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1995. this._value.g = 1.0;
  1996. }
  1997. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1998. this._value.b = 1.0;
  1999. }
  2000. this.onValueChangedObservable.notifyObservers(this._value);
  2001. },
  2002. enumerable: false,
  2003. configurable: true
  2004. });
  2005. Object.defineProperty(ColorPicker.prototype, "width", {
  2006. /**
  2007. * Gets or sets control width
  2008. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  2009. */
  2010. get: function () {
  2011. return this._width.toString(this._host);
  2012. },
  2013. set: function (value) {
  2014. if (this._width.toString(this._host) === value) {
  2015. return;
  2016. }
  2017. if (this._width.fromString(value)) {
  2018. this._height.fromString(value);
  2019. this._markAsDirty();
  2020. }
  2021. },
  2022. enumerable: false,
  2023. configurable: true
  2024. });
  2025. Object.defineProperty(ColorPicker.prototype, "height", {
  2026. /**
  2027. * Gets or sets control height
  2028. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  2029. */
  2030. get: function () {
  2031. return this._height.toString(this._host);
  2032. },
  2033. /** Gets or sets control height */
  2034. set: function (value) {
  2035. if (this._height.toString(this._host) === value) {
  2036. return;
  2037. }
  2038. if (this._height.fromString(value)) {
  2039. this._width.fromString(value);
  2040. this._markAsDirty();
  2041. }
  2042. },
  2043. enumerable: false,
  2044. configurable: true
  2045. });
  2046. Object.defineProperty(ColorPicker.prototype, "size", {
  2047. /** Gets or sets control size */
  2048. get: function () {
  2049. return this.width;
  2050. },
  2051. set: function (value) {
  2052. this.width = value;
  2053. },
  2054. enumerable: false,
  2055. configurable: true
  2056. });
  2057. ColorPicker.prototype._getTypeName = function () {
  2058. return "ColorPicker";
  2059. };
  2060. /** @hidden */
  2061. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  2062. if (parentMeasure.width < parentMeasure.height) {
  2063. this._currentMeasure.height = parentMeasure.width;
  2064. }
  2065. else {
  2066. this._currentMeasure.width = parentMeasure.height;
  2067. }
  2068. };
  2069. ColorPicker.prototype._updateSquareProps = function () {
  2070. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2071. var wheelThickness = radius * .2;
  2072. var innerDiameter = (radius - wheelThickness) * 2;
  2073. var squareSize = innerDiameter / (Math.sqrt(2));
  2074. var offset = radius - squareSize * .5;
  2075. this._squareLeft = this._currentMeasure.left + offset;
  2076. this._squareTop = this._currentMeasure.top + offset;
  2077. this._squareSize = squareSize;
  2078. };
  2079. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  2080. var lgh = context.createLinearGradient(left, top, width + left, top);
  2081. lgh.addColorStop(0, '#fff');
  2082. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  2083. context.fillStyle = lgh;
  2084. context.fillRect(left, top, width, height);
  2085. var lgv = context.createLinearGradient(left, top, left, height + top);
  2086. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  2087. lgv.addColorStop(1, '#000');
  2088. context.fillStyle = lgv;
  2089. context.fillRect(left, top, width, height);
  2090. };
  2091. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  2092. context.beginPath();
  2093. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  2094. context.lineWidth = 3;
  2095. context.strokeStyle = '#333333';
  2096. context.stroke();
  2097. context.beginPath();
  2098. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  2099. context.lineWidth = 3;
  2100. context.strokeStyle = '#ffffff';
  2101. context.stroke();
  2102. };
  2103. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  2104. var canvas = document.createElement("canvas");
  2105. canvas.width = radius * 2;
  2106. canvas.height = radius * 2;
  2107. var context = canvas.getContext("2d");
  2108. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  2109. var data = image.data;
  2110. var color = this._tmpColor;
  2111. var maxDistSq = radius * radius;
  2112. var innerRadius = radius - thickness;
  2113. var minDistSq = innerRadius * innerRadius;
  2114. for (var x = -radius; x < radius; x++) {
  2115. for (var y = -radius; y < radius; y++) {
  2116. var distSq = x * x + y * y;
  2117. if (distSq > maxDistSq || distSq < minDistSq) {
  2118. continue;
  2119. }
  2120. var dist = Math.sqrt(distSq);
  2121. var ang = Math.atan2(y, x);
  2122. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  2123. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  2124. data[index] = color.r * 255;
  2125. data[index + 1] = color.g * 255;
  2126. data[index + 2] = color.b * 255;
  2127. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2128. //apply less alpha to bigger color pickers
  2129. var alphaAmount = .2;
  2130. var maxAlpha = .2;
  2131. var minAlpha = .04;
  2132. var lowerRadius = 50;
  2133. var upperRadius = 150;
  2134. if (radius < lowerRadius) {
  2135. alphaAmount = maxAlpha;
  2136. }
  2137. else if (radius > upperRadius) {
  2138. alphaAmount = minAlpha;
  2139. }
  2140. else {
  2141. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  2142. }
  2143. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2144. if (alphaRatio < alphaAmount) {
  2145. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  2146. }
  2147. else if (alphaRatio > 1 - alphaAmount) {
  2148. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  2149. }
  2150. else {
  2151. data[index + 3] = 255;
  2152. }
  2153. }
  2154. }
  2155. context.putImageData(image, 0, 0);
  2156. return canvas;
  2157. };
  2158. /** @hidden */
  2159. ColorPicker.prototype._draw = function (context) {
  2160. context.save();
  2161. this._applyStates(context);
  2162. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2163. var wheelThickness = radius * .2;
  2164. var left = this._currentMeasure.left;
  2165. var top = this._currentMeasure.top;
  2166. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2167. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2168. }
  2169. this._updateSquareProps();
  2170. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2171. context.shadowColor = this.shadowColor;
  2172. context.shadowBlur = this.shadowBlur;
  2173. context.shadowOffsetX = this.shadowOffsetX;
  2174. context.shadowOffsetY = this.shadowOffsetY;
  2175. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2176. }
  2177. context.drawImage(this._colorWheelCanvas, left, top);
  2178. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2179. context.shadowBlur = 0;
  2180. context.shadowOffsetX = 0;
  2181. context.shadowOffsetY = 0;
  2182. }
  2183. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2184. var cx = this._squareLeft + this._squareSize * this._s;
  2185. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2186. this._drawCircle(cx, cy, radius * .04, context);
  2187. var dist = radius - wheelThickness * .5;
  2188. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2189. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2190. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2191. context.restore();
  2192. };
  2193. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2194. if (this._pointerStartedOnWheel) {
  2195. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2196. var centerX = radius + this._currentMeasure.left;
  2197. var centerY = radius + this._currentMeasure.top;
  2198. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2199. }
  2200. else if (this._pointerStartedOnSquare) {
  2201. this._updateSquareProps();
  2202. this._s = (x - this._squareLeft) / this._squareSize;
  2203. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2204. this._s = Math.min(this._s, 1);
  2205. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2206. this._v = Math.min(this._v, 1);
  2207. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2208. }
  2209. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2210. this.value = this._tmpColor;
  2211. };
  2212. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2213. this._updateSquareProps();
  2214. var left = this._squareLeft;
  2215. var top = this._squareTop;
  2216. var size = this._squareSize;
  2217. if (x >= left && x <= left + size &&
  2218. y >= top && y <= top + size) {
  2219. return true;
  2220. }
  2221. return false;
  2222. };
  2223. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2224. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2225. var centerX = radius + this._currentMeasure.left;
  2226. var centerY = radius + this._currentMeasure.top;
  2227. var wheelThickness = radius * .2;
  2228. var innerRadius = radius - wheelThickness;
  2229. var radiusSq = radius * radius;
  2230. var innerRadiusSq = innerRadius * innerRadius;
  2231. var dx = x - centerX;
  2232. var dy = y - centerY;
  2233. var distSq = dx * dx + dy * dy;
  2234. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2235. return true;
  2236. }
  2237. return false;
  2238. };
  2239. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  2240. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  2241. return false;
  2242. }
  2243. this._pointerIsDown = true;
  2244. this._pointerStartedOnSquare = false;
  2245. this._pointerStartedOnWheel = false;
  2246. // Invert transform
  2247. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2248. var x = this._transformedPosition.x;
  2249. var y = this._transformedPosition.y;
  2250. if (this._isPointOnSquare(x, y)) {
  2251. this._pointerStartedOnSquare = true;
  2252. }
  2253. else if (this._isPointOnWheel(x, y)) {
  2254. this._pointerStartedOnWheel = true;
  2255. }
  2256. this._updateValueFromPointer(x, y);
  2257. this._host._capturingControl[pointerId] = this;
  2258. this._lastPointerDownID = pointerId;
  2259. return true;
  2260. };
  2261. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  2262. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2263. if (pointerId != this._lastPointerDownID) {
  2264. return;
  2265. }
  2266. // Invert transform
  2267. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2268. var x = this._transformedPosition.x;
  2269. var y = this._transformedPosition.y;
  2270. if (this._pointerIsDown) {
  2271. this._updateValueFromPointer(x, y);
  2272. }
  2273. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
  2274. };
  2275. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  2276. this._pointerIsDown = false;
  2277. delete this._host._capturingControl[pointerId];
  2278. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick, pi);
  2279. };
  2280. ColorPicker.prototype._onCanvasBlur = function () {
  2281. this._forcePointerUp();
  2282. _super.prototype._onCanvasBlur.call(this);
  2283. };
  2284. /**
  2285. * This function expands the color picker by creating a color picker dialog with manual
  2286. * color value input and the ability to save colors into an array to be used later in
  2287. * subsequent launches of the dialogue.
  2288. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2289. * @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.
  2290. * @returns picked color as a hex string and the saved colors array as hex strings.
  2291. */
  2292. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2293. return new Promise(function (resolve, reject) {
  2294. // Default options
  2295. options.pickerWidth = options.pickerWidth || "640px";
  2296. options.pickerHeight = options.pickerHeight || "400px";
  2297. options.headerHeight = options.headerHeight || "35px";
  2298. options.lastColor = options.lastColor || "#000000";
  2299. options.swatchLimit = options.swatchLimit || 20;
  2300. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2301. // Window size settings
  2302. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2303. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2304. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2305. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2306. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2307. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2308. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2309. // Button Colors
  2310. var buttonColor = "#c0c0c0";
  2311. var buttonBackgroundColor = "#535353";
  2312. var buttonBackgroundHoverColor = "#414141";
  2313. var buttonBackgroundClickColor = "515151";
  2314. var buttonDisabledColor = "#555555";
  2315. var buttonDisabledBackgroundColor = "#454545";
  2316. var currentSwatchesOutlineColor = "#404040";
  2317. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2318. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2319. var iconColorDark = "#aaaaaa";
  2320. var iconColorLight = "#ffffff";
  2321. var closeIconColor;
  2322. // Button settings
  2323. var buttonFontSize;
  2324. var butEdit;
  2325. var buttonWidth;
  2326. var buttonHeight;
  2327. // Input Text Colors
  2328. var inputFieldLabels = ["R", "G", "B"];
  2329. var inputTextBackgroundColor = "#454545";
  2330. var inputTextColor = "#f0f0f0";
  2331. // This is the current color as set by either the picker or by entering a value
  2332. var currentColor;
  2333. // This int is used for naming swatches and serves as the index for calling them from the list
  2334. var swatchNumber;
  2335. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2336. var swatchDrawer;
  2337. var editSwatchMode = false;
  2338. // Color InputText fields that will be updated upon value change
  2339. var picker;
  2340. var rValInt;
  2341. var gValInt;
  2342. var bValInt;
  2343. var rValDec;
  2344. var gValDec;
  2345. var bValDec;
  2346. var hexVal;
  2347. var newSwatch;
  2348. var lastVal;
  2349. var activeField;
  2350. /**
  2351. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2352. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2353. * are will receive no update. This is to prevent the input from the user being overwritten.
  2354. */
  2355. function updateValues(value, inputField) {
  2356. activeField = inputField;
  2357. var pickedColor = value.toHexString();
  2358. newSwatch.background = pickedColor;
  2359. if (rValInt.name != activeField) {
  2360. rValInt.text = Math.floor(value.r * 255).toString();
  2361. }
  2362. if (gValInt.name != activeField) {
  2363. gValInt.text = Math.floor(value.g * 255).toString();
  2364. }
  2365. if (bValInt.name != activeField) {
  2366. bValInt.text = Math.floor(value.b * 255).toString();
  2367. }
  2368. if (rValDec.name != activeField) {
  2369. rValDec.text = value.r.toString();
  2370. }
  2371. if (gValDec.name != activeField) {
  2372. gValDec.text = value.g.toString();
  2373. }
  2374. if (bValDec.name != activeField) {
  2375. bValDec.text = value.b.toString();
  2376. }
  2377. if (hexVal.name != activeField) {
  2378. var minusPound = pickedColor.split("#");
  2379. hexVal.text = minusPound[1];
  2380. }
  2381. if (picker.name != activeField) {
  2382. picker.value = value;
  2383. }
  2384. }
  2385. // 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.
  2386. function updateInt(field, channel) {
  2387. var newValue = field.text;
  2388. var checkVal = /[^0-9]/g.test(newValue);
  2389. if (checkVal) {
  2390. field.text = lastVal;
  2391. return;
  2392. }
  2393. else {
  2394. if (newValue != "") {
  2395. if (Math.floor(parseInt(newValue)) < 0) {
  2396. newValue = "0";
  2397. }
  2398. else if (Math.floor(parseInt(newValue)) > 255) {
  2399. newValue = "255";
  2400. }
  2401. else if (isNaN(parseInt(newValue))) {
  2402. newValue = "0";
  2403. }
  2404. }
  2405. if (activeField == field.name) {
  2406. lastVal = newValue;
  2407. }
  2408. }
  2409. if (newValue != "") {
  2410. newValue = parseInt(newValue).toString();
  2411. field.text = newValue;
  2412. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2413. if (activeField == field.name) {
  2414. if (channel == "r") {
  2415. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2416. }
  2417. else if (channel == "g") {
  2418. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2419. }
  2420. else {
  2421. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2422. }
  2423. }
  2424. }
  2425. }
  2426. // 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.
  2427. function updateFloat(field, channel) {
  2428. var newValue = field.text;
  2429. var checkVal = /[^0-9\.]/g.test(newValue);
  2430. if (checkVal) {
  2431. field.text = lastVal;
  2432. return;
  2433. }
  2434. else {
  2435. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2436. if (parseFloat(newValue) < 0.0) {
  2437. newValue = "0.0";
  2438. }
  2439. else if (parseFloat(newValue) > 1.0) {
  2440. newValue = "1.0";
  2441. }
  2442. else if (isNaN(parseFloat(newValue))) {
  2443. newValue = "0.0";
  2444. }
  2445. }
  2446. if (activeField == field.name) {
  2447. lastVal = newValue;
  2448. }
  2449. }
  2450. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2451. newValue = parseFloat(newValue).toString();
  2452. field.text = newValue;
  2453. }
  2454. else {
  2455. newValue = "0.0";
  2456. }
  2457. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2458. if (activeField == field.name) {
  2459. if (channel == "r") {
  2460. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2461. }
  2462. else if (channel == "g") {
  2463. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2464. }
  2465. else {
  2466. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2467. }
  2468. }
  2469. }
  2470. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2471. function deleteSwatch(index) {
  2472. if (options.savedColors) {
  2473. options.savedColors.splice(index, 1);
  2474. }
  2475. if (options.savedColors && options.savedColors.length == 0) {
  2476. setEditButtonVisibility(false);
  2477. editSwatchMode = false;
  2478. }
  2479. }
  2480. // Creates and styles an individual swatch when updateSwatches is called.
  2481. function createSwatch() {
  2482. if (options.savedColors && options.savedColors[swatchNumber]) {
  2483. if (editSwatchMode) {
  2484. var icon = "b";
  2485. }
  2486. else {
  2487. var icon = "";
  2488. }
  2489. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2490. swatch.fontFamily = "BabylonJSglyphs";
  2491. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2492. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2493. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2494. if (swatchLuminence > luminanceLimit) {
  2495. swatch.color = iconColorDark;
  2496. }
  2497. else {
  2498. swatch.color = iconColorLight;
  2499. }
  2500. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2501. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2502. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2503. swatch.background = options.savedColors[swatchNumber];
  2504. swatch.thickness = 2;
  2505. var metadata_1 = swatchNumber;
  2506. swatch.pointerDownAnimation = function () {
  2507. swatch.thickness = 4;
  2508. };
  2509. swatch.pointerUpAnimation = function () {
  2510. swatch.thickness = 3;
  2511. };
  2512. swatch.pointerEnterAnimation = function () {
  2513. swatch.thickness = 3;
  2514. };
  2515. swatch.pointerOutAnimation = function () {
  2516. swatch.thickness = 2;
  2517. };
  2518. swatch.onPointerClickObservable.add(function () {
  2519. if (!editSwatchMode) {
  2520. if (options.savedColors) {
  2521. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2522. }
  2523. }
  2524. else {
  2525. deleteSwatch(metadata_1);
  2526. updateSwatches("", butSave);
  2527. }
  2528. });
  2529. return swatch;
  2530. }
  2531. else {
  2532. return null;
  2533. }
  2534. }
  2535. // Mode switch to render button text and close symbols on swatch controls
  2536. function editSwatches(mode) {
  2537. if (mode !== undefined) {
  2538. editSwatchMode = mode;
  2539. }
  2540. if (editSwatchMode) {
  2541. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2542. var thisButton = swatchDrawer.children[i];
  2543. thisButton.textBlock.text = "b";
  2544. }
  2545. if (butEdit !== undefined) {
  2546. butEdit.textBlock.text = "Done";
  2547. }
  2548. }
  2549. else {
  2550. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2551. var thisButton = swatchDrawer.children[i];
  2552. thisButton.textBlock.text = "";
  2553. }
  2554. if (butEdit !== undefined) {
  2555. butEdit.textBlock.text = "Edit";
  2556. }
  2557. }
  2558. }
  2559. /**
  2560. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2561. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2562. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2563. * saved colors there are and how many can be stored per row.
  2564. */
  2565. function updateSwatches(color, button) {
  2566. if (options.savedColors) {
  2567. if (color != "") {
  2568. options.savedColors.push(color);
  2569. }
  2570. swatchNumber = 0;
  2571. swatchDrawer.clearControls();
  2572. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2573. if (rowCount == 0) {
  2574. var gutterCount = 0;
  2575. }
  2576. else {
  2577. var gutterCount = rowCount + 1;
  2578. }
  2579. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2580. var currentRows = swatchDrawer.rowCount;
  2581. for (var i = 0; i < currentRows; i++) {
  2582. swatchDrawer.removeRowDefinition(0);
  2583. }
  2584. for (var i = 0; i < rowCount + gutterCount; i++) {
  2585. if (i % 2) {
  2586. swatchDrawer.addRowDefinition(swatchSize, true);
  2587. }
  2588. else {
  2589. swatchDrawer.addRowDefinition(gutterSize, true);
  2590. }
  2591. }
  2592. }
  2593. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2594. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2595. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2596. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2597. var totalButtonsThisRow = options.numSwatchesPerLine;
  2598. }
  2599. else {
  2600. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2601. }
  2602. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2603. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2604. if (x > options.numSwatchesPerLine) {
  2605. continue;
  2606. }
  2607. var swatch = createSwatch();
  2608. if (swatch != null) {
  2609. swatchDrawer.addControl(swatch, y, w);
  2610. w += 2;
  2611. swatchNumber++;
  2612. }
  2613. else {
  2614. continue;
  2615. }
  2616. }
  2617. }
  2618. if (options.savedColors.length >= options.swatchLimit) {
  2619. disableButton(button, true);
  2620. }
  2621. else {
  2622. disableButton(button, false);
  2623. }
  2624. }
  2625. }
  2626. // Shows or hides edit swatches button depending on if there are saved swatches
  2627. function setEditButtonVisibility(enableButton) {
  2628. if (enableButton) {
  2629. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2630. butEdit.width = buttonWidth;
  2631. butEdit.height = buttonHeight;
  2632. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2633. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2634. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2635. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2636. butEdit.thickness = 2;
  2637. butEdit.color = buttonColor;
  2638. butEdit.fontSize = buttonFontSize;
  2639. butEdit.background = buttonBackgroundColor;
  2640. butEdit.onPointerEnterObservable.add(function () {
  2641. butEdit.background = buttonBackgroundHoverColor;
  2642. });
  2643. butEdit.onPointerOutObservable.add(function () {
  2644. butEdit.background = buttonBackgroundColor;
  2645. });
  2646. butEdit.pointerDownAnimation = function () {
  2647. butEdit.background = buttonBackgroundClickColor;
  2648. };
  2649. butEdit.pointerUpAnimation = function () {
  2650. butEdit.background = buttonBackgroundHoverColor;
  2651. };
  2652. butEdit.onPointerClickObservable.add(function () {
  2653. if (editSwatchMode) {
  2654. editSwatchMode = false;
  2655. }
  2656. else {
  2657. editSwatchMode = true;
  2658. }
  2659. editSwatches();
  2660. });
  2661. pickerGrid.addControl(butEdit, 1, 0);
  2662. }
  2663. else {
  2664. pickerGrid.removeControl(butEdit);
  2665. }
  2666. }
  2667. // Called when the user hits the limit of saved colors in the drawer.
  2668. function disableButton(button, disabled) {
  2669. if (disabled) {
  2670. button.color = buttonDisabledColor;
  2671. button.background = buttonDisabledBackgroundColor;
  2672. }
  2673. else {
  2674. button.color = buttonColor;
  2675. button.background = buttonBackgroundColor;
  2676. }
  2677. }
  2678. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2679. function closePicker(color) {
  2680. if (options.savedColors && options.savedColors.length > 0) {
  2681. resolve({
  2682. savedColors: options.savedColors,
  2683. pickedColor: color
  2684. });
  2685. }
  2686. else {
  2687. resolve({
  2688. pickedColor: color
  2689. });
  2690. }
  2691. advancedTexture.removeControl(dialogContainer);
  2692. }
  2693. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2694. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2695. dialogContainer.name = "Dialog Container";
  2696. dialogContainer.width = options.pickerWidth;
  2697. if (options.savedColors) {
  2698. dialogContainer.height = containerSize;
  2699. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2700. dialogContainer.addRowDefinition(topRow, false);
  2701. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2702. }
  2703. else {
  2704. dialogContainer.height = options.pickerHeight;
  2705. dialogContainer.addRowDefinition(1.0, false);
  2706. }
  2707. advancedTexture.addControl(dialogContainer);
  2708. // Swatch drawer which contains all saved color buttons
  2709. if (options.savedColors) {
  2710. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2711. swatchDrawer.name = "Swatch Drawer";
  2712. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2713. swatchDrawer.background = buttonBackgroundColor;
  2714. swatchDrawer.width = options.pickerWidth;
  2715. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2716. if (initialRows == 0) {
  2717. var gutterCount = 0;
  2718. }
  2719. else {
  2720. var gutterCount = initialRows + 1;
  2721. }
  2722. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2723. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2724. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2725. if (i % 2 != 0) {
  2726. swatchDrawer.addRowDefinition(swatchSize, true);
  2727. }
  2728. else {
  2729. swatchDrawer.addRowDefinition(gutterSize, true);
  2730. }
  2731. }
  2732. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2733. if (i % 2 != 0) {
  2734. swatchDrawer.addColumnDefinition(swatchSize, true);
  2735. }
  2736. else {
  2737. swatchDrawer.addColumnDefinition(gutterSize, true);
  2738. }
  2739. }
  2740. dialogContainer.addControl(swatchDrawer, 1, 0);
  2741. }
  2742. // Picker container
  2743. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2744. pickerPanel.name = "Picker Panel";
  2745. pickerPanel.height = options.pickerHeight;
  2746. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2747. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2748. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2749. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2750. dialogContainer.addControl(pickerPanel, 0, 0);
  2751. // Picker container header
  2752. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2753. header.name = "Dialogue Header Bar";
  2754. header.background = "#cccccc";
  2755. header.thickness = 0;
  2756. pickerPanel.addControl(header, 0, 0);
  2757. // Header close button
  2758. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2759. closeButton.fontFamily = "BabylonJSglyphs";
  2760. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2761. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2762. closeButton.color = closeIconColor.toHexString();
  2763. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2764. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2765. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2766. closeButton.height = closeButton.width = options.headerHeight;
  2767. closeButton.background = header.background;
  2768. closeButton.thickness = 0;
  2769. closeButton.pointerDownAnimation = function () {
  2770. };
  2771. closeButton.pointerUpAnimation = function () {
  2772. closeButton.background = header.background;
  2773. };
  2774. closeButton.pointerEnterAnimation = function () {
  2775. closeButton.color = header.background;
  2776. closeButton.background = "red";
  2777. };
  2778. closeButton.pointerOutAnimation = function () {
  2779. closeButton.color = closeIconColor.toHexString();
  2780. closeButton.background = header.background;
  2781. };
  2782. closeButton.onPointerClickObservable.add(function () {
  2783. closePicker(currentSwatch.background);
  2784. });
  2785. pickerPanel.addControl(closeButton, 0, 0);
  2786. // Dialog container body
  2787. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2788. dialogBody.name = "Dialogue Body";
  2789. dialogBody.background = buttonBackgroundColor;
  2790. var dialogBodyCols = [0.4375, 0.5625];
  2791. dialogBody.addRowDefinition(1.0, false);
  2792. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2793. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2794. pickerPanel.addControl(dialogBody, 1, 0);
  2795. // Picker grid
  2796. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2797. pickerGrid.name = "Picker Grid";
  2798. pickerGrid.addRowDefinition(0.85, false);
  2799. pickerGrid.addRowDefinition(0.15, false);
  2800. dialogBody.addControl(pickerGrid, 0, 0);
  2801. // Picker control
  2802. picker = new ColorPicker();
  2803. picker.name = "GUI Color Picker";
  2804. if (options.pickerHeight < options.pickerWidth) {
  2805. picker.width = 0.89;
  2806. }
  2807. else {
  2808. picker.height = 0.89;
  2809. }
  2810. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2811. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2812. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2813. picker.onPointerDownObservable.add(function () {
  2814. activeField = picker.name;
  2815. lastVal = "";
  2816. editSwatches(false);
  2817. });
  2818. picker.onValueChangedObservable.add(function (value) {
  2819. if (activeField == picker.name) {
  2820. updateValues(value, picker.name);
  2821. }
  2822. });
  2823. pickerGrid.addControl(picker, 0, 0);
  2824. // Picker body right quarant
  2825. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2826. pickerBodyRight.name = "Dialogue Right Half";
  2827. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2828. var pickerBodyRightRows = [0.514, 0.486];
  2829. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2830. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2831. dialogBody.addControl(pickerBodyRight, 1, 1);
  2832. // Picker container swatches and buttons
  2833. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2834. pickerSwatchesButtons.name = "Swatches and Buttons";
  2835. var pickerButtonsCol = [0.417, 0.583];
  2836. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2837. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2838. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2839. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2840. // Picker Swatches quadrant
  2841. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2842. pickerSwatches.name = "New and Current Swatches";
  2843. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2844. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2845. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2846. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2847. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2848. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2849. // Active swatches
  2850. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2851. activeSwatches.name = "Active Swatches";
  2852. activeSwatches.width = 0.67;
  2853. activeSwatches.addRowDefinition(0.5, false);
  2854. activeSwatches.addRowDefinition(0.5, false);
  2855. pickerSwatches.addControl(activeSwatches, 2, 0);
  2856. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2857. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2858. if (options.pickerWidth > options.pickerHeight) {
  2859. var labelTextSize = labelHeight;
  2860. }
  2861. else {
  2862. var labelTextSize = labelWidth;
  2863. }
  2864. // New color swatch and previous color button
  2865. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2866. newText.text = "new";
  2867. newText.name = "New Color Label";
  2868. newText.color = buttonColor;
  2869. newText.fontSize = labelTextSize;
  2870. pickerSwatches.addControl(newText, 1, 0);
  2871. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2872. newSwatch.name = "New Color Swatch";
  2873. newSwatch.background = options.lastColor;
  2874. newSwatch.thickness = 0;
  2875. activeSwatches.addControl(newSwatch, 0, 0);
  2876. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2877. currentSwatch.background = options.lastColor;
  2878. currentSwatch.thickness = 0;
  2879. currentSwatch.onPointerClickObservable.add(function () {
  2880. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2881. updateValues(revertColor, currentSwatch.name);
  2882. editSwatches(false);
  2883. });
  2884. currentSwatch.pointerDownAnimation = function () { };
  2885. currentSwatch.pointerUpAnimation = function () { };
  2886. currentSwatch.pointerEnterAnimation = function () { };
  2887. currentSwatch.pointerOutAnimation = function () { };
  2888. activeSwatches.addControl(currentSwatch, 1, 0);
  2889. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2890. swatchOutline.name = "Swatch Outline";
  2891. swatchOutline.width = 0.67;
  2892. swatchOutline.thickness = 2;
  2893. swatchOutline.color = currentSwatchesOutlineColor;
  2894. swatchOutline.isHitTestVisible = false;
  2895. pickerSwatches.addControl(swatchOutline, 2, 0);
  2896. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2897. currentText.name = "Current Color Label";
  2898. currentText.text = "current";
  2899. currentText.color = buttonColor;
  2900. currentText.fontSize = labelTextSize;
  2901. pickerSwatches.addControl(currentText, 3, 0);
  2902. // Buttons grid
  2903. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2904. buttonGrid.name = "Button Grid";
  2905. buttonGrid.height = 0.8;
  2906. var buttonGridRows = 1 / 3;
  2907. buttonGrid.addRowDefinition(buttonGridRows, false);
  2908. buttonGrid.addRowDefinition(buttonGridRows, false);
  2909. buttonGrid.addRowDefinition(buttonGridRows, false);
  2910. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2911. // Determine pixel width and height for all buttons from overall panel dimensions
  2912. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2913. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2914. // Determine button type size
  2915. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2916. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2917. }
  2918. else {
  2919. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2920. }
  2921. // Panel Buttons
  2922. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2923. butOK.width = buttonWidth;
  2924. butOK.height = buttonHeight;
  2925. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2926. butOK.thickness = 2;
  2927. butOK.color = buttonColor;
  2928. butOK.fontSize = buttonFontSize;
  2929. butOK.background = buttonBackgroundColor;
  2930. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2931. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2932. butOK.pointerDownAnimation = function () {
  2933. butOK.background = buttonBackgroundClickColor;
  2934. };
  2935. butOK.pointerUpAnimation = function () {
  2936. butOK.background = buttonBackgroundHoverColor;
  2937. };
  2938. butOK.onPointerClickObservable.add(function () {
  2939. editSwatches(false);
  2940. closePicker(newSwatch.background);
  2941. });
  2942. buttonGrid.addControl(butOK, 0, 0);
  2943. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2944. butCancel.width = buttonWidth;
  2945. butCancel.height = buttonHeight;
  2946. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2947. butCancel.thickness = 2;
  2948. butCancel.color = buttonColor;
  2949. butCancel.fontSize = buttonFontSize;
  2950. butCancel.background = buttonBackgroundColor;
  2951. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2952. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2953. butCancel.pointerDownAnimation = function () {
  2954. butCancel.background = buttonBackgroundClickColor;
  2955. };
  2956. butCancel.pointerUpAnimation = function () {
  2957. butCancel.background = buttonBackgroundHoverColor;
  2958. };
  2959. butCancel.onPointerClickObservable.add(function () {
  2960. editSwatches(false);
  2961. closePicker(currentSwatch.background);
  2962. });
  2963. buttonGrid.addControl(butCancel, 1, 0);
  2964. if (options.savedColors) {
  2965. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2966. butSave.width = buttonWidth;
  2967. butSave.height = buttonHeight;
  2968. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2969. butSave.thickness = 2;
  2970. butSave.fontSize = buttonFontSize;
  2971. if (options.savedColors.length < options.swatchLimit) {
  2972. butSave.color = buttonColor;
  2973. butSave.background = buttonBackgroundColor;
  2974. }
  2975. else {
  2976. disableButton(butSave, true);
  2977. }
  2978. butSave.onPointerEnterObservable.add(function () {
  2979. if (options.savedColors) {
  2980. if (options.savedColors.length < options.swatchLimit) {
  2981. butSave.background = buttonBackgroundHoverColor;
  2982. }
  2983. }
  2984. });
  2985. butSave.onPointerOutObservable.add(function () {
  2986. if (options.savedColors) {
  2987. if (options.savedColors.length < options.swatchLimit) {
  2988. butSave.background = buttonBackgroundColor;
  2989. }
  2990. }
  2991. });
  2992. butSave.pointerDownAnimation = function () {
  2993. if (options.savedColors) {
  2994. if (options.savedColors.length < options.swatchLimit) {
  2995. butSave.background = buttonBackgroundClickColor;
  2996. }
  2997. }
  2998. };
  2999. butSave.pointerUpAnimation = function () {
  3000. if (options.savedColors) {
  3001. if (options.savedColors.length < options.swatchLimit) {
  3002. butSave.background = buttonBackgroundHoverColor;
  3003. }
  3004. }
  3005. };
  3006. butSave.onPointerClickObservable.add(function () {
  3007. if (options.savedColors) {
  3008. if (options.savedColors.length == 0) {
  3009. setEditButtonVisibility(true);
  3010. }
  3011. if (options.savedColors.length < options.swatchLimit) {
  3012. updateSwatches(newSwatch.background, butSave);
  3013. }
  3014. editSwatches(false);
  3015. }
  3016. });
  3017. if (options.savedColors.length > 0) {
  3018. setEditButtonVisibility(true);
  3019. }
  3020. buttonGrid.addControl(butSave, 2, 0);
  3021. }
  3022. // Picker color values input
  3023. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3024. pickerColorValues.name = "Dialog Lower Right";
  3025. pickerColorValues.addRowDefinition(0.02, false);
  3026. pickerColorValues.addRowDefinition(0.63, false);
  3027. pickerColorValues.addRowDefinition(0.21, false);
  3028. pickerColorValues.addRowDefinition(0.14, false);
  3029. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  3030. // RGB values text boxes
  3031. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  3032. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3033. rgbValuesQuadrant.name = "RGB Values";
  3034. rgbValuesQuadrant.width = 0.82;
  3035. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  3036. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  3037. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  3038. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  3039. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  3040. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  3041. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  3042. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  3043. for (var i = 0; i < inputFieldLabels.length; i++) {
  3044. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3045. labelText.text = inputFieldLabels[i];
  3046. labelText.color = buttonColor;
  3047. labelText.fontSize = buttonFontSize;
  3048. rgbValuesQuadrant.addControl(labelText, i, 0);
  3049. }
  3050. // Input fields for RGB values
  3051. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3052. rValInt.width = 0.83;
  3053. rValInt.height = 0.72;
  3054. rValInt.name = "rIntField";
  3055. rValInt.fontSize = buttonFontSize;
  3056. rValInt.text = (currentColor.r * 255).toString();
  3057. rValInt.color = inputTextColor;
  3058. rValInt.background = inputTextBackgroundColor;
  3059. rValInt.onFocusObservable.add(function () {
  3060. activeField = rValInt.name;
  3061. lastVal = rValInt.text;
  3062. editSwatches(false);
  3063. });
  3064. rValInt.onBlurObservable.add(function () {
  3065. if (rValInt.text == "") {
  3066. rValInt.text = "0";
  3067. }
  3068. updateInt(rValInt, "r");
  3069. if (activeField == rValInt.name) {
  3070. activeField = "";
  3071. }
  3072. });
  3073. rValInt.onTextChangedObservable.add(function () {
  3074. if (activeField == rValInt.name) {
  3075. updateInt(rValInt, "r");
  3076. }
  3077. });
  3078. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  3079. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3080. gValInt.width = 0.83;
  3081. gValInt.height = 0.72;
  3082. gValInt.name = "gIntField";
  3083. gValInt.fontSize = buttonFontSize;
  3084. gValInt.text = (currentColor.g * 255).toString();
  3085. gValInt.color = inputTextColor;
  3086. gValInt.background = inputTextBackgroundColor;
  3087. gValInt.onFocusObservable.add(function () {
  3088. activeField = gValInt.name;
  3089. lastVal = gValInt.text;
  3090. editSwatches(false);
  3091. });
  3092. gValInt.onBlurObservable.add(function () {
  3093. if (gValInt.text == "") {
  3094. gValInt.text = "0";
  3095. }
  3096. updateInt(gValInt, "g");
  3097. if (activeField == gValInt.name) {
  3098. activeField = "";
  3099. }
  3100. });
  3101. gValInt.onTextChangedObservable.add(function () {
  3102. if (activeField == gValInt.name) {
  3103. updateInt(gValInt, "g");
  3104. }
  3105. });
  3106. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  3107. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3108. bValInt.width = 0.83;
  3109. bValInt.height = 0.72;
  3110. bValInt.name = "bIntField";
  3111. bValInt.fontSize = buttonFontSize;
  3112. bValInt.text = (currentColor.b * 255).toString();
  3113. bValInt.color = inputTextColor;
  3114. bValInt.background = inputTextBackgroundColor;
  3115. bValInt.onFocusObservable.add(function () {
  3116. activeField = bValInt.name;
  3117. lastVal = bValInt.text;
  3118. editSwatches(false);
  3119. });
  3120. bValInt.onBlurObservable.add(function () {
  3121. if (bValInt.text == "") {
  3122. bValInt.text = "0";
  3123. }
  3124. updateInt(bValInt, "b");
  3125. if (activeField == bValInt.name) {
  3126. activeField = "";
  3127. }
  3128. });
  3129. bValInt.onTextChangedObservable.add(function () {
  3130. if (activeField == bValInt.name) {
  3131. updateInt(bValInt, "b");
  3132. }
  3133. });
  3134. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  3135. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3136. rValDec.width = 0.95;
  3137. rValDec.height = 0.72;
  3138. rValDec.name = "rDecField";
  3139. rValDec.fontSize = buttonFontSize;
  3140. rValDec.text = currentColor.r.toString();
  3141. rValDec.color = inputTextColor;
  3142. rValDec.background = inputTextBackgroundColor;
  3143. rValDec.onFocusObservable.add(function () {
  3144. activeField = rValDec.name;
  3145. lastVal = rValDec.text;
  3146. editSwatches(false);
  3147. });
  3148. rValDec.onBlurObservable.add(function () {
  3149. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3150. rValDec.text = "0";
  3151. updateFloat(rValDec, "r");
  3152. }
  3153. if (activeField == rValDec.name) {
  3154. activeField = "";
  3155. }
  3156. });
  3157. rValDec.onTextChangedObservable.add(function () {
  3158. if (activeField == rValDec.name) {
  3159. updateFloat(rValDec, "r");
  3160. }
  3161. });
  3162. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3163. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3164. gValDec.width = 0.95;
  3165. gValDec.height = 0.72;
  3166. gValDec.name = "gDecField";
  3167. gValDec.fontSize = buttonFontSize;
  3168. gValDec.text = currentColor.g.toString();
  3169. gValDec.color = inputTextColor;
  3170. gValDec.background = inputTextBackgroundColor;
  3171. gValDec.onFocusObservable.add(function () {
  3172. activeField = gValDec.name;
  3173. lastVal = gValDec.text;
  3174. editSwatches(false);
  3175. });
  3176. gValDec.onBlurObservable.add(function () {
  3177. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3178. gValDec.text = "0";
  3179. updateFloat(gValDec, "g");
  3180. }
  3181. if (activeField == gValDec.name) {
  3182. activeField = "";
  3183. }
  3184. });
  3185. gValDec.onTextChangedObservable.add(function () {
  3186. if (activeField == gValDec.name) {
  3187. updateFloat(gValDec, "g");
  3188. }
  3189. });
  3190. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3191. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3192. bValDec.width = 0.95;
  3193. bValDec.height = 0.72;
  3194. bValDec.name = "bDecField";
  3195. bValDec.fontSize = buttonFontSize;
  3196. bValDec.text = currentColor.b.toString();
  3197. bValDec.color = inputTextColor;
  3198. bValDec.background = inputTextBackgroundColor;
  3199. bValDec.onFocusObservable.add(function () {
  3200. activeField = bValDec.name;
  3201. lastVal = bValDec.text;
  3202. editSwatches(false);
  3203. });
  3204. bValDec.onBlurObservable.add(function () {
  3205. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3206. bValDec.text = "0";
  3207. updateFloat(bValDec, "b");
  3208. }
  3209. if (activeField == bValDec.name) {
  3210. activeField = "";
  3211. }
  3212. });
  3213. bValDec.onTextChangedObservable.add(function () {
  3214. if (activeField == bValDec.name) {
  3215. updateFloat(bValDec, "b");
  3216. }
  3217. });
  3218. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3219. // Hex value input
  3220. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3221. hexValueQuadrant.name = "Hex Value";
  3222. hexValueQuadrant.width = 0.82;
  3223. hexValueQuadrant.addRowDefinition(1.0, false);
  3224. hexValueQuadrant.addColumnDefinition(0.1, false);
  3225. hexValueQuadrant.addColumnDefinition(0.9, false);
  3226. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3227. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3228. labelText.text = "#";
  3229. labelText.color = buttonColor;
  3230. labelText.fontSize = buttonFontSize;
  3231. hexValueQuadrant.addControl(labelText, 0, 0);
  3232. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3233. hexVal.width = 0.96;
  3234. hexVal.height = 0.72;
  3235. hexVal.name = "hexField";
  3236. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3237. hexVal.fontSize = buttonFontSize;
  3238. var minusPound = options.lastColor.split("#");
  3239. hexVal.text = minusPound[1];
  3240. hexVal.color = inputTextColor;
  3241. hexVal.background = inputTextBackgroundColor;
  3242. hexVal.onFocusObservable.add(function () {
  3243. activeField = hexVal.name;
  3244. lastVal = hexVal.text;
  3245. editSwatches(false);
  3246. });
  3247. hexVal.onBlurObservable.add(function () {
  3248. if (hexVal.text.length == 3) {
  3249. var val = hexVal.text.split("");
  3250. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3251. }
  3252. if (hexVal.text == "") {
  3253. hexVal.text = "000000";
  3254. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3255. }
  3256. if (activeField == hexVal.name) {
  3257. activeField = "";
  3258. }
  3259. });
  3260. hexVal.onTextChangedObservable.add(function () {
  3261. var newHexValue = hexVal.text;
  3262. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3263. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3264. hexVal.text = lastVal;
  3265. }
  3266. else {
  3267. if (hexVal.text.length < 6) {
  3268. var leadingZero = 6 - hexVal.text.length;
  3269. for (var i = 0; i < leadingZero; i++) {
  3270. newHexValue = "0" + newHexValue;
  3271. }
  3272. }
  3273. if (hexVal.text.length == 3) {
  3274. var val = hexVal.text.split("");
  3275. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3276. }
  3277. newHexValue = "#" + newHexValue;
  3278. if (activeField == hexVal.name) {
  3279. lastVal = hexVal.text;
  3280. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3281. }
  3282. }
  3283. });
  3284. hexValueQuadrant.addControl(hexVal, 0, 1);
  3285. if (options.savedColors && options.savedColors.length > 0) {
  3286. updateSwatches("", butSave);
  3287. }
  3288. });
  3289. };
  3290. ColorPicker._Epsilon = 0.000001;
  3291. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3292. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3293. ], ColorPicker.prototype, "value", null);
  3294. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3295. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3296. ], ColorPicker.prototype, "width", null);
  3297. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3298. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3299. ], ColorPicker.prototype, "height", null);
  3300. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3301. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3302. ], ColorPicker.prototype, "size", null);
  3303. return ColorPicker;
  3304. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3305. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3306. /***/ }),
  3307. /***/ "./2D/controls/container.ts":
  3308. /*!**********************************!*\
  3309. !*** ./2D/controls/container.ts ***!
  3310. \**********************************/
  3311. /*! exports provided: Container */
  3312. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3313. "use strict";
  3314. __webpack_require__.r(__webpack_exports__);
  3315. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3316. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3317. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/perfCounter");
  3318. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3319. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3320. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3321. /**
  3322. * Root class for 2D containers
  3323. * @see https://doc.babylonjs.com/how_to/gui#containers
  3324. */
  3325. var Container = /** @class */ (function (_super) {
  3326. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3327. /**
  3328. * Creates a new Container
  3329. * @param name defines the name of the container
  3330. */
  3331. function Container(name) {
  3332. var _this = _super.call(this, name) || this;
  3333. _this.name = name;
  3334. /** @hidden */
  3335. _this._children = new Array();
  3336. /** @hidden */
  3337. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3338. /** @hidden */
  3339. _this._background = "";
  3340. /** @hidden */
  3341. _this._adaptWidthToChildren = false;
  3342. /** @hidden */
  3343. _this._adaptHeightToChildren = false;
  3344. /**
  3345. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3346. */
  3347. _this.logLayoutCycleErrors = false;
  3348. /**
  3349. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3350. */
  3351. _this.maxLayoutCycle = 3;
  3352. return _this;
  3353. }
  3354. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3355. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3356. get: function () {
  3357. return this._adaptHeightToChildren;
  3358. },
  3359. set: function (value) {
  3360. if (this._adaptHeightToChildren === value) {
  3361. return;
  3362. }
  3363. this._adaptHeightToChildren = value;
  3364. if (value) {
  3365. this.height = "100%";
  3366. }
  3367. this._markAsDirty();
  3368. },
  3369. enumerable: false,
  3370. configurable: true
  3371. });
  3372. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3373. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3374. get: function () {
  3375. return this._adaptWidthToChildren;
  3376. },
  3377. set: function (value) {
  3378. if (this._adaptWidthToChildren === value) {
  3379. return;
  3380. }
  3381. this._adaptWidthToChildren = value;
  3382. if (value) {
  3383. this.width = "100%";
  3384. }
  3385. this._markAsDirty();
  3386. },
  3387. enumerable: false,
  3388. configurable: true
  3389. });
  3390. Object.defineProperty(Container.prototype, "background", {
  3391. /** Gets or sets background color */
  3392. get: function () {
  3393. return this._background;
  3394. },
  3395. set: function (value) {
  3396. if (this._background === value) {
  3397. return;
  3398. }
  3399. this._background = value;
  3400. this._markAsDirty();
  3401. },
  3402. enumerable: false,
  3403. configurable: true
  3404. });
  3405. Object.defineProperty(Container.prototype, "children", {
  3406. /** Gets the list of children */
  3407. get: function () {
  3408. return this._children;
  3409. },
  3410. enumerable: false,
  3411. configurable: true
  3412. });
  3413. Container.prototype._getTypeName = function () {
  3414. return "Container";
  3415. };
  3416. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3417. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3418. var child = _a[_i];
  3419. child._markMatrixAsDirty();
  3420. }
  3421. };
  3422. /**
  3423. * Gets a child using its name
  3424. * @param name defines the child name to look for
  3425. * @returns the child control if found
  3426. */
  3427. Container.prototype.getChildByName = function (name) {
  3428. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3429. var child = _a[_i];
  3430. if (child.name === name) {
  3431. return child;
  3432. }
  3433. }
  3434. return null;
  3435. };
  3436. /**
  3437. * Gets a child using its type and its name
  3438. * @param name defines the child name to look for
  3439. * @param type defines the child type to look for
  3440. * @returns the child control if found
  3441. */
  3442. Container.prototype.getChildByType = function (name, type) {
  3443. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3444. var child = _a[_i];
  3445. if (child.typeName === type) {
  3446. return child;
  3447. }
  3448. }
  3449. return null;
  3450. };
  3451. /**
  3452. * Search for a specific control in children
  3453. * @param control defines the control to look for
  3454. * @returns true if the control is in child list
  3455. */
  3456. Container.prototype.containsControl = function (control) {
  3457. return this.children.indexOf(control) !== -1;
  3458. };
  3459. /**
  3460. * Adds a new control to the current container
  3461. * @param control defines the control to add
  3462. * @returns the current container
  3463. */
  3464. Container.prototype.addControl = function (control) {
  3465. if (!control) {
  3466. return this;
  3467. }
  3468. var index = this._children.indexOf(control);
  3469. if (index !== -1) {
  3470. return this;
  3471. }
  3472. control._link(this._host);
  3473. control._markAllAsDirty();
  3474. this._reOrderControl(control);
  3475. this._markAsDirty();
  3476. return this;
  3477. };
  3478. /**
  3479. * Removes all controls from the current container
  3480. * @returns the current container
  3481. */
  3482. Container.prototype.clearControls = function () {
  3483. var children = this.children.slice();
  3484. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3485. var child = children_1[_i];
  3486. this.removeControl(child);
  3487. }
  3488. return this;
  3489. };
  3490. /**
  3491. * Removes a control from the current container
  3492. * @param control defines the control to remove
  3493. * @returns the current container
  3494. */
  3495. Container.prototype.removeControl = function (control) {
  3496. var index = this._children.indexOf(control);
  3497. if (index !== -1) {
  3498. this._children.splice(index, 1);
  3499. control.parent = null;
  3500. }
  3501. control.linkWithMesh(null);
  3502. if (this._host) {
  3503. this._host._cleanControlAfterRemoval(control);
  3504. }
  3505. this._markAsDirty();
  3506. return this;
  3507. };
  3508. /** @hidden */
  3509. Container.prototype._reOrderControl = function (control) {
  3510. this.removeControl(control);
  3511. var wasAdded = false;
  3512. for (var index = 0; index < this._children.length; index++) {
  3513. if (this._children[index].zIndex > control.zIndex) {
  3514. this._children.splice(index, 0, control);
  3515. wasAdded = true;
  3516. break;
  3517. }
  3518. }
  3519. if (!wasAdded) {
  3520. this._children.push(control);
  3521. }
  3522. control.parent = this;
  3523. this._markAsDirty();
  3524. };
  3525. /** @hidden */
  3526. Container.prototype._offsetLeft = function (offset) {
  3527. _super.prototype._offsetLeft.call(this, offset);
  3528. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3529. var child = _a[_i];
  3530. child._offsetLeft(offset);
  3531. }
  3532. };
  3533. /** @hidden */
  3534. Container.prototype._offsetTop = function (offset) {
  3535. _super.prototype._offsetTop.call(this, offset);
  3536. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3537. var child = _a[_i];
  3538. child._offsetTop(offset);
  3539. }
  3540. };
  3541. /** @hidden */
  3542. Container.prototype._markAllAsDirty = function () {
  3543. _super.prototype._markAllAsDirty.call(this);
  3544. for (var index = 0; index < this._children.length; index++) {
  3545. this._children[index]._markAllAsDirty();
  3546. }
  3547. };
  3548. /** @hidden */
  3549. Container.prototype._localDraw = function (context) {
  3550. if (this._background) {
  3551. context.save();
  3552. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3553. context.shadowColor = this.shadowColor;
  3554. context.shadowBlur = this.shadowBlur;
  3555. context.shadowOffsetX = this.shadowOffsetX;
  3556. context.shadowOffsetY = this.shadowOffsetY;
  3557. }
  3558. context.fillStyle = this._background;
  3559. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3560. context.restore();
  3561. }
  3562. };
  3563. /** @hidden */
  3564. Container.prototype._link = function (host) {
  3565. _super.prototype._link.call(this, host);
  3566. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3567. var child = _a[_i];
  3568. child._link(host);
  3569. }
  3570. };
  3571. /** @hidden */
  3572. Container.prototype._beforeLayout = function () {
  3573. // Do nothing
  3574. };
  3575. /** @hidden */
  3576. Container.prototype._processMeasures = function (parentMeasure, context) {
  3577. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3578. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3579. this._evaluateClippingState(parentMeasure);
  3580. }
  3581. };
  3582. /** @hidden */
  3583. Container.prototype._layout = function (parentMeasure, context) {
  3584. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3585. return false;
  3586. }
  3587. this.host._numLayoutCalls++;
  3588. if (this._isDirty) {
  3589. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3590. }
  3591. var rebuildCount = 0;
  3592. context.save();
  3593. this._applyStates(context);
  3594. this._beforeLayout();
  3595. do {
  3596. var computedWidth = -1;
  3597. var computedHeight = -1;
  3598. this._rebuildLayout = false;
  3599. this._processMeasures(parentMeasure, context);
  3600. if (!this._isClipped) {
  3601. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3602. var child = _a[_i];
  3603. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3604. if (child._layout(this._measureForChildren, context)) {
  3605. if (this.adaptWidthToChildren && child._width.isPixel) {
  3606. computedWidth = Math.max(computedWidth, child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels);
  3607. }
  3608. if (this.adaptHeightToChildren && child._height.isPixel) {
  3609. computedHeight = Math.max(computedHeight, child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels);
  3610. }
  3611. }
  3612. }
  3613. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3614. computedWidth += this.paddingLeftInPixels + this.paddingRightInPixels;
  3615. if (this.width !== computedWidth + "px") {
  3616. this.width = computedWidth + "px";
  3617. this._rebuildLayout = true;
  3618. }
  3619. }
  3620. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3621. computedHeight += this.paddingTopInPixels + this.paddingBottomInPixels;
  3622. if (this.height !== computedHeight + "px") {
  3623. this.height = computedHeight + "px";
  3624. this._rebuildLayout = true;
  3625. }
  3626. }
  3627. this._postMeasure();
  3628. }
  3629. rebuildCount++;
  3630. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3631. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3632. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3633. }
  3634. context.restore();
  3635. if (this._isDirty) {
  3636. this.invalidateRect();
  3637. this._isDirty = false;
  3638. }
  3639. return true;
  3640. };
  3641. Container.prototype._postMeasure = function () {
  3642. // Do nothing by default
  3643. };
  3644. /** @hidden */
  3645. Container.prototype._draw = function (context, invalidatedRectangle) {
  3646. this._localDraw(context);
  3647. if (this.clipChildren) {
  3648. this._clipForChildren(context);
  3649. }
  3650. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3651. var child = _a[_i];
  3652. // Only redraw parts of the screen that are invalidated
  3653. if (invalidatedRectangle) {
  3654. if (!child._intersectsRect(invalidatedRectangle)) {
  3655. continue;
  3656. }
  3657. }
  3658. child._render(context, invalidatedRectangle);
  3659. }
  3660. };
  3661. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3662. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3663. if (!this.children) {
  3664. return;
  3665. }
  3666. for (var index = 0; index < this.children.length; index++) {
  3667. var item = this.children[index];
  3668. if (!predicate || predicate(item)) {
  3669. results.push(item);
  3670. }
  3671. if (!directDescendantsOnly) {
  3672. item.getDescendantsToRef(results, false, predicate);
  3673. }
  3674. }
  3675. };
  3676. /** @hidden */
  3677. Container.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  3678. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3679. return false;
  3680. }
  3681. if (!_super.prototype.contains.call(this, x, y)) {
  3682. return false;
  3683. }
  3684. // Checking backwards to pick closest first
  3685. for (var index = this._children.length - 1; index >= 0; index--) {
  3686. var child = this._children[index];
  3687. if (child._processPicking(x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY)) {
  3688. if (child.hoverCursor) {
  3689. this._host._changeCursor(child.hoverCursor);
  3690. }
  3691. return true;
  3692. }
  3693. }
  3694. if (!this.isHitTestVisible) {
  3695. return false;
  3696. }
  3697. return this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  3698. };
  3699. /** @hidden */
  3700. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3701. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3702. this._measureForChildren.copyFrom(this._currentMeasure);
  3703. };
  3704. /**
  3705. * Serializes the current control
  3706. * @param serializationObject defined the JSON serialized object
  3707. */
  3708. Container.prototype.serialize = function (serializationObject) {
  3709. _super.prototype.serialize.call(this, serializationObject);
  3710. if (!this.children.length) {
  3711. return;
  3712. }
  3713. serializationObject.children = [];
  3714. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3715. var child = _a[_i];
  3716. var childSerializationObject = {};
  3717. child.serialize(childSerializationObject);
  3718. serializationObject.children.push(childSerializationObject);
  3719. }
  3720. };
  3721. /** Releases associated resources */
  3722. Container.prototype.dispose = function () {
  3723. _super.prototype.dispose.call(this);
  3724. for (var index = this.children.length - 1; index >= 0; index--) {
  3725. this.children[index].dispose();
  3726. }
  3727. };
  3728. /** @hidden */
  3729. Container.prototype._parseFromContent = function (serializedObject, host) {
  3730. _super.prototype._parseFromContent.call(this, serializedObject, host);
  3731. this._link(host);
  3732. if (!serializedObject.children) {
  3733. return;
  3734. }
  3735. for (var _i = 0, _a = serializedObject.children; _i < _a.length; _i++) {
  3736. var childData = _a[_i];
  3737. this.addControl(_control__WEBPACK_IMPORTED_MODULE_2__["Control"].Parse(childData, host));
  3738. }
  3739. };
  3740. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3741. Object(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3742. ], Container.prototype, "maxLayoutCycle", void 0);
  3743. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3744. Object(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3745. ], Container.prototype, "adaptHeightToChildren", null);
  3746. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3747. Object(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3748. ], Container.prototype, "adaptWidthToChildren", null);
  3749. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3750. Object(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3751. ], Container.prototype, "background", null);
  3752. return Container;
  3753. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3754. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3755. /***/ }),
  3756. /***/ "./2D/controls/control.ts":
  3757. /*!********************************!*\
  3758. !*** ./2D/controls/control.ts ***!
  3759. \********************************/
  3760. /*! exports provided: Control */
  3761. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3762. "use strict";
  3763. __webpack_require__.r(__webpack_exports__);
  3764. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3765. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3766. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  3767. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  3768. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3769. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3770. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3771. /**
  3772. * Root class used for all 2D controls
  3773. * @see https://doc.babylonjs.com/how_to/gui#controls
  3774. */
  3775. var Control = /** @class */ (function () {
  3776. // Functions
  3777. /**
  3778. * Creates a new control
  3779. * @param name defines the name of the control
  3780. */
  3781. function Control(
  3782. /** defines the name of the control */
  3783. name) {
  3784. this.name = name;
  3785. this._alpha = 1;
  3786. this._alphaSet = false;
  3787. this._zIndex = 0;
  3788. /** @hidden */
  3789. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3790. this._fontFamily = "Arial";
  3791. this._fontStyle = "";
  3792. this._fontWeight = "";
  3793. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3794. /** @hidden */
  3795. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3796. /** @hidden */
  3797. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3798. this._color = "";
  3799. this._style = null;
  3800. /** @hidden */
  3801. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3802. /** @hidden */
  3803. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3804. /** @hidden */
  3805. this._isDirty = true;
  3806. /** @hidden */
  3807. this._wasDirty = false;
  3808. /** @hidden */
  3809. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3810. /** @hidden */
  3811. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3812. /** @hidden */
  3813. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3814. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3815. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3816. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3817. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3818. /** @hidden */
  3819. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3820. /** @hidden */
  3821. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3822. this._scaleX = 1.0;
  3823. this._scaleY = 1.0;
  3824. this._rotation = 0;
  3825. this._transformCenterX = 0.5;
  3826. this._transformCenterY = 0.5;
  3827. /** @hidden */
  3828. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_4__["Matrix2D"].Identity();
  3829. /** @hidden */
  3830. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_4__["Matrix2D"].Identity();
  3831. /** @hidden */
  3832. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  3833. this._isMatrixDirty = true;
  3834. this._isVisible = true;
  3835. this._isHighlighted = false;
  3836. this._fontSet = false;
  3837. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  3838. this._downCount = 0;
  3839. this._enterCount = -1;
  3840. this._doNotRender = false;
  3841. this._downPointerIds = {};
  3842. this._isEnabled = true;
  3843. this._disabledColor = "#9a9a9a";
  3844. this._disabledColorItem = "#6a6a6a";
  3845. /** @hidden */
  3846. this._rebuildLayout = false;
  3847. /** @hidden */
  3848. this._customData = {};
  3849. /** @hidden */
  3850. this._isClipped = false;
  3851. /** @hidden */
  3852. this._automaticSize = false;
  3853. /**
  3854. * Gets or sets an object used to store user defined information for the node
  3855. */
  3856. this.metadata = null;
  3857. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3858. this.isHitTestVisible = true;
  3859. /** Gets or sets a boolean indicating if the control can block pointer events */
  3860. this.isPointerBlocker = false;
  3861. /** Gets or sets a boolean indicating if the control can be focusable */
  3862. this.isFocusInvisible = false;
  3863. /**
  3864. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3865. * 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
  3866. */
  3867. this.clipChildren = true;
  3868. /**
  3869. * Gets or sets a boolean indicating that control content must be clipped
  3870. * 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
  3871. */
  3872. this.clipContent = true;
  3873. /**
  3874. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3875. */
  3876. this.useBitmapCache = false;
  3877. this._shadowOffsetX = 0;
  3878. this._shadowOffsetY = 0;
  3879. this._shadowBlur = 0;
  3880. this._shadowColor = 'black';
  3881. /** Gets or sets the cursor to use when the control is hovered */
  3882. this.hoverCursor = "";
  3883. /** @hidden */
  3884. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3885. /** @hidden */
  3886. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3887. /**
  3888. * An event triggered when pointer wheel is scrolled
  3889. */
  3890. this.onWheelObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3891. /**
  3892. * An event triggered when the pointer move over the control.
  3893. */
  3894. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3895. /**
  3896. * An event triggered when the pointer move out of the control.
  3897. */
  3898. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3899. /**
  3900. * An event triggered when the pointer taps the control
  3901. */
  3902. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3903. /**
  3904. * An event triggered when pointer up
  3905. */
  3906. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3907. /**
  3908. * An event triggered when a control is clicked on
  3909. */
  3910. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3911. /**
  3912. * An event triggered when pointer enters the control
  3913. */
  3914. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3915. /**
  3916. * An event triggered when the control is marked as dirty
  3917. */
  3918. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3919. /**
  3920. * An event triggered before drawing the control
  3921. */
  3922. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3923. /**
  3924. * An event triggered after the control was drawn
  3925. */
  3926. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3927. /**
  3928. * An event triggered when the control has been disposed
  3929. */
  3930. this.onDisposeObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3931. /**
  3932. * Gets or sets a fixed ratio for this control.
  3933. * When different from 0, the ratio is used to compute the "second" dimension.
  3934. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  3935. * second dimension is computed as first dimension * fixedRatio
  3936. */
  3937. this.fixedRatio = 0;
  3938. this._fixedRatioMasterIsWidth = true;
  3939. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"](0, 0, 0, 0);
  3940. }
  3941. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3942. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3943. get: function () {
  3944. return this._shadowOffsetX;
  3945. },
  3946. set: function (value) {
  3947. if (this._shadowOffsetX === value) {
  3948. return;
  3949. }
  3950. this._shadowOffsetX = value;
  3951. this._markAsDirty();
  3952. },
  3953. enumerable: false,
  3954. configurable: true
  3955. });
  3956. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3957. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3958. get: function () {
  3959. return this._shadowOffsetY;
  3960. },
  3961. set: function (value) {
  3962. if (this._shadowOffsetY === value) {
  3963. return;
  3964. }
  3965. this._shadowOffsetY = value;
  3966. this._markAsDirty();
  3967. },
  3968. enumerable: false,
  3969. configurable: true
  3970. });
  3971. Object.defineProperty(Control.prototype, "shadowBlur", {
  3972. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3973. get: function () {
  3974. return this._shadowBlur;
  3975. },
  3976. set: function (value) {
  3977. if (this._shadowBlur === value) {
  3978. return;
  3979. }
  3980. this._shadowBlur = value;
  3981. this._markAsDirty();
  3982. },
  3983. enumerable: false,
  3984. configurable: true
  3985. });
  3986. Object.defineProperty(Control.prototype, "shadowColor", {
  3987. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3988. get: function () {
  3989. return this._shadowColor;
  3990. },
  3991. set: function (value) {
  3992. if (this._shadowColor === value) {
  3993. return;
  3994. }
  3995. this._shadowColor = value;
  3996. this._markAsDirty();
  3997. },
  3998. enumerable: false,
  3999. configurable: true
  4000. });
  4001. Object.defineProperty(Control.prototype, "typeName", {
  4002. // Properties
  4003. /** Gets the control type name */
  4004. get: function () {
  4005. return this._getTypeName();
  4006. },
  4007. enumerable: false,
  4008. configurable: true
  4009. });
  4010. /**
  4011. * Get the current class name of the control.
  4012. * @returns current class name
  4013. */
  4014. Control.prototype.getClassName = function () {
  4015. return this._getTypeName();
  4016. };
  4017. Object.defineProperty(Control.prototype, "host", {
  4018. /**
  4019. * Get the hosting AdvancedDynamicTexture
  4020. */
  4021. get: function () {
  4022. return this._host;
  4023. },
  4024. enumerable: false,
  4025. configurable: true
  4026. });
  4027. Object.defineProperty(Control.prototype, "fontOffset", {
  4028. /** Gets or set information about font offsets (used to render and align text) */
  4029. get: function () {
  4030. return this._fontOffset;
  4031. },
  4032. set: function (offset) {
  4033. this._fontOffset = offset;
  4034. },
  4035. enumerable: false,
  4036. configurable: true
  4037. });
  4038. Object.defineProperty(Control.prototype, "alpha", {
  4039. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  4040. get: function () {
  4041. return this._alpha;
  4042. },
  4043. set: function (value) {
  4044. if (this._alpha === value) {
  4045. return;
  4046. }
  4047. this._alphaSet = true;
  4048. this._alpha = value;
  4049. this._markAsDirty();
  4050. },
  4051. enumerable: false,
  4052. configurable: true
  4053. });
  4054. Object.defineProperty(Control.prototype, "isHighlighted", {
  4055. /**
  4056. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  4057. */
  4058. get: function () {
  4059. return this._isHighlighted;
  4060. },
  4061. set: function (value) {
  4062. if (this._isHighlighted === value) {
  4063. return;
  4064. }
  4065. this._isHighlighted = value;
  4066. this._markAsDirty();
  4067. },
  4068. enumerable: false,
  4069. configurable: true
  4070. });
  4071. Object.defineProperty(Control.prototype, "scaleX", {
  4072. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  4073. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4074. */
  4075. get: function () {
  4076. return this._scaleX;
  4077. },
  4078. set: function (value) {
  4079. if (this._scaleX === value) {
  4080. return;
  4081. }
  4082. this._scaleX = value;
  4083. this._markAsDirty();
  4084. this._markMatrixAsDirty();
  4085. },
  4086. enumerable: false,
  4087. configurable: true
  4088. });
  4089. Object.defineProperty(Control.prototype, "scaleY", {
  4090. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  4091. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4092. */
  4093. get: function () {
  4094. return this._scaleY;
  4095. },
  4096. set: function (value) {
  4097. if (this._scaleY === value) {
  4098. return;
  4099. }
  4100. this._scaleY = value;
  4101. this._markAsDirty();
  4102. this._markMatrixAsDirty();
  4103. },
  4104. enumerable: false,
  4105. configurable: true
  4106. });
  4107. Object.defineProperty(Control.prototype, "rotation", {
  4108. /** Gets or sets the rotation angle (0 by default)
  4109. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4110. */
  4111. get: function () {
  4112. return this._rotation;
  4113. },
  4114. set: function (value) {
  4115. if (this._rotation === value) {
  4116. return;
  4117. }
  4118. this._rotation = value;
  4119. this._markAsDirty();
  4120. this._markMatrixAsDirty();
  4121. },
  4122. enumerable: false,
  4123. configurable: true
  4124. });
  4125. Object.defineProperty(Control.prototype, "transformCenterY", {
  4126. /** Gets or sets the transformation center on Y axis (0 by default)
  4127. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4128. */
  4129. get: function () {
  4130. return this._transformCenterY;
  4131. },
  4132. set: function (value) {
  4133. if (this._transformCenterY === value) {
  4134. return;
  4135. }
  4136. this._transformCenterY = value;
  4137. this._markAsDirty();
  4138. this._markMatrixAsDirty();
  4139. },
  4140. enumerable: false,
  4141. configurable: true
  4142. });
  4143. Object.defineProperty(Control.prototype, "transformCenterX", {
  4144. /** Gets or sets the transformation center on X axis (0 by default)
  4145. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4146. */
  4147. get: function () {
  4148. return this._transformCenterX;
  4149. },
  4150. set: function (value) {
  4151. if (this._transformCenterX === value) {
  4152. return;
  4153. }
  4154. this._transformCenterX = value;
  4155. this._markAsDirty();
  4156. this._markMatrixAsDirty();
  4157. },
  4158. enumerable: false,
  4159. configurable: true
  4160. });
  4161. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  4162. /**
  4163. * Gets or sets the horizontal alignment
  4164. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4165. */
  4166. get: function () {
  4167. return this._horizontalAlignment;
  4168. },
  4169. set: function (value) {
  4170. if (this._horizontalAlignment === value) {
  4171. return;
  4172. }
  4173. this._horizontalAlignment = value;
  4174. this._markAsDirty();
  4175. },
  4176. enumerable: false,
  4177. configurable: true
  4178. });
  4179. Object.defineProperty(Control.prototype, "verticalAlignment", {
  4180. /**
  4181. * Gets or sets the vertical alignment
  4182. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4183. */
  4184. get: function () {
  4185. return this._verticalAlignment;
  4186. },
  4187. set: function (value) {
  4188. if (this._verticalAlignment === value) {
  4189. return;
  4190. }
  4191. this._verticalAlignment = value;
  4192. this._markAsDirty();
  4193. },
  4194. enumerable: false,
  4195. configurable: true
  4196. });
  4197. Object.defineProperty(Control.prototype, "width", {
  4198. /**
  4199. * Gets or sets control width
  4200. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4201. */
  4202. get: function () {
  4203. return this._width.toString(this._host);
  4204. },
  4205. set: function (value) {
  4206. this._fixedRatioMasterIsWidth = true;
  4207. if (this._width.toString(this._host) === value) {
  4208. return;
  4209. }
  4210. if (this._width.fromString(value)) {
  4211. this._markAsDirty();
  4212. }
  4213. },
  4214. enumerable: false,
  4215. configurable: true
  4216. });
  4217. Object.defineProperty(Control.prototype, "widthInPixels", {
  4218. /**
  4219. * Gets or sets the control width in pixel
  4220. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4221. */
  4222. get: function () {
  4223. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4224. },
  4225. set: function (value) {
  4226. if (isNaN(value)) {
  4227. return;
  4228. }
  4229. this._fixedRatioMasterIsWidth = true;
  4230. this.width = value + "px";
  4231. },
  4232. enumerable: false,
  4233. configurable: true
  4234. });
  4235. Object.defineProperty(Control.prototype, "height", {
  4236. /**
  4237. * Gets or sets control height
  4238. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4239. */
  4240. get: function () {
  4241. return this._height.toString(this._host);
  4242. },
  4243. set: function (value) {
  4244. this._fixedRatioMasterIsWidth = false;
  4245. if (this._height.toString(this._host) === value) {
  4246. return;
  4247. }
  4248. if (this._height.fromString(value)) {
  4249. this._markAsDirty();
  4250. }
  4251. },
  4252. enumerable: false,
  4253. configurable: true
  4254. });
  4255. Object.defineProperty(Control.prototype, "heightInPixels", {
  4256. /**
  4257. * Gets or sets control height in pixel
  4258. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4259. */
  4260. get: function () {
  4261. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4262. },
  4263. set: function (value) {
  4264. if (isNaN(value)) {
  4265. return;
  4266. }
  4267. this._fixedRatioMasterIsWidth = false;
  4268. this.height = value + "px";
  4269. },
  4270. enumerable: false,
  4271. configurable: true
  4272. });
  4273. Object.defineProperty(Control.prototype, "fontFamily", {
  4274. /** Gets or set font family */
  4275. get: function () {
  4276. if (!this._fontSet) {
  4277. return "";
  4278. }
  4279. return this._fontFamily;
  4280. },
  4281. set: function (value) {
  4282. if (this._fontFamily === value) {
  4283. return;
  4284. }
  4285. this._fontFamily = value;
  4286. this._resetFontCache();
  4287. },
  4288. enumerable: false,
  4289. configurable: true
  4290. });
  4291. Object.defineProperty(Control.prototype, "fontStyle", {
  4292. /** Gets or sets font style */
  4293. get: function () {
  4294. return this._fontStyle;
  4295. },
  4296. set: function (value) {
  4297. if (this._fontStyle === value) {
  4298. return;
  4299. }
  4300. this._fontStyle = value;
  4301. this._resetFontCache();
  4302. },
  4303. enumerable: false,
  4304. configurable: true
  4305. });
  4306. Object.defineProperty(Control.prototype, "fontWeight", {
  4307. /** Gets or sets font weight */
  4308. get: function () {
  4309. return this._fontWeight;
  4310. },
  4311. set: function (value) {
  4312. if (this._fontWeight === value) {
  4313. return;
  4314. }
  4315. this._fontWeight = value;
  4316. this._resetFontCache();
  4317. },
  4318. enumerable: false,
  4319. configurable: true
  4320. });
  4321. Object.defineProperty(Control.prototype, "style", {
  4322. /**
  4323. * Gets or sets style
  4324. * @see https://doc.babylonjs.com/how_to/gui#styles
  4325. */
  4326. get: function () {
  4327. return this._style;
  4328. },
  4329. set: function (value) {
  4330. var _this = this;
  4331. if (this._style) {
  4332. this._style.onChangedObservable.remove(this._styleObserver);
  4333. this._styleObserver = null;
  4334. }
  4335. this._style = value;
  4336. if (this._style) {
  4337. this._styleObserver = this._style.onChangedObservable.add(function () {
  4338. _this._markAsDirty();
  4339. _this._resetFontCache();
  4340. });
  4341. }
  4342. this._markAsDirty();
  4343. this._resetFontCache();
  4344. },
  4345. enumerable: false,
  4346. configurable: true
  4347. });
  4348. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4349. /** @hidden */
  4350. get: function () {
  4351. return this._fontSize.isPercentage;
  4352. },
  4353. enumerable: false,
  4354. configurable: true
  4355. });
  4356. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4357. /** Gets or sets font size in pixels */
  4358. get: function () {
  4359. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4360. if (fontSizeToUse.isPixel) {
  4361. return fontSizeToUse.getValue(this._host);
  4362. }
  4363. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4364. },
  4365. set: function (value) {
  4366. if (isNaN(value)) {
  4367. return;
  4368. }
  4369. this.fontSize = value + "px";
  4370. },
  4371. enumerable: false,
  4372. configurable: true
  4373. });
  4374. Object.defineProperty(Control.prototype, "fontSize", {
  4375. /** Gets or sets font size */
  4376. get: function () {
  4377. return this._fontSize.toString(this._host);
  4378. },
  4379. set: function (value) {
  4380. if (this._fontSize.toString(this._host) === value) {
  4381. return;
  4382. }
  4383. if (this._fontSize.fromString(value)) {
  4384. this._markAsDirty();
  4385. this._resetFontCache();
  4386. }
  4387. },
  4388. enumerable: false,
  4389. configurable: true
  4390. });
  4391. Object.defineProperty(Control.prototype, "color", {
  4392. /** Gets or sets foreground color */
  4393. get: function () {
  4394. return this._color;
  4395. },
  4396. set: function (value) {
  4397. if (this._color === value) {
  4398. return;
  4399. }
  4400. this._color = value;
  4401. this._markAsDirty();
  4402. },
  4403. enumerable: false,
  4404. configurable: true
  4405. });
  4406. Object.defineProperty(Control.prototype, "zIndex", {
  4407. /** Gets or sets z index which is used to reorder controls on the z axis */
  4408. get: function () {
  4409. return this._zIndex;
  4410. },
  4411. set: function (value) {
  4412. if (this.zIndex === value) {
  4413. return;
  4414. }
  4415. this._zIndex = value;
  4416. if (this.parent) {
  4417. this.parent._reOrderControl(this);
  4418. }
  4419. },
  4420. enumerable: false,
  4421. configurable: true
  4422. });
  4423. Object.defineProperty(Control.prototype, "notRenderable", {
  4424. /** Gets or sets a boolean indicating if the control can be rendered */
  4425. get: function () {
  4426. return this._doNotRender;
  4427. },
  4428. set: function (value) {
  4429. if (this._doNotRender === value) {
  4430. return;
  4431. }
  4432. this._doNotRender = value;
  4433. this._markAsDirty();
  4434. },
  4435. enumerable: false,
  4436. configurable: true
  4437. });
  4438. Object.defineProperty(Control.prototype, "isVisible", {
  4439. /** Gets or sets a boolean indicating if the control is visible */
  4440. get: function () {
  4441. return this._isVisible;
  4442. },
  4443. set: function (value) {
  4444. if (this._isVisible === value) {
  4445. return;
  4446. }
  4447. this._isVisible = value;
  4448. this._markAsDirty(true);
  4449. },
  4450. enumerable: false,
  4451. configurable: true
  4452. });
  4453. Object.defineProperty(Control.prototype, "isDirty", {
  4454. /** Gets a boolean indicating that the control needs to update its rendering */
  4455. get: function () {
  4456. return this._isDirty;
  4457. },
  4458. enumerable: false,
  4459. configurable: true
  4460. });
  4461. Object.defineProperty(Control.prototype, "linkedMesh", {
  4462. /**
  4463. * Gets the current linked mesh (or null if none)
  4464. */
  4465. get: function () {
  4466. return this._linkedMesh;
  4467. },
  4468. enumerable: false,
  4469. configurable: true
  4470. });
  4471. Object.defineProperty(Control.prototype, "paddingLeft", {
  4472. /**
  4473. * Gets or sets a value indicating the padding to use on the left of the control
  4474. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4475. */
  4476. get: function () {
  4477. return this._paddingLeft.toString(this._host);
  4478. },
  4479. set: function (value) {
  4480. if (this._paddingLeft.fromString(value)) {
  4481. this._markAsDirty();
  4482. }
  4483. },
  4484. enumerable: false,
  4485. configurable: true
  4486. });
  4487. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4488. /**
  4489. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4490. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4491. */
  4492. get: function () {
  4493. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4494. },
  4495. set: function (value) {
  4496. if (isNaN(value)) {
  4497. return;
  4498. }
  4499. this.paddingLeft = value + "px";
  4500. },
  4501. enumerable: false,
  4502. configurable: true
  4503. });
  4504. Object.defineProperty(Control.prototype, "paddingRight", {
  4505. /**
  4506. * Gets or sets a value indicating the padding to use on the right of the control
  4507. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4508. */
  4509. get: function () {
  4510. return this._paddingRight.toString(this._host);
  4511. },
  4512. set: function (value) {
  4513. if (this._paddingRight.fromString(value)) {
  4514. this._markAsDirty();
  4515. }
  4516. },
  4517. enumerable: false,
  4518. configurable: true
  4519. });
  4520. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4521. /**
  4522. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4523. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4524. */
  4525. get: function () {
  4526. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4527. },
  4528. set: function (value) {
  4529. if (isNaN(value)) {
  4530. return;
  4531. }
  4532. this.paddingRight = value + "px";
  4533. },
  4534. enumerable: false,
  4535. configurable: true
  4536. });
  4537. Object.defineProperty(Control.prototype, "paddingTop", {
  4538. /**
  4539. * Gets or sets a value indicating the padding to use on the top of the control
  4540. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4541. */
  4542. get: function () {
  4543. return this._paddingTop.toString(this._host);
  4544. },
  4545. set: function (value) {
  4546. if (this._paddingTop.fromString(value)) {
  4547. this._markAsDirty();
  4548. }
  4549. },
  4550. enumerable: false,
  4551. configurable: true
  4552. });
  4553. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4554. /**
  4555. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4556. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4557. */
  4558. get: function () {
  4559. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4560. },
  4561. set: function (value) {
  4562. if (isNaN(value)) {
  4563. return;
  4564. }
  4565. this.paddingTop = value + "px";
  4566. },
  4567. enumerable: false,
  4568. configurable: true
  4569. });
  4570. Object.defineProperty(Control.prototype, "paddingBottom", {
  4571. /**
  4572. * Gets or sets a value indicating the padding to use on the bottom of the control
  4573. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4574. */
  4575. get: function () {
  4576. return this._paddingBottom.toString(this._host);
  4577. },
  4578. set: function (value) {
  4579. if (this._paddingBottom.fromString(value)) {
  4580. this._markAsDirty();
  4581. }
  4582. },
  4583. enumerable: false,
  4584. configurable: true
  4585. });
  4586. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4587. /**
  4588. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4589. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4590. */
  4591. get: function () {
  4592. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4593. },
  4594. set: function (value) {
  4595. if (isNaN(value)) {
  4596. return;
  4597. }
  4598. this.paddingBottom = value + "px";
  4599. },
  4600. enumerable: false,
  4601. configurable: true
  4602. });
  4603. Object.defineProperty(Control.prototype, "left", {
  4604. /**
  4605. * Gets or sets a value indicating the left coordinate of the control
  4606. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4607. */
  4608. get: function () {
  4609. return this._left.toString(this._host);
  4610. },
  4611. set: function (value) {
  4612. if (this._left.fromString(value)) {
  4613. this._markAsDirty();
  4614. }
  4615. },
  4616. enumerable: false,
  4617. configurable: true
  4618. });
  4619. Object.defineProperty(Control.prototype, "leftInPixels", {
  4620. /**
  4621. * Gets or sets a value indicating the left coordinate in pixels of the control
  4622. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4623. */
  4624. get: function () {
  4625. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4626. },
  4627. set: function (value) {
  4628. if (isNaN(value)) {
  4629. return;
  4630. }
  4631. this.left = value + "px";
  4632. },
  4633. enumerable: false,
  4634. configurable: true
  4635. });
  4636. Object.defineProperty(Control.prototype, "top", {
  4637. /**
  4638. * Gets or sets a value indicating the top coordinate of the control
  4639. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4640. */
  4641. get: function () {
  4642. return this._top.toString(this._host);
  4643. },
  4644. set: function (value) {
  4645. if (this._top.fromString(value)) {
  4646. this._markAsDirty();
  4647. }
  4648. },
  4649. enumerable: false,
  4650. configurable: true
  4651. });
  4652. Object.defineProperty(Control.prototype, "topInPixels", {
  4653. /**
  4654. * Gets or sets a value indicating the top coordinate in pixels of the control
  4655. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4656. */
  4657. get: function () {
  4658. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4659. },
  4660. set: function (value) {
  4661. if (isNaN(value)) {
  4662. return;
  4663. }
  4664. this.top = value + "px";
  4665. },
  4666. enumerable: false,
  4667. configurable: true
  4668. });
  4669. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4670. /**
  4671. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4672. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4673. */
  4674. get: function () {
  4675. return this._linkOffsetX.toString(this._host);
  4676. },
  4677. set: function (value) {
  4678. if (this._linkOffsetX.fromString(value)) {
  4679. this._markAsDirty();
  4680. }
  4681. },
  4682. enumerable: false,
  4683. configurable: true
  4684. });
  4685. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4686. /**
  4687. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4688. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4689. */
  4690. get: function () {
  4691. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4692. },
  4693. set: function (value) {
  4694. if (isNaN(value)) {
  4695. return;
  4696. }
  4697. this.linkOffsetX = value + "px";
  4698. },
  4699. enumerable: false,
  4700. configurable: true
  4701. });
  4702. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4703. /**
  4704. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4705. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4706. */
  4707. get: function () {
  4708. return this._linkOffsetY.toString(this._host);
  4709. },
  4710. set: function (value) {
  4711. if (this._linkOffsetY.fromString(value)) {
  4712. this._markAsDirty();
  4713. }
  4714. },
  4715. enumerable: false,
  4716. configurable: true
  4717. });
  4718. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4719. /**
  4720. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4721. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4722. */
  4723. get: function () {
  4724. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4725. },
  4726. set: function (value) {
  4727. if (isNaN(value)) {
  4728. return;
  4729. }
  4730. this.linkOffsetY = value + "px";
  4731. },
  4732. enumerable: false,
  4733. configurable: true
  4734. });
  4735. Object.defineProperty(Control.prototype, "centerX", {
  4736. /** Gets the center coordinate on X axis */
  4737. get: function () {
  4738. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4739. },
  4740. enumerable: false,
  4741. configurable: true
  4742. });
  4743. Object.defineProperty(Control.prototype, "centerY", {
  4744. /** Gets the center coordinate on Y axis */
  4745. get: function () {
  4746. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4747. },
  4748. enumerable: false,
  4749. configurable: true
  4750. });
  4751. Object.defineProperty(Control.prototype, "isEnabled", {
  4752. /** Gets or sets if control is Enabled */
  4753. get: function () {
  4754. return this._isEnabled;
  4755. },
  4756. set: function (value) {
  4757. if (this._isEnabled === value) {
  4758. return;
  4759. }
  4760. this._isEnabled = value;
  4761. this._markAsDirty();
  4762. },
  4763. enumerable: false,
  4764. configurable: true
  4765. });
  4766. Object.defineProperty(Control.prototype, "disabledColor", {
  4767. /** Gets or sets background color of control if it's disabled */
  4768. get: function () {
  4769. return this._disabledColor;
  4770. },
  4771. set: function (value) {
  4772. if (this._disabledColor === value) {
  4773. return;
  4774. }
  4775. this._disabledColor = value;
  4776. this._markAsDirty();
  4777. },
  4778. enumerable: false,
  4779. configurable: true
  4780. });
  4781. Object.defineProperty(Control.prototype, "disabledColorItem", {
  4782. /** Gets or sets front color of control if it's disabled */
  4783. get: function () {
  4784. return this._disabledColorItem;
  4785. },
  4786. set: function (value) {
  4787. if (this._disabledColorItem === value) {
  4788. return;
  4789. }
  4790. this._disabledColorItem = value;
  4791. this._markAsDirty();
  4792. },
  4793. enumerable: false,
  4794. configurable: true
  4795. });
  4796. /** @hidden */
  4797. Control.prototype._getTypeName = function () {
  4798. return "Control";
  4799. };
  4800. /**
  4801. * Gets the first ascendant in the hierarchy of the given type
  4802. * @param className defines the required type
  4803. * @returns the ascendant or null if not found
  4804. */
  4805. Control.prototype.getAscendantOfClass = function (className) {
  4806. if (!this.parent) {
  4807. return null;
  4808. }
  4809. if (this.parent.getClassName() === className) {
  4810. return this.parent;
  4811. }
  4812. return this.parent.getAscendantOfClass(className);
  4813. };
  4814. /** @hidden */
  4815. Control.prototype._resetFontCache = function () {
  4816. this._fontSet = true;
  4817. this._markAsDirty();
  4818. };
  4819. /**
  4820. * Determines if a container is an ascendant of the current control
  4821. * @param container defines the container to look for
  4822. * @returns true if the container is one of the ascendant of the control
  4823. */
  4824. Control.prototype.isAscendant = function (container) {
  4825. if (!this.parent) {
  4826. return false;
  4827. }
  4828. if (this.parent === container) {
  4829. return true;
  4830. }
  4831. return this.parent.isAscendant(container);
  4832. };
  4833. /**
  4834. * Gets coordinates in local control space
  4835. * @param globalCoordinates defines the coordinates to transform
  4836. * @returns the new coordinates in local space
  4837. */
  4838. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4839. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  4840. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4841. return result;
  4842. };
  4843. /**
  4844. * Gets coordinates in local control space
  4845. * @param globalCoordinates defines the coordinates to transform
  4846. * @param result defines the target vector2 where to store the result
  4847. * @returns the current control
  4848. */
  4849. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4850. result.x = globalCoordinates.x - this._currentMeasure.left;
  4851. result.y = globalCoordinates.y - this._currentMeasure.top;
  4852. return this;
  4853. };
  4854. /**
  4855. * Gets coordinates in parent local control space
  4856. * @param globalCoordinates defines the coordinates to transform
  4857. * @returns the new coordinates in parent local space
  4858. */
  4859. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4860. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  4861. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4862. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4863. return result;
  4864. };
  4865. /**
  4866. * Move the current control to a vector3 position projected onto the screen.
  4867. * @param position defines the target position
  4868. * @param scene defines the hosting scene
  4869. */
  4870. Control.prototype.moveToVector3 = function (position, scene) {
  4871. if (!this._host || this.parent !== this._host._rootContainer) {
  4872. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4873. return;
  4874. }
  4875. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4876. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4877. var globalViewport = this._host._getGlobalViewport(scene);
  4878. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4879. this._moveToProjectedPosition(projectedPosition);
  4880. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4881. this.notRenderable = true;
  4882. return;
  4883. }
  4884. this.notRenderable = false;
  4885. };
  4886. /**
  4887. * Will store all controls that have this control as ascendant in a given array
  4888. * @param results defines the array where to store the descendants
  4889. * @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
  4890. * @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
  4891. */
  4892. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4893. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4894. // Do nothing by default
  4895. };
  4896. /**
  4897. * Will return all controls that have this control as ascendant
  4898. * @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
  4899. * @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
  4900. * @return all child controls
  4901. */
  4902. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4903. var results = new Array();
  4904. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4905. return results;
  4906. };
  4907. /**
  4908. * Link current control with a target mesh
  4909. * @param mesh defines the mesh to link with
  4910. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4911. */
  4912. Control.prototype.linkWithMesh = function (mesh) {
  4913. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4914. if (mesh) {
  4915. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4916. }
  4917. return;
  4918. }
  4919. var index = this._host._linkedControls.indexOf(this);
  4920. if (index !== -1) {
  4921. this._linkedMesh = mesh;
  4922. if (!mesh) {
  4923. this._host._linkedControls.splice(index, 1);
  4924. }
  4925. return;
  4926. }
  4927. else if (!mesh) {
  4928. return;
  4929. }
  4930. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4931. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4932. this._linkedMesh = mesh;
  4933. this._host._linkedControls.push(this);
  4934. };
  4935. /**
  4936. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  4937. * @param { string | number} paddingTop - The value of the top padding.
  4938. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  4939. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  4940. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  4941. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4942. */
  4943. Control.prototype.setPadding = function (paddingTop, paddingRight, paddingBottom, paddingLeft) {
  4944. var top = paddingTop;
  4945. var right = paddingRight !== null && paddingRight !== void 0 ? paddingRight : top;
  4946. var bottom = paddingBottom !== null && paddingBottom !== void 0 ? paddingBottom : top;
  4947. var left = paddingLeft !== null && paddingLeft !== void 0 ? paddingLeft : right;
  4948. this.paddingTop = top;
  4949. this.paddingRight = right;
  4950. this.paddingBottom = bottom;
  4951. this.paddingLeft = left;
  4952. };
  4953. /**
  4954. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  4955. * @param { number} paddingTop - The value in pixels of the top padding.
  4956. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  4957. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  4958. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  4959. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4960. */
  4961. Control.prototype.setPaddingInPixels = function (paddingTop, paddingRight, paddingBottom, paddingLeft) {
  4962. var top = paddingTop;
  4963. var right = paddingRight !== null && paddingRight !== void 0 ? paddingRight : top;
  4964. var bottom = paddingBottom !== null && paddingBottom !== void 0 ? paddingBottom : top;
  4965. var left = paddingLeft !== null && paddingLeft !== void 0 ? paddingLeft : right;
  4966. this.paddingTopInPixels = top;
  4967. this.paddingRightInPixels = right;
  4968. this.paddingBottomInPixels = bottom;
  4969. this.paddingLeftInPixels = left;
  4970. };
  4971. /** @hidden */
  4972. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4973. var oldLeft = this._left.getValue(this._host);
  4974. var oldTop = this._top.getValue(this._host);
  4975. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4976. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4977. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4978. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4979. newLeft = oldLeft;
  4980. }
  4981. if (Math.abs(newTop - oldTop) < 0.5) {
  4982. newTop = oldTop;
  4983. }
  4984. }
  4985. this.left = newLeft + "px";
  4986. this.top = newTop + "px";
  4987. this._left.ignoreAdaptiveScaling = true;
  4988. this._top.ignoreAdaptiveScaling = true;
  4989. this._markAsDirty();
  4990. };
  4991. /** @hidden */
  4992. Control.prototype._offsetLeft = function (offset) {
  4993. this._isDirty = true;
  4994. this._currentMeasure.left += offset;
  4995. };
  4996. /** @hidden */
  4997. Control.prototype._offsetTop = function (offset) {
  4998. this._isDirty = true;
  4999. this._currentMeasure.top += offset;
  5000. };
  5001. /** @hidden */
  5002. Control.prototype._markMatrixAsDirty = function () {
  5003. this._isMatrixDirty = true;
  5004. this._flagDescendantsAsMatrixDirty();
  5005. };
  5006. /** @hidden */
  5007. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  5008. // No child
  5009. };
  5010. /** @hidden */
  5011. Control.prototype._intersectsRect = function (rect) {
  5012. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  5013. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  5014. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  5015. return false;
  5016. }
  5017. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  5018. return false;
  5019. }
  5020. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  5021. return false;
  5022. }
  5023. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  5024. return false;
  5025. }
  5026. return true;
  5027. };
  5028. /** @hidden */
  5029. Control.prototype.invalidateRect = function () {
  5030. this._transform();
  5031. if (this.host && this.host.useInvalidateRectOptimization) {
  5032. // Rotate by transform to get the measure transformed to global space
  5033. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  5034. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  5035. // the previous measure is used to properly clear a control that is scaled down
  5036. _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  5037. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5038. // Expand rect based on shadows
  5039. var shadowOffsetX = this.shadowOffsetX;
  5040. var shadowOffsetY = this.shadowOffsetY;
  5041. var shadowBlur = this.shadowBlur;
  5042. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5043. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5044. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5045. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5046. 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));
  5047. }
  5048. else {
  5049. 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));
  5050. }
  5051. }
  5052. };
  5053. /** @hidden */
  5054. Control.prototype._markAsDirty = function (force) {
  5055. if (force === void 0) { force = false; }
  5056. if (!this._isVisible && !force) {
  5057. return;
  5058. }
  5059. this._isDirty = true;
  5060. // Redraw only this rectangle
  5061. if (this._host) {
  5062. this._host.markAsDirty();
  5063. }
  5064. };
  5065. /** @hidden */
  5066. Control.prototype._markAllAsDirty = function () {
  5067. this._markAsDirty();
  5068. if (this._font) {
  5069. this._prepareFont();
  5070. }
  5071. };
  5072. /** @hidden */
  5073. Control.prototype._link = function (host) {
  5074. this._host = host;
  5075. if (this._host) {
  5076. this.uniqueId = this._host.getScene().getUniqueId();
  5077. }
  5078. };
  5079. /** @hidden */
  5080. Control.prototype._transform = function (context) {
  5081. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  5082. return;
  5083. }
  5084. // postTranslate
  5085. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  5086. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  5087. if (context) {
  5088. context.translate(offsetX, offsetY);
  5089. // rotate
  5090. context.rotate(this._rotation);
  5091. // scale
  5092. context.scale(this._scaleX, this._scaleY);
  5093. // preTranslate
  5094. context.translate(-offsetX, -offsetY);
  5095. }
  5096. // Need to update matrices?
  5097. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  5098. this._cachedOffsetX = offsetX;
  5099. this._cachedOffsetY = offsetY;
  5100. this._isMatrixDirty = false;
  5101. this._flagDescendantsAsMatrixDirty();
  5102. _math2D__WEBPACK_IMPORTED_MODULE_4__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  5103. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  5104. }
  5105. };
  5106. /** @hidden */
  5107. Control.prototype._renderHighlight = function (context) {
  5108. if (!this.isHighlighted) {
  5109. return;
  5110. }
  5111. context.save();
  5112. context.strokeStyle = "#4affff";
  5113. context.lineWidth = 2;
  5114. this._renderHighlightSpecific(context);
  5115. context.restore();
  5116. };
  5117. /** @hidden */
  5118. Control.prototype._renderHighlightSpecific = function (context) {
  5119. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5120. };
  5121. /** @hidden */
  5122. Control.prototype._applyStates = function (context) {
  5123. if (this._isFontSizeInPercentage) {
  5124. this._fontSet = true;
  5125. }
  5126. if (this._fontSet) {
  5127. this._prepareFont();
  5128. this._fontSet = false;
  5129. }
  5130. if (this._font) {
  5131. context.font = this._font;
  5132. }
  5133. if (this._color) {
  5134. context.fillStyle = this._color;
  5135. }
  5136. if (Control.AllowAlphaInheritance) {
  5137. context.globalAlpha *= this._alpha;
  5138. }
  5139. else if (this._alphaSet) {
  5140. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  5141. }
  5142. };
  5143. /** @hidden */
  5144. Control.prototype._layout = function (parentMeasure, context) {
  5145. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  5146. return false;
  5147. }
  5148. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  5149. this.host._numLayoutCalls++;
  5150. this._currentMeasure.addAndTransformToRef(this._transformMatrix, -this.paddingLeftInPixels | 0, -this.paddingTopInPixels | 0, this.paddingRightInPixels | 0, this.paddingBottomInPixels | 0, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  5151. context.save();
  5152. this._applyStates(context);
  5153. var rebuildCount = 0;
  5154. do {
  5155. this._rebuildLayout = false;
  5156. this._processMeasures(parentMeasure, context);
  5157. rebuildCount++;
  5158. } while (this._rebuildLayout && rebuildCount < 3);
  5159. if (rebuildCount >= 3) {
  5160. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  5161. }
  5162. context.restore();
  5163. this.invalidateRect();
  5164. this._evaluateClippingState(parentMeasure);
  5165. }
  5166. this._wasDirty = this._isDirty;
  5167. this._isDirty = false;
  5168. return true;
  5169. };
  5170. /** @hidden */
  5171. Control.prototype._processMeasures = function (parentMeasure, context) {
  5172. this._currentMeasure.copyFrom(parentMeasure);
  5173. // Let children take some pre-measurement actions
  5174. this._preMeasure(parentMeasure, context);
  5175. this._measure();
  5176. this._computeAlignment(parentMeasure, context);
  5177. // Convert to int values
  5178. this._currentMeasure.left = this._currentMeasure.left | 0;
  5179. this._currentMeasure.top = this._currentMeasure.top | 0;
  5180. this._currentMeasure.width = this._currentMeasure.width | 0;
  5181. this._currentMeasure.height = this._currentMeasure.height | 0;
  5182. // Let children add more features
  5183. this._additionalProcessing(parentMeasure, context);
  5184. this._cachedParentMeasure.copyFrom(parentMeasure);
  5185. if (this.onDirtyObservable.hasObservers()) {
  5186. this.onDirtyObservable.notifyObservers(this);
  5187. }
  5188. };
  5189. Control.prototype._evaluateClippingState = function (parentMeasure) {
  5190. if (this.parent && this.parent.clipChildren) {
  5191. // Early clip
  5192. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  5193. this._isClipped = true;
  5194. return;
  5195. }
  5196. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  5197. this._isClipped = true;
  5198. return;
  5199. }
  5200. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  5201. this._isClipped = true;
  5202. return;
  5203. }
  5204. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  5205. this._isClipped = true;
  5206. return;
  5207. }
  5208. }
  5209. this._isClipped = false;
  5210. };
  5211. /** @hidden */
  5212. Control.prototype._measure = function () {
  5213. // Width / Height
  5214. if (this._width.isPixel) {
  5215. this._currentMeasure.width = this._width.getValue(this._host);
  5216. }
  5217. else {
  5218. this._currentMeasure.width *= this._width.getValue(this._host);
  5219. }
  5220. if (this._height.isPixel) {
  5221. this._currentMeasure.height = this._height.getValue(this._host);
  5222. }
  5223. else {
  5224. this._currentMeasure.height *= this._height.getValue(this._host);
  5225. }
  5226. if (this.fixedRatio !== 0) {
  5227. if (this._fixedRatioMasterIsWidth) {
  5228. this._currentMeasure.height = this._currentMeasure.width * this.fixedRatio;
  5229. }
  5230. else {
  5231. this._currentMeasure.width = this._currentMeasure.height * this.fixedRatio;
  5232. }
  5233. }
  5234. };
  5235. /** @hidden */
  5236. Control.prototype._computeAlignment = function (parentMeasure, context) {
  5237. var width = this._currentMeasure.width;
  5238. var height = this._currentMeasure.height;
  5239. var parentWidth = parentMeasure.width;
  5240. var parentHeight = parentMeasure.height;
  5241. // Left / top
  5242. var x = 0;
  5243. var y = 0;
  5244. switch (this.horizontalAlignment) {
  5245. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  5246. x = 0;
  5247. break;
  5248. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  5249. x = parentWidth - width;
  5250. break;
  5251. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  5252. x = (parentWidth - width) / 2;
  5253. break;
  5254. }
  5255. switch (this.verticalAlignment) {
  5256. case Control.VERTICAL_ALIGNMENT_TOP:
  5257. y = 0;
  5258. break;
  5259. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  5260. y = parentHeight - height;
  5261. break;
  5262. case Control.VERTICAL_ALIGNMENT_CENTER:
  5263. y = (parentHeight - height) / 2;
  5264. break;
  5265. }
  5266. if (this._paddingLeft.isPixel) {
  5267. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  5268. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  5269. }
  5270. else {
  5271. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  5272. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  5273. }
  5274. if (this._paddingRight.isPixel) {
  5275. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  5276. }
  5277. else {
  5278. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  5279. }
  5280. if (this._paddingTop.isPixel) {
  5281. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  5282. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  5283. }
  5284. else {
  5285. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  5286. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  5287. }
  5288. if (this._paddingBottom.isPixel) {
  5289. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  5290. }
  5291. else {
  5292. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  5293. }
  5294. if (this._left.isPixel) {
  5295. this._currentMeasure.left += this._left.getValue(this._host);
  5296. }
  5297. else {
  5298. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  5299. }
  5300. if (this._top.isPixel) {
  5301. this._currentMeasure.top += this._top.getValue(this._host);
  5302. }
  5303. else {
  5304. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5305. }
  5306. this._currentMeasure.left += x;
  5307. this._currentMeasure.top += y;
  5308. };
  5309. /** @hidden */
  5310. Control.prototype._preMeasure = function (parentMeasure, context) {
  5311. // Do nothing
  5312. };
  5313. /** @hidden */
  5314. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5315. // Do nothing
  5316. };
  5317. /** @hidden */
  5318. Control.prototype._clipForChildren = function (context) {
  5319. // DO nothing
  5320. };
  5321. Control.prototype._clip = function (context, invalidatedRectangle) {
  5322. context.beginPath();
  5323. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5324. if (invalidatedRectangle) {
  5325. // Rotate the invalidated rect into the control's space
  5326. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5327. // Get the intersection of the rect in context space and the current context
  5328. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"](0, 0, 0, 0);
  5329. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5330. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5331. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5332. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5333. Control._ClipMeasure.copyFrom(intersection);
  5334. }
  5335. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5336. var shadowOffsetX = this.shadowOffsetX;
  5337. var shadowOffsetY = this.shadowOffsetY;
  5338. var shadowBlur = this.shadowBlur;
  5339. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5340. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5341. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5342. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5343. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5344. }
  5345. else {
  5346. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5347. }
  5348. context.clip();
  5349. };
  5350. /** @hidden */
  5351. Control.prototype._render = function (context, invalidatedRectangle) {
  5352. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5353. this._isDirty = false;
  5354. return false;
  5355. }
  5356. this.host._numRenderCalls++;
  5357. context.save();
  5358. this._applyStates(context);
  5359. // Transform
  5360. this._transform(context);
  5361. // Clip
  5362. if (this.clipContent) {
  5363. this._clip(context, invalidatedRectangle);
  5364. }
  5365. if (this.onBeforeDrawObservable.hasObservers()) {
  5366. this.onBeforeDrawObservable.notifyObservers(this);
  5367. }
  5368. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5369. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5370. }
  5371. else {
  5372. this._draw(context, invalidatedRectangle);
  5373. }
  5374. if (this.useBitmapCache && this._wasDirty) {
  5375. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5376. }
  5377. this._renderHighlight(context);
  5378. if (this.onAfterDrawObservable.hasObservers()) {
  5379. this.onAfterDrawObservable.notifyObservers(this);
  5380. }
  5381. context.restore();
  5382. return true;
  5383. };
  5384. /** @hidden */
  5385. Control.prototype._draw = function (context, invalidatedRectangle) {
  5386. // Do nothing
  5387. };
  5388. /**
  5389. * Tests if a given coordinates belong to the current control
  5390. * @param x defines x coordinate to test
  5391. * @param y defines y coordinate to test
  5392. * @returns true if the coordinates are inside the control
  5393. */
  5394. Control.prototype.contains = function (x, y) {
  5395. // Invert transform
  5396. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5397. x = this._transformedPosition.x;
  5398. y = this._transformedPosition.y;
  5399. // Check
  5400. if (x < this._currentMeasure.left) {
  5401. return false;
  5402. }
  5403. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5404. return false;
  5405. }
  5406. if (y < this._currentMeasure.top) {
  5407. return false;
  5408. }
  5409. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5410. return false;
  5411. }
  5412. if (this.isPointerBlocker) {
  5413. this._host._shouldBlockPointer = true;
  5414. }
  5415. return true;
  5416. };
  5417. /** @hidden */
  5418. Control.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  5419. if (!this._isEnabled) {
  5420. return false;
  5421. }
  5422. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5423. return false;
  5424. }
  5425. if (!this.contains(x, y)) {
  5426. return false;
  5427. }
  5428. this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  5429. return true;
  5430. };
  5431. /** @hidden */
  5432. Control.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  5433. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this, pi);
  5434. if (canNotify && this.parent != null) {
  5435. this.parent._onPointerMove(target, coordinates, pointerId, pi);
  5436. }
  5437. };
  5438. /** @hidden */
  5439. Control.prototype._onPointerEnter = function (target, pi) {
  5440. if (!this._isEnabled) {
  5441. return false;
  5442. }
  5443. if (this._enterCount > 0) {
  5444. return false;
  5445. }
  5446. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5447. this._enterCount = 0;
  5448. }
  5449. this._enterCount++;
  5450. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this, pi);
  5451. if (canNotify && this.parent != null) {
  5452. this.parent._onPointerEnter(target, pi);
  5453. }
  5454. return true;
  5455. };
  5456. /** @hidden */
  5457. Control.prototype._onPointerOut = function (target, pi, force) {
  5458. if (force === void 0) { force = false; }
  5459. if (!force && (!this._isEnabled || target === this)) {
  5460. return;
  5461. }
  5462. this._enterCount = 0;
  5463. var canNotify = true;
  5464. if (!target.isAscendant(this)) {
  5465. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this, pi);
  5466. }
  5467. if (canNotify && this.parent != null) {
  5468. this.parent._onPointerOut(target, pi, force);
  5469. }
  5470. };
  5471. /** @hidden */
  5472. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  5473. // Prevent pointerout to lose control context.
  5474. // Event redundancy is checked inside the function.
  5475. this._onPointerEnter(this, pi);
  5476. if (this._downCount !== 0) {
  5477. return false;
  5478. }
  5479. this._downCount++;
  5480. this._downPointerIds[pointerId] = true;
  5481. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_4__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this, pi);
  5482. if (canNotify && this.parent != null) {
  5483. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex, pi);
  5484. }
  5485. return true;
  5486. };
  5487. /** @hidden */
  5488. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  5489. if (!this._isEnabled) {
  5490. return;
  5491. }
  5492. this._downCount = 0;
  5493. delete this._downPointerIds[pointerId];
  5494. var canNotifyClick = notifyClick;
  5495. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5496. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_4__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this, pi);
  5497. }
  5498. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_4__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this, pi);
  5499. if (canNotify && this.parent != null) {
  5500. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick, pi);
  5501. }
  5502. };
  5503. /** @hidden */
  5504. Control.prototype._forcePointerUp = function (pointerId) {
  5505. if (pointerId === void 0) { pointerId = null; }
  5506. if (pointerId !== null) {
  5507. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero(), pointerId, 0, true);
  5508. }
  5509. else {
  5510. for (var key in this._downPointerIds) {
  5511. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero(), +key, 0, true);
  5512. }
  5513. }
  5514. };
  5515. /** @hidden */
  5516. Control.prototype._onWheelScroll = function (deltaX, deltaY) {
  5517. if (!this._isEnabled) {
  5518. return;
  5519. }
  5520. var canNotify = this.onWheelObservable.notifyObservers(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](deltaX, deltaY));
  5521. if (canNotify && this.parent != null) {
  5522. this.parent._onWheelScroll(deltaX, deltaY);
  5523. }
  5524. };
  5525. /** @hidden */
  5526. Control.prototype._onCanvasBlur = function () { };
  5527. /** @hidden */
  5528. Control.prototype._processObservables = function (type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY) {
  5529. if (!this._isEnabled) {
  5530. return false;
  5531. }
  5532. this._dummyVector2.copyFromFloats(x, y);
  5533. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  5534. this._onPointerMove(this, this._dummyVector2, pointerId, pi);
  5535. var previousControlOver = this._host._lastControlOver[pointerId];
  5536. if (previousControlOver && previousControlOver !== this) {
  5537. previousControlOver._onPointerOut(this, pi);
  5538. }
  5539. if (previousControlOver !== this) {
  5540. this._onPointerEnter(this, pi);
  5541. }
  5542. this._host._lastControlOver[pointerId] = this;
  5543. return true;
  5544. }
  5545. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  5546. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex, pi);
  5547. this._host._registerLastControlDown(this, pointerId);
  5548. this._host._lastPickedControl = this;
  5549. return true;
  5550. }
  5551. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  5552. if (this._host._lastControlDown[pointerId]) {
  5553. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true, pi);
  5554. }
  5555. delete this._host._lastControlDown[pointerId];
  5556. return true;
  5557. }
  5558. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  5559. if (this._host._lastControlOver[pointerId]) {
  5560. this._host._lastControlOver[pointerId]._onWheelScroll(deltaX, deltaY);
  5561. return true;
  5562. }
  5563. }
  5564. return false;
  5565. };
  5566. Control.prototype._prepareFont = function () {
  5567. if (!this._font && !this._fontSet) {
  5568. return;
  5569. }
  5570. if (this._style) {
  5571. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5572. }
  5573. else {
  5574. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5575. }
  5576. this._fontOffset = Control._GetFontOffset(this._font);
  5577. };
  5578. /**
  5579. * Serializes the current control
  5580. * @param serializationObject defined the JSON serialized object
  5581. */
  5582. Control.prototype.serialize = function (serializationObject) {
  5583. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, serializationObject);
  5584. serializationObject.name = this.name;
  5585. serializationObject.className = this.getClassName();
  5586. if (this._font) {
  5587. serializationObject.fontFamily = this.fontFamily;
  5588. serializationObject.fontSize = this.fontSize;
  5589. serializationObject.fontWeight = this.fontWeight;
  5590. serializationObject.fontStyle = this.fontStyle;
  5591. }
  5592. };
  5593. /** @hidden */
  5594. Control.prototype._parseFromContent = function (serializedObject, host) {
  5595. if (serializedObject.fontFamily) {
  5596. this.fontFamily = serializedObject.fontFamily;
  5597. }
  5598. if (serializedObject.fontSize) {
  5599. this.fontSize = serializedObject.fontSize;
  5600. }
  5601. if (serializedObject.fontWeight) {
  5602. this.fontWeight = serializedObject.fontWeight;
  5603. }
  5604. if (serializedObject.fontStyle) {
  5605. this.fontStyle = serializedObject.fontStyle;
  5606. }
  5607. };
  5608. /** Releases associated resources */
  5609. Control.prototype.dispose = function () {
  5610. this.onDirtyObservable.clear();
  5611. this.onBeforeDrawObservable.clear();
  5612. this.onAfterDrawObservable.clear();
  5613. this.onPointerDownObservable.clear();
  5614. this.onPointerEnterObservable.clear();
  5615. this.onPointerMoveObservable.clear();
  5616. this.onPointerOutObservable.clear();
  5617. this.onPointerUpObservable.clear();
  5618. this.onPointerClickObservable.clear();
  5619. this.onWheelObservable.clear();
  5620. if (this._styleObserver && this._style) {
  5621. this._style.onChangedObservable.remove(this._styleObserver);
  5622. this._styleObserver = null;
  5623. }
  5624. if (this.parent) {
  5625. this.parent.removeControl(this);
  5626. this.parent = null;
  5627. }
  5628. if (this._host) {
  5629. var index = this._host._linkedControls.indexOf(this);
  5630. if (index > -1) {
  5631. this.linkWithMesh(null);
  5632. }
  5633. }
  5634. // Callback
  5635. this.onDisposeObservable.notifyObservers(this);
  5636. this.onDisposeObservable.clear();
  5637. };
  5638. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5639. /** HORIZONTAL_ALIGNMENT_LEFT */
  5640. get: function () {
  5641. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5642. },
  5643. enumerable: false,
  5644. configurable: true
  5645. });
  5646. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5647. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5648. get: function () {
  5649. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5650. },
  5651. enumerable: false,
  5652. configurable: true
  5653. });
  5654. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5655. /** HORIZONTAL_ALIGNMENT_CENTER */
  5656. get: function () {
  5657. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5658. },
  5659. enumerable: false,
  5660. configurable: true
  5661. });
  5662. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5663. /** VERTICAL_ALIGNMENT_TOP */
  5664. get: function () {
  5665. return Control._VERTICAL_ALIGNMENT_TOP;
  5666. },
  5667. enumerable: false,
  5668. configurable: true
  5669. });
  5670. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5671. /** VERTICAL_ALIGNMENT_BOTTOM */
  5672. get: function () {
  5673. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5674. },
  5675. enumerable: false,
  5676. configurable: true
  5677. });
  5678. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5679. /** VERTICAL_ALIGNMENT_CENTER */
  5680. get: function () {
  5681. return Control._VERTICAL_ALIGNMENT_CENTER;
  5682. },
  5683. enumerable: false,
  5684. configurable: true
  5685. });
  5686. /** @hidden */
  5687. Control._GetFontOffset = function (font) {
  5688. if (Control._FontHeightSizes[font]) {
  5689. return Control._FontHeightSizes[font];
  5690. }
  5691. var text = document.createElement("span");
  5692. text.innerHTML = "Hg";
  5693. text.style.font = font;
  5694. var block = document.createElement("div");
  5695. block.style.display = "inline-block";
  5696. block.style.width = "1px";
  5697. block.style.height = "0px";
  5698. block.style.verticalAlign = "bottom";
  5699. var div = document.createElement("div");
  5700. div.style.whiteSpace = "nowrap";
  5701. div.appendChild(text);
  5702. div.appendChild(block);
  5703. document.body.appendChild(div);
  5704. var fontAscent = 0;
  5705. var fontHeight = 0;
  5706. try {
  5707. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5708. block.style.verticalAlign = "baseline";
  5709. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5710. }
  5711. finally {
  5712. document.body.removeChild(div);
  5713. }
  5714. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5715. Control._FontHeightSizes[font] = result;
  5716. return result;
  5717. };
  5718. /**
  5719. * Creates a Control from parsed data
  5720. * @param serializedObject defines parsed data
  5721. * @param host defines the hosting AdvancedDynamicTexture
  5722. * @returns a new Control
  5723. */
  5724. Control.Parse = function (serializedObject, host) {
  5725. var controlType = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].Instantiate("BABYLON.GUI." + serializedObject.className);
  5726. var control = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new controlType(); }, serializedObject, null);
  5727. control.name = serializedObject.name;
  5728. control._parseFromContent(serializedObject, host);
  5729. return control;
  5730. };
  5731. /** @hidden */
  5732. Control.drawEllipse = function (x, y, width, height, context) {
  5733. context.translate(x, y);
  5734. context.scale(width, height);
  5735. context.beginPath();
  5736. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5737. context.closePath();
  5738. context.scale(1 / width, 1 / height);
  5739. context.translate(-x, -y);
  5740. };
  5741. /**
  5742. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5743. */
  5744. Control.AllowAlphaInheritance = false;
  5745. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"](0, 0, 0, 0);
  5746. // Statics
  5747. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5748. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5749. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5750. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5751. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5752. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5753. Control._FontHeightSizes = {};
  5754. /**
  5755. * Creates a stack panel that can be used to render headers
  5756. * @param control defines the control to associate with the header
  5757. * @param text defines the text of the header
  5758. * @param size defines the size of the header
  5759. * @param options defines options used to configure the header
  5760. * @returns a new StackPanel
  5761. * @ignore
  5762. * @hidden
  5763. */
  5764. Control.AddHeader = function () { };
  5765. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5766. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5767. ], Control.prototype, "metadata", void 0);
  5768. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5769. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5770. ], Control.prototype, "isHitTestVisible", void 0);
  5771. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5772. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5773. ], Control.prototype, "isPointerBlocker", void 0);
  5774. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5775. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5776. ], Control.prototype, "isFocusInvisible", void 0);
  5777. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5778. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5779. ], Control.prototype, "clipChildren", void 0);
  5780. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5781. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5782. ], Control.prototype, "clipContent", void 0);
  5783. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5784. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5785. ], Control.prototype, "useBitmapCache", void 0);
  5786. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5787. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5788. ], Control.prototype, "shadowOffsetX", null);
  5789. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5790. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5791. ], Control.prototype, "shadowOffsetY", null);
  5792. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5793. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5794. ], Control.prototype, "shadowBlur", null);
  5795. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5796. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5797. ], Control.prototype, "shadowColor", null);
  5798. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5799. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5800. ], Control.prototype, "hoverCursor", void 0);
  5801. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5802. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5803. ], Control.prototype, "fontOffset", null);
  5804. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5805. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5806. ], Control.prototype, "alpha", null);
  5807. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5808. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5809. ], Control.prototype, "scaleX", null);
  5810. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5811. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5812. ], Control.prototype, "scaleY", null);
  5813. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5814. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5815. ], Control.prototype, "rotation", null);
  5816. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5817. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5818. ], Control.prototype, "transformCenterY", null);
  5819. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5820. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5821. ], Control.prototype, "transformCenterX", null);
  5822. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5823. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5824. ], Control.prototype, "horizontalAlignment", null);
  5825. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5826. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5827. ], Control.prototype, "verticalAlignment", null);
  5828. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5829. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5830. ], Control.prototype, "fixedRatio", void 0);
  5831. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5832. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5833. ], Control.prototype, "width", null);
  5834. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5835. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5836. ], Control.prototype, "height", null);
  5837. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5838. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5839. ], Control.prototype, "style", null);
  5840. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5841. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5842. ], Control.prototype, "color", null);
  5843. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5844. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5845. ], Control.prototype, "zIndex", null);
  5846. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5847. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5848. ], Control.prototype, "notRenderable", null);
  5849. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5850. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5851. ], Control.prototype, "isVisible", null);
  5852. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5853. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5854. ], Control.prototype, "paddingLeft", null);
  5855. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5856. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5857. ], Control.prototype, "paddingRight", null);
  5858. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5859. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5860. ], Control.prototype, "paddingTop", null);
  5861. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5862. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5863. ], Control.prototype, "paddingBottom", null);
  5864. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5865. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5866. ], Control.prototype, "left", null);
  5867. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5868. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5869. ], Control.prototype, "top", null);
  5870. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5871. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5872. ], Control.prototype, "linkOffsetX", null);
  5873. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5874. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5875. ], Control.prototype, "linkOffsetY", null);
  5876. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5877. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5878. ], Control.prototype, "isEnabled", null);
  5879. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5880. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5881. ], Control.prototype, "disabledColor", null);
  5882. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5883. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5884. ], Control.prototype, "disabledColorItem", null);
  5885. return Control;
  5886. }());
  5887. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5888. /***/ }),
  5889. /***/ "./2D/controls/displayGrid.ts":
  5890. /*!************************************!*\
  5891. !*** ./2D/controls/displayGrid.ts ***!
  5892. \************************************/
  5893. /*! exports provided: DisplayGrid */
  5894. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5895. "use strict";
  5896. __webpack_require__.r(__webpack_exports__);
  5897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5898. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5899. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5900. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5901. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5902. /** Class used to render a grid */
  5903. var DisplayGrid = /** @class */ (function (_super) {
  5904. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5905. /**
  5906. * Creates a new GridDisplayRectangle
  5907. * @param name defines the control name
  5908. */
  5909. function DisplayGrid(name) {
  5910. var _this = _super.call(this, name) || this;
  5911. _this.name = name;
  5912. _this._cellWidth = 20;
  5913. _this._cellHeight = 20;
  5914. _this._minorLineTickness = 1;
  5915. _this._minorLineColor = "DarkGray";
  5916. _this._majorLineTickness = 2;
  5917. _this._majorLineColor = "White";
  5918. _this._majorLineFrequency = 5;
  5919. _this._background = "Black";
  5920. _this._displayMajorLines = true;
  5921. _this._displayMinorLines = true;
  5922. return _this;
  5923. }
  5924. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5925. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5926. get: function () {
  5927. return this._displayMinorLines;
  5928. },
  5929. set: function (value) {
  5930. if (this._displayMinorLines === value) {
  5931. return;
  5932. }
  5933. this._displayMinorLines = value;
  5934. this._markAsDirty();
  5935. },
  5936. enumerable: false,
  5937. configurable: true
  5938. });
  5939. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5940. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5941. get: function () {
  5942. return this._displayMajorLines;
  5943. },
  5944. set: function (value) {
  5945. if (this._displayMajorLines === value) {
  5946. return;
  5947. }
  5948. this._displayMajorLines = value;
  5949. this._markAsDirty();
  5950. },
  5951. enumerable: false,
  5952. configurable: true
  5953. });
  5954. Object.defineProperty(DisplayGrid.prototype, "background", {
  5955. /** Gets or sets background color (Black by default) */
  5956. get: function () {
  5957. return this._background;
  5958. },
  5959. set: function (value) {
  5960. if (this._background === value) {
  5961. return;
  5962. }
  5963. this._background = value;
  5964. this._markAsDirty();
  5965. },
  5966. enumerable: false,
  5967. configurable: true
  5968. });
  5969. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5970. /** Gets or sets the width of each cell (20 by default) */
  5971. get: function () {
  5972. return this._cellWidth;
  5973. },
  5974. set: function (value) {
  5975. this._cellWidth = value;
  5976. this._markAsDirty();
  5977. },
  5978. enumerable: false,
  5979. configurable: true
  5980. });
  5981. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5982. /** Gets or sets the height of each cell (20 by default) */
  5983. get: function () {
  5984. return this._cellHeight;
  5985. },
  5986. set: function (value) {
  5987. this._cellHeight = value;
  5988. this._markAsDirty();
  5989. },
  5990. enumerable: false,
  5991. configurable: true
  5992. });
  5993. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5994. /** Gets or sets the tickness of minor lines (1 by default) */
  5995. get: function () {
  5996. return this._minorLineTickness;
  5997. },
  5998. set: function (value) {
  5999. this._minorLineTickness = value;
  6000. this._markAsDirty();
  6001. },
  6002. enumerable: false,
  6003. configurable: true
  6004. });
  6005. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  6006. /** Gets or sets the color of minor lines (DarkGray by default) */
  6007. get: function () {
  6008. return this._minorLineColor;
  6009. },
  6010. set: function (value) {
  6011. this._minorLineColor = value;
  6012. this._markAsDirty();
  6013. },
  6014. enumerable: false,
  6015. configurable: true
  6016. });
  6017. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  6018. /** Gets or sets the tickness of major lines (2 by default) */
  6019. get: function () {
  6020. return this._majorLineTickness;
  6021. },
  6022. set: function (value) {
  6023. this._majorLineTickness = value;
  6024. this._markAsDirty();
  6025. },
  6026. enumerable: false,
  6027. configurable: true
  6028. });
  6029. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  6030. /** Gets or sets the color of major lines (White by default) */
  6031. get: function () {
  6032. return this._majorLineColor;
  6033. },
  6034. set: function (value) {
  6035. this._majorLineColor = value;
  6036. this._markAsDirty();
  6037. },
  6038. enumerable: false,
  6039. configurable: true
  6040. });
  6041. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  6042. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  6043. get: function () {
  6044. return this._majorLineFrequency;
  6045. },
  6046. set: function (value) {
  6047. this._majorLineFrequency = value;
  6048. this._markAsDirty();
  6049. },
  6050. enumerable: false,
  6051. configurable: true
  6052. });
  6053. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  6054. context.save();
  6055. this._applyStates(context);
  6056. if (this._isEnabled) {
  6057. if (this._background) {
  6058. context.fillStyle = this._background;
  6059. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6060. }
  6061. var cellCountX = this._currentMeasure.width / this._cellWidth;
  6062. var cellCountY = this._currentMeasure.height / this._cellHeight;
  6063. // Minor lines
  6064. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  6065. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  6066. if (this._displayMinorLines) {
  6067. context.strokeStyle = this._minorLineColor;
  6068. context.lineWidth = this._minorLineTickness;
  6069. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  6070. var cellX = left + x * this.cellWidth;
  6071. context.beginPath();
  6072. context.moveTo(cellX, this._currentMeasure.top);
  6073. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  6074. context.stroke();
  6075. }
  6076. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  6077. var cellY = top_1 + y * this.cellHeight;
  6078. context.beginPath();
  6079. context.moveTo(this._currentMeasure.left, cellY);
  6080. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  6081. context.stroke();
  6082. }
  6083. }
  6084. // Major lines
  6085. if (this._displayMajorLines) {
  6086. context.strokeStyle = this._majorLineColor;
  6087. context.lineWidth = this._majorLineTickness;
  6088. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  6089. var cellX = left + x * this.cellWidth;
  6090. context.beginPath();
  6091. context.moveTo(cellX, this._currentMeasure.top);
  6092. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  6093. context.stroke();
  6094. }
  6095. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  6096. var cellY = top_1 + y * this.cellHeight;
  6097. context.moveTo(this._currentMeasure.left, cellY);
  6098. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  6099. context.closePath();
  6100. context.stroke();
  6101. }
  6102. }
  6103. }
  6104. context.restore();
  6105. };
  6106. DisplayGrid.prototype._getTypeName = function () {
  6107. return "DisplayGrid";
  6108. };
  6109. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6110. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6111. ], DisplayGrid.prototype, "displayMinorLines", null);
  6112. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6113. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6114. ], DisplayGrid.prototype, "displayMajorLines", null);
  6115. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6116. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6117. ], DisplayGrid.prototype, "background", null);
  6118. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6119. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6120. ], DisplayGrid.prototype, "cellWidth", null);
  6121. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6122. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6123. ], DisplayGrid.prototype, "cellHeight", null);
  6124. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6125. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6126. ], DisplayGrid.prototype, "minorLineTickness", null);
  6127. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6128. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6129. ], DisplayGrid.prototype, "minorLineColor", null);
  6130. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6131. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6132. ], DisplayGrid.prototype, "majorLineTickness", null);
  6133. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6134. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6135. ], DisplayGrid.prototype, "majorLineColor", null);
  6136. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6137. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6138. ], DisplayGrid.prototype, "majorLineFrequency", null);
  6139. return DisplayGrid;
  6140. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  6141. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  6142. /***/ }),
  6143. /***/ "./2D/controls/ellipse.ts":
  6144. /*!********************************!*\
  6145. !*** ./2D/controls/ellipse.ts ***!
  6146. \********************************/
  6147. /*! exports provided: Ellipse */
  6148. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6149. "use strict";
  6150. __webpack_require__.r(__webpack_exports__);
  6151. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  6152. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6153. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6154. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6155. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  6156. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  6157. /** Class used to create 2D ellipse containers */
  6158. var Ellipse = /** @class */ (function (_super) {
  6159. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  6160. /**
  6161. * Creates a new Ellipse
  6162. * @param name defines the control name
  6163. */
  6164. function Ellipse(name) {
  6165. var _this = _super.call(this, name) || this;
  6166. _this.name = name;
  6167. _this._thickness = 1;
  6168. return _this;
  6169. }
  6170. Object.defineProperty(Ellipse.prototype, "thickness", {
  6171. /** Gets or sets border thickness */
  6172. get: function () {
  6173. return this._thickness;
  6174. },
  6175. set: function (value) {
  6176. if (this._thickness === value) {
  6177. return;
  6178. }
  6179. this._thickness = value;
  6180. this._markAsDirty();
  6181. },
  6182. enumerable: false,
  6183. configurable: true
  6184. });
  6185. Ellipse.prototype._getTypeName = function () {
  6186. return "Ellipse";
  6187. };
  6188. Ellipse.prototype._localDraw = function (context) {
  6189. context.save();
  6190. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6191. context.shadowColor = this.shadowColor;
  6192. context.shadowBlur = this.shadowBlur;
  6193. context.shadowOffsetX = this.shadowOffsetX;
  6194. context.shadowOffsetY = this.shadowOffsetY;
  6195. }
  6196. _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);
  6197. if (this._background) {
  6198. context.fillStyle = this._background;
  6199. context.fill();
  6200. }
  6201. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6202. context.shadowBlur = 0;
  6203. context.shadowOffsetX = 0;
  6204. context.shadowOffsetY = 0;
  6205. }
  6206. if (this._thickness) {
  6207. if (this.color) {
  6208. context.strokeStyle = this.color;
  6209. }
  6210. context.lineWidth = this._thickness;
  6211. context.stroke();
  6212. }
  6213. context.restore();
  6214. };
  6215. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  6216. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6217. this._measureForChildren.width -= 2 * this._thickness;
  6218. this._measureForChildren.height -= 2 * this._thickness;
  6219. this._measureForChildren.left += this._thickness;
  6220. this._measureForChildren.top += this._thickness;
  6221. };
  6222. Ellipse.prototype._clipForChildren = function (context) {
  6223. _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);
  6224. context.clip();
  6225. };
  6226. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6227. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["serialize"])()
  6228. ], Ellipse.prototype, "thickness", null);
  6229. return Ellipse;
  6230. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6231. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  6232. /***/ }),
  6233. /***/ "./2D/controls/focusableButton.ts":
  6234. /*!****************************************!*\
  6235. !*** ./2D/controls/focusableButton.ts ***!
  6236. \****************************************/
  6237. /*! exports provided: FocusableButton */
  6238. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6239. "use strict";
  6240. __webpack_require__.r(__webpack_exports__);
  6241. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return FocusableButton; });
  6242. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6243. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6244. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  6245. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  6246. /**
  6247. * Class used to create a focusable button that can easily handle keyboard events
  6248. */
  6249. var FocusableButton = /** @class */ (function (_super) {
  6250. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FocusableButton, _super);
  6251. function FocusableButton(name) {
  6252. var _this = _super.call(this, name) || this;
  6253. _this.name = name;
  6254. /** Highlight color when button is focused */
  6255. _this.focusedColor = null;
  6256. _this._isFocused = false;
  6257. _this._unfocusedColor = null;
  6258. /** Observable raised when the control gets the focus */
  6259. _this.onFocusObservable = new babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  6260. /** Observable raised when the control loses the focus */
  6261. _this.onBlurObservable = new babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  6262. /** Observable raised when a key event was processed */
  6263. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  6264. _this._unfocusedColor = _this.color;
  6265. return _this;
  6266. }
  6267. /** @hidden */
  6268. FocusableButton.prototype.onBlur = function () {
  6269. if (this._isFocused) {
  6270. this._isFocused = false;
  6271. if (this.focusedColor && this._unfocusedColor != null) {
  6272. // Set color back to saved unfocused color
  6273. this.color = this._unfocusedColor;
  6274. }
  6275. this.onBlurObservable.notifyObservers(this);
  6276. }
  6277. };
  6278. /** @hidden */
  6279. FocusableButton.prototype.onFocus = function () {
  6280. this._isFocused = true;
  6281. if (this.focusedColor) {
  6282. // Save the unfocused color
  6283. this._unfocusedColor = this.color;
  6284. this.color = this.focusedColor;
  6285. }
  6286. this.onFocusObservable.notifyObservers(this);
  6287. };
  6288. /**
  6289. * Function called to get the list of controls that should not steal the focus from this control
  6290. * @returns an array of controls
  6291. */
  6292. FocusableButton.prototype.keepsFocusWith = function () {
  6293. return null;
  6294. };
  6295. /**
  6296. * Function to focus a button programmatically
  6297. */
  6298. FocusableButton.prototype.focus = function () {
  6299. this._host.moveFocusToControl(this);
  6300. };
  6301. /**
  6302. * Function to unfocus a button programmatically
  6303. */
  6304. FocusableButton.prototype.blur = function () {
  6305. this._host.focusedControl = null;
  6306. };
  6307. /**
  6308. * Handles the keyboard event
  6309. * @param evt Defines the KeyboardEvent
  6310. */
  6311. FocusableButton.prototype.processKeyboard = function (evt) {
  6312. this.onKeyboardEventProcessedObservable.notifyObservers(evt, -1, this);
  6313. };
  6314. /** @hidden */
  6315. FocusableButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  6316. // Clicking on button should focus
  6317. this.focus();
  6318. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi);
  6319. };
  6320. /** @hidden */
  6321. FocusableButton.prototype.displose = function () {
  6322. _super.prototype.dispose.call(this);
  6323. this.onBlurObservable.clear();
  6324. this.onFocusObservable.clear();
  6325. this.onKeyboardEventProcessedObservable.clear();
  6326. };
  6327. return FocusableButton;
  6328. }(_button__WEBPACK_IMPORTED_MODULE_1__["Button"]));
  6329. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FocusableButton"] = FocusableButton;
  6330. /***/ }),
  6331. /***/ "./2D/controls/grid.ts":
  6332. /*!*****************************!*\
  6333. !*** ./2D/controls/grid.ts ***!
  6334. \*****************************/
  6335. /*! exports provided: Grid */
  6336. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6337. "use strict";
  6338. __webpack_require__.r(__webpack_exports__);
  6339. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  6340. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6341. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6342. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6343. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6344. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  6345. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  6346. /**
  6347. * Class used to create a 2D grid container
  6348. */
  6349. var Grid = /** @class */ (function (_super) {
  6350. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  6351. /**
  6352. * Creates a new Grid
  6353. * @param name defines control name
  6354. */
  6355. function Grid(name) {
  6356. var _this = _super.call(this, name) || this;
  6357. _this.name = name;
  6358. _this._rowDefinitions = new Array();
  6359. _this._columnDefinitions = new Array();
  6360. _this._cells = {};
  6361. _this._childControls = new Array();
  6362. return _this;
  6363. }
  6364. Object.defineProperty(Grid.prototype, "columnCount", {
  6365. /**
  6366. * Gets the number of columns
  6367. */
  6368. get: function () {
  6369. return this._columnDefinitions.length;
  6370. },
  6371. enumerable: false,
  6372. configurable: true
  6373. });
  6374. Object.defineProperty(Grid.prototype, "rowCount", {
  6375. /**
  6376. * Gets the number of rows
  6377. */
  6378. get: function () {
  6379. return this._rowDefinitions.length;
  6380. },
  6381. enumerable: false,
  6382. configurable: true
  6383. });
  6384. Object.defineProperty(Grid.prototype, "children", {
  6385. /** Gets the list of children */
  6386. get: function () {
  6387. return this._childControls;
  6388. },
  6389. enumerable: false,
  6390. configurable: true
  6391. });
  6392. Object.defineProperty(Grid.prototype, "cells", {
  6393. /** Gets the list of cells (e.g. the containers) */
  6394. get: function () {
  6395. return this._cells;
  6396. },
  6397. enumerable: false,
  6398. configurable: true
  6399. });
  6400. /**
  6401. * Gets the definition of a specific row
  6402. * @param index defines the index of the row
  6403. * @returns the row definition
  6404. */
  6405. Grid.prototype.getRowDefinition = function (index) {
  6406. if (index < 0 || index >= this._rowDefinitions.length) {
  6407. return null;
  6408. }
  6409. return this._rowDefinitions[index];
  6410. };
  6411. /**
  6412. * Gets the definition of a specific column
  6413. * @param index defines the index of the column
  6414. * @returns the column definition
  6415. */
  6416. Grid.prototype.getColumnDefinition = function (index) {
  6417. if (index < 0 || index >= this._columnDefinitions.length) {
  6418. return null;
  6419. }
  6420. return this._columnDefinitions[index];
  6421. };
  6422. /**
  6423. * Adds a new row to the grid
  6424. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  6425. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  6426. * @returns the current grid
  6427. */
  6428. Grid.prototype.addRowDefinition = function (height, isPixel) {
  6429. if (isPixel === void 0) { isPixel = false; }
  6430. 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));
  6431. this._markAsDirty();
  6432. return this;
  6433. };
  6434. /**
  6435. * Adds a new column to the grid
  6436. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  6437. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  6438. * @returns the current grid
  6439. */
  6440. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  6441. if (isPixel === void 0) { isPixel = false; }
  6442. 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));
  6443. this._markAsDirty();
  6444. return this;
  6445. };
  6446. /**
  6447. * Update a row definition
  6448. * @param index defines the index of the row to update
  6449. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  6450. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  6451. * @returns the current grid
  6452. */
  6453. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  6454. if (isPixel === void 0) { isPixel = false; }
  6455. if (index < 0 || index >= this._rowDefinitions.length) {
  6456. return this;
  6457. }
  6458. var current = this._rowDefinitions[index];
  6459. if (current && current.isPixel === isPixel && current.internalValue === height) {
  6460. return this;
  6461. }
  6462. 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);
  6463. this._markAsDirty();
  6464. return this;
  6465. };
  6466. /**
  6467. * Update a column definition
  6468. * @param index defines the index of the column to update
  6469. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  6470. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  6471. * @returns the current grid
  6472. */
  6473. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  6474. if (isPixel === void 0) { isPixel = false; }
  6475. if (index < 0 || index >= this._columnDefinitions.length) {
  6476. return this;
  6477. }
  6478. var current = this._columnDefinitions[index];
  6479. if (current && current.isPixel === isPixel && current.internalValue === width) {
  6480. return this;
  6481. }
  6482. 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);
  6483. this._markAsDirty();
  6484. return this;
  6485. };
  6486. /**
  6487. * Gets the list of children stored in a specific cell
  6488. * @param row defines the row to check
  6489. * @param column defines the column to check
  6490. * @returns the list of controls
  6491. */
  6492. Grid.prototype.getChildrenAt = function (row, column) {
  6493. var cell = this._cells[row + ":" + column];
  6494. if (!cell) {
  6495. return null;
  6496. }
  6497. return cell.children;
  6498. };
  6499. /**
  6500. * Gets a string representing the child cell info (row x column)
  6501. * @param child defines the control to get info from
  6502. * @returns a string containing the child cell info (row x column)
  6503. */
  6504. Grid.prototype.getChildCellInfo = function (child) {
  6505. return child._tag;
  6506. };
  6507. Grid.prototype._removeCell = function (cell, key) {
  6508. if (!cell) {
  6509. return;
  6510. }
  6511. _super.prototype.removeControl.call(this, cell);
  6512. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  6513. var control = _a[_i];
  6514. var childIndex = this._childControls.indexOf(control);
  6515. if (childIndex !== -1) {
  6516. this._childControls.splice(childIndex, 1);
  6517. }
  6518. }
  6519. delete this._cells[key];
  6520. };
  6521. Grid.prototype._offsetCell = function (previousKey, key) {
  6522. if (!this._cells[key]) {
  6523. return;
  6524. }
  6525. this._cells[previousKey] = this._cells[key];
  6526. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  6527. var control = _a[_i];
  6528. control._tag = previousKey;
  6529. }
  6530. delete this._cells[key];
  6531. };
  6532. /**
  6533. * Remove a column definition at specified index
  6534. * @param index defines the index of the column to remove
  6535. * @returns the current grid
  6536. */
  6537. Grid.prototype.removeColumnDefinition = function (index) {
  6538. if (index < 0 || index >= this._columnDefinitions.length) {
  6539. return this;
  6540. }
  6541. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6542. var key = x + ":" + index;
  6543. var cell = this._cells[key];
  6544. this._removeCell(cell, key);
  6545. }
  6546. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6547. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  6548. var previousKey = x + ":" + (y - 1);
  6549. var key = x + ":" + y;
  6550. this._offsetCell(previousKey, key);
  6551. }
  6552. }
  6553. this._columnDefinitions.splice(index, 1);
  6554. this._markAsDirty();
  6555. return this;
  6556. };
  6557. /**
  6558. * Remove a row definition at specified index
  6559. * @param index defines the index of the row to remove
  6560. * @returns the current grid
  6561. */
  6562. Grid.prototype.removeRowDefinition = function (index) {
  6563. if (index < 0 || index >= this._rowDefinitions.length) {
  6564. return this;
  6565. }
  6566. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6567. var key = index + ":" + y;
  6568. var cell = this._cells[key];
  6569. this._removeCell(cell, key);
  6570. }
  6571. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6572. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  6573. var previousKey = x - 1 + ":" + y;
  6574. var key = x + ":" + y;
  6575. this._offsetCell(previousKey, key);
  6576. }
  6577. }
  6578. this._rowDefinitions.splice(index, 1);
  6579. this._markAsDirty();
  6580. return this;
  6581. };
  6582. /**
  6583. * Adds a new control to the current grid
  6584. * @param control defines the control to add
  6585. * @param row defines the row where to add the control (0 by default)
  6586. * @param column defines the column where to add the control (0 by default)
  6587. * @returns the current grid
  6588. */
  6589. Grid.prototype.addControl = function (control, row, column) {
  6590. if (row === void 0) { row = 0; }
  6591. if (column === void 0) { column = 0; }
  6592. if (this._rowDefinitions.length === 0) {
  6593. // Add default row definition
  6594. this.addRowDefinition(1, false);
  6595. }
  6596. if (this._columnDefinitions.length === 0) {
  6597. // Add default column definition
  6598. this.addColumnDefinition(1, false);
  6599. }
  6600. if (this._childControls.indexOf(control) !== -1) {
  6601. 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");
  6602. return this;
  6603. }
  6604. var x = Math.min(row, this._rowDefinitions.length - 1);
  6605. var y = Math.min(column, this._columnDefinitions.length - 1);
  6606. var key = x + ":" + y;
  6607. var goodContainer = this._cells[key];
  6608. if (!goodContainer) {
  6609. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6610. this._cells[key] = goodContainer;
  6611. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6612. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6613. _super.prototype.addControl.call(this, goodContainer);
  6614. }
  6615. goodContainer.addControl(control);
  6616. this._childControls.push(control);
  6617. control._tag = key;
  6618. control.parent = this;
  6619. this._markAsDirty();
  6620. return this;
  6621. };
  6622. /**
  6623. * Removes a control from the current container
  6624. * @param control defines the control to remove
  6625. * @returns the current container
  6626. */
  6627. Grid.prototype.removeControl = function (control) {
  6628. var index = this._childControls.indexOf(control);
  6629. if (index !== -1) {
  6630. this._childControls.splice(index, 1);
  6631. }
  6632. var cell = this._cells[control._tag];
  6633. if (cell) {
  6634. cell.removeControl(control);
  6635. control._tag = null;
  6636. }
  6637. this._markAsDirty();
  6638. return this;
  6639. };
  6640. Grid.prototype._getTypeName = function () {
  6641. return "Grid";
  6642. };
  6643. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6644. var widths = [];
  6645. var heights = [];
  6646. var lefts = [];
  6647. var tops = [];
  6648. var availableWidth = this._currentMeasure.width;
  6649. var globalWidthPercentage = 0;
  6650. var availableHeight = this._currentMeasure.height;
  6651. var globalHeightPercentage = 0;
  6652. // Heights
  6653. var index = 0;
  6654. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6655. var value = _a[_i];
  6656. if (value.isPixel) {
  6657. var height = value.getValue(this._host);
  6658. availableHeight -= height;
  6659. heights[index] = height;
  6660. }
  6661. else {
  6662. globalHeightPercentage += value.internalValue;
  6663. }
  6664. index++;
  6665. }
  6666. var top = 0;
  6667. index = 0;
  6668. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6669. var value = _c[_b];
  6670. tops.push(top);
  6671. if (!value.isPixel) {
  6672. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6673. top += height;
  6674. heights[index] = height;
  6675. }
  6676. else {
  6677. top += value.getValue(this._host);
  6678. }
  6679. index++;
  6680. }
  6681. // Widths
  6682. index = 0;
  6683. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6684. var value = _e[_d];
  6685. if (value.isPixel) {
  6686. var width = value.getValue(this._host);
  6687. availableWidth -= width;
  6688. widths[index] = width;
  6689. }
  6690. else {
  6691. globalWidthPercentage += value.internalValue;
  6692. }
  6693. index++;
  6694. }
  6695. var left = 0;
  6696. index = 0;
  6697. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6698. var value = _g[_f];
  6699. lefts.push(left);
  6700. if (!value.isPixel) {
  6701. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6702. left += width;
  6703. widths[index] = width;
  6704. }
  6705. else {
  6706. left += value.getValue(this._host);
  6707. }
  6708. index++;
  6709. }
  6710. definitionCallback(lefts, tops, widths, heights);
  6711. };
  6712. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6713. var _this = this;
  6714. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6715. // Setting child sizes
  6716. for (var key in _this._cells) {
  6717. if (!_this._cells.hasOwnProperty(key)) {
  6718. continue;
  6719. }
  6720. var split = key.split(":");
  6721. var x = parseInt(split[0]);
  6722. var y = parseInt(split[1]);
  6723. var cell = _this._cells[key];
  6724. cell.left = lefts[y] + "px";
  6725. cell.top = tops[x] + "px";
  6726. cell.width = widths[y] + "px";
  6727. cell.height = heights[x] + "px";
  6728. cell._left.ignoreAdaptiveScaling = true;
  6729. cell._top.ignoreAdaptiveScaling = true;
  6730. cell._width.ignoreAdaptiveScaling = true;
  6731. cell._height.ignoreAdaptiveScaling = true;
  6732. }
  6733. });
  6734. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6735. };
  6736. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6737. for (var key in this._cells) {
  6738. if (!this._cells.hasOwnProperty(key)) {
  6739. continue;
  6740. }
  6741. var child = this._cells[key];
  6742. child._markMatrixAsDirty();
  6743. }
  6744. };
  6745. Grid.prototype._renderHighlightSpecific = function (context) {
  6746. var _this = this;
  6747. _super.prototype._renderHighlightSpecific.call(this, context);
  6748. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6749. // Columns
  6750. for (var index = 0; index < lefts.length; index++) {
  6751. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6752. context.beginPath();
  6753. context.moveTo(left, _this._currentMeasure.top);
  6754. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6755. context.stroke();
  6756. }
  6757. // Rows
  6758. for (var index = 0; index < tops.length; index++) {
  6759. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6760. context.beginPath();
  6761. context.moveTo(_this._currentMeasure.left, top_1);
  6762. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6763. context.stroke();
  6764. }
  6765. });
  6766. context.restore();
  6767. };
  6768. /** Releases associated resources */
  6769. Grid.prototype.dispose = function () {
  6770. _super.prototype.dispose.call(this);
  6771. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6772. var control = _a[_i];
  6773. control.dispose();
  6774. }
  6775. this._childControls = [];
  6776. };
  6777. return Grid;
  6778. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6779. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6780. /***/ }),
  6781. /***/ "./2D/controls/image.ts":
  6782. /*!******************************!*\
  6783. !*** ./2D/controls/image.ts ***!
  6784. \******************************/
  6785. /*! exports provided: Image */
  6786. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6787. "use strict";
  6788. __webpack_require__.r(__webpack_exports__);
  6789. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6790. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6791. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6792. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6793. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6794. /**
  6795. * Class used to create 2D images
  6796. */
  6797. var Image = /** @class */ (function (_super) {
  6798. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6799. /**
  6800. * Creates a new Image
  6801. * @param name defines the control name
  6802. * @param url defines the image url
  6803. */
  6804. function Image(name, url) {
  6805. if (url === void 0) { url = null; }
  6806. var _this = _super.call(this, name) || this;
  6807. _this.name = name;
  6808. _this._workingCanvas = null;
  6809. _this._loaded = false;
  6810. _this._stretch = Image.STRETCH_FILL;
  6811. _this._autoScale = false;
  6812. _this._sourceLeft = 0;
  6813. _this._sourceTop = 0;
  6814. _this._sourceWidth = 0;
  6815. _this._sourceHeight = 0;
  6816. _this._svgAttributesComputationCompleted = false;
  6817. _this._isSVG = false;
  6818. _this._cellWidth = 0;
  6819. _this._cellHeight = 0;
  6820. _this._cellId = -1;
  6821. _this._populateNinePatchSlicesFromImage = false;
  6822. _this._imageDataCache = { data: null, key: "" };
  6823. /**
  6824. * Observable notified when the content is loaded
  6825. */
  6826. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6827. /**
  6828. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6829. */
  6830. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6831. _this.source = url;
  6832. return _this;
  6833. }
  6834. Object.defineProperty(Image.prototype, "isLoaded", {
  6835. /**
  6836. * Gets a boolean indicating that the content is loaded
  6837. */
  6838. get: function () {
  6839. return this._loaded;
  6840. },
  6841. enumerable: false,
  6842. configurable: true
  6843. });
  6844. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6845. /**
  6846. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6847. */
  6848. get: function () {
  6849. return this._populateNinePatchSlicesFromImage;
  6850. },
  6851. set: function (value) {
  6852. if (this._populateNinePatchSlicesFromImage === value) {
  6853. return;
  6854. }
  6855. this._populateNinePatchSlicesFromImage = value;
  6856. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6857. this._extractNinePatchSliceDataFromImage();
  6858. }
  6859. },
  6860. enumerable: false,
  6861. configurable: true
  6862. });
  6863. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6864. /**
  6865. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6866. * Beware using this as this will comsume more memory as the image has to be stored twice
  6867. */
  6868. get: function () {
  6869. return this._detectPointerOnOpaqueOnly;
  6870. },
  6871. set: function (value) {
  6872. if (this._detectPointerOnOpaqueOnly === value) {
  6873. return;
  6874. }
  6875. this._detectPointerOnOpaqueOnly = value;
  6876. },
  6877. enumerable: false,
  6878. configurable: true
  6879. });
  6880. Object.defineProperty(Image.prototype, "sliceLeft", {
  6881. /**
  6882. * Gets or sets the left value for slicing (9-patch)
  6883. */
  6884. get: function () {
  6885. return this._sliceLeft;
  6886. },
  6887. set: function (value) {
  6888. if (this._sliceLeft === value) {
  6889. return;
  6890. }
  6891. this._sliceLeft = value;
  6892. this._markAsDirty();
  6893. },
  6894. enumerable: false,
  6895. configurable: true
  6896. });
  6897. Object.defineProperty(Image.prototype, "sliceRight", {
  6898. /**
  6899. * Gets or sets the right value for slicing (9-patch)
  6900. */
  6901. get: function () {
  6902. return this._sliceRight;
  6903. },
  6904. set: function (value) {
  6905. if (this._sliceRight === value) {
  6906. return;
  6907. }
  6908. this._sliceRight = value;
  6909. this._markAsDirty();
  6910. },
  6911. enumerable: false,
  6912. configurable: true
  6913. });
  6914. Object.defineProperty(Image.prototype, "sliceTop", {
  6915. /**
  6916. * Gets or sets the top value for slicing (9-patch)
  6917. */
  6918. get: function () {
  6919. return this._sliceTop;
  6920. },
  6921. set: function (value) {
  6922. if (this._sliceTop === value) {
  6923. return;
  6924. }
  6925. this._sliceTop = value;
  6926. this._markAsDirty();
  6927. },
  6928. enumerable: false,
  6929. configurable: true
  6930. });
  6931. Object.defineProperty(Image.prototype, "sliceBottom", {
  6932. /**
  6933. * Gets or sets the bottom value for slicing (9-patch)
  6934. */
  6935. get: function () {
  6936. return this._sliceBottom;
  6937. },
  6938. set: function (value) {
  6939. if (this._sliceBottom === value) {
  6940. return;
  6941. }
  6942. this._sliceBottom = value;
  6943. this._markAsDirty();
  6944. },
  6945. enumerable: false,
  6946. configurable: true
  6947. });
  6948. Object.defineProperty(Image.prototype, "sourceLeft", {
  6949. /**
  6950. * Gets or sets the left coordinate in the source image
  6951. */
  6952. get: function () {
  6953. return this._sourceLeft;
  6954. },
  6955. set: function (value) {
  6956. if (this._sourceLeft === value) {
  6957. return;
  6958. }
  6959. this._sourceLeft = value;
  6960. this._markAsDirty();
  6961. },
  6962. enumerable: false,
  6963. configurable: true
  6964. });
  6965. Object.defineProperty(Image.prototype, "sourceTop", {
  6966. /**
  6967. * Gets or sets the top coordinate in the source image
  6968. */
  6969. get: function () {
  6970. return this._sourceTop;
  6971. },
  6972. set: function (value) {
  6973. if (this._sourceTop === value) {
  6974. return;
  6975. }
  6976. this._sourceTop = value;
  6977. this._markAsDirty();
  6978. },
  6979. enumerable: false,
  6980. configurable: true
  6981. });
  6982. Object.defineProperty(Image.prototype, "sourceWidth", {
  6983. /**
  6984. * Gets or sets the width to capture in the source image
  6985. */
  6986. get: function () {
  6987. return this._sourceWidth;
  6988. },
  6989. set: function (value) {
  6990. if (this._sourceWidth === value) {
  6991. return;
  6992. }
  6993. this._sourceWidth = value;
  6994. this._markAsDirty();
  6995. },
  6996. enumerable: false,
  6997. configurable: true
  6998. });
  6999. Object.defineProperty(Image.prototype, "sourceHeight", {
  7000. /**
  7001. * Gets or sets the height to capture in the source image
  7002. */
  7003. get: function () {
  7004. return this._sourceHeight;
  7005. },
  7006. set: function (value) {
  7007. if (this._sourceHeight === value) {
  7008. return;
  7009. }
  7010. this._sourceHeight = value;
  7011. this._markAsDirty();
  7012. },
  7013. enumerable: false,
  7014. configurable: true
  7015. });
  7016. Object.defineProperty(Image.prototype, "isSVG", {
  7017. /** Indicates if the format of the image is SVG */
  7018. get: function () {
  7019. return this._isSVG;
  7020. },
  7021. enumerable: false,
  7022. configurable: true
  7023. });
  7024. Object.defineProperty(Image.prototype, "svgAttributesComputationCompleted", {
  7025. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  7026. get: function () {
  7027. return this._svgAttributesComputationCompleted;
  7028. },
  7029. enumerable: false,
  7030. configurable: true
  7031. });
  7032. Object.defineProperty(Image.prototype, "autoScale", {
  7033. /**
  7034. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  7035. * @see https://doc.babylonjs.com/how_to/gui#image
  7036. */
  7037. get: function () {
  7038. return this._autoScale;
  7039. },
  7040. set: function (value) {
  7041. if (this._autoScale === value) {
  7042. return;
  7043. }
  7044. this._autoScale = value;
  7045. if (value && this._loaded) {
  7046. this.synchronizeSizeWithContent();
  7047. }
  7048. },
  7049. enumerable: false,
  7050. configurable: true
  7051. });
  7052. Object.defineProperty(Image.prototype, "stretch", {
  7053. /** Gets or sets the streching mode used by the image */
  7054. get: function () {
  7055. return this._stretch;
  7056. },
  7057. set: function (value) {
  7058. if (this._stretch === value) {
  7059. return;
  7060. }
  7061. this._stretch = value;
  7062. this._markAsDirty();
  7063. },
  7064. enumerable: false,
  7065. configurable: true
  7066. });
  7067. /** @hidden */
  7068. Image.prototype._rotate90 = function (n, preserveProperties) {
  7069. if (preserveProperties === void 0) { preserveProperties = false; }
  7070. var canvas = document.createElement("canvas");
  7071. var context = canvas.getContext("2d");
  7072. var width = this._domImage.width;
  7073. var height = this._domImage.height;
  7074. canvas.width = height;
  7075. canvas.height = width;
  7076. context.translate(canvas.width / 2, canvas.height / 2);
  7077. context.rotate((n * Math.PI) / 2);
  7078. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  7079. var dataUrl = canvas.toDataURL("image/jpg");
  7080. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  7081. if (preserveProperties) {
  7082. rotatedImage._stretch = this._stretch;
  7083. rotatedImage._autoScale = this._autoScale;
  7084. rotatedImage._cellId = this._cellId;
  7085. rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;
  7086. rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;
  7087. }
  7088. this._handleRotationForSVGImage(this, rotatedImage, n);
  7089. this._imageDataCache.data = null;
  7090. return rotatedImage;
  7091. };
  7092. Image.prototype._handleRotationForSVGImage = function (srcImage, dstImage, n) {
  7093. var _this = this;
  7094. if (!srcImage._isSVG) {
  7095. return;
  7096. }
  7097. if (srcImage._svgAttributesComputationCompleted) {
  7098. this._rotate90SourceProperties(srcImage, dstImage, n);
  7099. this._markAsDirty();
  7100. }
  7101. else {
  7102. srcImage.onSVGAttributesComputedObservable.addOnce(function () {
  7103. _this._rotate90SourceProperties(srcImage, dstImage, n);
  7104. _this._markAsDirty();
  7105. });
  7106. }
  7107. };
  7108. Image.prototype._rotate90SourceProperties = function (srcImage, dstImage, n) {
  7109. var _a, _b;
  7110. var srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
  7111. var dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
  7112. if (n != 0) {
  7113. var mult = n < 0 ? -1 : 1;
  7114. n = n % 4;
  7115. for (var i = 0; i < Math.abs(n); ++i) {
  7116. dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;
  7117. dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;
  7118. _a = [dstHeight, dstWidth], dstWidth = _a[0], dstHeight = _a[1];
  7119. if (n < 0) {
  7120. dstTop -= dstHeight;
  7121. }
  7122. else {
  7123. dstLeft -= dstWidth;
  7124. }
  7125. srcLeft = dstLeft;
  7126. srcTop = dstTop;
  7127. _b = [srcHeight, srcWidth], srcWidth = _b[0], srcHeight = _b[1];
  7128. }
  7129. }
  7130. dstImage.sourceLeft = dstLeft;
  7131. dstImage.sourceTop = dstTop;
  7132. dstImage.sourceWidth = dstWidth;
  7133. dstImage.sourceHeight = dstHeight;
  7134. };
  7135. Object.defineProperty(Image.prototype, "domImage", {
  7136. get: function () {
  7137. return this._domImage;
  7138. },
  7139. /**
  7140. * Gets or sets the internal DOM image used to render the control
  7141. */
  7142. set: function (value) {
  7143. var _this = this;
  7144. this._domImage = value;
  7145. this._loaded = false;
  7146. this._imageDataCache.data = null;
  7147. if (this._domImage.width) {
  7148. this._onImageLoaded();
  7149. }
  7150. else {
  7151. this._domImage.onload = function () {
  7152. _this._onImageLoaded();
  7153. };
  7154. }
  7155. },
  7156. enumerable: false,
  7157. configurable: true
  7158. });
  7159. Image.prototype._onImageLoaded = function () {
  7160. this._imageDataCache.data = null;
  7161. this._imageWidth = this._domImage.width;
  7162. this._imageHeight = this._domImage.height;
  7163. this._loaded = true;
  7164. if (this._populateNinePatchSlicesFromImage) {
  7165. this._extractNinePatchSliceDataFromImage();
  7166. }
  7167. if (this._autoScale) {
  7168. this.synchronizeSizeWithContent();
  7169. }
  7170. this.onImageLoadedObservable.notifyObservers(this);
  7171. this._markAsDirty();
  7172. };
  7173. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  7174. if (!this._workingCanvas) {
  7175. this._workingCanvas = document.createElement("canvas");
  7176. }
  7177. var canvas = this._workingCanvas;
  7178. var context = canvas.getContext("2d");
  7179. var width = this._domImage.width;
  7180. var height = this._domImage.height;
  7181. canvas.width = width;
  7182. canvas.height = height;
  7183. context.drawImage(this._domImage, 0, 0, width, height);
  7184. var imageData = context.getImageData(0, 0, width, height);
  7185. // Left and right
  7186. this._sliceLeft = -1;
  7187. this._sliceRight = -1;
  7188. for (var x = 0; x < width; x++) {
  7189. var alpha = imageData.data[x * 4 + 3];
  7190. if (alpha > 127 && this._sliceLeft === -1) {
  7191. this._sliceLeft = x;
  7192. continue;
  7193. }
  7194. if (alpha < 127 && this._sliceLeft > -1) {
  7195. this._sliceRight = x;
  7196. break;
  7197. }
  7198. }
  7199. // top and bottom
  7200. this._sliceTop = -1;
  7201. this._sliceBottom = -1;
  7202. for (var y = 0; y < height; y++) {
  7203. var alpha = imageData.data[y * width * 4 + 3];
  7204. if (alpha > 127 && this._sliceTop === -1) {
  7205. this._sliceTop = y;
  7206. continue;
  7207. }
  7208. if (alpha < 127 && this._sliceTop > -1) {
  7209. this._sliceBottom = y;
  7210. break;
  7211. }
  7212. }
  7213. };
  7214. Object.defineProperty(Image.prototype, "source", {
  7215. /**
  7216. * Gets the image source url
  7217. */
  7218. get: function () {
  7219. return this._source;
  7220. },
  7221. /**
  7222. * Gets or sets image source url
  7223. */
  7224. set: function (value) {
  7225. var _this = this;
  7226. if (this._source === value) {
  7227. return;
  7228. }
  7229. this._loaded = false;
  7230. this._source = value;
  7231. this._imageDataCache.data = null;
  7232. if (value) {
  7233. value = this._svgCheck(value);
  7234. }
  7235. this._domImage = document.createElement("img");
  7236. this._domImage.onload = function () {
  7237. _this._onImageLoaded();
  7238. };
  7239. if (value) {
  7240. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  7241. this._domImage.src = value;
  7242. }
  7243. },
  7244. enumerable: false,
  7245. configurable: true
  7246. });
  7247. /**
  7248. * Checks for svg document with icon id present
  7249. */
  7250. Image.prototype._svgCheck = function (value) {
  7251. var _this = this;
  7252. if (window.SVGSVGElement && value.search(/.svg#/gi) !== -1 && value.indexOf("#") === value.lastIndexOf("#")) {
  7253. this._isSVG = true;
  7254. var svgsrc = value.split("#")[0];
  7255. var elemid = value.split("#")[1];
  7256. // check if object alr exist in document
  7257. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  7258. if (svgExist) {
  7259. var svgDoc = svgExist.contentDocument;
  7260. // get viewbox width and height, get svg document width and height in px
  7261. if (svgDoc && svgDoc.documentElement) {
  7262. var vb = svgDoc.documentElement.getAttribute("viewBox");
  7263. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  7264. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  7265. var elem = svgDoc.getElementById(elemid);
  7266. if (elem && vb && docwidth && docheight) {
  7267. this._getSVGAttribs(svgExist, elemid);
  7268. return value;
  7269. }
  7270. }
  7271. // wait for object to load
  7272. svgExist.addEventListener("load", function () {
  7273. _this._getSVGAttribs(svgExist, elemid);
  7274. });
  7275. }
  7276. else {
  7277. // create document object
  7278. var svgImage = document.createElement("object");
  7279. svgImage.data = svgsrc;
  7280. svgImage.type = "image/svg+xml";
  7281. svgImage.width = "0%";
  7282. svgImage.height = "0%";
  7283. document.body.appendChild(svgImage);
  7284. // when the object has loaded, get the element attribs
  7285. svgImage.onload = function () {
  7286. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  7287. if (svgobj) {
  7288. _this._getSVGAttribs(svgobj, elemid);
  7289. }
  7290. };
  7291. }
  7292. return svgsrc;
  7293. }
  7294. else {
  7295. return value;
  7296. }
  7297. };
  7298. /**
  7299. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  7300. * given external svg file and icon id
  7301. */
  7302. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  7303. var svgDoc = svgsrc.contentDocument;
  7304. // get viewbox width and height, get svg document width and height in px
  7305. if (svgDoc && svgDoc.documentElement) {
  7306. var vb = svgDoc.documentElement.getAttribute("viewBox");
  7307. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  7308. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  7309. // get element bbox and matrix transform
  7310. var elem = svgDoc.getElementById(elemid);
  7311. if (vb && docwidth && docheight && elem) {
  7312. var vb_width = Number(vb.split(" ")[2]);
  7313. var vb_height = Number(vb.split(" ")[3]);
  7314. var elem_bbox = elem.getBBox();
  7315. var elem_matrix_a = 1;
  7316. var elem_matrix_d = 1;
  7317. var elem_matrix_e = 0;
  7318. var elem_matrix_f = 0;
  7319. if (elem.transform && elem.transform.baseVal.consolidate()) {
  7320. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  7321. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  7322. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  7323. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  7324. }
  7325. // compute source coordinates and dimensions
  7326. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  7327. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  7328. this.sourceWidth = elem_bbox.width * elem_matrix_a * (docwidth / vb_width);
  7329. this.sourceHeight = elem_bbox.height * elem_matrix_d * (docheight / vb_height);
  7330. this._svgAttributesComputationCompleted = true;
  7331. this.onSVGAttributesComputedObservable.notifyObservers(this);
  7332. }
  7333. }
  7334. };
  7335. Object.defineProperty(Image.prototype, "cellWidth", {
  7336. /**
  7337. * Gets or sets the cell width to use when animation sheet is enabled
  7338. * @see https://doc.babylonjs.com/how_to/gui#image
  7339. */
  7340. get: function () {
  7341. return this._cellWidth;
  7342. },
  7343. set: function (value) {
  7344. if (this._cellWidth === value) {
  7345. return;
  7346. }
  7347. this._cellWidth = value;
  7348. this._markAsDirty();
  7349. },
  7350. enumerable: false,
  7351. configurable: true
  7352. });
  7353. Object.defineProperty(Image.prototype, "cellHeight", {
  7354. /**
  7355. * Gets or sets the cell height to use when animation sheet is enabled
  7356. * @see https://doc.babylonjs.com/how_to/gui#image
  7357. */
  7358. get: function () {
  7359. return this._cellHeight;
  7360. },
  7361. set: function (value) {
  7362. if (this._cellHeight === value) {
  7363. return;
  7364. }
  7365. this._cellHeight = value;
  7366. this._markAsDirty();
  7367. },
  7368. enumerable: false,
  7369. configurable: true
  7370. });
  7371. Object.defineProperty(Image.prototype, "cellId", {
  7372. /**
  7373. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  7374. * @see https://doc.babylonjs.com/how_to/gui#image
  7375. */
  7376. get: function () {
  7377. return this._cellId;
  7378. },
  7379. set: function (value) {
  7380. if (this._cellId === value) {
  7381. return;
  7382. }
  7383. this._cellId = value;
  7384. this._markAsDirty();
  7385. },
  7386. enumerable: false,
  7387. configurable: true
  7388. });
  7389. /**
  7390. * Tests if a given coordinates belong to the current control
  7391. * @param x defines x coordinate to test
  7392. * @param y defines y coordinate to test
  7393. * @returns true if the coordinates are inside the control
  7394. */
  7395. Image.prototype.contains = function (x, y) {
  7396. if (!_super.prototype.contains.call(this, x, y)) {
  7397. return false;
  7398. }
  7399. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  7400. return true;
  7401. }
  7402. var width = this._currentMeasure.width | 0;
  7403. var height = this._currentMeasure.height | 0;
  7404. var key = width + "_" + height;
  7405. var imageData = this._imageDataCache.data;
  7406. if (!imageData || this._imageDataCache.key !== key) {
  7407. var canvas = this._workingCanvas;
  7408. var context_1 = canvas.getContext("2d");
  7409. this._imageDataCache.data = imageData = context_1.getImageData(0, 0, width, height).data;
  7410. this._imageDataCache.key = key;
  7411. }
  7412. x = (x - this._currentMeasure.left) | 0;
  7413. y = (y - this._currentMeasure.top) | 0;
  7414. var pickedPixel = imageData[(x + y * width) * 4 + 3];
  7415. return pickedPixel > 0;
  7416. };
  7417. Image.prototype._getTypeName = function () {
  7418. return "Image";
  7419. };
  7420. /** Force the control to synchronize with its content */
  7421. Image.prototype.synchronizeSizeWithContent = function () {
  7422. if (!this._loaded) {
  7423. return;
  7424. }
  7425. this.width = this._domImage.width + "px";
  7426. this.height = this._domImage.height + "px";
  7427. };
  7428. Image.prototype._processMeasures = function (parentMeasure, context) {
  7429. if (this._loaded) {
  7430. switch (this._stretch) {
  7431. case Image.STRETCH_NONE:
  7432. break;
  7433. case Image.STRETCH_FILL:
  7434. break;
  7435. case Image.STRETCH_UNIFORM:
  7436. break;
  7437. case Image.STRETCH_NINE_PATCH:
  7438. break;
  7439. case Image.STRETCH_EXTEND:
  7440. if (this._autoScale) {
  7441. this.synchronizeSizeWithContent();
  7442. }
  7443. if (this.parent && this.parent.parent) {
  7444. // Will update root size if root is not the top root
  7445. this.parent.adaptWidthToChildren = true;
  7446. this.parent.adaptHeightToChildren = true;
  7447. }
  7448. break;
  7449. }
  7450. }
  7451. _super.prototype._processMeasures.call(this, parentMeasure, context);
  7452. };
  7453. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  7454. if (!this._detectPointerOnOpaqueOnly) {
  7455. return;
  7456. }
  7457. if (!this._workingCanvas) {
  7458. this._workingCanvas = document.createElement("canvas");
  7459. }
  7460. var canvas = this._workingCanvas;
  7461. var width = this._currentMeasure.width;
  7462. var height = this._currentMeasure.height;
  7463. var context = canvas.getContext("2d");
  7464. canvas.width = width;
  7465. canvas.height = height;
  7466. context.clearRect(0, 0, width, height);
  7467. };
  7468. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  7469. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  7470. if (!this._detectPointerOnOpaqueOnly) {
  7471. return;
  7472. }
  7473. var canvas = this._workingCanvas;
  7474. context = canvas.getContext("2d");
  7475. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  7476. };
  7477. Image.prototype._draw = function (context) {
  7478. context.save();
  7479. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7480. context.shadowColor = this.shadowColor;
  7481. context.shadowBlur = this.shadowBlur;
  7482. context.shadowOffsetX = this.shadowOffsetX;
  7483. context.shadowOffsetY = this.shadowOffsetY;
  7484. }
  7485. var x, y, width, height;
  7486. if (this.cellId == -1) {
  7487. x = this._sourceLeft;
  7488. y = this._sourceTop;
  7489. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  7490. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  7491. }
  7492. else {
  7493. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  7494. var column = (this.cellId / rowCount) >> 0;
  7495. var row = this.cellId % rowCount;
  7496. x = this.cellWidth * row;
  7497. y = this.cellHeight * column;
  7498. width = this.cellWidth;
  7499. height = this.cellHeight;
  7500. }
  7501. this._prepareWorkingCanvasForOpaqueDetection();
  7502. this._applyStates(context);
  7503. if (this._loaded) {
  7504. switch (this._stretch) {
  7505. case Image.STRETCH_NONE:
  7506. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7507. break;
  7508. case Image.STRETCH_FILL:
  7509. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7510. break;
  7511. case Image.STRETCH_UNIFORM:
  7512. var hRatio = this._currentMeasure.width / width;
  7513. var vRatio = this._currentMeasure.height / height;
  7514. var ratio = Math.min(hRatio, vRatio);
  7515. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  7516. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  7517. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  7518. break;
  7519. case Image.STRETCH_EXTEND:
  7520. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7521. break;
  7522. case Image.STRETCH_NINE_PATCH:
  7523. this._renderNinePatch(context);
  7524. break;
  7525. }
  7526. }
  7527. context.restore();
  7528. };
  7529. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  7530. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  7531. };
  7532. Image.prototype._renderNinePatch = function (context) {
  7533. var height = this._imageHeight;
  7534. var leftWidth = this._sliceLeft;
  7535. var topHeight = this._sliceTop;
  7536. var bottomHeight = this._imageHeight - this._sliceBottom;
  7537. var rightWidth = this._imageWidth - this._sliceRight;
  7538. var left = 0;
  7539. var top = 0;
  7540. if (this._populateNinePatchSlicesFromImage) {
  7541. left = 1;
  7542. top = 1;
  7543. height -= 2;
  7544. leftWidth -= 1;
  7545. topHeight -= 1;
  7546. bottomHeight -= 1;
  7547. rightWidth -= 1;
  7548. }
  7549. var centerWidth = this._sliceRight - this._sliceLeft;
  7550. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft;
  7551. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  7552. // Corners
  7553. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  7554. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  7555. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  7556. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  7557. // Center
  7558. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight);
  7559. // Borders
  7560. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  7561. 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);
  7562. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  7563. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  7564. };
  7565. Image.prototype.dispose = function () {
  7566. _super.prototype.dispose.call(this);
  7567. this.onImageLoadedObservable.clear();
  7568. this.onSVGAttributesComputedObservable.clear();
  7569. };
  7570. // Static
  7571. /** STRETCH_NONE */
  7572. Image.STRETCH_NONE = 0;
  7573. /** STRETCH_FILL */
  7574. Image.STRETCH_FILL = 1;
  7575. /** STRETCH_UNIFORM */
  7576. Image.STRETCH_UNIFORM = 2;
  7577. /** STRETCH_EXTEND */
  7578. Image.STRETCH_EXTEND = 3;
  7579. /** NINE_PATCH */
  7580. Image.STRETCH_NINE_PATCH = 4;
  7581. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7582. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7583. ], Image.prototype, "populateNinePatchSlicesFromImage", null);
  7584. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7585. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7586. ], Image.prototype, "detectPointerOnOpaqueOnly", null);
  7587. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7588. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7589. ], Image.prototype, "sliceLeft", null);
  7590. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7591. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7592. ], Image.prototype, "sliceRight", null);
  7593. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7594. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7595. ], Image.prototype, "sliceTop", null);
  7596. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7597. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7598. ], Image.prototype, "sliceBottom", null);
  7599. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7600. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7601. ], Image.prototype, "sourceLeft", null);
  7602. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7603. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7604. ], Image.prototype, "sourceTop", null);
  7605. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7606. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7607. ], Image.prototype, "sourceWidth", null);
  7608. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7609. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7610. ], Image.prototype, "sourceHeight", null);
  7611. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7612. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7613. ], Image.prototype, "autoScale", null);
  7614. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7615. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7616. ], Image.prototype, "stretch", null);
  7617. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7618. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7619. ], Image.prototype, "source", null);
  7620. return Image;
  7621. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7622. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  7623. /***/ }),
  7624. /***/ "./2D/controls/index.ts":
  7625. /*!******************************!*\
  7626. !*** ./2D/controls/index.ts ***!
  7627. \******************************/
  7628. /*! 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 */
  7629. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7630. "use strict";
  7631. __webpack_require__.r(__webpack_exports__);
  7632. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  7633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  7634. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  7635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  7636. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  7637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  7638. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  7639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  7640. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  7642. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  7643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  7644. /* harmony import */ var _focusableButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./focusableButton */ "./2D/controls/focusableButton.ts");
  7645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return _focusableButton__WEBPACK_IMPORTED_MODULE_6__["FocusableButton"]; });
  7646. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  7647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_7__["Grid"]; });
  7648. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  7649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_8__["Image"]; });
  7650. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_9__["InputText"]; });
  7652. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  7653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_10__["InputPassword"]; });
  7654. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  7655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_11__["Line"]; });
  7656. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  7657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_12__["MultiLine"]; });
  7658. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  7659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_13__["RadioButton"]; });
  7660. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  7661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_14__["StackPanel"]; });
  7662. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  7663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["SelectorGroup"]; });
  7664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["CheckboxGroup"]; });
  7665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["RadioGroup"]; });
  7666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["SliderGroup"]; });
  7667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["SelectionPanel"]; });
  7668. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  7669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_16__["ScrollViewer"]; });
  7670. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  7671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_17__["TextWrapping"]; });
  7672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_17__["TextBlock"]; });
  7673. /* harmony import */ var _textWrapper__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./textWrapper */ "./2D/controls/textWrapper.ts");
  7674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _textWrapper__WEBPACK_IMPORTED_MODULE_18__["TextWrapper"]; });
  7675. /* harmony import */ var _toggleButton__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./toggleButton */ "./2D/controls/toggleButton.ts");
  7676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return _toggleButton__WEBPACK_IMPORTED_MODULE_19__["ToggleButton"]; });
  7677. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  7678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_20__["KeyPropertySet"]; });
  7679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_20__["VirtualKeyboard"]; });
  7680. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  7681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_21__["Rectangle"]; });
  7682. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  7683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_22__["DisplayGrid"]; });
  7684. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  7685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_23__["BaseSlider"]; });
  7686. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  7687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_24__["Slider"]; });
  7688. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  7689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_25__["ImageBasedSlider"]; });
  7690. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  7691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_26__["ScrollBar"]; });
  7692. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  7693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_27__["ImageScrollBar"]; });
  7694. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  7695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_28__["name"]; });
  7696. /***/ }),
  7697. /***/ "./2D/controls/inputPassword.ts":
  7698. /*!**************************************!*\
  7699. !*** ./2D/controls/inputPassword.ts ***!
  7700. \**************************************/
  7701. /*! exports provided: InputPassword */
  7702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7703. "use strict";
  7704. __webpack_require__.r(__webpack_exports__);
  7705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  7706. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7707. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7708. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  7709. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  7710. /* harmony import */ var _textWrapper__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textWrapper */ "./2D/controls/textWrapper.ts");
  7711. /**
  7712. * Class used to create a password control
  7713. */
  7714. var InputPassword = /** @class */ (function (_super) {
  7715. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  7716. function InputPassword() {
  7717. return _super !== null && _super.apply(this, arguments) || this;
  7718. }
  7719. InputPassword.prototype._beforeRenderText = function (textWrapper) {
  7720. var pwdTextWrapper = new _textWrapper__WEBPACK_IMPORTED_MODULE_3__["TextWrapper"]();
  7721. var txt = "";
  7722. for (var i = 0; i < textWrapper.length; i++) {
  7723. txt += "\u2022";
  7724. }
  7725. pwdTextWrapper.text = txt;
  7726. return pwdTextWrapper;
  7727. };
  7728. return InputPassword;
  7729. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  7730. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  7731. /***/ }),
  7732. /***/ "./2D/controls/inputText.ts":
  7733. /*!**********************************!*\
  7734. !*** ./2D/controls/inputText.ts ***!
  7735. \**********************************/
  7736. /*! exports provided: InputText */
  7737. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7738. "use strict";
  7739. __webpack_require__.r(__webpack_exports__);
  7740. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  7741. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7742. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  7743. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  7744. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7745. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7746. /* harmony import */ var _textWrapper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textWrapper */ "./2D/controls/textWrapper.ts");
  7747. /**
  7748. * Class used to create input text control
  7749. */
  7750. var InputText = /** @class */ (function (_super) {
  7751. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7752. /**
  7753. * Creates a new InputText
  7754. * @param name defines the control name
  7755. * @param text defines the text of the control
  7756. */
  7757. function InputText(name, text) {
  7758. if (text === void 0) { text = ""; }
  7759. var _this = _super.call(this, name) || this;
  7760. _this.name = name;
  7761. _this._placeholderText = "";
  7762. _this._background = "#222222";
  7763. _this._focusedBackground = "#000000";
  7764. _this._focusedColor = "white";
  7765. _this._placeholderColor = "gray";
  7766. _this._thickness = 1;
  7767. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7768. _this._autoStretchWidth = true;
  7769. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7770. _this._isFocused = false;
  7771. _this._blinkIsEven = false;
  7772. _this._cursorOffset = 0;
  7773. _this._deadKey = false;
  7774. _this._addKey = true;
  7775. _this._currentKey = "";
  7776. _this._isTextHighlightOn = false;
  7777. _this._textHighlightColor = "#d5e0ff";
  7778. _this._highligherOpacity = 0.4;
  7779. _this._highlightedText = "";
  7780. _this._startHighlightIndex = 0;
  7781. _this._endHighlightIndex = 0;
  7782. _this._cursorIndex = -1;
  7783. _this._onFocusSelectAll = false;
  7784. _this._isPointerDown = false;
  7785. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7786. _this.promptMessage = "Please enter text:";
  7787. /** Force disable prompt on mobile device */
  7788. _this.disableMobilePrompt = false;
  7789. /** Observable raised when the text changes */
  7790. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7791. /** Observable raised just before an entered character is to be added */
  7792. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7793. /** Observable raised when the control gets the focus */
  7794. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7795. /** Observable raised when the control loses the focus */
  7796. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7797. /**Observable raised when the text is highlighted */
  7798. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7799. /**Observable raised when copy event is triggered */
  7800. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7801. /** Observable raised when cut event is triggered */
  7802. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7803. /** Observable raised when paste event is triggered */
  7804. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7805. /** Observable raised when a key event was processed */
  7806. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7807. _this.text = text;
  7808. _this.isPointerBlocker = true;
  7809. return _this;
  7810. }
  7811. Object.defineProperty(InputText.prototype, "maxWidth", {
  7812. /** Gets or sets the maximum width allowed by the control */
  7813. get: function () {
  7814. return this._maxWidth.toString(this._host);
  7815. },
  7816. set: function (value) {
  7817. if (this._maxWidth.toString(this._host) === value) {
  7818. return;
  7819. }
  7820. if (this._maxWidth.fromString(value)) {
  7821. this._markAsDirty();
  7822. }
  7823. },
  7824. enumerable: false,
  7825. configurable: true
  7826. });
  7827. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7828. /** Gets the maximum width allowed by the control in pixels */
  7829. get: function () {
  7830. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7831. },
  7832. enumerable: false,
  7833. configurable: true
  7834. });
  7835. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7836. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7837. get: function () {
  7838. return this._highligherOpacity;
  7839. },
  7840. set: function (value) {
  7841. if (this._highligherOpacity === value) {
  7842. return;
  7843. }
  7844. this._highligherOpacity = value;
  7845. this._markAsDirty();
  7846. },
  7847. enumerable: false,
  7848. configurable: true
  7849. });
  7850. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7851. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7852. get: function () {
  7853. return this._onFocusSelectAll;
  7854. },
  7855. set: function (value) {
  7856. if (this._onFocusSelectAll === value) {
  7857. return;
  7858. }
  7859. this._onFocusSelectAll = value;
  7860. this._markAsDirty();
  7861. },
  7862. enumerable: false,
  7863. configurable: true
  7864. });
  7865. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7866. /** Gets or sets the text hightlight color */
  7867. get: function () {
  7868. return this._textHighlightColor;
  7869. },
  7870. set: function (value) {
  7871. if (this._textHighlightColor === value) {
  7872. return;
  7873. }
  7874. this._textHighlightColor = value;
  7875. this._markAsDirty();
  7876. },
  7877. enumerable: false,
  7878. configurable: true
  7879. });
  7880. Object.defineProperty(InputText.prototype, "margin", {
  7881. /** Gets or sets control margin */
  7882. get: function () {
  7883. return this._margin.toString(this._host);
  7884. },
  7885. set: function (value) {
  7886. if (this._margin.toString(this._host) === value) {
  7887. return;
  7888. }
  7889. if (this._margin.fromString(value)) {
  7890. this._markAsDirty();
  7891. }
  7892. },
  7893. enumerable: false,
  7894. configurable: true
  7895. });
  7896. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7897. /** Gets control margin in pixels */
  7898. get: function () {
  7899. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7900. },
  7901. enumerable: false,
  7902. configurable: true
  7903. });
  7904. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7905. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7906. get: function () {
  7907. return this._autoStretchWidth;
  7908. },
  7909. set: function (value) {
  7910. if (this._autoStretchWidth === value) {
  7911. return;
  7912. }
  7913. this._autoStretchWidth = value;
  7914. this._markAsDirty();
  7915. },
  7916. enumerable: false,
  7917. configurable: true
  7918. });
  7919. Object.defineProperty(InputText.prototype, "thickness", {
  7920. /** Gets or sets border thickness */
  7921. get: function () {
  7922. return this._thickness;
  7923. },
  7924. set: function (value) {
  7925. if (this._thickness === value) {
  7926. return;
  7927. }
  7928. this._thickness = value;
  7929. this._markAsDirty();
  7930. },
  7931. enumerable: false,
  7932. configurable: true
  7933. });
  7934. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7935. /** Gets or sets the background color when focused */
  7936. get: function () {
  7937. return this._focusedBackground;
  7938. },
  7939. set: function (value) {
  7940. if (this._focusedBackground === value) {
  7941. return;
  7942. }
  7943. this._focusedBackground = value;
  7944. this._markAsDirty();
  7945. },
  7946. enumerable: false,
  7947. configurable: true
  7948. });
  7949. Object.defineProperty(InputText.prototype, "focusedColor", {
  7950. /** Gets or sets the background color when focused */
  7951. get: function () {
  7952. return this._focusedColor;
  7953. },
  7954. set: function (value) {
  7955. if (this._focusedColor === value) {
  7956. return;
  7957. }
  7958. this._focusedColor = value;
  7959. this._markAsDirty();
  7960. },
  7961. enumerable: false,
  7962. configurable: true
  7963. });
  7964. Object.defineProperty(InputText.prototype, "background", {
  7965. /** Gets or sets the background color */
  7966. get: function () {
  7967. return this._background;
  7968. },
  7969. set: function (value) {
  7970. if (this._background === value) {
  7971. return;
  7972. }
  7973. this._background = value;
  7974. this._markAsDirty();
  7975. },
  7976. enumerable: false,
  7977. configurable: true
  7978. });
  7979. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7980. /** Gets or sets the placeholder color */
  7981. get: function () {
  7982. return this._placeholderColor;
  7983. },
  7984. set: function (value) {
  7985. if (this._placeholderColor === value) {
  7986. return;
  7987. }
  7988. this._placeholderColor = value;
  7989. this._markAsDirty();
  7990. },
  7991. enumerable: false,
  7992. configurable: true
  7993. });
  7994. Object.defineProperty(InputText.prototype, "placeholderText", {
  7995. /** Gets or sets the text displayed when the control is empty */
  7996. get: function () {
  7997. return this._placeholderText;
  7998. },
  7999. set: function (value) {
  8000. if (this._placeholderText === value) {
  8001. return;
  8002. }
  8003. this._placeholderText = value;
  8004. this._markAsDirty();
  8005. },
  8006. enumerable: false,
  8007. configurable: true
  8008. });
  8009. Object.defineProperty(InputText.prototype, "deadKey", {
  8010. /** Gets or sets the dead key flag */
  8011. get: function () {
  8012. return this._deadKey;
  8013. },
  8014. set: function (flag) {
  8015. this._deadKey = flag;
  8016. },
  8017. enumerable: false,
  8018. configurable: true
  8019. });
  8020. Object.defineProperty(InputText.prototype, "highlightedText", {
  8021. /** Gets or sets the highlight text */
  8022. get: function () {
  8023. return this._highlightedText;
  8024. },
  8025. set: function (text) {
  8026. if (this._highlightedText === text) {
  8027. return;
  8028. }
  8029. this._highlightedText = text;
  8030. this._markAsDirty();
  8031. },
  8032. enumerable: false,
  8033. configurable: true
  8034. });
  8035. Object.defineProperty(InputText.prototype, "addKey", {
  8036. /** Gets or sets if the current key should be added */
  8037. get: function () {
  8038. return this._addKey;
  8039. },
  8040. set: function (flag) {
  8041. this._addKey = flag;
  8042. },
  8043. enumerable: false,
  8044. configurable: true
  8045. });
  8046. Object.defineProperty(InputText.prototype, "currentKey", {
  8047. /** Gets or sets the value of the current key being entered */
  8048. get: function () {
  8049. return this._currentKey;
  8050. },
  8051. set: function (key) {
  8052. this._currentKey = key;
  8053. },
  8054. enumerable: false,
  8055. configurable: true
  8056. });
  8057. Object.defineProperty(InputText.prototype, "text", {
  8058. /** Gets or sets the text displayed in the control */
  8059. get: function () {
  8060. return this._textWrapper.text;
  8061. },
  8062. set: function (value) {
  8063. var valueAsString = value.toString(); // Forcing convertion
  8064. if (!this._textWrapper) {
  8065. this._textWrapper = new _textWrapper__WEBPACK_IMPORTED_MODULE_4__["TextWrapper"]();
  8066. }
  8067. if (this._textWrapper.text === valueAsString) {
  8068. return;
  8069. }
  8070. this._textWrapper.text = valueAsString;
  8071. this._textHasChanged();
  8072. },
  8073. enumerable: false,
  8074. configurable: true
  8075. });
  8076. InputText.prototype._textHasChanged = function () {
  8077. this._markAsDirty();
  8078. this.onTextChangedObservable.notifyObservers(this);
  8079. };
  8080. Object.defineProperty(InputText.prototype, "width", {
  8081. /** Gets or sets control width */
  8082. get: function () {
  8083. return this._width.toString(this._host);
  8084. },
  8085. set: function (value) {
  8086. if (this._width.toString(this._host) === value) {
  8087. return;
  8088. }
  8089. if (this._width.fromString(value)) {
  8090. this._markAsDirty();
  8091. }
  8092. this.autoStretchWidth = false;
  8093. },
  8094. enumerable: false,
  8095. configurable: true
  8096. });
  8097. /** @hidden */
  8098. InputText.prototype.onBlur = function () {
  8099. this._isFocused = false;
  8100. this._scrollLeft = null;
  8101. this._cursorOffset = 0;
  8102. clearTimeout(this._blinkTimeout);
  8103. this._markAsDirty();
  8104. this.onBlurObservable.notifyObservers(this);
  8105. this._host.unRegisterClipboardEvents();
  8106. if (this._onClipboardObserver) {
  8107. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  8108. }
  8109. var scene = this._host.getScene();
  8110. if (this._onPointerDblTapObserver && scene) {
  8111. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  8112. }
  8113. };
  8114. /** @hidden */
  8115. InputText.prototype.onFocus = function () {
  8116. var _this = this;
  8117. if (!this._isEnabled) {
  8118. return;
  8119. }
  8120. this._scrollLeft = null;
  8121. this._isFocused = true;
  8122. this._blinkIsEven = false;
  8123. this._cursorOffset = 0;
  8124. this._markAsDirty();
  8125. this.onFocusObservable.notifyObservers(this);
  8126. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  8127. var value = prompt(this.promptMessage);
  8128. if (value !== null) {
  8129. this.text = value;
  8130. }
  8131. this._host.focusedControl = null;
  8132. return;
  8133. }
  8134. this._host.registerClipboardEvents();
  8135. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  8136. // process clipboard event, can be configured.
  8137. switch (clipboardInfo.type) {
  8138. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  8139. _this._onCopyText(clipboardInfo.event);
  8140. _this.onTextCopyObservable.notifyObservers(_this);
  8141. break;
  8142. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  8143. _this._onCutText(clipboardInfo.event);
  8144. _this.onTextCutObservable.notifyObservers(_this);
  8145. break;
  8146. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  8147. _this._onPasteText(clipboardInfo.event);
  8148. _this.onTextPasteObservable.notifyObservers(_this);
  8149. break;
  8150. default: return;
  8151. }
  8152. });
  8153. var scene = this._host.getScene();
  8154. if (scene) {
  8155. //register the pointer double tap event
  8156. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  8157. if (!_this._isFocused) {
  8158. return;
  8159. }
  8160. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  8161. _this._processDblClick(pointerInfo);
  8162. }
  8163. });
  8164. }
  8165. if (this._onFocusSelectAll) {
  8166. this._selectAllText();
  8167. }
  8168. };
  8169. /**
  8170. * Function to focus an inputText programmatically
  8171. */
  8172. InputText.prototype.focus = function () {
  8173. this._host.moveFocusToControl(this);
  8174. };
  8175. /**
  8176. * Function to unfocus an inputText programmatically
  8177. */
  8178. InputText.prototype.blur = function () {
  8179. this._host.focusedControl = null;
  8180. };
  8181. InputText.prototype._getTypeName = function () {
  8182. return "InputText";
  8183. };
  8184. /**
  8185. * Function called to get the list of controls that should not steal the focus from this control
  8186. * @returns an array of controls
  8187. */
  8188. InputText.prototype.keepsFocusWith = function () {
  8189. if (!this._connectedVirtualKeyboard) {
  8190. return null;
  8191. }
  8192. return [this._connectedVirtualKeyboard];
  8193. };
  8194. /** @hidden */
  8195. InputText.prototype.processKey = function (keyCode, key, evt) {
  8196. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  8197. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  8198. return;
  8199. }
  8200. //select all
  8201. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  8202. this._selectAllText();
  8203. evt.preventDefault();
  8204. return;
  8205. }
  8206. // Specific cases
  8207. switch (keyCode) {
  8208. case 32: //SPACE
  8209. key = " "; //ie11 key for space is "Spacebar"
  8210. break;
  8211. case 191: //SLASH
  8212. if (evt) {
  8213. evt.preventDefault();
  8214. }
  8215. break;
  8216. case 8: // BACKSPACE
  8217. if (this._textWrapper.text && this._textWrapper.length > 0) {
  8218. //delete the highlighted text
  8219. if (this._isTextHighlightOn) {
  8220. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
  8221. this._textHasChanged();
  8222. this._isTextHighlightOn = false;
  8223. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8224. this._blinkIsEven = false;
  8225. if (evt) {
  8226. evt.preventDefault();
  8227. }
  8228. return;
  8229. }
  8230. //delete single character
  8231. if (this._cursorOffset === 0) {
  8232. this.text = this._textWrapper.substr(0, this._textWrapper.length - 1);
  8233. }
  8234. else {
  8235. var deletePosition = this._textWrapper.length - this._cursorOffset;
  8236. if (deletePosition > 0) {
  8237. this._textWrapper.removePart(deletePosition - 1, deletePosition);
  8238. this._textHasChanged();
  8239. }
  8240. }
  8241. }
  8242. if (evt) {
  8243. evt.preventDefault();
  8244. }
  8245. return;
  8246. case 46: // DELETE
  8247. if (this._isTextHighlightOn) {
  8248. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
  8249. this._textHasChanged();
  8250. this._isTextHighlightOn = false;
  8251. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8252. if (evt) {
  8253. evt.preventDefault();
  8254. }
  8255. return;
  8256. }
  8257. if (this._textWrapper.text && this._textWrapper.length > 0 && this._cursorOffset > 0) {
  8258. var deletePosition = this._textWrapper.length - this._cursorOffset;
  8259. this._textWrapper.removePart(deletePosition, deletePosition + 1);
  8260. this._textHasChanged();
  8261. this._cursorOffset--;
  8262. }
  8263. if (evt) {
  8264. evt.preventDefault();
  8265. }
  8266. return;
  8267. case 13: // RETURN
  8268. this._host.focusedControl = null;
  8269. this._isTextHighlightOn = false;
  8270. return;
  8271. case 35: // END
  8272. this._cursorOffset = 0;
  8273. this._blinkIsEven = false;
  8274. this._isTextHighlightOn = false;
  8275. this._markAsDirty();
  8276. return;
  8277. case 36: // HOME
  8278. this._cursorOffset = this._textWrapper.length;
  8279. this._blinkIsEven = false;
  8280. this._isTextHighlightOn = false;
  8281. this._markAsDirty();
  8282. return;
  8283. case 37: // LEFT
  8284. this._cursorOffset++;
  8285. if (this._cursorOffset > this._textWrapper.length) {
  8286. this._cursorOffset = this._textWrapper.length;
  8287. }
  8288. if (evt && evt.shiftKey) {
  8289. // update the cursor
  8290. this._blinkIsEven = false;
  8291. // shift + ctrl/cmd + <-
  8292. if (evt.ctrlKey || evt.metaKey) {
  8293. if (!this._isTextHighlightOn) {
  8294. if (this._textWrapper.length === this._cursorOffset) {
  8295. return;
  8296. }
  8297. else {
  8298. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset + 1;
  8299. }
  8300. }
  8301. this._startHighlightIndex = 0;
  8302. this._cursorIndex = this._textWrapper.length - this._endHighlightIndex;
  8303. this._cursorOffset = this._textWrapper.length;
  8304. this._isTextHighlightOn = true;
  8305. this._markAsDirty();
  8306. return;
  8307. }
  8308. //store the starting point
  8309. if (!this._isTextHighlightOn) {
  8310. this._isTextHighlightOn = true;
  8311. this._cursorIndex = (this._cursorOffset >= this._textWrapper.length) ? this._textWrapper.length : this._cursorOffset - 1;
  8312. }
  8313. //if text is already highlighted
  8314. else if (this._cursorIndex === -1) {
  8315. this._cursorIndex = this._textWrapper.length - this._endHighlightIndex;
  8316. this._cursorOffset = (this._startHighlightIndex === 0) ? this._textWrapper.length : this._textWrapper.length - this._startHighlightIndex + 1;
  8317. }
  8318. //set the highlight indexes
  8319. if (this._cursorIndex < this._cursorOffset) {
  8320. this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8321. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8322. }
  8323. else if (this._cursorIndex > this._cursorOffset) {
  8324. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8325. this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8326. }
  8327. else {
  8328. this._isTextHighlightOn = false;
  8329. }
  8330. this._markAsDirty();
  8331. return;
  8332. }
  8333. if (this._isTextHighlightOn) {
  8334. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8335. this._isTextHighlightOn = false;
  8336. }
  8337. if (evt && (evt.ctrlKey || evt.metaKey)) {
  8338. this._cursorOffset = this._textWrapper.length;
  8339. evt.preventDefault();
  8340. }
  8341. this._blinkIsEven = false;
  8342. this._isTextHighlightOn = false;
  8343. this._cursorIndex = -1;
  8344. this._markAsDirty();
  8345. return;
  8346. case 39: // RIGHT
  8347. this._cursorOffset--;
  8348. if (this._cursorOffset < 0) {
  8349. this._cursorOffset = 0;
  8350. }
  8351. if (evt && evt.shiftKey) {
  8352. //update the cursor
  8353. this._blinkIsEven = false;
  8354. //shift + ctrl/cmd + ->
  8355. if (evt.ctrlKey || evt.metaKey) {
  8356. if (!this._isTextHighlightOn) {
  8357. if (this._cursorOffset === 0) {
  8358. return;
  8359. }
  8360. else {
  8361. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset - 1;
  8362. }
  8363. }
  8364. this._endHighlightIndex = this._textWrapper.length;
  8365. this._isTextHighlightOn = true;
  8366. this._cursorIndex = this._textWrapper.length - this._startHighlightIndex;
  8367. this._cursorOffset = 0;
  8368. this._markAsDirty();
  8369. return;
  8370. }
  8371. if (!this._isTextHighlightOn) {
  8372. this._isTextHighlightOn = true;
  8373. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  8374. }
  8375. //if text is already highlighted
  8376. else if (this._cursorIndex === -1) {
  8377. this._cursorIndex = this._textWrapper.length - this._startHighlightIndex;
  8378. this._cursorOffset = (this._textWrapper.length === this._endHighlightIndex) ? 0 : this._textWrapper.length - this._endHighlightIndex - 1;
  8379. }
  8380. //set the highlight indexes
  8381. if (this._cursorIndex < this._cursorOffset) {
  8382. this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8383. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8384. }
  8385. else if (this._cursorIndex > this._cursorOffset) {
  8386. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8387. this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8388. }
  8389. else {
  8390. this._isTextHighlightOn = false;
  8391. }
  8392. this._markAsDirty();
  8393. return;
  8394. }
  8395. if (this._isTextHighlightOn) {
  8396. this._cursorOffset = this._textWrapper.length - this._endHighlightIndex;
  8397. this._isTextHighlightOn = false;
  8398. }
  8399. //ctr + ->
  8400. if (evt && (evt.ctrlKey || evt.metaKey)) {
  8401. this._cursorOffset = 0;
  8402. evt.preventDefault();
  8403. }
  8404. this._blinkIsEven = false;
  8405. this._isTextHighlightOn = false;
  8406. this._cursorIndex = -1;
  8407. this._markAsDirty();
  8408. return;
  8409. case 222: // Dead
  8410. if (evt) {
  8411. evt.preventDefault();
  8412. }
  8413. this._cursorIndex = -1;
  8414. this.deadKey = true;
  8415. break;
  8416. }
  8417. // Printable characters
  8418. if (key &&
  8419. ((keyCode === -1) || // Direct access
  8420. (keyCode === 32) || // Space
  8421. (keyCode > 47 && keyCode < 64) || // Numbers
  8422. (keyCode > 64 && keyCode < 91) || // Letters
  8423. (keyCode > 159 && keyCode < 193) || // Special characters
  8424. (keyCode > 218 && keyCode < 223) || // Special characters
  8425. (keyCode > 95 && keyCode < 112))) { // Numpad
  8426. this._currentKey = key;
  8427. this.onBeforeKeyAddObservable.notifyObservers(this);
  8428. key = this._currentKey;
  8429. if (this._addKey) {
  8430. if (this._isTextHighlightOn) {
  8431. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex, key);
  8432. this._textHasChanged();
  8433. this._cursorOffset = this._textWrapper.length - (this._startHighlightIndex + 1);
  8434. this._isTextHighlightOn = false;
  8435. this._blinkIsEven = false;
  8436. this._markAsDirty();
  8437. }
  8438. else if (this._cursorOffset === 0) {
  8439. this.text += key;
  8440. }
  8441. else {
  8442. var insertPosition = this._textWrapper.length - this._cursorOffset;
  8443. this._textWrapper.removePart(insertPosition, insertPosition, key);
  8444. this._textHasChanged();
  8445. }
  8446. }
  8447. }
  8448. };
  8449. /** @hidden */
  8450. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  8451. //update the cursor
  8452. this._blinkIsEven = false;
  8453. if (this._cursorIndex === -1) {
  8454. this._cursorIndex = offset;
  8455. }
  8456. else {
  8457. if (this._cursorIndex < this._cursorOffset) {
  8458. this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8459. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8460. }
  8461. else if (this._cursorIndex > this._cursorOffset) {
  8462. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8463. this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8464. }
  8465. else {
  8466. this._isTextHighlightOn = false;
  8467. this._markAsDirty();
  8468. return;
  8469. }
  8470. }
  8471. this._isTextHighlightOn = true;
  8472. this._markAsDirty();
  8473. };
  8474. /** @hidden */
  8475. InputText.prototype._processDblClick = function (evt) {
  8476. //pre-find the start and end index of the word under cursor, speeds up the rendering
  8477. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8478. this._endHighlightIndex = this._startHighlightIndex;
  8479. var moveLeft, moveRight;
  8480. do {
  8481. moveRight = this._endHighlightIndex < this._textWrapper.length && this._textWrapper.isWord(this._endHighlightIndex) ? ++this._endHighlightIndex : 0;
  8482. moveLeft = this._startHighlightIndex > 0 && this._textWrapper.isWord(this._startHighlightIndex - 1) ? --this._startHighlightIndex : 0;
  8483. } while (moveLeft || moveRight);
  8484. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8485. this.onTextHighlightObservable.notifyObservers(this);
  8486. this._isTextHighlightOn = true;
  8487. this._clickedCoordinate = null;
  8488. this._blinkIsEven = true;
  8489. this._cursorIndex = -1;
  8490. this._markAsDirty();
  8491. };
  8492. /** @hidden */
  8493. InputText.prototype._selectAllText = function () {
  8494. this._blinkIsEven = true;
  8495. this._isTextHighlightOn = true;
  8496. this._startHighlightIndex = 0;
  8497. this._endHighlightIndex = this._textWrapper.length;
  8498. this._cursorOffset = this._textWrapper.length;
  8499. this._cursorIndex = -1;
  8500. this._markAsDirty();
  8501. };
  8502. /**
  8503. * Handles the keyboard event
  8504. * @param evt Defines the KeyboardEvent
  8505. */
  8506. InputText.prototype.processKeyboard = function (evt) {
  8507. // process pressed key
  8508. this.processKey(evt.keyCode, evt.key, evt);
  8509. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  8510. };
  8511. /** @hidden */
  8512. InputText.prototype._onCopyText = function (ev) {
  8513. this._isTextHighlightOn = false;
  8514. //when write permission to clipbaord data is denied
  8515. try {
  8516. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  8517. }
  8518. catch (_a) { } //pass
  8519. this._host.clipboardData = this._highlightedText;
  8520. };
  8521. /** @hidden */
  8522. InputText.prototype._onCutText = function (ev) {
  8523. if (!this._highlightedText) {
  8524. return;
  8525. }
  8526. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
  8527. this._textHasChanged();
  8528. this._isTextHighlightOn = false;
  8529. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8530. //when write permission to clipbaord data is denied
  8531. try {
  8532. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  8533. }
  8534. catch (_a) { } //pass
  8535. this._host.clipboardData = this._highlightedText;
  8536. this._highlightedText = "";
  8537. };
  8538. /** @hidden */
  8539. InputText.prototype._onPasteText = function (ev) {
  8540. var data = "";
  8541. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  8542. data = ev.clipboardData.getData("text/plain");
  8543. }
  8544. else {
  8545. //get the cached data; returns blank string by default
  8546. data = this._host.clipboardData;
  8547. }
  8548. var insertPosition = this._textWrapper.length - this._cursorOffset;
  8549. this._textWrapper.removePart(insertPosition, insertPosition, data);
  8550. this._textHasChanged();
  8551. };
  8552. InputText.prototype._draw = function (context, invalidatedRectangle) {
  8553. var _this = this;
  8554. context.save();
  8555. this._applyStates(context);
  8556. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8557. context.shadowColor = this.shadowColor;
  8558. context.shadowBlur = this.shadowBlur;
  8559. context.shadowOffsetX = this.shadowOffsetX;
  8560. context.shadowOffsetY = this.shadowOffsetY;
  8561. }
  8562. // Background
  8563. if (this._isFocused) {
  8564. if (this._focusedBackground) {
  8565. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  8566. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8567. }
  8568. }
  8569. else if (this._background) {
  8570. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8571. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8572. }
  8573. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8574. context.shadowBlur = 0;
  8575. context.shadowOffsetX = 0;
  8576. context.shadowOffsetY = 0;
  8577. }
  8578. if (!this._fontOffset) {
  8579. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  8580. }
  8581. // Text
  8582. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  8583. if (this.color) {
  8584. context.fillStyle = this.color;
  8585. }
  8586. var text = this._beforeRenderText(this._textWrapper);
  8587. if (!this._isFocused && !this._textWrapper.text && this._placeholderText) {
  8588. text = new _textWrapper__WEBPACK_IMPORTED_MODULE_4__["TextWrapper"]();
  8589. text.text = this._placeholderText;
  8590. if (this._placeholderColor) {
  8591. context.fillStyle = this._placeholderColor;
  8592. }
  8593. }
  8594. this._textWidth = context.measureText(text.text).width;
  8595. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  8596. if (this._autoStretchWidth) {
  8597. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  8598. }
  8599. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  8600. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  8601. context.save();
  8602. context.beginPath();
  8603. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  8604. context.clip();
  8605. if (this._isFocused && this._textWidth > availableWidth) {
  8606. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  8607. if (!this._scrollLeft) {
  8608. this._scrollLeft = textLeft;
  8609. }
  8610. }
  8611. else {
  8612. this._scrollLeft = clipTextLeft;
  8613. }
  8614. context.fillText(text.text, this._scrollLeft, this._currentMeasure.top + rootY);
  8615. // Cursor
  8616. if (this._isFocused) {
  8617. // Need to move cursor
  8618. if (this._clickedCoordinate) {
  8619. var rightPosition = this._scrollLeft + this._textWidth;
  8620. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  8621. var currentSize = 0;
  8622. this._cursorOffset = 0;
  8623. var previousDist = 0;
  8624. do {
  8625. if (this._cursorOffset) {
  8626. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  8627. }
  8628. this._cursorOffset++;
  8629. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  8630. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  8631. // Find closest move
  8632. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  8633. this._cursorOffset--;
  8634. }
  8635. this._blinkIsEven = false;
  8636. this._clickedCoordinate = null;
  8637. }
  8638. // Render cursor
  8639. if (!this._blinkIsEven) {
  8640. var cursorOffsetText = text.substr(text.length - this._cursorOffset);
  8641. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  8642. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  8643. if (cursorLeft < clipTextLeft) {
  8644. this._scrollLeft += (clipTextLeft - cursorLeft);
  8645. cursorLeft = clipTextLeft;
  8646. this._markAsDirty();
  8647. }
  8648. else if (cursorLeft > clipTextLeft + availableWidth) {
  8649. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  8650. cursorLeft = clipTextLeft + availableWidth;
  8651. this._markAsDirty();
  8652. }
  8653. if (!this._isTextHighlightOn) {
  8654. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  8655. }
  8656. }
  8657. clearTimeout(this._blinkTimeout);
  8658. this._blinkTimeout = setTimeout(function () {
  8659. _this._blinkIsEven = !_this._blinkIsEven;
  8660. _this._markAsDirty();
  8661. }, 500);
  8662. //show the highlighted text
  8663. if (this._isTextHighlightOn) {
  8664. clearTimeout(this._blinkTimeout);
  8665. var highlightCursorOffsetWidth = context.measureText(text.substring(this._startHighlightIndex)).width;
  8666. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  8667. this._highlightedText = text.substring(this._startHighlightIndex, this._endHighlightIndex);
  8668. var width = context.measureText(text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  8669. if (highlightCursorLeft < clipTextLeft) {
  8670. width = width - (clipTextLeft - highlightCursorLeft);
  8671. if (!width) {
  8672. // when using left arrow on text.length > availableWidth;
  8673. // assigns the width of the first letter after clipTextLeft
  8674. width = context.measureText(text.charAt(text.length - this._cursorOffset)).width;
  8675. }
  8676. highlightCursorLeft = clipTextLeft;
  8677. }
  8678. //for transparancy
  8679. context.globalAlpha = this._highligherOpacity;
  8680. context.fillStyle = this._textHighlightColor;
  8681. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  8682. context.globalAlpha = 1.0;
  8683. }
  8684. }
  8685. context.restore();
  8686. // Border
  8687. if (this._thickness) {
  8688. if (this._isFocused) {
  8689. if (this.focusedColor) {
  8690. context.strokeStyle = this.focusedColor;
  8691. }
  8692. }
  8693. else {
  8694. if (this.color) {
  8695. context.strokeStyle = this.color;
  8696. }
  8697. }
  8698. context.lineWidth = this._thickness;
  8699. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8700. }
  8701. context.restore();
  8702. };
  8703. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  8704. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  8705. return false;
  8706. }
  8707. this._clickedCoordinate = coordinates.x;
  8708. this._isTextHighlightOn = false;
  8709. this._highlightedText = "";
  8710. this._cursorIndex = -1;
  8711. this._isPointerDown = true;
  8712. this._host._capturingControl[pointerId] = this;
  8713. if (this._host.focusedControl === this) {
  8714. // Move cursor
  8715. clearTimeout(this._blinkTimeout);
  8716. this._markAsDirty();
  8717. return true;
  8718. }
  8719. if (!this._isEnabled) {
  8720. return false;
  8721. }
  8722. this._host.focusedControl = this;
  8723. return true;
  8724. };
  8725. InputText.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  8726. if (this._host.focusedControl === this && this._isPointerDown) {
  8727. this._clickedCoordinate = coordinates.x;
  8728. this._markAsDirty();
  8729. this._updateValueFromCursorIndex(this._cursorOffset);
  8730. }
  8731. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
  8732. };
  8733. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  8734. this._isPointerDown = false;
  8735. delete this._host._capturingControl[pointerId];
  8736. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  8737. };
  8738. InputText.prototype._beforeRenderText = function (textWrapper) {
  8739. return textWrapper;
  8740. };
  8741. InputText.prototype.dispose = function () {
  8742. _super.prototype.dispose.call(this);
  8743. this.onBlurObservable.clear();
  8744. this.onFocusObservable.clear();
  8745. this.onTextChangedObservable.clear();
  8746. this.onTextCopyObservable.clear();
  8747. this.onTextCutObservable.clear();
  8748. this.onTextPasteObservable.clear();
  8749. this.onTextHighlightObservable.clear();
  8750. this.onKeyboardEventProcessedObservable.clear();
  8751. };
  8752. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8753. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8754. ], InputText.prototype, "promptMessage", void 0);
  8755. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8756. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8757. ], InputText.prototype, "disableMobilePrompt", void 0);
  8758. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8759. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8760. ], InputText.prototype, "maxWidth", null);
  8761. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8762. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8763. ], InputText.prototype, "highligherOpacity", null);
  8764. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8765. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8766. ], InputText.prototype, "onFocusSelectAll", null);
  8767. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8768. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8769. ], InputText.prototype, "textHighlightColor", null);
  8770. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8771. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8772. ], InputText.prototype, "margin", null);
  8773. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8774. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8775. ], InputText.prototype, "autoStretchWidth", null);
  8776. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8777. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8778. ], InputText.prototype, "thickness", null);
  8779. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8780. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8781. ], InputText.prototype, "focusedBackground", null);
  8782. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8783. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8784. ], InputText.prototype, "focusedColor", null);
  8785. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8786. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8787. ], InputText.prototype, "background", null);
  8788. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8789. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8790. ], InputText.prototype, "placeholderColor", null);
  8791. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8792. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8793. ], InputText.prototype, "placeholderText", null);
  8794. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8795. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8796. ], InputText.prototype, "deadKey", null);
  8797. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8798. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8799. ], InputText.prototype, "text", null);
  8800. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8801. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8802. ], InputText.prototype, "width", null);
  8803. return InputText;
  8804. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8805. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  8806. /***/ }),
  8807. /***/ "./2D/controls/line.ts":
  8808. /*!*****************************!*\
  8809. !*** ./2D/controls/line.ts ***!
  8810. \*****************************/
  8811. /*! exports provided: Line */
  8812. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8813. "use strict";
  8814. __webpack_require__.r(__webpack_exports__);
  8815. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  8816. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8817. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  8818. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  8819. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8820. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  8821. /** Class used to render 2D lines */
  8822. var Line = /** @class */ (function (_super) {
  8823. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8824. /**
  8825. * Creates a new Line
  8826. * @param name defines the control name
  8827. */
  8828. function Line(name) {
  8829. var _this = _super.call(this, name) || this;
  8830. _this.name = name;
  8831. _this._lineWidth = 1;
  8832. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8833. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8834. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8835. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8836. _this._dash = new Array();
  8837. _this._automaticSize = true;
  8838. _this.isHitTestVisible = false;
  8839. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8840. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8841. return _this;
  8842. }
  8843. Object.defineProperty(Line.prototype, "dash", {
  8844. /** Gets or sets the dash pattern */
  8845. get: function () {
  8846. return this._dash;
  8847. },
  8848. set: function (value) {
  8849. if (this._dash === value) {
  8850. return;
  8851. }
  8852. this._dash = value;
  8853. this._markAsDirty();
  8854. },
  8855. enumerable: false,
  8856. configurable: true
  8857. });
  8858. Object.defineProperty(Line.prototype, "connectedControl", {
  8859. /** Gets or sets the control connected with the line end */
  8860. get: function () {
  8861. return this._connectedControl;
  8862. },
  8863. set: function (value) {
  8864. var _this = this;
  8865. if (this._connectedControl === value) {
  8866. return;
  8867. }
  8868. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8869. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8870. this._connectedControlDirtyObserver = null;
  8871. }
  8872. if (value) {
  8873. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8874. }
  8875. this._connectedControl = value;
  8876. this._markAsDirty();
  8877. },
  8878. enumerable: false,
  8879. configurable: true
  8880. });
  8881. Object.defineProperty(Line.prototype, "x1", {
  8882. /** Gets or sets start coordinates on X axis */
  8883. get: function () {
  8884. return this._x1.toString(this._host);
  8885. },
  8886. set: function (value) {
  8887. if (this._x1.toString(this._host) === value) {
  8888. return;
  8889. }
  8890. if (this._x1.fromString(value)) {
  8891. this._markAsDirty();
  8892. }
  8893. },
  8894. enumerable: false,
  8895. configurable: true
  8896. });
  8897. Object.defineProperty(Line.prototype, "y1", {
  8898. /** Gets or sets start coordinates on Y axis */
  8899. get: function () {
  8900. return this._y1.toString(this._host);
  8901. },
  8902. set: function (value) {
  8903. if (this._y1.toString(this._host) === value) {
  8904. return;
  8905. }
  8906. if (this._y1.fromString(value)) {
  8907. this._markAsDirty();
  8908. }
  8909. },
  8910. enumerable: false,
  8911. configurable: true
  8912. });
  8913. Object.defineProperty(Line.prototype, "x2", {
  8914. /** Gets or sets end coordinates on X axis */
  8915. get: function () {
  8916. return this._x2.toString(this._host);
  8917. },
  8918. set: function (value) {
  8919. if (this._x2.toString(this._host) === value) {
  8920. return;
  8921. }
  8922. if (this._x2.fromString(value)) {
  8923. this._markAsDirty();
  8924. }
  8925. },
  8926. enumerable: false,
  8927. configurable: true
  8928. });
  8929. Object.defineProperty(Line.prototype, "y2", {
  8930. /** Gets or sets end coordinates on Y axis */
  8931. get: function () {
  8932. return this._y2.toString(this._host);
  8933. },
  8934. set: function (value) {
  8935. if (this._y2.toString(this._host) === value) {
  8936. return;
  8937. }
  8938. if (this._y2.fromString(value)) {
  8939. this._markAsDirty();
  8940. }
  8941. },
  8942. enumerable: false,
  8943. configurable: true
  8944. });
  8945. Object.defineProperty(Line.prototype, "lineWidth", {
  8946. /** Gets or sets line width */
  8947. get: function () {
  8948. return this._lineWidth;
  8949. },
  8950. set: function (value) {
  8951. if (this._lineWidth === value) {
  8952. return;
  8953. }
  8954. this._lineWidth = value;
  8955. this._markAsDirty();
  8956. },
  8957. enumerable: false,
  8958. configurable: true
  8959. });
  8960. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8961. /** Gets or sets horizontal alignment */
  8962. set: function (value) {
  8963. return;
  8964. },
  8965. enumerable: false,
  8966. configurable: true
  8967. });
  8968. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8969. /** Gets or sets vertical alignment */
  8970. set: function (value) {
  8971. return;
  8972. },
  8973. enumerable: false,
  8974. configurable: true
  8975. });
  8976. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8977. get: function () {
  8978. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8979. },
  8980. enumerable: false,
  8981. configurable: true
  8982. });
  8983. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8984. get: function () {
  8985. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8986. },
  8987. enumerable: false,
  8988. configurable: true
  8989. });
  8990. Line.prototype._getTypeName = function () {
  8991. return "Line";
  8992. };
  8993. Line.prototype._draw = function (context) {
  8994. context.save();
  8995. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8996. context.shadowColor = this.shadowColor;
  8997. context.shadowBlur = this.shadowBlur;
  8998. context.shadowOffsetX = this.shadowOffsetX;
  8999. context.shadowOffsetY = this.shadowOffsetY;
  9000. }
  9001. this._applyStates(context);
  9002. context.strokeStyle = this.color;
  9003. context.lineWidth = this._lineWidth;
  9004. context.setLineDash(this._dash);
  9005. context.beginPath();
  9006. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  9007. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  9008. context.stroke();
  9009. context.restore();
  9010. };
  9011. Line.prototype._measure = function () {
  9012. // Width / Height
  9013. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  9014. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  9015. };
  9016. Line.prototype._computeAlignment = function (parentMeasure, context) {
  9017. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  9018. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  9019. };
  9020. /**
  9021. * Move one end of the line given 3D cartesian coordinates.
  9022. * @param position Targeted world position
  9023. * @param scene Scene
  9024. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  9025. */
  9026. Line.prototype.moveToVector3 = function (position, scene, end) {
  9027. if (end === void 0) { end = false; }
  9028. if (!this._host || this.parent !== this._host._rootContainer) {
  9029. 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");
  9030. return;
  9031. }
  9032. var globalViewport = this._host._getGlobalViewport(scene);
  9033. 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);
  9034. this._moveToProjectedPosition(projectedPosition, end);
  9035. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  9036. this.notRenderable = true;
  9037. return;
  9038. }
  9039. this.notRenderable = false;
  9040. };
  9041. /**
  9042. * Move one end of the line to a position in screen absolute space.
  9043. * @param projectedPosition Position in screen absolute space (X, Y)
  9044. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  9045. */
  9046. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  9047. if (end === void 0) { end = false; }
  9048. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  9049. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  9050. if (end) {
  9051. this.x2 = x;
  9052. this.y2 = y;
  9053. this._x2.ignoreAdaptiveScaling = true;
  9054. this._y2.ignoreAdaptiveScaling = true;
  9055. }
  9056. else {
  9057. this.x1 = x;
  9058. this.y1 = y;
  9059. this._x1.ignoreAdaptiveScaling = true;
  9060. this._y1.ignoreAdaptiveScaling = true;
  9061. }
  9062. };
  9063. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9064. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9065. ], Line.prototype, "dash", null);
  9066. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9067. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9068. ], Line.prototype, "x1", null);
  9069. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9070. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9071. ], Line.prototype, "y1", null);
  9072. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9073. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9074. ], Line.prototype, "x2", null);
  9075. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9076. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9077. ], Line.prototype, "y2", null);
  9078. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9079. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9080. ], Line.prototype, "lineWidth", null);
  9081. return Line;
  9082. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9083. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  9084. /***/ }),
  9085. /***/ "./2D/controls/multiLine.ts":
  9086. /*!**********************************!*\
  9087. !*** ./2D/controls/multiLine.ts ***!
  9088. \**********************************/
  9089. /*! exports provided: MultiLine */
  9090. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9091. "use strict";
  9092. __webpack_require__.r(__webpack_exports__);
  9093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  9094. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9095. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/perfCounter");
  9096. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  9097. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9098. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  9099. /**
  9100. * Class used to create multi line control
  9101. */
  9102. var MultiLine = /** @class */ (function (_super) {
  9103. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  9104. /**
  9105. * Creates a new MultiLine
  9106. * @param name defines the control name
  9107. */
  9108. function MultiLine(name) {
  9109. var _this = _super.call(this, name) || this;
  9110. _this.name = name;
  9111. _this._lineWidth = 1;
  9112. /** Function called when a point is updated */
  9113. _this.onPointUpdate = function () {
  9114. _this._markAsDirty();
  9115. };
  9116. _this._automaticSize = true;
  9117. _this.isHitTestVisible = false;
  9118. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9119. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  9120. _this._dash = [];
  9121. _this._points = [];
  9122. return _this;
  9123. }
  9124. Object.defineProperty(MultiLine.prototype, "dash", {
  9125. /** Gets or sets dash pattern */
  9126. get: function () {
  9127. return this._dash;
  9128. },
  9129. set: function (value) {
  9130. if (this._dash === value) {
  9131. return;
  9132. }
  9133. this._dash = value;
  9134. this._markAsDirty();
  9135. },
  9136. enumerable: false,
  9137. configurable: true
  9138. });
  9139. /**
  9140. * Gets point stored at specified index
  9141. * @param index defines the index to look for
  9142. * @returns the requested point if found
  9143. */
  9144. MultiLine.prototype.getAt = function (index) {
  9145. if (!this._points[index]) {
  9146. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  9147. }
  9148. return this._points[index];
  9149. };
  9150. /**
  9151. * Adds new points to the point collection
  9152. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  9153. * @returns the list of created MultiLinePoint
  9154. */
  9155. MultiLine.prototype.add = function () {
  9156. var _this = this;
  9157. var items = [];
  9158. for (var _i = 0; _i < arguments.length; _i++) {
  9159. items[_i] = arguments[_i];
  9160. }
  9161. return items.map(function (item) { return _this.push(item); });
  9162. };
  9163. /**
  9164. * Adds a new point to the point collection
  9165. * @param item defines the item (mesh, control or 2d coordiantes) to add
  9166. * @returns the created MultiLinePoint
  9167. */
  9168. MultiLine.prototype.push = function (item) {
  9169. var point = this.getAt(this._points.length);
  9170. if (item == null) {
  9171. return point;
  9172. }
  9173. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  9174. point.mesh = item;
  9175. }
  9176. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  9177. point.control = item;
  9178. }
  9179. else if (item.x != null && item.y != null) {
  9180. point.x = item.x;
  9181. point.y = item.y;
  9182. }
  9183. return point;
  9184. };
  9185. /**
  9186. * Remove a specific value or point from the active point collection
  9187. * @param value defines the value or point to remove
  9188. */
  9189. MultiLine.prototype.remove = function (value) {
  9190. var index;
  9191. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  9192. index = this._points.indexOf(value);
  9193. if (index === -1) {
  9194. return;
  9195. }
  9196. }
  9197. else {
  9198. index = value;
  9199. }
  9200. var point = this._points[index];
  9201. if (!point) {
  9202. return;
  9203. }
  9204. point.dispose();
  9205. this._points.splice(index, 1);
  9206. };
  9207. /**
  9208. * Resets this object to initial state (no point)
  9209. */
  9210. MultiLine.prototype.reset = function () {
  9211. while (this._points.length > 0) {
  9212. this.remove(this._points.length - 1);
  9213. }
  9214. };
  9215. /**
  9216. * Resets all links
  9217. */
  9218. MultiLine.prototype.resetLinks = function () {
  9219. this._points.forEach(function (point) {
  9220. if (point != null) {
  9221. point.resetLinks();
  9222. }
  9223. });
  9224. };
  9225. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  9226. /** Gets or sets line width */
  9227. get: function () {
  9228. return this._lineWidth;
  9229. },
  9230. set: function (value) {
  9231. if (this._lineWidth === value) {
  9232. return;
  9233. }
  9234. this._lineWidth = value;
  9235. this._markAsDirty();
  9236. },
  9237. enumerable: false,
  9238. configurable: true
  9239. });
  9240. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  9241. set: function (value) {
  9242. return;
  9243. },
  9244. enumerable: false,
  9245. configurable: true
  9246. });
  9247. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  9248. set: function (value) {
  9249. return;
  9250. },
  9251. enumerable: false,
  9252. configurable: true
  9253. });
  9254. MultiLine.prototype._getTypeName = function () {
  9255. return "MultiLine";
  9256. };
  9257. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  9258. context.save();
  9259. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9260. context.shadowColor = this.shadowColor;
  9261. context.shadowBlur = this.shadowBlur;
  9262. context.shadowOffsetX = this.shadowOffsetX;
  9263. context.shadowOffsetY = this.shadowOffsetY;
  9264. }
  9265. this._applyStates(context);
  9266. context.strokeStyle = this.color;
  9267. context.lineWidth = this._lineWidth;
  9268. context.setLineDash(this._dash);
  9269. context.beginPath();
  9270. var first = true; //first index is not necessarily 0
  9271. var previousPoint;
  9272. this._points.forEach(function (point) {
  9273. if (!point) {
  9274. return;
  9275. }
  9276. if (first) {
  9277. context.moveTo(point._point.x, point._point.y);
  9278. first = false;
  9279. }
  9280. else {
  9281. if (point._point.z < 1 && previousPoint.z < 1) {
  9282. context.lineTo(point._point.x, point._point.y);
  9283. }
  9284. else {
  9285. context.moveTo(point._point.x, point._point.y);
  9286. }
  9287. }
  9288. previousPoint = point._point;
  9289. });
  9290. context.stroke();
  9291. context.restore();
  9292. };
  9293. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  9294. var _this = this;
  9295. this._minX = null;
  9296. this._minY = null;
  9297. this._maxX = null;
  9298. this._maxY = null;
  9299. this._points.forEach(function (point, index) {
  9300. if (!point) {
  9301. return;
  9302. }
  9303. point.translate();
  9304. if (_this._minX == null || point._point.x < _this._minX) {
  9305. _this._minX = point._point.x;
  9306. }
  9307. if (_this._minY == null || point._point.y < _this._minY) {
  9308. _this._minY = point._point.y;
  9309. }
  9310. if (_this._maxX == null || point._point.x > _this._maxX) {
  9311. _this._maxX = point._point.x;
  9312. }
  9313. if (_this._maxY == null || point._point.y > _this._maxY) {
  9314. _this._maxY = point._point.y;
  9315. }
  9316. });
  9317. if (this._minX == null) {
  9318. this._minX = 0;
  9319. }
  9320. if (this._minY == null) {
  9321. this._minY = 0;
  9322. }
  9323. if (this._maxX == null) {
  9324. this._maxX = 0;
  9325. }
  9326. if (this._maxY == null) {
  9327. this._maxY = 0;
  9328. }
  9329. };
  9330. MultiLine.prototype._measure = function () {
  9331. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  9332. return;
  9333. }
  9334. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  9335. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  9336. };
  9337. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  9338. if (this._minX == null || this._minY == null) {
  9339. return;
  9340. }
  9341. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  9342. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  9343. };
  9344. MultiLine.prototype.dispose = function () {
  9345. this.reset();
  9346. _super.prototype.dispose.call(this);
  9347. };
  9348. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9349. Object(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9350. ], MultiLine.prototype, "dash", null);
  9351. return MultiLine;
  9352. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9353. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  9354. /***/ }),
  9355. /***/ "./2D/controls/radioButton.ts":
  9356. /*!************************************!*\
  9357. !*** ./2D/controls/radioButton.ts ***!
  9358. \************************************/
  9359. /*! exports provided: RadioButton */
  9360. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9361. "use strict";
  9362. __webpack_require__.r(__webpack_exports__);
  9363. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  9364. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9365. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  9366. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9367. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9368. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9369. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9370. /**
  9371. * Class used to create radio button controls
  9372. */
  9373. var RadioButton = /** @class */ (function (_super) {
  9374. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  9375. /**
  9376. * Creates a new RadioButton
  9377. * @param name defines the control name
  9378. */
  9379. function RadioButton(name) {
  9380. var _this = _super.call(this, name) || this;
  9381. _this.name = name;
  9382. _this._isChecked = false;
  9383. _this._background = "black";
  9384. _this._checkSizeRatio = 0.8;
  9385. _this._thickness = 1;
  9386. /** Gets or sets group name */
  9387. _this.group = "";
  9388. /** Observable raised when isChecked is changed */
  9389. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9390. _this.isPointerBlocker = true;
  9391. return _this;
  9392. }
  9393. Object.defineProperty(RadioButton.prototype, "thickness", {
  9394. /** Gets or sets border thickness */
  9395. get: function () {
  9396. return this._thickness;
  9397. },
  9398. set: function (value) {
  9399. if (this._thickness === value) {
  9400. return;
  9401. }
  9402. this._thickness = value;
  9403. this._markAsDirty();
  9404. },
  9405. enumerable: false,
  9406. configurable: true
  9407. });
  9408. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  9409. /** Gets or sets a value indicating the ratio between overall size and check size */
  9410. get: function () {
  9411. return this._checkSizeRatio;
  9412. },
  9413. set: function (value) {
  9414. value = Math.max(Math.min(1, value), 0);
  9415. if (this._checkSizeRatio === value) {
  9416. return;
  9417. }
  9418. this._checkSizeRatio = value;
  9419. this._markAsDirty();
  9420. },
  9421. enumerable: false,
  9422. configurable: true
  9423. });
  9424. Object.defineProperty(RadioButton.prototype, "background", {
  9425. /** Gets or sets background color */
  9426. get: function () {
  9427. return this._background;
  9428. },
  9429. set: function (value) {
  9430. if (this._background === value) {
  9431. return;
  9432. }
  9433. this._background = value;
  9434. this._markAsDirty();
  9435. },
  9436. enumerable: false,
  9437. configurable: true
  9438. });
  9439. Object.defineProperty(RadioButton.prototype, "isChecked", {
  9440. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  9441. get: function () {
  9442. return this._isChecked;
  9443. },
  9444. set: function (value) {
  9445. var _this = this;
  9446. if (this._isChecked === value) {
  9447. return;
  9448. }
  9449. this._isChecked = value;
  9450. this._markAsDirty();
  9451. this.onIsCheckedChangedObservable.notifyObservers(value);
  9452. if (this._isChecked && this._host) {
  9453. // Update all controls from same group
  9454. this._host.executeOnAllControls(function (control) {
  9455. if (control === _this) {
  9456. return;
  9457. }
  9458. if (control.group === undefined) {
  9459. return;
  9460. }
  9461. var childRadio = control;
  9462. if (childRadio.group === _this.group) {
  9463. childRadio.isChecked = false;
  9464. }
  9465. });
  9466. }
  9467. },
  9468. enumerable: false,
  9469. configurable: true
  9470. });
  9471. RadioButton.prototype._getTypeName = function () {
  9472. return "RadioButton";
  9473. };
  9474. RadioButton.prototype._draw = function (context) {
  9475. context.save();
  9476. this._applyStates(context);
  9477. var actualWidth = this._currentMeasure.width - this._thickness;
  9478. var actualHeight = this._currentMeasure.height - this._thickness;
  9479. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9480. context.shadowColor = this.shadowColor;
  9481. context.shadowBlur = this.shadowBlur;
  9482. context.shadowOffsetX = this.shadowOffsetX;
  9483. context.shadowOffsetY = this.shadowOffsetY;
  9484. }
  9485. // Outer
  9486. _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);
  9487. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  9488. context.fill();
  9489. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9490. context.shadowBlur = 0;
  9491. context.shadowOffsetX = 0;
  9492. context.shadowOffsetY = 0;
  9493. }
  9494. context.strokeStyle = this.color;
  9495. context.lineWidth = this._thickness;
  9496. context.stroke();
  9497. // Inner
  9498. if (this._isChecked) {
  9499. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  9500. var offsetWidth = actualWidth * this._checkSizeRatio;
  9501. var offseHeight = actualHeight * this._checkSizeRatio;
  9502. _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);
  9503. context.fill();
  9504. }
  9505. context.restore();
  9506. };
  9507. // Events
  9508. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  9509. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  9510. return false;
  9511. }
  9512. if (!this.isChecked) {
  9513. this.isChecked = true;
  9514. }
  9515. return true;
  9516. };
  9517. /**
  9518. * Utility function to easily create a radio button with a header
  9519. * @param title defines the label to use for the header
  9520. * @param group defines the group to use for the radio button
  9521. * @param isChecked defines the initial state of the radio button
  9522. * @param onValueChanged defines the callback to call when value changes
  9523. * @returns a StackPanel containing the radio button and a textBlock
  9524. */
  9525. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  9526. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  9527. panel.isVertical = false;
  9528. panel.height = "30px";
  9529. var radio = new RadioButton();
  9530. radio.width = "20px";
  9531. radio.height = "20px";
  9532. radio.isChecked = isChecked;
  9533. radio.color = "green";
  9534. radio.group = group;
  9535. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  9536. panel.addControl(radio);
  9537. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  9538. header.text = title;
  9539. header.width = "180px";
  9540. header.paddingLeft = "5px";
  9541. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9542. header.color = "white";
  9543. panel.addControl(header);
  9544. return panel;
  9545. };
  9546. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9547. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9548. ], RadioButton.prototype, "thickness", null);
  9549. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9550. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9551. ], RadioButton.prototype, "group", void 0);
  9552. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9553. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9554. ], RadioButton.prototype, "checkSizeRatio", null);
  9555. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9556. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9557. ], RadioButton.prototype, "background", null);
  9558. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9559. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9560. ], RadioButton.prototype, "isChecked", null);
  9561. return RadioButton;
  9562. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9563. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  9564. /***/ }),
  9565. /***/ "./2D/controls/rectangle.ts":
  9566. /*!**********************************!*\
  9567. !*** ./2D/controls/rectangle.ts ***!
  9568. \**********************************/
  9569. /*! exports provided: Rectangle */
  9570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9571. "use strict";
  9572. __webpack_require__.r(__webpack_exports__);
  9573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  9574. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9575. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9576. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  9577. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  9578. /** Class used to create rectangle container */
  9579. var Rectangle = /** @class */ (function (_super) {
  9580. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  9581. /**
  9582. * Creates a new Rectangle
  9583. * @param name defines the control name
  9584. */
  9585. function Rectangle(name) {
  9586. var _this = _super.call(this, name) || this;
  9587. _this.name = name;
  9588. _this._thickness = 1;
  9589. _this._cornerRadius = 0;
  9590. return _this;
  9591. }
  9592. Object.defineProperty(Rectangle.prototype, "thickness", {
  9593. /** Gets or sets border thickness */
  9594. get: function () {
  9595. return this._thickness;
  9596. },
  9597. set: function (value) {
  9598. if (this._thickness === value) {
  9599. return;
  9600. }
  9601. this._thickness = value;
  9602. this._markAsDirty();
  9603. },
  9604. enumerable: false,
  9605. configurable: true
  9606. });
  9607. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  9608. /** Gets or sets the corner radius angle */
  9609. get: function () {
  9610. return this._cornerRadius;
  9611. },
  9612. set: function (value) {
  9613. if (value < 0) {
  9614. value = 0;
  9615. }
  9616. if (this._cornerRadius === value) {
  9617. return;
  9618. }
  9619. this._cornerRadius = value;
  9620. this._markAsDirty();
  9621. },
  9622. enumerable: false,
  9623. configurable: true
  9624. });
  9625. Rectangle.prototype._getTypeName = function () {
  9626. return "Rectangle";
  9627. };
  9628. Rectangle.prototype._localDraw = function (context) {
  9629. context.save();
  9630. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9631. context.shadowColor = this.shadowColor;
  9632. context.shadowBlur = this.shadowBlur;
  9633. context.shadowOffsetX = this.shadowOffsetX;
  9634. context.shadowOffsetY = this.shadowOffsetY;
  9635. }
  9636. if (this._background) {
  9637. context.fillStyle = this._background;
  9638. if (this._cornerRadius) {
  9639. this._drawRoundedRect(context, this._thickness / 2);
  9640. context.fill();
  9641. }
  9642. else {
  9643. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  9644. }
  9645. }
  9646. if (this._thickness) {
  9647. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9648. context.shadowBlur = 0;
  9649. context.shadowOffsetX = 0;
  9650. context.shadowOffsetY = 0;
  9651. }
  9652. if (this.color) {
  9653. context.strokeStyle = this.color;
  9654. }
  9655. context.lineWidth = this._thickness;
  9656. if (this._cornerRadius) {
  9657. this._drawRoundedRect(context, this._thickness / 2);
  9658. context.stroke();
  9659. }
  9660. else {
  9661. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  9662. }
  9663. }
  9664. context.restore();
  9665. };
  9666. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  9667. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9668. this._measureForChildren.width -= 2 * this._thickness;
  9669. this._measureForChildren.height -= 2 * this._thickness;
  9670. this._measureForChildren.left += this._thickness;
  9671. this._measureForChildren.top += this._thickness;
  9672. };
  9673. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  9674. if (offset === void 0) { offset = 0; }
  9675. var x = this._currentMeasure.left + offset;
  9676. var y = this._currentMeasure.top + offset;
  9677. var width = this._currentMeasure.width - offset * 2;
  9678. var height = this._currentMeasure.height - offset * 2;
  9679. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  9680. context.beginPath();
  9681. context.moveTo(x + radius, y);
  9682. context.lineTo(x + width - radius, y);
  9683. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  9684. context.lineTo(x + width, y + height - radius);
  9685. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  9686. context.lineTo(x + radius, y + height);
  9687. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  9688. context.lineTo(x, y + radius);
  9689. context.quadraticCurveTo(x, y, x + radius, y);
  9690. context.closePath();
  9691. };
  9692. Rectangle.prototype._clipForChildren = function (context) {
  9693. if (this._cornerRadius) {
  9694. this._drawRoundedRect(context, this._thickness);
  9695. context.clip();
  9696. }
  9697. };
  9698. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9699. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  9700. ], Rectangle.prototype, "thickness", null);
  9701. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9702. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  9703. ], Rectangle.prototype, "cornerRadius", null);
  9704. return Rectangle;
  9705. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9706. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  9707. /***/ }),
  9708. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  9709. /*!***************************************************!*\
  9710. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  9711. \***************************************************/
  9712. /*! exports provided: ScrollViewer */
  9713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9714. "use strict";
  9715. __webpack_require__.r(__webpack_exports__);
  9716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  9717. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9718. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  9719. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  9720. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9721. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  9722. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  9723. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  9724. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  9725. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__);
  9726. /**
  9727. * Class used to hold a viewer window and sliders in a grid
  9728. */
  9729. var ScrollViewer = /** @class */ (function (_super) {
  9730. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  9731. /**
  9732. * Creates a new ScrollViewer
  9733. * @param name of ScrollViewer
  9734. */
  9735. function ScrollViewer(name, isImageBased) {
  9736. var _this = _super.call(this, name) || this;
  9737. _this._barSize = 20;
  9738. _this._pointerIsOver = false;
  9739. _this._wheelPrecision = 0.05;
  9740. _this._thumbLength = 0.5;
  9741. _this._thumbHeight = 1;
  9742. _this._barImageHeight = 1;
  9743. _this._horizontalBarImageHeight = 1;
  9744. _this._verticalBarImageHeight = 1;
  9745. _this._oldWindowContentsWidth = 0;
  9746. _this._oldWindowContentsHeight = 0;
  9747. _this._forceHorizontalBar = false;
  9748. _this._forceVerticalBar = false;
  9749. _this._useImageBar = isImageBased ? isImageBased : false;
  9750. _this.onDirtyObservable.add(function () {
  9751. _this._horizontalBarSpace.color = _this.color;
  9752. _this._verticalBarSpace.color = _this.color;
  9753. _this._dragSpace.color = _this.color;
  9754. });
  9755. _this.onPointerEnterObservable.add(function () {
  9756. _this._pointerIsOver = true;
  9757. });
  9758. _this.onPointerOutObservable.add(function () {
  9759. _this._pointerIsOver = false;
  9760. });
  9761. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_2__["Grid"]();
  9762. if (_this._useImageBar) {
  9763. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9764. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9765. }
  9766. else {
  9767. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9768. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9769. }
  9770. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__["_ScrollViewerWindow"]("scrollViewer_window");
  9771. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9772. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9773. _this._grid.addColumnDefinition(1);
  9774. _this._grid.addColumnDefinition(0, true);
  9775. _this._grid.addRowDefinition(1);
  9776. _this._grid.addRowDefinition(0, true);
  9777. _super.prototype.addControl.call(_this, _this._grid);
  9778. _this._grid.addControl(_this._window, 0, 0);
  9779. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9780. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9781. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9782. _this._verticalBarSpace.thickness = 1;
  9783. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  9784. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  9785. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9786. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9787. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9788. _this._horizontalBarSpace.thickness = 1;
  9789. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  9790. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  9791. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9792. _this._dragSpace.thickness = 1;
  9793. _this._grid.addControl(_this._dragSpace, 1, 1);
  9794. // Colors
  9795. if (!_this._useImageBar) {
  9796. _this.barColor = "grey";
  9797. _this.barBackground = "transparent";
  9798. }
  9799. return _this;
  9800. }
  9801. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  9802. /**
  9803. * Gets the horizontal scrollbar
  9804. */
  9805. get: function () {
  9806. return this._horizontalBar;
  9807. },
  9808. enumerable: false,
  9809. configurable: true
  9810. });
  9811. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  9812. /**
  9813. * Gets the vertical scrollbar
  9814. */
  9815. get: function () {
  9816. return this._verticalBar;
  9817. },
  9818. enumerable: false,
  9819. configurable: true
  9820. });
  9821. /**
  9822. * Adds a new control to the current container
  9823. * @param control defines the control to add
  9824. * @returns the current container
  9825. */
  9826. ScrollViewer.prototype.addControl = function (control) {
  9827. if (!control) {
  9828. return this;
  9829. }
  9830. this._window.addControl(control);
  9831. return this;
  9832. };
  9833. /**
  9834. * Removes a control from the current container
  9835. * @param control defines the control to remove
  9836. * @returns the current container
  9837. */
  9838. ScrollViewer.prototype.removeControl = function (control) {
  9839. this._window.removeControl(control);
  9840. return this;
  9841. };
  9842. Object.defineProperty(ScrollViewer.prototype, "children", {
  9843. /** Gets the list of children */
  9844. get: function () {
  9845. return this._window.children;
  9846. },
  9847. enumerable: false,
  9848. configurable: true
  9849. });
  9850. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  9851. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9852. var child = _a[_i];
  9853. child._markMatrixAsDirty();
  9854. }
  9855. };
  9856. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  9857. /**
  9858. * Freezes or unfreezes the controls in the window.
  9859. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  9860. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  9861. */
  9862. get: function () {
  9863. return this._window.freezeControls;
  9864. },
  9865. set: function (value) {
  9866. this._window.freezeControls = value;
  9867. },
  9868. enumerable: false,
  9869. configurable: true
  9870. });
  9871. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  9872. /** Gets the bucket width */
  9873. get: function () {
  9874. return this._window.bucketWidth;
  9875. },
  9876. enumerable: false,
  9877. configurable: true
  9878. });
  9879. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9880. /** Gets the bucket height */
  9881. get: function () {
  9882. return this._window.bucketHeight;
  9883. },
  9884. enumerable: false,
  9885. configurable: true
  9886. });
  9887. /**
  9888. * Sets the bucket sizes.
  9889. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9890. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9891. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9892. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9893. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9894. * used), that's why it is not enabled by default.
  9895. * @param width width of the bucket
  9896. * @param height height of the bucket
  9897. */
  9898. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9899. this._window.setBucketSizes(width, height);
  9900. };
  9901. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9902. /**
  9903. * Forces the horizontal scroll bar to be displayed
  9904. */
  9905. get: function () {
  9906. return this._forceHorizontalBar;
  9907. },
  9908. set: function (value) {
  9909. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9910. this._horizontalBar.isVisible = value;
  9911. this._forceHorizontalBar = value;
  9912. },
  9913. enumerable: false,
  9914. configurable: true
  9915. });
  9916. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9917. /**
  9918. * Forces the vertical scroll bar to be displayed
  9919. */
  9920. get: function () {
  9921. return this._forceVerticalBar;
  9922. },
  9923. set: function (value) {
  9924. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9925. this._verticalBar.isVisible = value;
  9926. this._forceVerticalBar = value;
  9927. },
  9928. enumerable: false,
  9929. configurable: true
  9930. });
  9931. /** Reset the scroll viewer window to initial size */
  9932. ScrollViewer.prototype.resetWindow = function () {
  9933. this._window.width = "100%";
  9934. this._window.height = "100%";
  9935. };
  9936. ScrollViewer.prototype._getTypeName = function () {
  9937. return "ScrollViewer";
  9938. };
  9939. ScrollViewer.prototype._buildClientSizes = function () {
  9940. var ratio = this.host.idealRatio;
  9941. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9942. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9943. this._clientWidth = this._window.parentClientWidth;
  9944. this._clientHeight = this._window.parentClientHeight;
  9945. };
  9946. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  9947. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9948. this._buildClientSizes();
  9949. };
  9950. ScrollViewer.prototype._postMeasure = function () {
  9951. _super.prototype._postMeasure.call(this);
  9952. this._updateScroller();
  9953. this._setWindowPosition(false);
  9954. };
  9955. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  9956. /**
  9957. * Gets or sets the mouse wheel precision
  9958. * from 0 to 1 with a default value of 0.05
  9959. * */
  9960. get: function () {
  9961. return this._wheelPrecision;
  9962. },
  9963. set: function (value) {
  9964. if (this._wheelPrecision === value) {
  9965. return;
  9966. }
  9967. if (value < 0) {
  9968. value = 0;
  9969. }
  9970. if (value > 1) {
  9971. value = 1;
  9972. }
  9973. this._wheelPrecision = value;
  9974. },
  9975. enumerable: false,
  9976. configurable: true
  9977. });
  9978. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  9979. /** Gets or sets the scroll bar container background color */
  9980. get: function () {
  9981. return this._horizontalBarSpace.background;
  9982. },
  9983. set: function (color) {
  9984. if (this._horizontalBarSpace.background === color) {
  9985. return;
  9986. }
  9987. this._horizontalBarSpace.background = color;
  9988. this._verticalBarSpace.background = color;
  9989. },
  9990. enumerable: false,
  9991. configurable: true
  9992. });
  9993. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9994. /** Gets or sets the bar color */
  9995. get: function () {
  9996. return this._barColor;
  9997. },
  9998. set: function (color) {
  9999. if (this._barColor === color) {
  10000. return;
  10001. }
  10002. this._barColor = color;
  10003. this._horizontalBar.color = color;
  10004. this._verticalBar.color = color;
  10005. },
  10006. enumerable: false,
  10007. configurable: true
  10008. });
  10009. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  10010. /** Gets or sets the bar image */
  10011. get: function () {
  10012. return this._barImage;
  10013. },
  10014. set: function (value) {
  10015. if (this._barImage === value) {
  10016. return;
  10017. }
  10018. this._barImage = value;
  10019. var hb = this._horizontalBar;
  10020. var vb = this._verticalBar;
  10021. hb.thumbImage = value;
  10022. vb.thumbImage = value;
  10023. },
  10024. enumerable: false,
  10025. configurable: true
  10026. });
  10027. Object.defineProperty(ScrollViewer.prototype, "horizontalThumbImage", {
  10028. /** Gets or sets the horizontal bar image */
  10029. get: function () {
  10030. return this._horizontalBarImage;
  10031. },
  10032. set: function (value) {
  10033. if (this._horizontalBarImage === value) {
  10034. return;
  10035. }
  10036. this._horizontalBarImage = value;
  10037. var hb = this._horizontalBar;
  10038. hb.thumbImage = value;
  10039. },
  10040. enumerable: false,
  10041. configurable: true
  10042. });
  10043. Object.defineProperty(ScrollViewer.prototype, "verticalThumbImage", {
  10044. /** Gets or sets the vertical bar image */
  10045. get: function () {
  10046. return this._verticalBarImage;
  10047. },
  10048. set: function (value) {
  10049. if (this._verticalBarImage === value) {
  10050. return;
  10051. }
  10052. this._verticalBarImage = value;
  10053. var vb = this._verticalBar;
  10054. vb.thumbImage = value;
  10055. },
  10056. enumerable: false,
  10057. configurable: true
  10058. });
  10059. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  10060. /** Gets or sets the size of the bar */
  10061. get: function () {
  10062. return this._barSize;
  10063. },
  10064. set: function (value) {
  10065. if (this._barSize === value) {
  10066. return;
  10067. }
  10068. this._barSize = value;
  10069. this._markAsDirty();
  10070. if (this._horizontalBar.isVisible) {
  10071. this._grid.setRowDefinition(1, this._barSize, true);
  10072. }
  10073. if (this._verticalBar.isVisible) {
  10074. this._grid.setColumnDefinition(1, this._barSize, true);
  10075. }
  10076. },
  10077. enumerable: false,
  10078. configurable: true
  10079. });
  10080. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  10081. /** Gets or sets the length of the thumb */
  10082. get: function () {
  10083. return this._thumbLength;
  10084. },
  10085. set: function (value) {
  10086. if (this._thumbLength === value) {
  10087. return;
  10088. }
  10089. if (value <= 0) {
  10090. value = 0.1;
  10091. }
  10092. if (value > 1) {
  10093. value = 1;
  10094. }
  10095. this._thumbLength = value;
  10096. var hb = this._horizontalBar;
  10097. var vb = this._verticalBar;
  10098. hb.thumbLength = value;
  10099. vb.thumbLength = value;
  10100. this._markAsDirty();
  10101. },
  10102. enumerable: false,
  10103. configurable: true
  10104. });
  10105. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  10106. /** Gets or sets the height of the thumb */
  10107. get: function () {
  10108. return this._thumbHeight;
  10109. },
  10110. set: function (value) {
  10111. if (this._thumbHeight === value) {
  10112. return;
  10113. }
  10114. if (value <= 0) {
  10115. value = 0.1;
  10116. }
  10117. if (value > 1) {
  10118. value = 1;
  10119. }
  10120. this._thumbHeight = value;
  10121. var hb = this._horizontalBar;
  10122. var vb = this._verticalBar;
  10123. hb.thumbHeight = value;
  10124. vb.thumbHeight = value;
  10125. this._markAsDirty();
  10126. },
  10127. enumerable: false,
  10128. configurable: true
  10129. });
  10130. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  10131. /** Gets or sets the height of the bar image */
  10132. get: function () {
  10133. return this._barImageHeight;
  10134. },
  10135. set: function (value) {
  10136. if (this._barImageHeight === value) {
  10137. return;
  10138. }
  10139. if (value <= 0) {
  10140. value = 0.1;
  10141. }
  10142. if (value > 1) {
  10143. value = 1;
  10144. }
  10145. this._barImageHeight = value;
  10146. var hb = this._horizontalBar;
  10147. var vb = this._verticalBar;
  10148. hb.barImageHeight = value;
  10149. vb.barImageHeight = value;
  10150. this._markAsDirty();
  10151. },
  10152. enumerable: false,
  10153. configurable: true
  10154. });
  10155. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImageHeight", {
  10156. /** Gets or sets the height of the horizontal bar image */
  10157. get: function () {
  10158. return this._horizontalBarImageHeight;
  10159. },
  10160. set: function (value) {
  10161. if (this._horizontalBarImageHeight === value) {
  10162. return;
  10163. }
  10164. if (value <= 0) {
  10165. value = 0.1;
  10166. }
  10167. if (value > 1) {
  10168. value = 1;
  10169. }
  10170. this._horizontalBarImageHeight = value;
  10171. var hb = this._horizontalBar;
  10172. hb.barImageHeight = value;
  10173. this._markAsDirty();
  10174. },
  10175. enumerable: false,
  10176. configurable: true
  10177. });
  10178. Object.defineProperty(ScrollViewer.prototype, "verticalBarImageHeight", {
  10179. /** Gets or sets the height of the vertical bar image */
  10180. get: function () {
  10181. return this._verticalBarImageHeight;
  10182. },
  10183. set: function (value) {
  10184. if (this._verticalBarImageHeight === value) {
  10185. return;
  10186. }
  10187. if (value <= 0) {
  10188. value = 0.1;
  10189. }
  10190. if (value > 1) {
  10191. value = 1;
  10192. }
  10193. this._verticalBarImageHeight = value;
  10194. var vb = this._verticalBar;
  10195. vb.barImageHeight = value;
  10196. this._markAsDirty();
  10197. },
  10198. enumerable: false,
  10199. configurable: true
  10200. });
  10201. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  10202. /** Gets or sets the bar background */
  10203. get: function () {
  10204. return this._barBackground;
  10205. },
  10206. set: function (color) {
  10207. if (this._barBackground === color) {
  10208. return;
  10209. }
  10210. this._barBackground = color;
  10211. var hb = this._horizontalBar;
  10212. var vb = this._verticalBar;
  10213. hb.background = color;
  10214. vb.background = color;
  10215. this._dragSpace.background = color;
  10216. },
  10217. enumerable: false,
  10218. configurable: true
  10219. });
  10220. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  10221. /** Gets or sets the bar background image */
  10222. get: function () {
  10223. return this._barBackgroundImage;
  10224. },
  10225. set: function (value) {
  10226. if (this._barBackgroundImage === value) {
  10227. }
  10228. this._barBackgroundImage = value;
  10229. var hb = this._horizontalBar;
  10230. var vb = this._verticalBar;
  10231. hb.backgroundImage = value;
  10232. vb.backgroundImage = value;
  10233. },
  10234. enumerable: false,
  10235. configurable: true
  10236. });
  10237. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImage", {
  10238. /** Gets or sets the horizontal bar background image */
  10239. get: function () {
  10240. return this._horizontalBarBackgroundImage;
  10241. },
  10242. set: function (value) {
  10243. if (this._horizontalBarBackgroundImage === value) {
  10244. }
  10245. this._horizontalBarBackgroundImage = value;
  10246. var hb = this._horizontalBar;
  10247. hb.backgroundImage = value;
  10248. },
  10249. enumerable: false,
  10250. configurable: true
  10251. });
  10252. Object.defineProperty(ScrollViewer.prototype, "verticalBarImage", {
  10253. /** Gets or sets the vertical bar background image */
  10254. get: function () {
  10255. return this._verticalBarBackgroundImage;
  10256. },
  10257. set: function (value) {
  10258. if (this._verticalBarBackgroundImage === value) {
  10259. }
  10260. this._verticalBarBackgroundImage = value;
  10261. var vb = this._verticalBar;
  10262. vb.backgroundImage = value;
  10263. },
  10264. enumerable: false,
  10265. configurable: true
  10266. });
  10267. ScrollViewer.prototype._setWindowPosition = function (force) {
  10268. if (force === void 0) { force = true; }
  10269. var ratio = this.host.idealRatio;
  10270. var windowContentsWidth = this._window._currentMeasure.width;
  10271. var windowContentsHeight = this._window._currentMeasure.height;
  10272. if (!force && this._oldWindowContentsWidth === windowContentsWidth && this._oldWindowContentsHeight === windowContentsHeight) {
  10273. return;
  10274. }
  10275. this._oldWindowContentsWidth = windowContentsWidth;
  10276. this._oldWindowContentsHeight = windowContentsHeight;
  10277. var _endLeft = this._clientWidth - windowContentsWidth;
  10278. var _endTop = this._clientHeight - windowContentsHeight;
  10279. var newLeft = (this._horizontalBar.value / ratio) * _endLeft + "px";
  10280. var newTop = (this._verticalBar.value / ratio) * _endTop + "px";
  10281. if (newLeft !== this._window.left) {
  10282. this._window.left = newLeft;
  10283. if (!this.freezeControls) {
  10284. this._rebuildLayout = true;
  10285. }
  10286. }
  10287. if (newTop !== this._window.top) {
  10288. this._window.top = newTop;
  10289. if (!this.freezeControls) {
  10290. this._rebuildLayout = true;
  10291. }
  10292. }
  10293. };
  10294. /** @hidden */
  10295. ScrollViewer.prototype._updateScroller = function () {
  10296. var windowContentsWidth = this._window._currentMeasure.width;
  10297. var windowContentsHeight = this._window._currentMeasure.height;
  10298. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  10299. this._grid.setRowDefinition(1, 0, true);
  10300. this._horizontalBar.isVisible = false;
  10301. this._horizontalBar.value = 0;
  10302. this._rebuildLayout = true;
  10303. }
  10304. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  10305. this._grid.setRowDefinition(1, this._barSize, true);
  10306. this._horizontalBar.isVisible = true;
  10307. this._rebuildLayout = true;
  10308. }
  10309. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  10310. this._grid.setColumnDefinition(1, 0, true);
  10311. this._verticalBar.isVisible = false;
  10312. this._verticalBar.value = 0;
  10313. this._rebuildLayout = true;
  10314. }
  10315. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  10316. this._grid.setColumnDefinition(1, this._barSize, true);
  10317. this._verticalBar.isVisible = true;
  10318. this._rebuildLayout = true;
  10319. }
  10320. this._buildClientSizes();
  10321. var ratio = this.host.idealRatio;
  10322. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientWidth / ratio) + "px";
  10323. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientHeight / ratio) + "px";
  10324. };
  10325. ScrollViewer.prototype._link = function (host) {
  10326. _super.prototype._link.call(this, host);
  10327. this._attachWheel();
  10328. };
  10329. /** @hidden */
  10330. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  10331. var _this = this;
  10332. barControl.paddingLeft = 0;
  10333. barControl.width = "100%";
  10334. barControl.height = "100%";
  10335. barControl.barOffset = 0;
  10336. barControl.value = 0;
  10337. barControl.maximum = 1;
  10338. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10339. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10340. barControl.isVertical = isVertical;
  10341. barControl.rotation = rotation;
  10342. barControl.isVisible = false;
  10343. barContainer.addControl(barControl);
  10344. barControl.onValueChangedObservable.add(function (value) {
  10345. _this._setWindowPosition();
  10346. });
  10347. };
  10348. /** @hidden */
  10349. ScrollViewer.prototype._attachWheel = function () {
  10350. var _this = this;
  10351. if (!this._host || this._onWheelObserver) {
  10352. return;
  10353. }
  10354. this._onWheelObserver = this.onWheelObservable.add(function (pi) {
  10355. if (!_this._pointerIsOver) {
  10356. return;
  10357. }
  10358. if (_this._verticalBar.isVisible == true) {
  10359. if (pi.y < 0 && _this._verticalBar.value > 0) {
  10360. _this._verticalBar.value -= _this._wheelPrecision;
  10361. }
  10362. else if (pi.y > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  10363. _this._verticalBar.value += _this._wheelPrecision;
  10364. }
  10365. }
  10366. if (_this._horizontalBar.isVisible == true) {
  10367. if (pi.x < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  10368. _this._horizontalBar.value += _this._wheelPrecision;
  10369. }
  10370. else if (pi.x > 0 && _this._horizontalBar.value > 0) {
  10371. _this._horizontalBar.value -= _this._wheelPrecision;
  10372. }
  10373. }
  10374. });
  10375. };
  10376. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  10377. if (!this.isHighlighted) {
  10378. return;
  10379. }
  10380. _super.prototype._renderHighlightSpecific.call(this, context);
  10381. this._grid._renderHighlightSpecific(context);
  10382. context.restore();
  10383. };
  10384. /** Releases associated resources */
  10385. ScrollViewer.prototype.dispose = function () {
  10386. this.onWheelObservable.remove(this._onWheelObserver);
  10387. this._onWheelObserver = null;
  10388. _super.prototype.dispose.call(this);
  10389. };
  10390. return ScrollViewer;
  10391. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10392. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  10393. /***/ }),
  10394. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  10395. /*!*********************************************************!*\
  10396. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  10397. \*********************************************************/
  10398. /*! exports provided: _ScrollViewerWindow */
  10399. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10400. "use strict";
  10401. __webpack_require__.r(__webpack_exports__);
  10402. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  10403. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10404. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10405. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  10406. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10407. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10408. /**
  10409. * Class used to hold a the container for ScrollViewer
  10410. * @hidden
  10411. */
  10412. var _ScrollViewerWindow = /** @class */ (function (_super) {
  10413. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  10414. /**
  10415. * Creates a new ScrollViewerWindow
  10416. * @param name of ScrollViewerWindow
  10417. */
  10418. function _ScrollViewerWindow(name) {
  10419. var _this = _super.call(this, name) || this;
  10420. _this._freezeControls = false;
  10421. _this._bucketWidth = 0;
  10422. _this._bucketHeight = 0;
  10423. _this._buckets = {};
  10424. return _this;
  10425. }
  10426. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  10427. get: function () {
  10428. return this._freezeControls;
  10429. },
  10430. set: function (value) {
  10431. if (this._freezeControls === value) {
  10432. return;
  10433. }
  10434. if (!value) {
  10435. this._restoreMeasures();
  10436. }
  10437. // trigger a full normal layout calculation to be sure all children have their measures up to date
  10438. this._freezeControls = false;
  10439. var textureSize = this.host.getSize();
  10440. var renderWidth = textureSize.width;
  10441. var renderHeight = textureSize.height;
  10442. var context = this.host.getContext();
  10443. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  10444. this.host._numLayoutCalls = 0;
  10445. this.host._rootContainer._layout(measure, context);
  10446. // in freeze mode, prepare children measures accordingly
  10447. if (value) {
  10448. this._updateMeasures();
  10449. if (this._useBuckets()) {
  10450. this._makeBuckets();
  10451. }
  10452. }
  10453. this._freezeControls = value;
  10454. this.host.markAsDirty(); // redraw with the (new) current settings
  10455. },
  10456. enumerable: false,
  10457. configurable: true
  10458. });
  10459. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  10460. get: function () {
  10461. return this._bucketWidth;
  10462. },
  10463. enumerable: false,
  10464. configurable: true
  10465. });
  10466. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  10467. get: function () {
  10468. return this._bucketHeight;
  10469. },
  10470. enumerable: false,
  10471. configurable: true
  10472. });
  10473. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  10474. this._bucketWidth = width;
  10475. this._bucketHeight = height;
  10476. if (this._useBuckets()) {
  10477. if (this._freezeControls) {
  10478. this._makeBuckets();
  10479. }
  10480. }
  10481. else {
  10482. this._buckets = {};
  10483. }
  10484. };
  10485. _ScrollViewerWindow.prototype._useBuckets = function () {
  10486. return this._bucketWidth > 0 && this._bucketHeight > 0;
  10487. };
  10488. _ScrollViewerWindow.prototype._makeBuckets = function () {
  10489. this._buckets = {};
  10490. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  10491. this._dispatchInBuckets(this._children);
  10492. this._oldLeft = null;
  10493. this._oldTop = null;
  10494. };
  10495. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  10496. for (var i = 0; i < children.length; ++i) {
  10497. var child = children[i];
  10498. 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);
  10499. while (bStartY <= bEndY) {
  10500. for (var x = bStartX; x <= bEndX; ++x) {
  10501. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  10502. if (!lstc) {
  10503. lstc = [];
  10504. this._buckets[bucket] = lstc;
  10505. }
  10506. lstc.push(child);
  10507. }
  10508. bStartY++;
  10509. }
  10510. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  10511. this._dispatchInBuckets(child._children);
  10512. }
  10513. }
  10514. };
  10515. // reset left and top measures for the window and all its children
  10516. _ScrollViewerWindow.prototype._updateMeasures = function () {
  10517. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  10518. this._measureForChildren.left -= left;
  10519. this._measureForChildren.top -= top;
  10520. this._currentMeasure.left -= left;
  10521. this._currentMeasure.top -= top;
  10522. this._customData.origLeftForChildren = this._measureForChildren.left;
  10523. this._customData.origTopForChildren = this._measureForChildren.top;
  10524. this._customData.origLeft = this._currentMeasure.left;
  10525. this._customData.origTop = this._currentMeasure.top;
  10526. this._updateChildrenMeasures(this._children, left, top);
  10527. };
  10528. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  10529. for (var i = 0; i < children.length; ++i) {
  10530. var child = children[i];
  10531. child._currentMeasure.left -= left;
  10532. child._currentMeasure.top -= top;
  10533. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  10534. child._customData._origTop = child._currentMeasure.top;
  10535. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  10536. this._updateChildrenMeasures(child._children, left, top);
  10537. }
  10538. }
  10539. };
  10540. _ScrollViewerWindow.prototype._restoreMeasures = function () {
  10541. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  10542. this._measureForChildren.left = this._customData.origLeftForChildren + left;
  10543. this._measureForChildren.top = this._customData.origTopForChildren + top;
  10544. this._currentMeasure.left = this._customData.origLeft + left;
  10545. this._currentMeasure.top = this._customData.origTop + top;
  10546. };
  10547. _ScrollViewerWindow.prototype._getTypeName = function () {
  10548. return "ScrollViewerWindow";
  10549. };
  10550. /** @hidden */
  10551. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  10552. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10553. this._parentMeasure = parentMeasure;
  10554. this._measureForChildren.left = this._currentMeasure.left;
  10555. this._measureForChildren.top = this._currentMeasure.top;
  10556. this._measureForChildren.width = parentMeasure.width;
  10557. this._measureForChildren.height = parentMeasure.height;
  10558. };
  10559. /** @hidden */
  10560. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  10561. if (this._freezeControls) {
  10562. this.invalidateRect(); // will trigger a redraw of the window
  10563. return false;
  10564. }
  10565. return _super.prototype._layout.call(this, parentMeasure, context);
  10566. };
  10567. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  10568. for (var i = 0; i < children.length; ++i) {
  10569. var child = children[i];
  10570. child._currentMeasure.left = child._customData._origLeft + left;
  10571. child._currentMeasure.top = child._customData._origTop + top;
  10572. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  10573. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  10574. this._scrollChildren(child._children, left, top);
  10575. }
  10576. }
  10577. };
  10578. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  10579. 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);
  10580. while (bStartY <= bEndY) {
  10581. for (var x = bStartX; x <= bEndX; ++x) {
  10582. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  10583. if (lstc) {
  10584. for (var i = 0; i < lstc.length; ++i) {
  10585. var child = lstc[i];
  10586. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  10587. child._currentMeasure.top = child._customData._origTop + scrollTop;
  10588. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  10589. }
  10590. }
  10591. }
  10592. bStartY++;
  10593. }
  10594. };
  10595. /** @hidden */
  10596. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  10597. if (!this._freezeControls) {
  10598. _super.prototype._draw.call(this, context, invalidatedRectangle);
  10599. return;
  10600. }
  10601. this._localDraw(context);
  10602. if (this.clipChildren) {
  10603. this._clipForChildren(context);
  10604. }
  10605. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  10606. if (this._useBuckets()) {
  10607. if (this._oldLeft !== null && this._oldTop !== null) {
  10608. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  10609. this._scrollChildrenWithBuckets(left, top, left, top);
  10610. }
  10611. else {
  10612. this._scrollChildren(this._children, left, top);
  10613. }
  10614. }
  10615. else {
  10616. this._scrollChildren(this._children, left, top);
  10617. }
  10618. this._oldLeft = left;
  10619. this._oldTop = top;
  10620. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10621. var child = _a[_i];
  10622. if (!child._intersectsRect(this._parentMeasure)) {
  10623. continue;
  10624. }
  10625. child._render(context, this._parentMeasure);
  10626. }
  10627. };
  10628. _ScrollViewerWindow.prototype._postMeasure = function () {
  10629. if (this._freezeControls) {
  10630. _super.prototype._postMeasure.call(this);
  10631. return;
  10632. }
  10633. var maxWidth = this.parentClientWidth;
  10634. var maxHeight = this.parentClientHeight;
  10635. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10636. var child = _a[_i];
  10637. if (!child.isVisible || child.notRenderable) {
  10638. continue;
  10639. }
  10640. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  10641. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  10642. }
  10643. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  10644. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  10645. }
  10646. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width + child.paddingRightInPixels);
  10647. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height + child.paddingBottomInPixels);
  10648. }
  10649. if (this._currentMeasure.width !== maxWidth) {
  10650. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  10651. this._currentMeasure.width = maxWidth;
  10652. this._rebuildLayout = true;
  10653. this._isDirty = true;
  10654. }
  10655. if (this._currentMeasure.height !== maxHeight) {
  10656. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  10657. this._currentMeasure.height = maxHeight;
  10658. this._rebuildLayout = true;
  10659. this._isDirty = true;
  10660. }
  10661. _super.prototype._postMeasure.call(this);
  10662. };
  10663. return _ScrollViewerWindow;
  10664. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10665. /***/ }),
  10666. /***/ "./2D/controls/selector.ts":
  10667. /*!*********************************!*\
  10668. !*** ./2D/controls/selector.ts ***!
  10669. \*********************************/
  10670. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  10671. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10672. "use strict";
  10673. __webpack_require__.r(__webpack_exports__);
  10674. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  10675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  10676. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  10677. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  10678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  10679. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10680. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  10681. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10682. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10683. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10684. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  10685. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  10686. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  10687. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10688. /** Class used to create a RadioGroup
  10689. * which contains groups of radio buttons
  10690. */
  10691. var SelectorGroup = /** @class */ (function () {
  10692. /**
  10693. * Creates a new SelectorGroup
  10694. * @param name of group, used as a group heading
  10695. */
  10696. function SelectorGroup(
  10697. /** name of SelectorGroup */
  10698. name) {
  10699. this.name = name;
  10700. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10701. this._selectors = new Array();
  10702. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10703. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10704. this._groupHeader = this._addGroupHeader(name);
  10705. }
  10706. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  10707. /** Gets the groupPanel of the SelectorGroup */
  10708. get: function () {
  10709. return this._groupPanel;
  10710. },
  10711. enumerable: false,
  10712. configurable: true
  10713. });
  10714. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  10715. /** Gets the selectors array */
  10716. get: function () {
  10717. return this._selectors;
  10718. },
  10719. enumerable: false,
  10720. configurable: true
  10721. });
  10722. Object.defineProperty(SelectorGroup.prototype, "header", {
  10723. /** Gets and sets the group header */
  10724. get: function () {
  10725. return this._groupHeader.text;
  10726. },
  10727. set: function (label) {
  10728. if (this._groupHeader.text === "label") {
  10729. return;
  10730. }
  10731. this._groupHeader.text = label;
  10732. },
  10733. enumerable: false,
  10734. configurable: true
  10735. });
  10736. /** @hidden */
  10737. SelectorGroup.prototype._addGroupHeader = function (text) {
  10738. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  10739. groupHeading.width = 0.9;
  10740. groupHeading.height = "30px";
  10741. groupHeading.textWrapping = true;
  10742. groupHeading.color = "black";
  10743. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10744. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10745. groupHeading.left = "2px";
  10746. this._groupPanel.addControl(groupHeading);
  10747. return groupHeading;
  10748. };
  10749. /** @hidden*/
  10750. SelectorGroup.prototype._getSelector = function (selectorNb) {
  10751. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10752. return;
  10753. }
  10754. return this._selectors[selectorNb];
  10755. };
  10756. /** Removes the selector at the given position
  10757. * @param selectorNb the position of the selector within the group
  10758. */
  10759. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  10760. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10761. return;
  10762. }
  10763. this._groupPanel.removeControl(this._selectors[selectorNb]);
  10764. this._selectors.splice(selectorNb, 1);
  10765. };
  10766. return SelectorGroup;
  10767. }());
  10768. /** Class used to create a CheckboxGroup
  10769. * which contains groups of checkbox buttons
  10770. */
  10771. var CheckboxGroup = /** @class */ (function (_super) {
  10772. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  10773. function CheckboxGroup() {
  10774. return _super !== null && _super.apply(this, arguments) || this;
  10775. }
  10776. /** Adds a checkbox as a control
  10777. * @param text is the label for the selector
  10778. * @param func is the function called when the Selector is checked
  10779. * @param checked is true when Selector is checked
  10780. */
  10781. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  10782. if (func === void 0) { func = function (s) { }; }
  10783. if (checked === void 0) { checked = false; }
  10784. var checked = checked || false;
  10785. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  10786. button.width = "20px";
  10787. button.height = "20px";
  10788. button.color = "#364249";
  10789. button.background = "#CCCCCC";
  10790. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10791. button.onIsCheckedChangedObservable.add(function (state) {
  10792. func(state);
  10793. });
  10794. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  10795. _selector.height = "30px";
  10796. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10797. _selector.left = "4px";
  10798. this.groupPanel.addControl(_selector);
  10799. this.selectors.push(_selector);
  10800. button.isChecked = checked;
  10801. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10802. button.color = this.groupPanel.parent.parent.buttonColor;
  10803. button.background = this.groupPanel.parent.parent.buttonBackground;
  10804. }
  10805. };
  10806. /** @hidden */
  10807. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10808. this.selectors[selectorNb].children[1].text = label;
  10809. };
  10810. /** @hidden */
  10811. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10812. this.selectors[selectorNb].children[1].color = color;
  10813. };
  10814. /** @hidden */
  10815. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10816. this.selectors[selectorNb].children[0].color = color;
  10817. };
  10818. /** @hidden */
  10819. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10820. this.selectors[selectorNb].children[0].background = color;
  10821. };
  10822. return CheckboxGroup;
  10823. }(SelectorGroup));
  10824. /** Class used to create a RadioGroup
  10825. * which contains groups of radio buttons
  10826. */
  10827. var RadioGroup = /** @class */ (function (_super) {
  10828. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  10829. function RadioGroup() {
  10830. var _this = _super !== null && _super.apply(this, arguments) || this;
  10831. _this._selectNb = 0;
  10832. return _this;
  10833. }
  10834. /** Adds a radio button as a control
  10835. * @param label is the label for the selector
  10836. * @param func is the function called when the Selector is checked
  10837. * @param checked is true when Selector is checked
  10838. */
  10839. RadioGroup.prototype.addRadio = function (label, func, checked) {
  10840. if (func === void 0) { func = function (n) { }; }
  10841. if (checked === void 0) { checked = false; }
  10842. var nb = this._selectNb++;
  10843. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  10844. button.name = label;
  10845. button.width = "20px";
  10846. button.height = "20px";
  10847. button.color = "#364249";
  10848. button.background = "#CCCCCC";
  10849. button.group = this.name;
  10850. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10851. button.onIsCheckedChangedObservable.add(function (state) {
  10852. if (state) {
  10853. func(nb);
  10854. }
  10855. });
  10856. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  10857. _selector.height = "30px";
  10858. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10859. _selector.left = "4px";
  10860. this.groupPanel.addControl(_selector);
  10861. this.selectors.push(_selector);
  10862. button.isChecked = checked;
  10863. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10864. button.color = this.groupPanel.parent.parent.buttonColor;
  10865. button.background = this.groupPanel.parent.parent.buttonBackground;
  10866. }
  10867. };
  10868. /** @hidden */
  10869. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10870. this.selectors[selectorNb].children[1].text = label;
  10871. };
  10872. /** @hidden */
  10873. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10874. this.selectors[selectorNb].children[1].color = color;
  10875. };
  10876. /** @hidden */
  10877. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10878. this.selectors[selectorNb].children[0].color = color;
  10879. };
  10880. /** @hidden */
  10881. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10882. this.selectors[selectorNb].children[0].background = color;
  10883. };
  10884. return RadioGroup;
  10885. }(SelectorGroup));
  10886. /** Class used to create a SliderGroup
  10887. * which contains groups of slider buttons
  10888. */
  10889. var SliderGroup = /** @class */ (function (_super) {
  10890. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  10891. function SliderGroup() {
  10892. return _super !== null && _super.apply(this, arguments) || this;
  10893. }
  10894. /**
  10895. * Adds a slider to the SelectorGroup
  10896. * @param label is the label for the SliderBar
  10897. * @param func is the function called when the Slider moves
  10898. * @param unit is a string describing the units used, eg degrees or metres
  10899. * @param min is the minimum value for the Slider
  10900. * @param max is the maximum value for the Slider
  10901. * @param value is the start value for the Slider between min and max
  10902. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  10903. */
  10904. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  10905. if (func === void 0) { func = function (v) { }; }
  10906. if (unit === void 0) { unit = "Units"; }
  10907. if (min === void 0) { min = 0; }
  10908. if (max === void 0) { max = 0; }
  10909. if (value === void 0) { value = 0; }
  10910. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  10911. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  10912. button.name = unit;
  10913. button.value = value;
  10914. button.minimum = min;
  10915. button.maximum = max;
  10916. button.width = 0.9;
  10917. button.height = "20px";
  10918. button.color = "#364249";
  10919. button.background = "#CCCCCC";
  10920. button.borderColor = "black";
  10921. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10922. button.left = "4px";
  10923. button.paddingBottom = "4px";
  10924. button.onValueChangedObservable.add(function (value) {
  10925. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  10926. func(value);
  10927. });
  10928. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  10929. _selector.height = "60px";
  10930. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10931. _selector.left = "4px";
  10932. _selector.children[0].name = label;
  10933. this.groupPanel.addControl(_selector);
  10934. this.selectors.push(_selector);
  10935. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10936. button.color = this.groupPanel.parent.parent.buttonColor;
  10937. button.background = this.groupPanel.parent.parent.buttonBackground;
  10938. }
  10939. };
  10940. /** @hidden */
  10941. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10942. this.selectors[selectorNb].children[0].name = label;
  10943. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  10944. };
  10945. /** @hidden */
  10946. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10947. this.selectors[selectorNb].children[0].color = color;
  10948. };
  10949. /** @hidden */
  10950. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10951. this.selectors[selectorNb].children[1].color = color;
  10952. };
  10953. /** @hidden */
  10954. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10955. this.selectors[selectorNb].children[1].background = color;
  10956. };
  10957. return SliderGroup;
  10958. }(SelectorGroup));
  10959. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  10960. * @see https://doc.babylonjs.com/how_to/selector
  10961. */
  10962. var SelectionPanel = /** @class */ (function (_super) {
  10963. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  10964. /**
  10965. * Creates a new SelectionPanel
  10966. * @param name of SelectionPanel
  10967. * @param groups is an array of SelectionGroups
  10968. */
  10969. function SelectionPanel(
  10970. /** name of SelectionPanel */
  10971. name,
  10972. /** an array of SelectionGroups */
  10973. groups) {
  10974. if (groups === void 0) { groups = []; }
  10975. var _this = _super.call(this, name) || this;
  10976. _this.name = name;
  10977. _this.groups = groups;
  10978. _this._buttonColor = "#364249";
  10979. _this._buttonBackground = "#CCCCCC";
  10980. _this._headerColor = "black";
  10981. _this._barColor = "white";
  10982. _this._barHeight = "2px";
  10983. _this._spacerHeight = "20px";
  10984. _this._bars = new Array();
  10985. _this._groups = groups;
  10986. _this.thickness = 2;
  10987. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10988. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10989. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10990. _this._panel.top = 5;
  10991. _this._panel.left = 5;
  10992. _this._panel.width = 0.95;
  10993. if (groups.length > 0) {
  10994. for (var i = 0; i < groups.length - 1; i++) {
  10995. _this._panel.addControl(groups[i].groupPanel);
  10996. _this._addSpacer();
  10997. }
  10998. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  10999. }
  11000. _this.addControl(_this._panel);
  11001. return _this;
  11002. }
  11003. SelectionPanel.prototype._getTypeName = function () {
  11004. return "SelectionPanel";
  11005. };
  11006. Object.defineProperty(SelectionPanel.prototype, "panel", {
  11007. /** Gets the (stack) panel of the SelectionPanel */
  11008. get: function () {
  11009. return this._panel;
  11010. },
  11011. enumerable: false,
  11012. configurable: true
  11013. });
  11014. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  11015. /** Gets or sets the headerColor */
  11016. get: function () {
  11017. return this._headerColor;
  11018. },
  11019. set: function (color) {
  11020. if (this._headerColor === color) {
  11021. return;
  11022. }
  11023. this._headerColor = color;
  11024. this._setHeaderColor();
  11025. },
  11026. enumerable: false,
  11027. configurable: true
  11028. });
  11029. SelectionPanel.prototype._setHeaderColor = function () {
  11030. for (var i = 0; i < this._groups.length; i++) {
  11031. this._groups[i].groupPanel.children[0].color = this._headerColor;
  11032. }
  11033. };
  11034. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  11035. /** Gets or sets the button color */
  11036. get: function () {
  11037. return this._buttonColor;
  11038. },
  11039. set: function (color) {
  11040. if (this._buttonColor === color) {
  11041. return;
  11042. }
  11043. this._buttonColor = color;
  11044. this._setbuttonColor();
  11045. },
  11046. enumerable: false,
  11047. configurable: true
  11048. });
  11049. SelectionPanel.prototype._setbuttonColor = function () {
  11050. for (var i = 0; i < this._groups.length; i++) {
  11051. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  11052. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  11053. }
  11054. }
  11055. };
  11056. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  11057. /** Gets or sets the label color */
  11058. get: function () {
  11059. return this._labelColor;
  11060. },
  11061. set: function (color) {
  11062. if (this._labelColor === color) {
  11063. return;
  11064. }
  11065. this._labelColor = color;
  11066. this._setLabelColor();
  11067. },
  11068. enumerable: false,
  11069. configurable: true
  11070. });
  11071. SelectionPanel.prototype._setLabelColor = function () {
  11072. for (var i = 0; i < this._groups.length; i++) {
  11073. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  11074. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  11075. }
  11076. }
  11077. };
  11078. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  11079. /** Gets or sets the button background */
  11080. get: function () {
  11081. return this._buttonBackground;
  11082. },
  11083. set: function (color) {
  11084. if (this._buttonBackground === color) {
  11085. return;
  11086. }
  11087. this._buttonBackground = color;
  11088. this._setButtonBackground();
  11089. },
  11090. enumerable: false,
  11091. configurable: true
  11092. });
  11093. SelectionPanel.prototype._setButtonBackground = function () {
  11094. for (var i = 0; i < this._groups.length; i++) {
  11095. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  11096. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  11097. }
  11098. }
  11099. };
  11100. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  11101. /** Gets or sets the color of separator bar */
  11102. get: function () {
  11103. return this._barColor;
  11104. },
  11105. set: function (color) {
  11106. if (this._barColor === color) {
  11107. return;
  11108. }
  11109. this._barColor = color;
  11110. this._setBarColor();
  11111. },
  11112. enumerable: false,
  11113. configurable: true
  11114. });
  11115. SelectionPanel.prototype._setBarColor = function () {
  11116. for (var i = 0; i < this._bars.length; i++) {
  11117. this._bars[i].children[0].background = this._barColor;
  11118. }
  11119. };
  11120. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  11121. /** Gets or sets the height of separator bar */
  11122. get: function () {
  11123. return this._barHeight;
  11124. },
  11125. set: function (value) {
  11126. if (this._barHeight === value) {
  11127. return;
  11128. }
  11129. this._barHeight = value;
  11130. this._setBarHeight();
  11131. },
  11132. enumerable: false,
  11133. configurable: true
  11134. });
  11135. SelectionPanel.prototype._setBarHeight = function () {
  11136. for (var i = 0; i < this._bars.length; i++) {
  11137. this._bars[i].children[0].height = this._barHeight;
  11138. }
  11139. };
  11140. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  11141. /** Gets or sets the height of spacers*/
  11142. get: function () {
  11143. return this._spacerHeight;
  11144. },
  11145. set: function (value) {
  11146. if (this._spacerHeight === value) {
  11147. return;
  11148. }
  11149. this._spacerHeight = value;
  11150. this._setSpacerHeight();
  11151. },
  11152. enumerable: false,
  11153. configurable: true
  11154. });
  11155. SelectionPanel.prototype._setSpacerHeight = function () {
  11156. for (var i = 0; i < this._bars.length; i++) {
  11157. this._bars[i].height = this._spacerHeight;
  11158. }
  11159. };
  11160. /** Adds a bar between groups */
  11161. SelectionPanel.prototype._addSpacer = function () {
  11162. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  11163. separator.width = 1;
  11164. separator.height = this._spacerHeight;
  11165. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11166. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  11167. bar.width = 1;
  11168. bar.height = this._barHeight;
  11169. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11170. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  11171. bar.background = this._barColor;
  11172. bar.color = "transparent";
  11173. separator.addControl(bar);
  11174. this._panel.addControl(separator);
  11175. this._bars.push(separator);
  11176. };
  11177. /** Add a group to the selection panel
  11178. * @param group is the selector group to add
  11179. */
  11180. SelectionPanel.prototype.addGroup = function (group) {
  11181. if (this._groups.length > 0) {
  11182. this._addSpacer();
  11183. }
  11184. this._panel.addControl(group.groupPanel);
  11185. this._groups.push(group);
  11186. group.groupPanel.children[0].color = this._headerColor;
  11187. for (var j = 0; j < group.selectors.length; j++) {
  11188. group._setSelectorButtonColor(j, this._buttonColor);
  11189. group._setSelectorButtonBackground(j, this._buttonBackground);
  11190. }
  11191. };
  11192. /** Remove the group from the given position
  11193. * @param groupNb is the position of the group in the list
  11194. */
  11195. SelectionPanel.prototype.removeGroup = function (groupNb) {
  11196. if (groupNb < 0 || groupNb >= this._groups.length) {
  11197. return;
  11198. }
  11199. var group = this._groups[groupNb];
  11200. this._panel.removeControl(group.groupPanel);
  11201. this._groups.splice(groupNb, 1);
  11202. if (groupNb < this._bars.length) {
  11203. this._panel.removeControl(this._bars[groupNb]);
  11204. this._bars.splice(groupNb, 1);
  11205. }
  11206. };
  11207. /** Change a group header label
  11208. * @param label is the new group header label
  11209. * @param groupNb is the number of the group to relabel
  11210. * */
  11211. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  11212. if (groupNb < 0 || groupNb >= this._groups.length) {
  11213. return;
  11214. }
  11215. var group = this._groups[groupNb];
  11216. group.groupPanel.children[0].text = label;
  11217. };
  11218. /** Change selector label to the one given
  11219. * @param label is the new selector label
  11220. * @param groupNb is the number of the groupcontaining the selector
  11221. * @param selectorNb is the number of the selector within a group to relabel
  11222. * */
  11223. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  11224. if (groupNb < 0 || groupNb >= this._groups.length) {
  11225. return;
  11226. }
  11227. var group = this._groups[groupNb];
  11228. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  11229. return;
  11230. }
  11231. group._setSelectorLabel(selectorNb, label);
  11232. };
  11233. /** For a given group position remove the selector at the given position
  11234. * @param groupNb is the number of the group to remove the selector from
  11235. * @param selectorNb is the number of the selector within the group
  11236. */
  11237. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  11238. if (groupNb < 0 || groupNb >= this._groups.length) {
  11239. return;
  11240. }
  11241. var group = this._groups[groupNb];
  11242. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  11243. return;
  11244. }
  11245. group.removeSelector(selectorNb);
  11246. };
  11247. /** For a given group position of correct type add a checkbox button
  11248. * @param groupNb is the number of the group to remove the selector from
  11249. * @param label is the label for the selector
  11250. * @param func is the function called when the Selector is checked
  11251. * @param checked is true when Selector is checked
  11252. */
  11253. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  11254. if (func === void 0) { func = function () { }; }
  11255. if (checked === void 0) { checked = false; }
  11256. if (groupNb < 0 || groupNb >= this._groups.length) {
  11257. return;
  11258. }
  11259. var group = this._groups[groupNb];
  11260. group.addCheckbox(label, func, checked);
  11261. };
  11262. /** For a given group position of correct type add a radio button
  11263. * @param groupNb is the number of the group to remove the selector from
  11264. * @param label is the label for the selector
  11265. * @param func is the function called when the Selector is checked
  11266. * @param checked is true when Selector is checked
  11267. */
  11268. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  11269. if (func === void 0) { func = function () { }; }
  11270. if (checked === void 0) { checked = false; }
  11271. if (groupNb < 0 || groupNb >= this._groups.length) {
  11272. return;
  11273. }
  11274. var group = this._groups[groupNb];
  11275. group.addRadio(label, func, checked);
  11276. };
  11277. /**
  11278. * For a given slider group add a slider
  11279. * @param groupNb is the number of the group to add the slider to
  11280. * @param label is the label for the Slider
  11281. * @param func is the function called when the Slider moves
  11282. * @param unit is a string describing the units used, eg degrees or metres
  11283. * @param min is the minimum value for the Slider
  11284. * @param max is the maximum value for the Slider
  11285. * @param value is the start value for the Slider between min and max
  11286. * @param onVal is the function used to format the value displayed, eg radians to degrees
  11287. */
  11288. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  11289. if (func === void 0) { func = function () { }; }
  11290. if (unit === void 0) { unit = "Units"; }
  11291. if (min === void 0) { min = 0; }
  11292. if (max === void 0) { max = 0; }
  11293. if (value === void 0) { value = 0; }
  11294. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  11295. if (groupNb < 0 || groupNb >= this._groups.length) {
  11296. return;
  11297. }
  11298. var group = this._groups[groupNb];
  11299. group.addSlider(label, func, unit, min, max, value, onVal);
  11300. };
  11301. return SelectionPanel;
  11302. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  11303. /***/ }),
  11304. /***/ "./2D/controls/sliders/baseSlider.ts":
  11305. /*!*******************************************!*\
  11306. !*** ./2D/controls/sliders/baseSlider.ts ***!
  11307. \*******************************************/
  11308. /*! exports provided: BaseSlider */
  11309. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11310. "use strict";
  11311. __webpack_require__.r(__webpack_exports__);
  11312. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  11313. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11314. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  11315. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11316. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  11317. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  11318. /**
  11319. * Class used to create slider controls
  11320. */
  11321. var BaseSlider = /** @class */ (function (_super) {
  11322. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  11323. /**
  11324. * Creates a new BaseSlider
  11325. * @param name defines the control name
  11326. */
  11327. function BaseSlider(name) {
  11328. var _this = _super.call(this, name) || this;
  11329. _this.name = name;
  11330. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  11331. _this._minimum = 0;
  11332. _this._maximum = 100;
  11333. _this._value = 50;
  11334. _this._isVertical = false;
  11335. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  11336. _this._isThumbClamped = false;
  11337. _this._displayThumb = true;
  11338. _this._step = 0;
  11339. _this._lastPointerDownID = -1;
  11340. // Shared rendering info
  11341. _this._effectiveBarOffset = 0;
  11342. /** Observable raised when the sldier value changes */
  11343. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11344. // Events
  11345. _this._pointerIsDown = false;
  11346. _this.isPointerBlocker = true;
  11347. return _this;
  11348. }
  11349. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  11350. /** Gets or sets a boolean indicating if the thumb must be rendered */
  11351. get: function () {
  11352. return this._displayThumb;
  11353. },
  11354. set: function (value) {
  11355. if (this._displayThumb === value) {
  11356. return;
  11357. }
  11358. this._displayThumb = value;
  11359. this._markAsDirty();
  11360. },
  11361. enumerable: false,
  11362. configurable: true
  11363. });
  11364. Object.defineProperty(BaseSlider.prototype, "step", {
  11365. /** Gets or sets a step to apply to values (0 by default) */
  11366. get: function () {
  11367. return this._step;
  11368. },
  11369. set: function (value) {
  11370. if (this._step === value) {
  11371. return;
  11372. }
  11373. this._step = value;
  11374. this._markAsDirty();
  11375. },
  11376. enumerable: false,
  11377. configurable: true
  11378. });
  11379. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  11380. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  11381. get: function () {
  11382. return this._barOffset.toString(this._host);
  11383. },
  11384. set: function (value) {
  11385. if (this._barOffset.toString(this._host) === value) {
  11386. return;
  11387. }
  11388. if (this._barOffset.fromString(value)) {
  11389. this._markAsDirty();
  11390. }
  11391. },
  11392. enumerable: false,
  11393. configurable: true
  11394. });
  11395. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  11396. /** Gets main bar offset in pixels*/
  11397. get: function () {
  11398. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  11399. },
  11400. enumerable: false,
  11401. configurable: true
  11402. });
  11403. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  11404. /** Gets or sets thumb width */
  11405. get: function () {
  11406. return this._thumbWidth.toString(this._host);
  11407. },
  11408. set: function (value) {
  11409. if (this._thumbWidth.toString(this._host) === value) {
  11410. return;
  11411. }
  11412. if (this._thumbWidth.fromString(value)) {
  11413. this._markAsDirty();
  11414. }
  11415. },
  11416. enumerable: false,
  11417. configurable: true
  11418. });
  11419. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  11420. /** Gets thumb width in pixels */
  11421. get: function () {
  11422. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  11423. },
  11424. enumerable: false,
  11425. configurable: true
  11426. });
  11427. Object.defineProperty(BaseSlider.prototype, "minimum", {
  11428. /** Gets or sets minimum value */
  11429. get: function () {
  11430. return this._minimum;
  11431. },
  11432. set: function (value) {
  11433. if (this._minimum === value) {
  11434. return;
  11435. }
  11436. this._minimum = value;
  11437. this._markAsDirty();
  11438. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  11439. },
  11440. enumerable: false,
  11441. configurable: true
  11442. });
  11443. Object.defineProperty(BaseSlider.prototype, "maximum", {
  11444. /** Gets or sets maximum value */
  11445. get: function () {
  11446. return this._maximum;
  11447. },
  11448. set: function (value) {
  11449. if (this._maximum === value) {
  11450. return;
  11451. }
  11452. this._maximum = value;
  11453. this._markAsDirty();
  11454. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  11455. },
  11456. enumerable: false,
  11457. configurable: true
  11458. });
  11459. Object.defineProperty(BaseSlider.prototype, "value", {
  11460. /** Gets or sets current value */
  11461. get: function () {
  11462. return this._value;
  11463. },
  11464. set: function (value) {
  11465. value = Math.max(Math.min(value, this._maximum), this._minimum);
  11466. if (this._value === value) {
  11467. return;
  11468. }
  11469. this._value = value;
  11470. this._markAsDirty();
  11471. this.onValueChangedObservable.notifyObservers(this._value);
  11472. },
  11473. enumerable: false,
  11474. configurable: true
  11475. });
  11476. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  11477. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  11478. get: function () {
  11479. return this._isVertical;
  11480. },
  11481. set: function (value) {
  11482. if (this._isVertical === value) {
  11483. return;
  11484. }
  11485. this._isVertical = value;
  11486. this._markAsDirty();
  11487. },
  11488. enumerable: false,
  11489. configurable: true
  11490. });
  11491. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  11492. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  11493. get: function () {
  11494. return this._isThumbClamped;
  11495. },
  11496. set: function (value) {
  11497. if (this._isThumbClamped === value) {
  11498. return;
  11499. }
  11500. this._isThumbClamped = value;
  11501. this._markAsDirty();
  11502. },
  11503. enumerable: false,
  11504. configurable: true
  11505. });
  11506. BaseSlider.prototype._getTypeName = function () {
  11507. return "BaseSlider";
  11508. };
  11509. BaseSlider.prototype._getThumbPosition = function () {
  11510. if (this.isVertical) {
  11511. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  11512. }
  11513. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  11514. };
  11515. BaseSlider.prototype._getThumbThickness = function (type) {
  11516. var thumbThickness = 0;
  11517. switch (type) {
  11518. case "circle":
  11519. if (this._thumbWidth.isPixel) {
  11520. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  11521. }
  11522. else {
  11523. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11524. }
  11525. break;
  11526. case "rectangle":
  11527. if (this._thumbWidth.isPixel) {
  11528. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  11529. }
  11530. else {
  11531. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11532. }
  11533. }
  11534. return thumbThickness;
  11535. };
  11536. BaseSlider.prototype._prepareRenderingData = function (type) {
  11537. // Main bar
  11538. this._effectiveBarOffset = 0;
  11539. this._renderLeft = this._currentMeasure.left;
  11540. this._renderTop = this._currentMeasure.top;
  11541. this._renderWidth = this._currentMeasure.width;
  11542. this._renderHeight = this._currentMeasure.height;
  11543. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  11544. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  11545. this._effectiveThumbThickness = this._getThumbThickness(type);
  11546. if (this.displayThumb) {
  11547. this._backgroundBoxLength -= this._effectiveThumbThickness;
  11548. }
  11549. //throw error when height is less than width for vertical slider
  11550. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  11551. console.error("Height should be greater than width");
  11552. return;
  11553. }
  11554. if (this._barOffset.isPixel) {
  11555. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  11556. }
  11557. else {
  11558. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  11559. }
  11560. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  11561. if (this.isVertical) {
  11562. this._renderLeft += this._effectiveBarOffset;
  11563. if (!this.isThumbClamped && this.displayThumb) {
  11564. this._renderTop += (this._effectiveThumbThickness / 2);
  11565. }
  11566. this._renderHeight = this._backgroundBoxLength;
  11567. this._renderWidth = this._backgroundBoxThickness;
  11568. }
  11569. else {
  11570. this._renderTop += this._effectiveBarOffset;
  11571. if (!this.isThumbClamped && this.displayThumb) {
  11572. this._renderLeft += (this._effectiveThumbThickness / 2);
  11573. }
  11574. this._renderHeight = this._backgroundBoxThickness;
  11575. this._renderWidth = this._backgroundBoxLength;
  11576. }
  11577. };
  11578. /** @hidden */
  11579. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  11580. if (this.rotation != 0) {
  11581. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11582. x = this._transformedPosition.x;
  11583. y = this._transformedPosition.y;
  11584. }
  11585. var value;
  11586. if (this._isVertical) {
  11587. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  11588. }
  11589. else {
  11590. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  11591. }
  11592. var mult = (1 / this._step) | 0;
  11593. this.value = this._step ? ((value * mult) | 0) / mult : value;
  11594. };
  11595. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  11596. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  11597. return false;
  11598. }
  11599. this._pointerIsDown = true;
  11600. this._updateValueFromPointer(coordinates.x, coordinates.y);
  11601. this._host._capturingControl[pointerId] = this;
  11602. this._lastPointerDownID = pointerId;
  11603. return true;
  11604. };
  11605. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  11606. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  11607. if (pointerId != this._lastPointerDownID) {
  11608. return;
  11609. }
  11610. if (this._pointerIsDown) {
  11611. this._updateValueFromPointer(coordinates.x, coordinates.y);
  11612. }
  11613. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
  11614. };
  11615. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  11616. this._pointerIsDown = false;
  11617. delete this._host._capturingControl[pointerId];
  11618. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  11619. };
  11620. BaseSlider.prototype._onCanvasBlur = function () {
  11621. this._forcePointerUp();
  11622. _super.prototype._onCanvasBlur.call(this);
  11623. };
  11624. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11625. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11626. ], BaseSlider.prototype, "displayThumb", null);
  11627. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11628. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11629. ], BaseSlider.prototype, "step", null);
  11630. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11631. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11632. ], BaseSlider.prototype, "barOffset", null);
  11633. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11634. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11635. ], BaseSlider.prototype, "thumbWidth", null);
  11636. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11637. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11638. ], BaseSlider.prototype, "minimum", null);
  11639. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11640. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11641. ], BaseSlider.prototype, "maximum", null);
  11642. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11643. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11644. ], BaseSlider.prototype, "value", null);
  11645. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11646. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11647. ], BaseSlider.prototype, "isVertical", null);
  11648. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11649. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11650. ], BaseSlider.prototype, "isThumbClamped", null);
  11651. return BaseSlider;
  11652. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  11653. /***/ }),
  11654. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  11655. /*!*************************************************!*\
  11656. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  11657. \*************************************************/
  11658. /*! exports provided: ImageBasedSlider */
  11659. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11660. "use strict";
  11661. __webpack_require__.r(__webpack_exports__);
  11662. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  11663. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11664. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11665. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11666. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  11667. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  11668. /**
  11669. * Class used to create slider controls based on images
  11670. */
  11671. var ImageBasedSlider = /** @class */ (function (_super) {
  11672. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  11673. /**
  11674. * Creates a new ImageBasedSlider
  11675. * @param name defines the control name
  11676. */
  11677. function ImageBasedSlider(name) {
  11678. var _this = _super.call(this, name) || this;
  11679. _this.name = name;
  11680. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11681. return _this;
  11682. }
  11683. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  11684. get: function () {
  11685. return this._displayThumb && this.thumbImage != null;
  11686. },
  11687. set: function (value) {
  11688. if (this._displayThumb === value) {
  11689. return;
  11690. }
  11691. this._displayThumb = value;
  11692. this._markAsDirty();
  11693. },
  11694. enumerable: false,
  11695. configurable: true
  11696. });
  11697. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  11698. /**
  11699. * Gets or sets the image used to render the background
  11700. */
  11701. get: function () {
  11702. return this._backgroundImage;
  11703. },
  11704. set: function (value) {
  11705. var _this = this;
  11706. if (this._backgroundImage === value) {
  11707. return;
  11708. }
  11709. this._backgroundImage = value;
  11710. if (value && !value.isLoaded) {
  11711. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11712. }
  11713. this._markAsDirty();
  11714. },
  11715. enumerable: false,
  11716. configurable: true
  11717. });
  11718. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  11719. /**
  11720. * Gets or sets the image used to render the value bar
  11721. */
  11722. get: function () {
  11723. return this._valueBarImage;
  11724. },
  11725. set: function (value) {
  11726. var _this = this;
  11727. if (this._valueBarImage === value) {
  11728. return;
  11729. }
  11730. this._valueBarImage = value;
  11731. if (value && !value.isLoaded) {
  11732. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11733. }
  11734. this._markAsDirty();
  11735. },
  11736. enumerable: false,
  11737. configurable: true
  11738. });
  11739. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  11740. /**
  11741. * Gets or sets the image used to render the thumb
  11742. */
  11743. get: function () {
  11744. return this._thumbImage;
  11745. },
  11746. set: function (value) {
  11747. var _this = this;
  11748. if (this._thumbImage === value) {
  11749. return;
  11750. }
  11751. this._thumbImage = value;
  11752. if (value && !value.isLoaded) {
  11753. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11754. }
  11755. this._markAsDirty();
  11756. },
  11757. enumerable: false,
  11758. configurable: true
  11759. });
  11760. ImageBasedSlider.prototype._getTypeName = function () {
  11761. return "ImageBasedSlider";
  11762. };
  11763. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  11764. context.save();
  11765. this._applyStates(context);
  11766. this._prepareRenderingData("rectangle");
  11767. var thumbPosition = this._getThumbPosition();
  11768. var left = this._renderLeft;
  11769. var top = this._renderTop;
  11770. var width = this._renderWidth;
  11771. var height = this._renderHeight;
  11772. // Background
  11773. if (this._backgroundImage) {
  11774. this._tempMeasure.copyFromFloats(left, top, width, height);
  11775. if (this.isThumbClamped && this.displayThumb) {
  11776. if (this.isVertical) {
  11777. this._tempMeasure.height += this._effectiveThumbThickness;
  11778. }
  11779. else {
  11780. this._tempMeasure.width += this._effectiveThumbThickness;
  11781. }
  11782. }
  11783. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11784. this._backgroundImage._draw(context);
  11785. }
  11786. // Bar
  11787. if (this._valueBarImage) {
  11788. if (this.isVertical) {
  11789. if (this.isThumbClamped && this.displayThumb) {
  11790. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11791. }
  11792. else {
  11793. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  11794. }
  11795. }
  11796. else {
  11797. if (this.isThumbClamped && this.displayThumb) {
  11798. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  11799. }
  11800. else {
  11801. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  11802. }
  11803. }
  11804. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  11805. this._valueBarImage._draw(context);
  11806. }
  11807. // Thumb
  11808. if (this.displayThumb) {
  11809. if (this.isVertical) {
  11810. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11811. }
  11812. else {
  11813. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11814. }
  11815. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11816. this._thumbImage._draw(context);
  11817. }
  11818. context.restore();
  11819. };
  11820. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11821. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["serialize"])()
  11822. ], ImageBasedSlider.prototype, "displayThumb", null);
  11823. return ImageBasedSlider;
  11824. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11825. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  11826. /***/ }),
  11827. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  11828. /*!***********************************************!*\
  11829. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  11830. \***********************************************/
  11831. /*! exports provided: ImageScrollBar */
  11832. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11833. "use strict";
  11834. __webpack_require__.r(__webpack_exports__);
  11835. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  11836. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11837. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11838. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11839. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  11840. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__);
  11841. /**
  11842. * Class used to create slider controls
  11843. */
  11844. var ImageScrollBar = /** @class */ (function (_super) {
  11845. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  11846. /**
  11847. * Creates a new ImageScrollBar
  11848. * @param name defines the control name
  11849. */
  11850. function ImageScrollBar(name) {
  11851. var _this = _super.call(this, name) || this;
  11852. _this.name = name;
  11853. _this._thumbLength = 0.5;
  11854. _this._thumbHeight = 1;
  11855. _this._barImageHeight = 1;
  11856. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11857. /** Number of 90° rotation to apply on the images when in vertical mode */
  11858. _this.num90RotationInVerticalMode = 1;
  11859. return _this;
  11860. }
  11861. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  11862. /**
  11863. * Gets or sets the image used to render the background for horizontal bar
  11864. */
  11865. get: function () {
  11866. return this._backgroundBaseImage;
  11867. },
  11868. set: function (value) {
  11869. var _this = this;
  11870. if (this._backgroundBaseImage === value) {
  11871. return;
  11872. }
  11873. this._backgroundBaseImage = value;
  11874. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11875. if (!value.isLoaded) {
  11876. value.onImageLoadedObservable.addOnce(function () {
  11877. var rotatedValue = value._rotate90(_this.num90RotationInVerticalMode, true);
  11878. _this._backgroundImage = rotatedValue;
  11879. if (!rotatedValue.isLoaded) {
  11880. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11881. _this._markAsDirty();
  11882. });
  11883. }
  11884. _this._markAsDirty();
  11885. });
  11886. }
  11887. else {
  11888. this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);
  11889. this._markAsDirty();
  11890. }
  11891. }
  11892. else {
  11893. this._backgroundImage = value;
  11894. if (value && !value.isLoaded) {
  11895. value.onImageLoadedObservable.addOnce(function () {
  11896. _this._markAsDirty();
  11897. });
  11898. }
  11899. this._markAsDirty();
  11900. }
  11901. },
  11902. enumerable: false,
  11903. configurable: true
  11904. });
  11905. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  11906. /**
  11907. * Gets or sets the image used to render the thumb
  11908. */
  11909. get: function () {
  11910. return this._thumbBaseImage;
  11911. },
  11912. set: function (value) {
  11913. var _this = this;
  11914. if (this._thumbBaseImage === value) {
  11915. return;
  11916. }
  11917. this._thumbBaseImage = value;
  11918. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11919. if (!value.isLoaded) {
  11920. value.onImageLoadedObservable.addOnce(function () {
  11921. var rotatedValue = value._rotate90(-_this.num90RotationInVerticalMode, true);
  11922. _this._thumbImage = rotatedValue;
  11923. if (!rotatedValue.isLoaded) {
  11924. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11925. _this._markAsDirty();
  11926. });
  11927. }
  11928. _this._markAsDirty();
  11929. });
  11930. }
  11931. else {
  11932. this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);
  11933. this._markAsDirty();
  11934. }
  11935. }
  11936. else {
  11937. this._thumbImage = value;
  11938. if (value && !value.isLoaded) {
  11939. value.onImageLoadedObservable.addOnce(function () {
  11940. _this._markAsDirty();
  11941. });
  11942. }
  11943. this._markAsDirty();
  11944. }
  11945. },
  11946. enumerable: false,
  11947. configurable: true
  11948. });
  11949. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  11950. /**
  11951. * Gets or sets the length of the thumb
  11952. */
  11953. get: function () {
  11954. return this._thumbLength;
  11955. },
  11956. set: function (value) {
  11957. if (this._thumbLength === value) {
  11958. return;
  11959. }
  11960. this._thumbLength = value;
  11961. this._markAsDirty();
  11962. },
  11963. enumerable: false,
  11964. configurable: true
  11965. });
  11966. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  11967. /**
  11968. * Gets or sets the height of the thumb
  11969. */
  11970. get: function () {
  11971. return this._thumbHeight;
  11972. },
  11973. set: function (value) {
  11974. if (this._thumbLength === value) {
  11975. return;
  11976. }
  11977. this._thumbHeight = value;
  11978. this._markAsDirty();
  11979. },
  11980. enumerable: false,
  11981. configurable: true
  11982. });
  11983. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  11984. /**
  11985. * Gets or sets the height of the bar image
  11986. */
  11987. get: function () {
  11988. return this._barImageHeight;
  11989. },
  11990. set: function (value) {
  11991. if (this._barImageHeight === value) {
  11992. return;
  11993. }
  11994. this._barImageHeight = value;
  11995. this._markAsDirty();
  11996. },
  11997. enumerable: false,
  11998. configurable: true
  11999. });
  12000. ImageScrollBar.prototype._getTypeName = function () {
  12001. return "ImageScrollBar";
  12002. };
  12003. ImageScrollBar.prototype._getThumbThickness = function () {
  12004. var thumbThickness = 0;
  12005. if (this._thumbWidth.isPixel) {
  12006. thumbThickness = this._thumbWidth.getValue(this._host);
  12007. }
  12008. else {
  12009. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  12010. }
  12011. return thumbThickness;
  12012. };
  12013. ImageScrollBar.prototype._draw = function (context) {
  12014. context.save();
  12015. this._applyStates(context);
  12016. this._prepareRenderingData("rectangle");
  12017. var thumbPosition = this._getThumbPosition();
  12018. var left = this._renderLeft;
  12019. var top = this._renderTop;
  12020. var width = this._renderWidth;
  12021. var height = this._renderHeight;
  12022. // Background
  12023. if (this._backgroundImage) {
  12024. this._tempMeasure.copyFromFloats(left, top, width, height);
  12025. if (this.isVertical) {
  12026. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  12027. this._tempMeasure.height += this._effectiveThumbThickness;
  12028. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  12029. }
  12030. else {
  12031. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  12032. this._tempMeasure.width += this._effectiveThumbThickness;
  12033. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  12034. }
  12035. this._backgroundImage._draw(context);
  12036. }
  12037. // Thumb
  12038. if (this.isVertical) {
  12039. 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);
  12040. }
  12041. else {
  12042. 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);
  12043. }
  12044. if (this._thumbImage) {
  12045. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  12046. this._thumbImage._draw(context);
  12047. }
  12048. context.restore();
  12049. };
  12050. /** @hidden */
  12051. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  12052. if (this.rotation != 0) {
  12053. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  12054. x = this._transformedPosition.x;
  12055. y = this._transformedPosition.y;
  12056. }
  12057. if (this._first) {
  12058. this._first = false;
  12059. this._originX = x;
  12060. this._originY = y;
  12061. // Check if move is required
  12062. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  12063. if (this.isVertical) {
  12064. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  12065. }
  12066. else {
  12067. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  12068. }
  12069. }
  12070. }
  12071. // Delta mode
  12072. var delta = 0;
  12073. if (this.isVertical) {
  12074. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  12075. }
  12076. else {
  12077. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  12078. }
  12079. this.value += delta * (this.maximum - this.minimum);
  12080. this._originX = x;
  12081. this._originY = y;
  12082. };
  12083. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  12084. this._first = true;
  12085. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi);
  12086. };
  12087. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12088. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"])()
  12089. ], ImageScrollBar.prototype, "num90RotationInVerticalMode", void 0);
  12090. return ImageScrollBar;
  12091. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  12092. /***/ }),
  12093. /***/ "./2D/controls/sliders/scrollBar.ts":
  12094. /*!******************************************!*\
  12095. !*** ./2D/controls/sliders/scrollBar.ts ***!
  12096. \******************************************/
  12097. /*! exports provided: ScrollBar */
  12098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12099. "use strict";
  12100. __webpack_require__.r(__webpack_exports__);
  12101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  12102. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12103. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  12104. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  12105. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  12106. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__);
  12107. /**
  12108. * Class used to create slider controls
  12109. */
  12110. var ScrollBar = /** @class */ (function (_super) {
  12111. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  12112. /**
  12113. * Creates a new Slider
  12114. * @param name defines the control name
  12115. */
  12116. function ScrollBar(name) {
  12117. var _this = _super.call(this, name) || this;
  12118. _this.name = name;
  12119. _this._background = "black";
  12120. _this._borderColor = "white";
  12121. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  12122. return _this;
  12123. }
  12124. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  12125. /** Gets or sets border color */
  12126. get: function () {
  12127. return this._borderColor;
  12128. },
  12129. set: function (value) {
  12130. if (this._borderColor === value) {
  12131. return;
  12132. }
  12133. this._borderColor = value;
  12134. this._markAsDirty();
  12135. },
  12136. enumerable: false,
  12137. configurable: true
  12138. });
  12139. Object.defineProperty(ScrollBar.prototype, "background", {
  12140. /** Gets or sets background color */
  12141. get: function () {
  12142. return this._background;
  12143. },
  12144. set: function (value) {
  12145. if (this._background === value) {
  12146. return;
  12147. }
  12148. this._background = value;
  12149. this._markAsDirty();
  12150. },
  12151. enumerable: false,
  12152. configurable: true
  12153. });
  12154. ScrollBar.prototype._getTypeName = function () {
  12155. return "Scrollbar";
  12156. };
  12157. ScrollBar.prototype._getThumbThickness = function () {
  12158. var thumbThickness = 0;
  12159. if (this._thumbWidth.isPixel) {
  12160. thumbThickness = this._thumbWidth.getValue(this._host);
  12161. }
  12162. else {
  12163. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  12164. }
  12165. return thumbThickness;
  12166. };
  12167. ScrollBar.prototype._draw = function (context) {
  12168. context.save();
  12169. this._applyStates(context);
  12170. this._prepareRenderingData("rectangle");
  12171. var left = this._renderLeft;
  12172. var thumbPosition = this._getThumbPosition();
  12173. context.fillStyle = this._background;
  12174. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  12175. // Value bar
  12176. context.fillStyle = this.color;
  12177. // Thumb
  12178. if (this.isVertical) {
  12179. this._tempMeasure.left = left - this._effectiveBarOffset;
  12180. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  12181. this._tempMeasure.width = this._currentMeasure.width;
  12182. this._tempMeasure.height = this._effectiveThumbThickness;
  12183. }
  12184. else {
  12185. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  12186. this._tempMeasure.top = this._currentMeasure.top;
  12187. this._tempMeasure.width = this._effectiveThumbThickness;
  12188. this._tempMeasure.height = this._currentMeasure.height;
  12189. }
  12190. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  12191. context.restore();
  12192. };
  12193. /** @hidden */
  12194. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  12195. if (this.rotation != 0) {
  12196. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  12197. x = this._transformedPosition.x;
  12198. y = this._transformedPosition.y;
  12199. }
  12200. if (this._first) {
  12201. this._first = false;
  12202. this._originX = x;
  12203. this._originY = y;
  12204. // Check if move is required
  12205. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  12206. if (this.isVertical) {
  12207. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  12208. }
  12209. else {
  12210. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  12211. }
  12212. }
  12213. }
  12214. // Delta mode
  12215. var delta = 0;
  12216. if (this.isVertical) {
  12217. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  12218. }
  12219. else {
  12220. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  12221. }
  12222. this.value += delta * (this.maximum - this.minimum);
  12223. this._originX = x;
  12224. this._originY = y;
  12225. };
  12226. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  12227. this._first = true;
  12228. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi);
  12229. };
  12230. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12231. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"])()
  12232. ], ScrollBar.prototype, "borderColor", null);
  12233. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12234. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"])()
  12235. ], ScrollBar.prototype, "background", null);
  12236. return ScrollBar;
  12237. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  12238. /***/ }),
  12239. /***/ "./2D/controls/sliders/slider.ts":
  12240. /*!***************************************!*\
  12241. !*** ./2D/controls/sliders/slider.ts ***!
  12242. \***************************************/
  12243. /*! exports provided: Slider */
  12244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12245. "use strict";
  12246. __webpack_require__.r(__webpack_exports__);
  12247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  12248. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12249. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  12250. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  12251. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  12252. /**
  12253. * Class used to create slider controls
  12254. */
  12255. var Slider = /** @class */ (function (_super) {
  12256. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  12257. /**
  12258. * Creates a new Slider
  12259. * @param name defines the control name
  12260. */
  12261. function Slider(name) {
  12262. var _this = _super.call(this, name) || this;
  12263. _this.name = name;
  12264. _this._background = "black";
  12265. _this._borderColor = "white";
  12266. _this._thumbColor = "";
  12267. _this._isThumbCircle = false;
  12268. _this._displayValueBar = true;
  12269. return _this;
  12270. }
  12271. Object.defineProperty(Slider.prototype, "displayValueBar", {
  12272. /** Gets or sets a boolean indicating if the value bar must be rendered */
  12273. get: function () {
  12274. return this._displayValueBar;
  12275. },
  12276. set: function (value) {
  12277. if (this._displayValueBar === value) {
  12278. return;
  12279. }
  12280. this._displayValueBar = value;
  12281. this._markAsDirty();
  12282. },
  12283. enumerable: false,
  12284. configurable: true
  12285. });
  12286. Object.defineProperty(Slider.prototype, "borderColor", {
  12287. /** Gets or sets border color */
  12288. get: function () {
  12289. return this._borderColor;
  12290. },
  12291. set: function (value) {
  12292. if (this._borderColor === value) {
  12293. return;
  12294. }
  12295. this._borderColor = value;
  12296. this._markAsDirty();
  12297. },
  12298. enumerable: false,
  12299. configurable: true
  12300. });
  12301. Object.defineProperty(Slider.prototype, "background", {
  12302. /** Gets or sets background color */
  12303. get: function () {
  12304. return this._background;
  12305. },
  12306. set: function (value) {
  12307. if (this._background === value) {
  12308. return;
  12309. }
  12310. this._background = value;
  12311. this._markAsDirty();
  12312. },
  12313. enumerable: false,
  12314. configurable: true
  12315. });
  12316. Object.defineProperty(Slider.prototype, "thumbColor", {
  12317. /** Gets or sets thumb's color */
  12318. get: function () {
  12319. return this._thumbColor;
  12320. },
  12321. set: function (value) {
  12322. if (this._thumbColor === value) {
  12323. return;
  12324. }
  12325. this._thumbColor = value;
  12326. this._markAsDirty();
  12327. },
  12328. enumerable: false,
  12329. configurable: true
  12330. });
  12331. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  12332. /** Gets or sets a boolean indicating if the thumb should be round or square */
  12333. get: function () {
  12334. return this._isThumbCircle;
  12335. },
  12336. set: function (value) {
  12337. if (this._isThumbCircle === value) {
  12338. return;
  12339. }
  12340. this._isThumbCircle = value;
  12341. this._markAsDirty();
  12342. },
  12343. enumerable: false,
  12344. configurable: true
  12345. });
  12346. Slider.prototype._getTypeName = function () {
  12347. return "Slider";
  12348. };
  12349. Slider.prototype._draw = function (context, invalidatedRectangle) {
  12350. context.save();
  12351. this._applyStates(context);
  12352. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  12353. var left = this._renderLeft;
  12354. var top = this._renderTop;
  12355. var width = this._renderWidth;
  12356. var height = this._renderHeight;
  12357. var radius = 0;
  12358. if (this.isThumbClamped && this.isThumbCircle) {
  12359. if (this.isVertical) {
  12360. top += (this._effectiveThumbThickness / 2);
  12361. }
  12362. else {
  12363. left += (this._effectiveThumbThickness / 2);
  12364. }
  12365. radius = this._backgroundBoxThickness / 2;
  12366. }
  12367. else {
  12368. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  12369. }
  12370. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12371. context.shadowColor = this.shadowColor;
  12372. context.shadowBlur = this.shadowBlur;
  12373. context.shadowOffsetX = this.shadowOffsetX;
  12374. context.shadowOffsetY = this.shadowOffsetY;
  12375. }
  12376. var thumbPosition = this._getThumbPosition();
  12377. context.fillStyle = this._background;
  12378. if (this.isVertical) {
  12379. if (this.isThumbClamped) {
  12380. if (this.isThumbCircle) {
  12381. context.beginPath();
  12382. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  12383. context.fill();
  12384. context.fillRect(left, top, width, height);
  12385. }
  12386. else {
  12387. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  12388. }
  12389. }
  12390. else {
  12391. context.fillRect(left, top, width, height);
  12392. }
  12393. }
  12394. else {
  12395. if (this.isThumbClamped) {
  12396. if (this.isThumbCircle) {
  12397. context.beginPath();
  12398. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  12399. context.fill();
  12400. context.fillRect(left, top, width, height);
  12401. }
  12402. else {
  12403. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  12404. }
  12405. }
  12406. else {
  12407. context.fillRect(left, top, width, height);
  12408. }
  12409. }
  12410. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12411. context.shadowBlur = 0;
  12412. context.shadowOffsetX = 0;
  12413. context.shadowOffsetY = 0;
  12414. }
  12415. // Value bar
  12416. context.fillStyle = this.color;
  12417. if (this._displayValueBar) {
  12418. if (this.isVertical) {
  12419. if (this.isThumbClamped) {
  12420. if (this.isThumbCircle) {
  12421. context.beginPath();
  12422. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  12423. context.fill();
  12424. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  12425. }
  12426. else {
  12427. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  12428. }
  12429. }
  12430. else {
  12431. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  12432. }
  12433. }
  12434. else {
  12435. if (this.isThumbClamped) {
  12436. if (this.isThumbCircle) {
  12437. context.beginPath();
  12438. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  12439. context.fill();
  12440. context.fillRect(left, top, thumbPosition, height);
  12441. }
  12442. else {
  12443. context.fillRect(left, top, thumbPosition, height);
  12444. }
  12445. }
  12446. else {
  12447. context.fillRect(left, top, thumbPosition, height);
  12448. }
  12449. }
  12450. }
  12451. // Thumb
  12452. context.fillStyle = this._thumbColor || this.color;
  12453. if (this.displayThumb) {
  12454. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12455. context.shadowColor = this.shadowColor;
  12456. context.shadowBlur = this.shadowBlur;
  12457. context.shadowOffsetX = this.shadowOffsetX;
  12458. context.shadowOffsetY = this.shadowOffsetY;
  12459. }
  12460. if (this._isThumbCircle) {
  12461. context.beginPath();
  12462. if (this.isVertical) {
  12463. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  12464. }
  12465. else {
  12466. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  12467. }
  12468. context.fill();
  12469. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12470. context.shadowBlur = 0;
  12471. context.shadowOffsetX = 0;
  12472. context.shadowOffsetY = 0;
  12473. }
  12474. context.strokeStyle = this._borderColor;
  12475. context.stroke();
  12476. }
  12477. else {
  12478. if (this.isVertical) {
  12479. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  12480. }
  12481. else {
  12482. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  12483. }
  12484. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12485. context.shadowBlur = 0;
  12486. context.shadowOffsetX = 0;
  12487. context.shadowOffsetY = 0;
  12488. }
  12489. context.strokeStyle = this._borderColor;
  12490. if (this.isVertical) {
  12491. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  12492. }
  12493. else {
  12494. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  12495. }
  12496. }
  12497. }
  12498. context.restore();
  12499. };
  12500. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12501. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  12502. ], Slider.prototype, "displayValueBar", null);
  12503. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12504. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  12505. ], Slider.prototype, "borderColor", null);
  12506. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12507. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  12508. ], Slider.prototype, "background", null);
  12509. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12510. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  12511. ], Slider.prototype, "thumbColor", null);
  12512. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12513. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  12514. ], Slider.prototype, "isThumbCircle", null);
  12515. return Slider;
  12516. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  12517. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  12518. /***/ }),
  12519. /***/ "./2D/controls/stackPanel.ts":
  12520. /*!***********************************!*\
  12521. !*** ./2D/controls/stackPanel.ts ***!
  12522. \***********************************/
  12523. /*! exports provided: StackPanel */
  12524. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12525. "use strict";
  12526. __webpack_require__.r(__webpack_exports__);
  12527. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  12528. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12529. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  12530. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  12531. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  12532. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12533. /**
  12534. * Class used to create a 2D stack panel container
  12535. */
  12536. var StackPanel = /** @class */ (function (_super) {
  12537. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  12538. /**
  12539. * Creates a new StackPanel
  12540. * @param name defines control name
  12541. */
  12542. function StackPanel(name) {
  12543. var _this = _super.call(this, name) || this;
  12544. _this.name = name;
  12545. _this._isVertical = true;
  12546. _this._manualWidth = false;
  12547. _this._manualHeight = false;
  12548. _this._doNotTrackManualChanges = false;
  12549. /**
  12550. * Gets or sets a boolean indicating that layou warnings should be ignored
  12551. */
  12552. _this.ignoreLayoutWarnings = false;
  12553. return _this;
  12554. }
  12555. Object.defineProperty(StackPanel.prototype, "isVertical", {
  12556. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  12557. get: function () {
  12558. return this._isVertical;
  12559. },
  12560. set: function (value) {
  12561. if (this._isVertical === value) {
  12562. return;
  12563. }
  12564. this._isVertical = value;
  12565. this._markAsDirty();
  12566. },
  12567. enumerable: false,
  12568. configurable: true
  12569. });
  12570. Object.defineProperty(StackPanel.prototype, "width", {
  12571. get: function () {
  12572. return this._width.toString(this._host);
  12573. },
  12574. /**
  12575. * Gets or sets panel width.
  12576. * This value should not be set when in horizontal mode as it will be computed automatically
  12577. */
  12578. set: function (value) {
  12579. if (!this._doNotTrackManualChanges) {
  12580. this._manualWidth = true;
  12581. }
  12582. if (this._width.toString(this._host) === value) {
  12583. return;
  12584. }
  12585. if (this._width.fromString(value)) {
  12586. this._markAsDirty();
  12587. }
  12588. },
  12589. enumerable: false,
  12590. configurable: true
  12591. });
  12592. Object.defineProperty(StackPanel.prototype, "height", {
  12593. get: function () {
  12594. return this._height.toString(this._host);
  12595. },
  12596. /**
  12597. * Gets or sets panel height.
  12598. * This value should not be set when in vertical mode as it will be computed automatically
  12599. */
  12600. set: function (value) {
  12601. if (!this._doNotTrackManualChanges) {
  12602. this._manualHeight = true;
  12603. }
  12604. if (this._height.toString(this._host) === value) {
  12605. return;
  12606. }
  12607. if (this._height.fromString(value)) {
  12608. this._markAsDirty();
  12609. }
  12610. },
  12611. enumerable: false,
  12612. configurable: true
  12613. });
  12614. StackPanel.prototype._getTypeName = function () {
  12615. return "StackPanel";
  12616. };
  12617. /** @hidden */
  12618. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  12619. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12620. var child = _a[_i];
  12621. if (this._isVertical) {
  12622. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  12623. }
  12624. else {
  12625. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  12626. }
  12627. }
  12628. _super.prototype._preMeasure.call(this, parentMeasure, context);
  12629. };
  12630. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  12631. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  12632. this._measureForChildren.copyFrom(parentMeasure);
  12633. this._measureForChildren.left = this._currentMeasure.left;
  12634. this._measureForChildren.top = this._currentMeasure.top;
  12635. if (!this.isVertical || this._manualWidth) {
  12636. this._measureForChildren.width = this._currentMeasure.width;
  12637. }
  12638. if (this.isVertical || this._manualHeight) {
  12639. this._measureForChildren.height = this._currentMeasure.height;
  12640. }
  12641. };
  12642. StackPanel.prototype._postMeasure = function () {
  12643. var stackWidth = 0;
  12644. var stackHeight = 0;
  12645. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12646. var child = _a[_i];
  12647. if (!child.isVisible || child.notRenderable) {
  12648. continue;
  12649. }
  12650. if (this._isVertical) {
  12651. if (child.top !== stackHeight + "px") {
  12652. child.top = stackHeight + "px";
  12653. this._rebuildLayout = true;
  12654. child._top.ignoreAdaptiveScaling = true;
  12655. }
  12656. if (child._height.isPercentage && !child._automaticSize) {
  12657. if (!this.ignoreLayoutWarnings) {
  12658. 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");
  12659. }
  12660. }
  12661. else {
  12662. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  12663. }
  12664. }
  12665. else {
  12666. if (child.left !== stackWidth + "px") {
  12667. child.left = stackWidth + "px";
  12668. this._rebuildLayout = true;
  12669. child._left.ignoreAdaptiveScaling = true;
  12670. }
  12671. if (child._width.isPercentage && !child._automaticSize) {
  12672. if (!this.ignoreLayoutWarnings) {
  12673. 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");
  12674. }
  12675. }
  12676. else {
  12677. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  12678. }
  12679. }
  12680. }
  12681. stackWidth += this.paddingLeftInPixels + this.paddingRightInPixels;
  12682. stackHeight += this.paddingTopInPixels + this.paddingBottomInPixels;
  12683. this._doNotTrackManualChanges = true;
  12684. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  12685. // User can now define their own height and width for stack panel.
  12686. var panelWidthChanged = false;
  12687. var panelHeightChanged = false;
  12688. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  12689. var previousHeight = this.height;
  12690. this.height = stackHeight + "px";
  12691. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  12692. }
  12693. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  12694. var previousWidth = this.width;
  12695. this.width = stackWidth + "px";
  12696. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  12697. }
  12698. if (panelHeightChanged) {
  12699. this._height.ignoreAdaptiveScaling = true;
  12700. }
  12701. if (panelWidthChanged) {
  12702. this._width.ignoreAdaptiveScaling = true;
  12703. }
  12704. this._doNotTrackManualChanges = false;
  12705. if (panelWidthChanged || panelHeightChanged) {
  12706. this._rebuildLayout = true;
  12707. }
  12708. _super.prototype._postMeasure.call(this);
  12709. };
  12710. /**
  12711. * Serializes the current control
  12712. * @param serializationObject defined the JSON serialized object
  12713. */
  12714. StackPanel.prototype.serialize = function (serializationObject) {
  12715. _super.prototype.serialize.call(this, serializationObject);
  12716. serializationObject.manualWidth = this._manualWidth;
  12717. serializationObject.manualHeight = this._manualHeight;
  12718. };
  12719. /** @hidden */
  12720. StackPanel.prototype._parseFromContent = function (serializedObject, host) {
  12721. this._manualWidth = serializedObject.manualWidth;
  12722. this._manualHeight = serializedObject.manualHeight;
  12723. _super.prototype._parseFromContent.call(this, serializedObject, host);
  12724. };
  12725. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12726. Object(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12727. ], StackPanel.prototype, "ignoreLayoutWarnings", void 0);
  12728. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12729. Object(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12730. ], StackPanel.prototype, "isVertical", null);
  12731. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12732. Object(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12733. ], StackPanel.prototype, "width", null);
  12734. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12735. Object(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12736. ], StackPanel.prototype, "height", null);
  12737. return StackPanel;
  12738. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  12739. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  12740. /***/ }),
  12741. /***/ "./2D/controls/statics.ts":
  12742. /*!********************************!*\
  12743. !*** ./2D/controls/statics.ts ***!
  12744. \********************************/
  12745. /*! exports provided: name */
  12746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12747. "use strict";
  12748. __webpack_require__.r(__webpack_exports__);
  12749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  12750. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12751. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12752. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  12753. /**
  12754. * Forcing an export so that this code will execute
  12755. * @hidden
  12756. */
  12757. var name = "Statics";
  12758. /**
  12759. * Creates a stack panel that can be used to render headers
  12760. * @param control defines the control to associate with the header
  12761. * @param text defines the text of the header
  12762. * @param size defines the size of the header
  12763. * @param options defines options used to configure the header
  12764. * @returns a new StackPanel
  12765. */
  12766. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  12767. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  12768. var isHorizontal = options ? options.isHorizontal : true;
  12769. var controlFirst = options ? options.controlFirst : true;
  12770. panel.isVertical = !isHorizontal;
  12771. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  12772. header.text = text;
  12773. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  12774. if (isHorizontal) {
  12775. header.width = size;
  12776. }
  12777. else {
  12778. header.height = size;
  12779. }
  12780. if (controlFirst) {
  12781. panel.addControl(control);
  12782. panel.addControl(header);
  12783. header.paddingLeft = "5px";
  12784. }
  12785. else {
  12786. panel.addControl(header);
  12787. panel.addControl(control);
  12788. header.paddingRight = "5px";
  12789. }
  12790. header.shadowBlur = control.shadowBlur;
  12791. header.shadowColor = control.shadowColor;
  12792. header.shadowOffsetX = control.shadowOffsetX;
  12793. header.shadowOffsetY = control.shadowOffsetY;
  12794. return panel;
  12795. };
  12796. /***/ }),
  12797. /***/ "./2D/controls/textBlock.ts":
  12798. /*!**********************************!*\
  12799. !*** ./2D/controls/textBlock.ts ***!
  12800. \**********************************/
  12801. /*! exports provided: TextWrapping, TextBlock */
  12802. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12803. "use strict";
  12804. __webpack_require__.r(__webpack_exports__);
  12805. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  12806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  12807. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12808. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12809. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12810. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  12811. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12812. /**
  12813. * Enum that determines the text-wrapping mode to use.
  12814. */
  12815. var TextWrapping;
  12816. (function (TextWrapping) {
  12817. /**
  12818. * Clip the text when it's larger than Control.width; this is the default mode.
  12819. */
  12820. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  12821. /**
  12822. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  12823. */
  12824. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  12825. /**
  12826. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  12827. */
  12828. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  12829. })(TextWrapping || (TextWrapping = {}));
  12830. /**
  12831. * Class used to create text block control
  12832. */
  12833. var TextBlock = /** @class */ (function (_super) {
  12834. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  12835. /**
  12836. * Creates a new TextBlock object
  12837. * @param name defines the name of the control
  12838. * @param text defines the text to display (emptry string by default)
  12839. */
  12840. function TextBlock(
  12841. /**
  12842. * Defines the name of the control
  12843. */
  12844. name, text) {
  12845. if (text === void 0) { text = ""; }
  12846. var _this = _super.call(this, name) || this;
  12847. _this.name = name;
  12848. _this._text = "";
  12849. _this._textWrapping = TextWrapping.Clip;
  12850. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  12851. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  12852. _this._resizeToFit = false;
  12853. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  12854. _this._outlineWidth = 0;
  12855. _this._outlineColor = "white";
  12856. _this._underline = false;
  12857. _this._lineThrough = false;
  12858. /**
  12859. * An event triggered after the text is changed
  12860. */
  12861. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12862. /**
  12863. * An event triggered after the text was broken up into lines
  12864. */
  12865. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12866. _this.text = text;
  12867. return _this;
  12868. }
  12869. Object.defineProperty(TextBlock.prototype, "lines", {
  12870. /**
  12871. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  12872. */
  12873. get: function () {
  12874. return this._lines;
  12875. },
  12876. enumerable: false,
  12877. configurable: true
  12878. });
  12879. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  12880. /**
  12881. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12882. */
  12883. get: function () {
  12884. return this._resizeToFit;
  12885. },
  12886. /**
  12887. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12888. */
  12889. set: function (value) {
  12890. if (this._resizeToFit === value) {
  12891. return;
  12892. }
  12893. this._resizeToFit = value;
  12894. if (this._resizeToFit) {
  12895. this._width.ignoreAdaptiveScaling = true;
  12896. this._height.ignoreAdaptiveScaling = true;
  12897. }
  12898. this._markAsDirty();
  12899. },
  12900. enumerable: false,
  12901. configurable: true
  12902. });
  12903. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  12904. /**
  12905. * Gets or sets a boolean indicating if text must be wrapped
  12906. */
  12907. get: function () {
  12908. return this._textWrapping;
  12909. },
  12910. /**
  12911. * Gets or sets a boolean indicating if text must be wrapped
  12912. */
  12913. set: function (value) {
  12914. if (this._textWrapping === value) {
  12915. return;
  12916. }
  12917. this._textWrapping = +value;
  12918. this._markAsDirty();
  12919. },
  12920. enumerable: false,
  12921. configurable: true
  12922. });
  12923. Object.defineProperty(TextBlock.prototype, "text", {
  12924. /**
  12925. * Gets or sets text to display
  12926. */
  12927. get: function () {
  12928. return this._text;
  12929. },
  12930. /**
  12931. * Gets or sets text to display
  12932. */
  12933. set: function (value) {
  12934. if (this._text === value) {
  12935. return;
  12936. }
  12937. this._text = value;
  12938. this._markAsDirty();
  12939. this.onTextChangedObservable.notifyObservers(this);
  12940. },
  12941. enumerable: false,
  12942. configurable: true
  12943. });
  12944. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  12945. /**
  12946. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12947. */
  12948. get: function () {
  12949. return this._textHorizontalAlignment;
  12950. },
  12951. /**
  12952. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12953. */
  12954. set: function (value) {
  12955. if (this._textHorizontalAlignment === value) {
  12956. return;
  12957. }
  12958. this._textHorizontalAlignment = value;
  12959. this._markAsDirty();
  12960. },
  12961. enumerable: false,
  12962. configurable: true
  12963. });
  12964. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  12965. /**
  12966. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12967. */
  12968. get: function () {
  12969. return this._textVerticalAlignment;
  12970. },
  12971. /**
  12972. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12973. */
  12974. set: function (value) {
  12975. if (this._textVerticalAlignment === value) {
  12976. return;
  12977. }
  12978. this._textVerticalAlignment = value;
  12979. this._markAsDirty();
  12980. },
  12981. enumerable: false,
  12982. configurable: true
  12983. });
  12984. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  12985. /**
  12986. * Gets or sets line spacing value
  12987. */
  12988. get: function () {
  12989. return this._lineSpacing.toString(this._host);
  12990. },
  12991. /**
  12992. * Gets or sets line spacing value
  12993. */
  12994. set: function (value) {
  12995. if (this._lineSpacing.fromString(value)) {
  12996. this._markAsDirty();
  12997. }
  12998. },
  12999. enumerable: false,
  13000. configurable: true
  13001. });
  13002. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  13003. /**
  13004. * Gets or sets outlineWidth of the text to display
  13005. */
  13006. get: function () {
  13007. return this._outlineWidth;
  13008. },
  13009. /**
  13010. * Gets or sets outlineWidth of the text to display
  13011. */
  13012. set: function (value) {
  13013. if (this._outlineWidth === value) {
  13014. return;
  13015. }
  13016. this._outlineWidth = value;
  13017. this._markAsDirty();
  13018. },
  13019. enumerable: false,
  13020. configurable: true
  13021. });
  13022. Object.defineProperty(TextBlock.prototype, "underline", {
  13023. /**
  13024. * Gets or sets a boolean indicating that text must have underline
  13025. */
  13026. get: function () {
  13027. return this._underline;
  13028. },
  13029. /**
  13030. * Gets or sets a boolean indicating that text must have underline
  13031. */
  13032. set: function (value) {
  13033. if (this._underline === value) {
  13034. return;
  13035. }
  13036. this._underline = value;
  13037. this._markAsDirty();
  13038. },
  13039. enumerable: false,
  13040. configurable: true
  13041. });
  13042. Object.defineProperty(TextBlock.prototype, "lineThrough", {
  13043. /**
  13044. * Gets or sets an boolean indicating that text must be crossed out
  13045. */
  13046. get: function () {
  13047. return this._lineThrough;
  13048. },
  13049. /**
  13050. * Gets or sets an boolean indicating that text must be crossed out
  13051. */
  13052. set: function (value) {
  13053. if (this._lineThrough === value) {
  13054. return;
  13055. }
  13056. this._lineThrough = value;
  13057. this._markAsDirty();
  13058. },
  13059. enumerable: false,
  13060. configurable: true
  13061. });
  13062. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  13063. /**
  13064. * Gets or sets outlineColor of the text to display
  13065. */
  13066. get: function () {
  13067. return this._outlineColor;
  13068. },
  13069. /**
  13070. * Gets or sets outlineColor of the text to display
  13071. */
  13072. set: function (value) {
  13073. if (this._outlineColor === value) {
  13074. return;
  13075. }
  13076. this._outlineColor = value;
  13077. this._markAsDirty();
  13078. },
  13079. enumerable: false,
  13080. configurable: true
  13081. });
  13082. TextBlock.prototype._getTypeName = function () {
  13083. return "TextBlock";
  13084. };
  13085. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  13086. if (!this._fontOffset) {
  13087. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  13088. }
  13089. _super.prototype._processMeasures.call(this, parentMeasure, context);
  13090. // Prepare lines
  13091. this._lines = this._breakLines(this._currentMeasure.width, context);
  13092. this.onLinesReadyObservable.notifyObservers(this);
  13093. var maxLineWidth = 0;
  13094. for (var i = 0; i < this._lines.length; i++) {
  13095. var line = this._lines[i];
  13096. if (line.width > maxLineWidth) {
  13097. maxLineWidth = line.width;
  13098. }
  13099. }
  13100. if (this._resizeToFit) {
  13101. if (this._textWrapping === TextWrapping.Clip) {
  13102. var newWidth = (this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth) | 0;
  13103. if (newWidth !== this._width.internalValue) {
  13104. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  13105. this._rebuildLayout = true;
  13106. }
  13107. }
  13108. var newHeight = (this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length) | 0;
  13109. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  13110. var lineSpacing = 0;
  13111. if (this._lineSpacing.isPixel) {
  13112. lineSpacing = this._lineSpacing.getValue(this._host);
  13113. }
  13114. else {
  13115. lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  13116. }
  13117. newHeight += (this._lines.length - 1) * lineSpacing;
  13118. }
  13119. if (newHeight !== this._height.internalValue) {
  13120. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  13121. this._rebuildLayout = true;
  13122. }
  13123. }
  13124. };
  13125. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  13126. var width = this._currentMeasure.width;
  13127. var x = 0;
  13128. switch (this._textHorizontalAlignment) {
  13129. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  13130. x = 0;
  13131. break;
  13132. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  13133. x = width - textWidth;
  13134. break;
  13135. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  13136. x = (width - textWidth) / 2;
  13137. break;
  13138. }
  13139. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  13140. context.shadowColor = this.shadowColor;
  13141. context.shadowBlur = this.shadowBlur;
  13142. context.shadowOffsetX = this.shadowOffsetX;
  13143. context.shadowOffsetY = this.shadowOffsetY;
  13144. }
  13145. if (this.outlineWidth) {
  13146. context.strokeText(text, this._currentMeasure.left + x, y);
  13147. }
  13148. context.fillText(text, this._currentMeasure.left + x, y);
  13149. if (this._underline) {
  13150. context.beginPath();
  13151. context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
  13152. context.moveTo(this._currentMeasure.left + x, y + 3);
  13153. context.lineTo(this._currentMeasure.left + x + textWidth, y + 3);
  13154. context.stroke();
  13155. context.closePath();
  13156. }
  13157. if (this._lineThrough) {
  13158. context.beginPath();
  13159. context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
  13160. context.moveTo(this._currentMeasure.left + x, y - this.fontSizeInPixels / 3);
  13161. context.lineTo(this._currentMeasure.left + x + textWidth, y - this.fontSizeInPixels / 3);
  13162. context.stroke();
  13163. context.closePath();
  13164. }
  13165. };
  13166. /** @hidden */
  13167. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  13168. context.save();
  13169. this._applyStates(context);
  13170. // Render lines
  13171. this._renderLines(context);
  13172. context.restore();
  13173. };
  13174. TextBlock.prototype._applyStates = function (context) {
  13175. _super.prototype._applyStates.call(this, context);
  13176. if (this.outlineWidth) {
  13177. context.lineWidth = this.outlineWidth;
  13178. context.strokeStyle = this.outlineColor;
  13179. context.lineJoin = 'miter';
  13180. context.miterLimit = 2;
  13181. }
  13182. };
  13183. TextBlock.prototype._breakLines = function (refWidth, context) {
  13184. var lines = [];
  13185. var _lines = this.text.split("\n");
  13186. if (this._textWrapping === TextWrapping.Ellipsis) {
  13187. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  13188. var _line = _lines_1[_i];
  13189. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  13190. }
  13191. }
  13192. else if (this._textWrapping === TextWrapping.WordWrap) {
  13193. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  13194. var _line = _lines_2[_a];
  13195. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  13196. }
  13197. }
  13198. else {
  13199. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  13200. var _line = _lines_3[_b];
  13201. lines.push(this._parseLine(_line, context));
  13202. }
  13203. }
  13204. return lines;
  13205. };
  13206. TextBlock.prototype._parseLine = function (line, context) {
  13207. if (line === void 0) { line = ""; }
  13208. return { text: line, width: context.measureText(line).width };
  13209. };
  13210. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  13211. if (line === void 0) { line = ""; }
  13212. var lineWidth = context.measureText(line).width;
  13213. if (lineWidth > width) {
  13214. line += "…";
  13215. }
  13216. // unicode support. split('') does not work with unicode!
  13217. // make sure Array.from is available
  13218. var characters = Array.from && Array.from(line);
  13219. if (!characters) {
  13220. // no array.from, use the old method
  13221. while (line.length > 2 && lineWidth > width) {
  13222. line = line.slice(0, -2) + "…";
  13223. lineWidth = context.measureText(line).width;
  13224. }
  13225. }
  13226. else {
  13227. while (characters.length && lineWidth > width) {
  13228. characters.pop();
  13229. line = characters.join("") + "...";
  13230. lineWidth = context.measureText(line).width;
  13231. }
  13232. }
  13233. return { text: line, width: lineWidth };
  13234. };
  13235. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  13236. if (line === void 0) { line = ""; }
  13237. var lines = [];
  13238. var words = this.wordSplittingFunction ? this.wordSplittingFunction(line) : line.split(" ");
  13239. var lineWidth = 0;
  13240. for (var n = 0; n < words.length; n++) {
  13241. var testLine = n > 0 ? line + " " + words[n] : words[0];
  13242. var metrics = context.measureText(testLine);
  13243. var testWidth = metrics.width;
  13244. if (testWidth > width && n > 0) {
  13245. lines.push({ text: line, width: lineWidth });
  13246. line = words[n];
  13247. lineWidth = context.measureText(line).width;
  13248. }
  13249. else {
  13250. lineWidth = testWidth;
  13251. line = testLine;
  13252. }
  13253. }
  13254. lines.push({ text: line, width: lineWidth });
  13255. return lines;
  13256. };
  13257. TextBlock.prototype._renderLines = function (context) {
  13258. var height = this._currentMeasure.height;
  13259. var rootY = 0;
  13260. switch (this._textVerticalAlignment) {
  13261. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  13262. rootY = this._fontOffset.ascent;
  13263. break;
  13264. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  13265. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  13266. break;
  13267. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  13268. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  13269. break;
  13270. }
  13271. rootY += this._currentMeasure.top;
  13272. for (var i = 0; i < this._lines.length; i++) {
  13273. var line = this._lines[i];
  13274. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  13275. if (this._lineSpacing.isPixel) {
  13276. rootY += this._lineSpacing.getValue(this._host);
  13277. }
  13278. else {
  13279. rootY = rootY + this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  13280. }
  13281. }
  13282. this._drawText(line.text, line.width, rootY, context);
  13283. rootY += this._fontOffset.height;
  13284. }
  13285. };
  13286. /**
  13287. * Given a width constraint applied on the text block, find the expected height
  13288. * @returns expected height
  13289. */
  13290. TextBlock.prototype.computeExpectedHeight = function () {
  13291. if (this.text && this.widthInPixels) {
  13292. var context_1 = document.createElement("canvas").getContext("2d");
  13293. if (context_1) {
  13294. this._applyStates(context_1);
  13295. if (!this._fontOffset) {
  13296. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  13297. }
  13298. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  13299. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  13300. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  13301. var lineSpacing = 0;
  13302. if (this._lineSpacing.isPixel) {
  13303. lineSpacing = this._lineSpacing.getValue(this._host);
  13304. }
  13305. else {
  13306. lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  13307. }
  13308. newHeight += (lines.length - 1) * lineSpacing;
  13309. }
  13310. return newHeight;
  13311. }
  13312. }
  13313. return 0;
  13314. };
  13315. TextBlock.prototype.dispose = function () {
  13316. _super.prototype.dispose.call(this);
  13317. this.onTextChangedObservable.clear();
  13318. };
  13319. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13320. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13321. ], TextBlock.prototype, "resizeToFit", null);
  13322. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13323. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13324. ], TextBlock.prototype, "textWrapping", null);
  13325. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13326. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13327. ], TextBlock.prototype, "text", null);
  13328. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13329. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13330. ], TextBlock.prototype, "textHorizontalAlignment", null);
  13331. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13332. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13333. ], TextBlock.prototype, "textVerticalAlignment", null);
  13334. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13335. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13336. ], TextBlock.prototype, "lineSpacing", null);
  13337. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13338. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13339. ], TextBlock.prototype, "outlineWidth", null);
  13340. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13341. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13342. ], TextBlock.prototype, "underline", null);
  13343. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13344. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13345. ], TextBlock.prototype, "lineThrough", null);
  13346. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13347. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13348. ], TextBlock.prototype, "outlineColor", null);
  13349. return TextBlock;
  13350. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  13351. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  13352. /***/ }),
  13353. /***/ "./2D/controls/textWrapper.ts":
  13354. /*!************************************!*\
  13355. !*** ./2D/controls/textWrapper.ts ***!
  13356. \************************************/
  13357. /*! exports provided: TextWrapper */
  13358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13359. "use strict";
  13360. __webpack_require__.r(__webpack_exports__);
  13361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return TextWrapper; });
  13362. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13363. /** @hidden */
  13364. var TextWrapper = /** @class */ (function () {
  13365. function TextWrapper() {
  13366. }
  13367. Object.defineProperty(TextWrapper.prototype, "text", {
  13368. get: function () {
  13369. return this._characters ? this._characters.join("") : this._text;
  13370. },
  13371. set: function (txt) {
  13372. this._text = txt;
  13373. this._characters = Array.from && Array.from(txt);
  13374. },
  13375. enumerable: false,
  13376. configurable: true
  13377. });
  13378. Object.defineProperty(TextWrapper.prototype, "length", {
  13379. get: function () {
  13380. return this._characters ? this._characters.length : this._text.length;
  13381. },
  13382. enumerable: false,
  13383. configurable: true
  13384. });
  13385. TextWrapper.prototype.removePart = function (idxStart, idxEnd, insertTxt) {
  13386. var _a;
  13387. this._text = this._text.slice(0, idxStart) + (insertTxt ? insertTxt : "") + this._text.slice(idxEnd);
  13388. if (this._characters) {
  13389. var newCharacters = insertTxt ? Array.from(insertTxt) : [];
  13390. (_a = this._characters).splice.apply(_a, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spreadArrays"])([idxStart, idxEnd - idxStart], newCharacters));
  13391. }
  13392. };
  13393. TextWrapper.prototype.charAt = function (idx) {
  13394. return this._characters ? this._characters[idx] : this._text.charAt(idx);
  13395. };
  13396. TextWrapper.prototype.substr = function (from, length) {
  13397. if (this._characters) {
  13398. if (isNaN(from)) {
  13399. from = 0;
  13400. }
  13401. else if (from >= 0) {
  13402. from = Math.min(from, this._characters.length);
  13403. }
  13404. else {
  13405. from = this._characters.length + Math.max(from, -this._characters.length);
  13406. }
  13407. if (length === undefined) {
  13408. length = this._characters.length - from;
  13409. }
  13410. else if (isNaN(length)) {
  13411. length = 0;
  13412. }
  13413. else if (length < 0) {
  13414. length = 0;
  13415. }
  13416. var temp = [];
  13417. while (--length >= 0) {
  13418. temp[length] = this._characters[from + length];
  13419. }
  13420. return temp.join("");
  13421. }
  13422. return this._text.substr(from, length);
  13423. };
  13424. TextWrapper.prototype.substring = function (from, to) {
  13425. if (this._characters) {
  13426. if (isNaN(from)) {
  13427. from = 0;
  13428. }
  13429. else if (from > this._characters.length) {
  13430. from = this._characters.length;
  13431. }
  13432. else if (from < 0) {
  13433. from = 0;
  13434. }
  13435. if (to === undefined) {
  13436. to = this._characters.length;
  13437. }
  13438. else if (isNaN(to)) {
  13439. to = 0;
  13440. }
  13441. else if (to > this._characters.length) {
  13442. to = this._characters.length;
  13443. }
  13444. else if (to < 0) {
  13445. to = 0;
  13446. }
  13447. var temp = [];
  13448. var idx = 0;
  13449. while (from < to) {
  13450. temp[idx++] = this._characters[from++];
  13451. }
  13452. return temp.join("");
  13453. }
  13454. return this._text.substring(from, to);
  13455. };
  13456. TextWrapper.prototype.isWord = function (index) {
  13457. var rWord = /\w/g;
  13458. return this._characters ? this._characters[index].search(rWord) !== -1 : this._text.search(rWord) !== -1;
  13459. };
  13460. return TextWrapper;
  13461. }());
  13462. /***/ }),
  13463. /***/ "./2D/controls/toggleButton.ts":
  13464. /*!*************************************!*\
  13465. !*** ./2D/controls/toggleButton.ts ***!
  13466. \*************************************/
  13467. /*! exports provided: ToggleButton */
  13468. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13469. "use strict";
  13470. __webpack_require__.r(__webpack_exports__);
  13471. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return ToggleButton; });
  13472. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13473. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  13474. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  13475. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  13476. /**
  13477. * Class used to create toggle buttons
  13478. */
  13479. var ToggleButton = /** @class */ (function (_super) {
  13480. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ToggleButton, _super);
  13481. /**
  13482. * Creates a new ToggleButton
  13483. * @param name defines the control name
  13484. * @param group defines the toggle group this toggle belongs to
  13485. */
  13486. function ToggleButton(name, group) {
  13487. var _this = _super.call(this, name) || this;
  13488. _this.name = name;
  13489. /** Observable raised when isActive is changed */
  13490. _this.onIsActiveChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  13491. /**
  13492. * 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
  13493. */
  13494. _this.delegatePickingToChildren = false;
  13495. _this._isActive = false;
  13496. _this.group = group !== null && group !== void 0 ? group : "";
  13497. _this.thickness = 0;
  13498. _this.isPointerBlocker = true;
  13499. var alphaStore = null;
  13500. _this.toActiveAnimation = function () {
  13501. _this.thickness = 1;
  13502. };
  13503. _this.toInactiveAnimation = function () {
  13504. _this.thickness = 0;
  13505. };
  13506. _this.pointerEnterActiveAnimation = function () {
  13507. alphaStore = _this.alpha;
  13508. _this.alpha -= 0.1;
  13509. };
  13510. _this.pointerOutActiveAnimation = function () {
  13511. if (alphaStore !== null) {
  13512. _this.alpha = alphaStore;
  13513. }
  13514. };
  13515. _this.pointerDownActiveAnimation = function () {
  13516. _this.scaleX -= 0.05;
  13517. _this.scaleY -= 0.05;
  13518. };
  13519. _this.pointerUpActiveAnimation = function () {
  13520. _this.scaleX += 0.05;
  13521. _this.scaleY += 0.05;
  13522. };
  13523. _this.pointerEnterInactiveAnimation = function () {
  13524. alphaStore = _this.alpha;
  13525. _this.alpha -= 0.1;
  13526. };
  13527. _this.pointerOutInactiveAnimation = function () {
  13528. if (alphaStore !== null) {
  13529. _this.alpha = alphaStore;
  13530. }
  13531. };
  13532. _this.pointerDownInactiveAnimation = function () {
  13533. _this.scaleX -= 0.05;
  13534. _this.scaleY -= 0.05;
  13535. };
  13536. _this.pointerUpInactiveAnimation = function () {
  13537. _this.scaleX += 0.05;
  13538. _this.scaleY += 0.05;
  13539. };
  13540. return _this;
  13541. }
  13542. Object.defineProperty(ToggleButton.prototype, "image", {
  13543. /**
  13544. * Returns the ToggleButton's image control if it exists
  13545. */
  13546. get: function () {
  13547. return this._image;
  13548. },
  13549. enumerable: false,
  13550. configurable: true
  13551. });
  13552. Object.defineProperty(ToggleButton.prototype, "textBlock", {
  13553. /**
  13554. * Returns the ToggleButton's child TextBlock control if it exists
  13555. */
  13556. get: function () {
  13557. return this._textBlock;
  13558. },
  13559. enumerable: false,
  13560. configurable: true
  13561. });
  13562. Object.defineProperty(ToggleButton.prototype, "group", {
  13563. /** Gets or sets group name this toggle button belongs to */
  13564. get: function () {
  13565. return this._group;
  13566. },
  13567. set: function (value) {
  13568. if (this._group === value) {
  13569. return;
  13570. }
  13571. this._group = value;
  13572. },
  13573. enumerable: false,
  13574. configurable: true
  13575. });
  13576. Object.defineProperty(ToggleButton.prototype, "isActive", {
  13577. /** Gets or sets a boolean indicating if the toogle button is active or not */
  13578. get: function () {
  13579. return this._isActive;
  13580. },
  13581. set: function (value) {
  13582. var _this = this;
  13583. var _a, _b;
  13584. // Function modeled after radioButton.ts
  13585. if (this._isActive === value) {
  13586. return;
  13587. }
  13588. this._isActive = value;
  13589. // Update the visual state based on the new value
  13590. if (this._isActive) {
  13591. (_a = this.toActiveAnimation) === null || _a === void 0 ? void 0 : _a.call(this);
  13592. }
  13593. else {
  13594. (_b = this.toInactiveAnimation) === null || _b === void 0 ? void 0 : _b.call(this);
  13595. }
  13596. this._markAsDirty();
  13597. this.onIsActiveChangedObservable.notifyObservers(value);
  13598. if (this._isActive && this._host && this._group) {
  13599. // A toggle button in a group can only have 1 active element at a given time.
  13600. // If this toggle button has a group, set other toggle buttons in the group to inactive.
  13601. this._host.executeOnAllControls(function (control) {
  13602. // Check for control type ToggleButton
  13603. if (control.typeName === "ToggleButton") {
  13604. // Don't do anything to this toggle button
  13605. if (control === _this) {
  13606. return;
  13607. }
  13608. var childToggle = control;
  13609. // If toggle button is in same group, set isActive to false
  13610. if (childToggle.group === _this.group) {
  13611. childToggle.isActive = false;
  13612. }
  13613. }
  13614. });
  13615. }
  13616. },
  13617. enumerable: false,
  13618. configurable: true
  13619. });
  13620. ToggleButton.prototype._getTypeName = function () {
  13621. return "ToggleButton";
  13622. };
  13623. // While being a container, the toggle button behaves like a control.
  13624. /** @hidden */
  13625. ToggleButton.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  13626. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  13627. return false;
  13628. }
  13629. if (!_super.prototype.contains.call(this, x, y)) {
  13630. return false;
  13631. }
  13632. if (this.delegatePickingToChildren) {
  13633. var contains = false;
  13634. for (var index = this._children.length - 1; index >= 0; index--) {
  13635. var child = this._children[index];
  13636. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  13637. contains = true;
  13638. break;
  13639. }
  13640. }
  13641. if (!contains) {
  13642. return false;
  13643. }
  13644. }
  13645. this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  13646. return true;
  13647. };
  13648. /** @hidden */
  13649. ToggleButton.prototype._onPointerEnter = function (target, pi) {
  13650. if (!_super.prototype._onPointerEnter.call(this, target, pi)) {
  13651. return false;
  13652. }
  13653. if (this._isActive) {
  13654. if (this.pointerEnterActiveAnimation) {
  13655. this.pointerEnterActiveAnimation();
  13656. }
  13657. }
  13658. else {
  13659. if (this.pointerEnterInactiveAnimation) {
  13660. this.pointerEnterInactiveAnimation();
  13661. }
  13662. }
  13663. return true;
  13664. };
  13665. /** @hidden */
  13666. ToggleButton.prototype._onPointerOut = function (target, pi, force) {
  13667. if (force === void 0) { force = false; }
  13668. if (this._isActive) {
  13669. if (this.pointerOutActiveAnimation) {
  13670. this.pointerOutActiveAnimation();
  13671. }
  13672. }
  13673. else {
  13674. if (this.pointerOutInactiveAnimation) {
  13675. this.pointerOutInactiveAnimation();
  13676. }
  13677. }
  13678. _super.prototype._onPointerOut.call(this, target, pi, force);
  13679. };
  13680. /** @hidden */
  13681. ToggleButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  13682. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  13683. return false;
  13684. }
  13685. if (this._isActive) {
  13686. if (this.pointerDownActiveAnimation) {
  13687. this.pointerDownActiveAnimation();
  13688. }
  13689. }
  13690. else {
  13691. if (this.pointerDownInactiveAnimation) {
  13692. this.pointerDownInactiveAnimation();
  13693. }
  13694. }
  13695. return true;
  13696. };
  13697. /** @hidden */
  13698. ToggleButton.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  13699. if (this._isActive) {
  13700. if (this.pointerUpActiveAnimation) {
  13701. this.pointerUpActiveAnimation();
  13702. }
  13703. }
  13704. else {
  13705. if (this.pointerUpInactiveAnimation) {
  13706. this.pointerUpInactiveAnimation();
  13707. }
  13708. }
  13709. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick, pi);
  13710. };
  13711. return ToggleButton;
  13712. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  13713. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ToggleButton"] = ToggleButton;
  13714. /***/ }),
  13715. /***/ "./2D/controls/virtualKeyboard.ts":
  13716. /*!****************************************!*\
  13717. !*** ./2D/controls/virtualKeyboard.ts ***!
  13718. \****************************************/
  13719. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  13720. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13721. "use strict";
  13722. __webpack_require__.r(__webpack_exports__);
  13723. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  13724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  13725. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13726. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  13727. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  13728. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  13729. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  13730. /**
  13731. * Class used to store key control properties
  13732. */
  13733. var KeyPropertySet = /** @class */ (function () {
  13734. function KeyPropertySet() {
  13735. }
  13736. return KeyPropertySet;
  13737. }());
  13738. /**
  13739. * Class used to create virtual keyboard
  13740. */
  13741. var VirtualKeyboard = /** @class */ (function (_super) {
  13742. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  13743. function VirtualKeyboard() {
  13744. var _this = _super !== null && _super.apply(this, arguments) || this;
  13745. /** Observable raised when a key is pressed */
  13746. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  13747. /** Gets or sets default key button width */
  13748. _this.defaultButtonWidth = "40px";
  13749. /** Gets or sets default key button height */
  13750. _this.defaultButtonHeight = "40px";
  13751. /** Gets or sets default key button left padding */
  13752. _this.defaultButtonPaddingLeft = "2px";
  13753. /** Gets or sets default key button right padding */
  13754. _this.defaultButtonPaddingRight = "2px";
  13755. /** Gets or sets default key button top padding */
  13756. _this.defaultButtonPaddingTop = "2px";
  13757. /** Gets or sets default key button bottom padding */
  13758. _this.defaultButtonPaddingBottom = "2px";
  13759. /** Gets or sets default key button foreground color */
  13760. _this.defaultButtonColor = "#DDD";
  13761. /** Gets or sets default key button background color */
  13762. _this.defaultButtonBackground = "#070707";
  13763. /** Gets or sets shift button foreground color */
  13764. _this.shiftButtonColor = "#7799FF";
  13765. /** Gets or sets shift button thickness*/
  13766. _this.selectedShiftThickness = 1;
  13767. /** Gets shift key state */
  13768. _this.shiftState = 0;
  13769. _this._currentlyConnectedInputText = null;
  13770. _this._connectedInputTexts = [];
  13771. _this._onKeyPressObserver = null;
  13772. return _this;
  13773. }
  13774. VirtualKeyboard.prototype._getTypeName = function () {
  13775. return "VirtualKeyboard";
  13776. };
  13777. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  13778. var _this = this;
  13779. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  13780. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  13781. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  13782. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  13783. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  13784. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  13785. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  13786. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  13787. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  13788. button.thickness = 0;
  13789. button.isFocusInvisible = true;
  13790. button.shadowColor = this.shadowColor;
  13791. button.shadowBlur = this.shadowBlur;
  13792. button.shadowOffsetX = this.shadowOffsetX;
  13793. button.shadowOffsetY = this.shadowOffsetY;
  13794. button.onPointerUpObservable.add(function () {
  13795. _this.onKeyPressObservable.notifyObservers(key);
  13796. });
  13797. return button;
  13798. };
  13799. /**
  13800. * Adds a new row of keys
  13801. * @param keys defines the list of keys to add
  13802. * @param propertySets defines the associated property sets
  13803. */
  13804. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  13805. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  13806. panel.isVertical = false;
  13807. panel.isFocusInvisible = true;
  13808. var maxKey = null;
  13809. for (var i = 0; i < keys.length; i++) {
  13810. var properties = null;
  13811. if (propertySets && propertySets.length === keys.length) {
  13812. properties = propertySets[i];
  13813. }
  13814. var key = this._createKey(keys[i], properties);
  13815. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  13816. maxKey = key;
  13817. }
  13818. panel.addControl(key);
  13819. }
  13820. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  13821. this.addControl(panel);
  13822. };
  13823. /**
  13824. * Set the shift key to a specific state
  13825. * @param shiftState defines the new shift state
  13826. */
  13827. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  13828. if (!this.children) {
  13829. return;
  13830. }
  13831. for (var i = 0; i < this.children.length; i++) {
  13832. var row = this.children[i];
  13833. if (!row || !row.children) {
  13834. continue;
  13835. }
  13836. var rowContainer = row;
  13837. for (var j = 0; j < rowContainer.children.length; j++) {
  13838. var button = rowContainer.children[j];
  13839. if (!button || !button.children[0]) {
  13840. continue;
  13841. }
  13842. var button_tblock = button.children[0];
  13843. if (button_tblock.text === "\u21E7") {
  13844. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  13845. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  13846. }
  13847. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  13848. }
  13849. }
  13850. };
  13851. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  13852. /** Gets the input text control currently attached to the keyboard */
  13853. get: function () {
  13854. return this._currentlyConnectedInputText;
  13855. },
  13856. enumerable: false,
  13857. configurable: true
  13858. });
  13859. /**
  13860. * Connects the keyboard with an input text control
  13861. *
  13862. * @param input defines the target control
  13863. */
  13864. VirtualKeyboard.prototype.connect = function (input) {
  13865. var _this = this;
  13866. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  13867. if (inputTextAlreadyConnected) {
  13868. return;
  13869. }
  13870. if (this._onKeyPressObserver === null) {
  13871. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  13872. if (!_this._currentlyConnectedInputText) {
  13873. return;
  13874. }
  13875. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  13876. switch (key) {
  13877. case "\u21E7":
  13878. _this.shiftState++;
  13879. if (_this.shiftState > 2) {
  13880. _this.shiftState = 0;
  13881. }
  13882. _this.applyShiftState(_this.shiftState);
  13883. return;
  13884. case "\u2190":
  13885. _this._currentlyConnectedInputText.processKey(8);
  13886. return;
  13887. case "\u21B5":
  13888. _this._currentlyConnectedInputText.processKey(13);
  13889. return;
  13890. }
  13891. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  13892. if (_this.shiftState === 1) {
  13893. _this.shiftState = 0;
  13894. _this.applyShiftState(_this.shiftState);
  13895. }
  13896. });
  13897. }
  13898. this.isVisible = false;
  13899. this._currentlyConnectedInputText = input;
  13900. input._connectedVirtualKeyboard = this;
  13901. // Events hooking
  13902. var onFocusObserver = input.onFocusObservable.add(function () {
  13903. _this._currentlyConnectedInputText = input;
  13904. input._connectedVirtualKeyboard = _this;
  13905. _this.isVisible = true;
  13906. });
  13907. var onBlurObserver = input.onBlurObservable.add(function () {
  13908. input._connectedVirtualKeyboard = null;
  13909. _this._currentlyConnectedInputText = null;
  13910. _this.isVisible = false;
  13911. });
  13912. this._connectedInputTexts.push({
  13913. input: input,
  13914. onBlurObserver: onBlurObserver,
  13915. onFocusObserver: onFocusObserver
  13916. });
  13917. };
  13918. /**
  13919. * Disconnects the keyboard from connected InputText controls
  13920. *
  13921. * @param input optionally defines a target control, otherwise all are disconnected
  13922. */
  13923. VirtualKeyboard.prototype.disconnect = function (input) {
  13924. var _this = this;
  13925. if (input) {
  13926. // .find not available on IE
  13927. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  13928. if (filtered.length === 1) {
  13929. this._removeConnectedInputObservables(filtered[0]);
  13930. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  13931. if (this._currentlyConnectedInputText === input) {
  13932. this._currentlyConnectedInputText = null;
  13933. }
  13934. }
  13935. }
  13936. else {
  13937. this._connectedInputTexts.forEach(function (connectedInputText) {
  13938. _this._removeConnectedInputObservables(connectedInputText);
  13939. });
  13940. this._connectedInputTexts = [];
  13941. }
  13942. if (this._connectedInputTexts.length === 0) {
  13943. this._currentlyConnectedInputText = null;
  13944. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  13945. this._onKeyPressObserver = null;
  13946. }
  13947. };
  13948. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  13949. connectedInputText.input._connectedVirtualKeyboard = null;
  13950. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  13951. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  13952. };
  13953. /**
  13954. * Release all resources
  13955. */
  13956. VirtualKeyboard.prototype.dispose = function () {
  13957. _super.prototype.dispose.call(this);
  13958. this.disconnect();
  13959. };
  13960. // Statics
  13961. /**
  13962. * Creates a new keyboard using a default layout
  13963. *
  13964. * @param name defines control name
  13965. * @returns a new VirtualKeyboard
  13966. */
  13967. VirtualKeyboard.CreateDefaultLayout = function (name) {
  13968. var returnValue = new VirtualKeyboard(name);
  13969. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  13970. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  13971. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  13972. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  13973. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  13974. return returnValue;
  13975. };
  13976. return VirtualKeyboard;
  13977. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  13978. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  13979. /***/ }),
  13980. /***/ "./2D/index.ts":
  13981. /*!*********************!*\
  13982. !*** ./2D/index.ts ***!
  13983. \*********************/
  13984. /*! 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 */
  13985. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13986. "use strict";
  13987. __webpack_require__.r(__webpack_exports__);
  13988. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  13989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  13990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  13991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  13992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  13993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  13994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  13995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["FocusableButton"]; });
  13996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  13997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  13998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  13999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapper"]; });
  14013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ToggleButton"]; });
  14014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  14023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14024. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  14026. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  14027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  14028. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  14029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  14030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  14031. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  14032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  14033. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  14034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  14035. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  14036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  14037. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  14038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  14039. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  14040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  14041. /***/ }),
  14042. /***/ "./2D/math2D.ts":
  14043. /*!**********************!*\
  14044. !*** ./2D/math2D.ts ***!
  14045. \**********************/
  14046. /*! exports provided: Vector2WithInfo, Matrix2D */
  14047. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14048. "use strict";
  14049. __webpack_require__.r(__webpack_exports__);
  14050. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  14051. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  14052. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14053. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  14054. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  14055. /**
  14056. * Class used to transport Vector2 information for pointer events
  14057. */
  14058. var Vector2WithInfo = /** @class */ (function (_super) {
  14059. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  14060. /**
  14061. * Creates a new Vector2WithInfo
  14062. * @param source defines the vector2 data to transport
  14063. * @param buttonIndex defines the current mouse button index
  14064. */
  14065. function Vector2WithInfo(source,
  14066. /** defines the current mouse button index */
  14067. buttonIndex) {
  14068. if (buttonIndex === void 0) { buttonIndex = 0; }
  14069. var _this = _super.call(this, source.x, source.y) || this;
  14070. _this.buttonIndex = buttonIndex;
  14071. return _this;
  14072. }
  14073. return Vector2WithInfo;
  14074. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  14075. /** Class used to provide 2D matrix features */
  14076. var Matrix2D = /** @class */ (function () {
  14077. /**
  14078. * Creates a new matrix
  14079. * @param m00 defines value for (0, 0)
  14080. * @param m01 defines value for (0, 1)
  14081. * @param m10 defines value for (1, 0)
  14082. * @param m11 defines value for (1, 1)
  14083. * @param m20 defines value for (2, 0)
  14084. * @param m21 defines value for (2, 1)
  14085. */
  14086. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  14087. /** Gets the internal array of 6 floats used to store matrix data */
  14088. this.m = new Float32Array(6);
  14089. this.fromValues(m00, m01, m10, m11, m20, m21);
  14090. }
  14091. /**
  14092. * Fills the matrix from direct values
  14093. * @param m00 defines value for (0, 0)
  14094. * @param m01 defines value for (0, 1)
  14095. * @param m10 defines value for (1, 0)
  14096. * @param m11 defines value for (1, 1)
  14097. * @param m20 defines value for (2, 0)
  14098. * @param m21 defines value for (2, 1)
  14099. * @returns the current modified matrix
  14100. */
  14101. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  14102. this.m[0] = m00;
  14103. this.m[1] = m01;
  14104. this.m[2] = m10;
  14105. this.m[3] = m11;
  14106. this.m[4] = m20;
  14107. this.m[5] = m21;
  14108. return this;
  14109. };
  14110. /**
  14111. * Gets matrix determinant
  14112. * @returns the determinant
  14113. */
  14114. Matrix2D.prototype.determinant = function () {
  14115. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  14116. };
  14117. /**
  14118. * Inverses the matrix and stores it in a target matrix
  14119. * @param result defines the target matrix
  14120. * @returns the current matrix
  14121. */
  14122. Matrix2D.prototype.invertToRef = function (result) {
  14123. var l0 = this.m[0];
  14124. var l1 = this.m[1];
  14125. var l2 = this.m[2];
  14126. var l3 = this.m[3];
  14127. var l4 = this.m[4];
  14128. var l5 = this.m[5];
  14129. var det = this.determinant();
  14130. if (det < (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  14131. result.m[0] = 0;
  14132. result.m[1] = 0;
  14133. result.m[2] = 0;
  14134. result.m[3] = 0;
  14135. result.m[4] = 0;
  14136. result.m[5] = 0;
  14137. return this;
  14138. }
  14139. var detDiv = 1 / det;
  14140. var det4 = l2 * l5 - l3 * l4;
  14141. var det5 = l1 * l4 - l0 * l5;
  14142. result.m[0] = l3 * detDiv;
  14143. result.m[1] = -l1 * detDiv;
  14144. result.m[2] = -l2 * detDiv;
  14145. result.m[3] = l0 * detDiv;
  14146. result.m[4] = det4 * detDiv;
  14147. result.m[5] = det5 * detDiv;
  14148. return this;
  14149. };
  14150. /**
  14151. * Multiplies the current matrix with another one
  14152. * @param other defines the second operand
  14153. * @param result defines the target matrix
  14154. * @returns the current matrix
  14155. */
  14156. Matrix2D.prototype.multiplyToRef = function (other, result) {
  14157. var l0 = this.m[0];
  14158. var l1 = this.m[1];
  14159. var l2 = this.m[2];
  14160. var l3 = this.m[3];
  14161. var l4 = this.m[4];
  14162. var l5 = this.m[5];
  14163. var r0 = other.m[0];
  14164. var r1 = other.m[1];
  14165. var r2 = other.m[2];
  14166. var r3 = other.m[3];
  14167. var r4 = other.m[4];
  14168. var r5 = other.m[5];
  14169. result.m[0] = l0 * r0 + l1 * r2;
  14170. result.m[1] = l0 * r1 + l1 * r3;
  14171. result.m[2] = l2 * r0 + l3 * r2;
  14172. result.m[3] = l2 * r1 + l3 * r3;
  14173. result.m[4] = l4 * r0 + l5 * r2 + r4;
  14174. result.m[5] = l4 * r1 + l5 * r3 + r5;
  14175. return this;
  14176. };
  14177. /**
  14178. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  14179. * @param x defines the x coordinate to transform
  14180. * @param y defines the x coordinate to transform
  14181. * @param result defines the target vector2
  14182. * @returns the current matrix
  14183. */
  14184. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  14185. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  14186. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  14187. return this;
  14188. };
  14189. // Statics
  14190. /**
  14191. * Creates an identity matrix
  14192. * @returns a new matrix
  14193. */
  14194. Matrix2D.Identity = function () {
  14195. return new Matrix2D(1, 0, 0, 1, 0, 0);
  14196. };
  14197. /**
  14198. * Creates a translation matrix and stores it in a target matrix
  14199. * @param x defines the x coordinate of the translation
  14200. * @param y defines the y coordinate of the translation
  14201. * @param result defines the target matrix
  14202. */
  14203. Matrix2D.TranslationToRef = function (x, y, result) {
  14204. result.fromValues(1, 0, 0, 1, x, y);
  14205. };
  14206. /**
  14207. * Creates a scaling matrix and stores it in a target matrix
  14208. * @param x defines the x coordinate of the scaling
  14209. * @param y defines the y coordinate of the scaling
  14210. * @param result defines the target matrix
  14211. */
  14212. Matrix2D.ScalingToRef = function (x, y, result) {
  14213. result.fromValues(x, 0, 0, y, 0, 0);
  14214. };
  14215. /**
  14216. * Creates a rotation matrix and stores it in a target matrix
  14217. * @param angle defines the rotation angle
  14218. * @param result defines the target matrix
  14219. */
  14220. Matrix2D.RotationToRef = function (angle, result) {
  14221. var s = Math.sin(angle);
  14222. var c = Math.cos(angle);
  14223. result.fromValues(c, s, -s, c, 0, 0);
  14224. };
  14225. /**
  14226. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  14227. * @param tx defines the x coordinate of the translation
  14228. * @param ty defines the y coordinate of the translation
  14229. * @param angle defines the rotation angle
  14230. * @param scaleX defines the x coordinate of the scaling
  14231. * @param scaleY defines the y coordinate of the scaling
  14232. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  14233. * @param result defines the target matrix
  14234. */
  14235. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  14236. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  14237. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  14238. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  14239. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  14240. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  14241. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  14242. if (parentMatrix) {
  14243. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  14244. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  14245. }
  14246. else {
  14247. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  14248. }
  14249. };
  14250. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  14251. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  14252. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  14253. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  14254. Matrix2D._TempCompose0 = Matrix2D.Identity();
  14255. Matrix2D._TempCompose1 = Matrix2D.Identity();
  14256. Matrix2D._TempCompose2 = Matrix2D.Identity();
  14257. return Matrix2D;
  14258. }());
  14259. /***/ }),
  14260. /***/ "./2D/measure.ts":
  14261. /*!***********************!*\
  14262. !*** ./2D/measure.ts ***!
  14263. \***********************/
  14264. /*! exports provided: Measure */
  14265. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14266. "use strict";
  14267. __webpack_require__.r(__webpack_exports__);
  14268. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  14269. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  14270. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  14271. var tmpRect = [
  14272. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14273. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14274. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14275. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14276. ];
  14277. var tmpRect2 = [
  14278. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14279. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14280. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14281. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14282. ];
  14283. var tmpV1 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  14284. var tmpV2 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  14285. /**
  14286. * Class used to store 2D control sizes
  14287. */
  14288. var Measure = /** @class */ (function () {
  14289. /**
  14290. * Creates a new measure
  14291. * @param left defines left coordinate
  14292. * @param top defines top coordinate
  14293. * @param width defines width dimension
  14294. * @param height defines height dimension
  14295. */
  14296. function Measure(
  14297. /** defines left coordinate */
  14298. left,
  14299. /** defines top coordinate */
  14300. top,
  14301. /** defines width dimension */
  14302. width,
  14303. /** defines height dimension */
  14304. height) {
  14305. this.left = left;
  14306. this.top = top;
  14307. this.width = width;
  14308. this.height = height;
  14309. }
  14310. /**
  14311. * Copy from another measure
  14312. * @param other defines the other measure to copy from
  14313. */
  14314. Measure.prototype.copyFrom = function (other) {
  14315. this.left = other.left;
  14316. this.top = other.top;
  14317. this.width = other.width;
  14318. this.height = other.height;
  14319. };
  14320. /**
  14321. * Copy from a group of 4 floats
  14322. * @param left defines left coordinate
  14323. * @param top defines top coordinate
  14324. * @param width defines width dimension
  14325. * @param height defines height dimension
  14326. */
  14327. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  14328. this.left = left;
  14329. this.top = top;
  14330. this.width = width;
  14331. this.height = height;
  14332. };
  14333. /**
  14334. * Computes the axis aligned bounding box measure for two given measures
  14335. * @param a Input measure
  14336. * @param b Input measure
  14337. * @param result the resulting bounding measure
  14338. */
  14339. Measure.CombineToRef = function (a, b, result) {
  14340. var left = Math.min(a.left, b.left);
  14341. var top = Math.min(a.top, b.top);
  14342. var right = Math.max(a.left + a.width, b.left + b.width);
  14343. var bottom = Math.max(a.top + a.height, b.top + b.height);
  14344. result.left = left;
  14345. result.top = top;
  14346. result.width = right - left;
  14347. result.height = bottom - top;
  14348. };
  14349. /**
  14350. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  14351. * @param transform the matrix to transform the measure before computing the AABB
  14352. * @param addX number to add to left
  14353. * @param addY number to add to top
  14354. * @param addWidth number to add to width
  14355. * @param addHeight number to add to height
  14356. * @param result the resulting AABB
  14357. */
  14358. Measure.prototype.addAndTransformToRef = function (transform, addX, addY, addWidth, addHeight, result) {
  14359. var left = this.left + addX;
  14360. var top = this.top + addY;
  14361. var width = this.width + addWidth;
  14362. var height = this.height + addHeight;
  14363. tmpRect[0].copyFromFloats(left, top);
  14364. tmpRect[1].copyFromFloats(left + width, top);
  14365. tmpRect[2].copyFromFloats(left + width, top + height);
  14366. tmpRect[3].copyFromFloats(left, top + height);
  14367. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  14368. tmpV2.copyFromFloats(0, 0);
  14369. for (var i = 0; i < 4; i++) {
  14370. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  14371. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  14372. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  14373. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  14374. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  14375. }
  14376. result.left = tmpV1.x;
  14377. result.top = tmpV1.y;
  14378. result.width = tmpV2.x - tmpV1.x;
  14379. result.height = tmpV2.y - tmpV1.y;
  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 result the resulting AABB
  14385. */
  14386. Measure.prototype.transformToRef = function (transform, result) {
  14387. this.addAndTransformToRef(transform, 0, 0, 0, 0, result);
  14388. };
  14389. /**
  14390. * Check equality between this measure and another one
  14391. * @param other defines the other measures
  14392. * @returns true if both measures are equals
  14393. */
  14394. Measure.prototype.isEqualsTo = function (other) {
  14395. if (this.left !== other.left) {
  14396. return false;
  14397. }
  14398. if (this.top !== other.top) {
  14399. return false;
  14400. }
  14401. if (this.width !== other.width) {
  14402. return false;
  14403. }
  14404. if (this.height !== other.height) {
  14405. return false;
  14406. }
  14407. return true;
  14408. };
  14409. /**
  14410. * Creates an empty measure
  14411. * @returns a new measure
  14412. */
  14413. Measure.Empty = function () {
  14414. return new Measure(0, 0, 0, 0);
  14415. };
  14416. return Measure;
  14417. }());
  14418. /***/ }),
  14419. /***/ "./2D/multiLinePoint.ts":
  14420. /*!******************************!*\
  14421. !*** ./2D/multiLinePoint.ts ***!
  14422. \******************************/
  14423. /*! exports provided: MultiLinePoint */
  14424. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14425. "use strict";
  14426. __webpack_require__.r(__webpack_exports__);
  14427. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  14428. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  14429. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  14430. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  14431. /**
  14432. * Class used to store a point for a MultiLine object.
  14433. * The point can be pure 2D coordinates, a mesh or a control
  14434. */
  14435. var MultiLinePoint = /** @class */ (function () {
  14436. /**
  14437. * Creates a new MultiLinePoint
  14438. * @param multiLine defines the source MultiLine object
  14439. */
  14440. function MultiLinePoint(multiLine) {
  14441. this._multiLine = multiLine;
  14442. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  14443. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  14444. this._point = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  14445. }
  14446. Object.defineProperty(MultiLinePoint.prototype, "x", {
  14447. /** Gets or sets x coordinate */
  14448. get: function () {
  14449. return this._x.toString(this._multiLine._host);
  14450. },
  14451. set: function (value) {
  14452. if (this._x.toString(this._multiLine._host) === value) {
  14453. return;
  14454. }
  14455. if (this._x.fromString(value)) {
  14456. this._multiLine._markAsDirty();
  14457. }
  14458. },
  14459. enumerable: false,
  14460. configurable: true
  14461. });
  14462. Object.defineProperty(MultiLinePoint.prototype, "y", {
  14463. /** Gets or sets y coordinate */
  14464. get: function () {
  14465. return this._y.toString(this._multiLine._host);
  14466. },
  14467. set: function (value) {
  14468. if (this._y.toString(this._multiLine._host) === value) {
  14469. return;
  14470. }
  14471. if (this._y.fromString(value)) {
  14472. this._multiLine._markAsDirty();
  14473. }
  14474. },
  14475. enumerable: false,
  14476. configurable: true
  14477. });
  14478. Object.defineProperty(MultiLinePoint.prototype, "control", {
  14479. /** Gets or sets the control associated with this point */
  14480. get: function () {
  14481. return this._control;
  14482. },
  14483. set: function (value) {
  14484. if (this._control === value) {
  14485. return;
  14486. }
  14487. if (this._control && this._controlObserver) {
  14488. this._control.onDirtyObservable.remove(this._controlObserver);
  14489. this._controlObserver = null;
  14490. }
  14491. this._control = value;
  14492. if (this._control) {
  14493. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  14494. }
  14495. this._multiLine._markAsDirty();
  14496. },
  14497. enumerable: false,
  14498. configurable: true
  14499. });
  14500. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  14501. /** Gets or sets the mesh associated with this point */
  14502. get: function () {
  14503. return this._mesh;
  14504. },
  14505. set: function (value) {
  14506. if (this._mesh === value) {
  14507. return;
  14508. }
  14509. if (this._mesh && this._meshObserver) {
  14510. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  14511. }
  14512. this._mesh = value;
  14513. if (this._mesh) {
  14514. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  14515. }
  14516. this._multiLine._markAsDirty();
  14517. },
  14518. enumerable: false,
  14519. configurable: true
  14520. });
  14521. /** Resets links */
  14522. MultiLinePoint.prototype.resetLinks = function () {
  14523. this.control = null;
  14524. this.mesh = null;
  14525. };
  14526. /**
  14527. * Gets a translation vector with Z component
  14528. * @returns the translation vector
  14529. */
  14530. MultiLinePoint.prototype.translate = function () {
  14531. this._point = this._translatePoint();
  14532. return this._point;
  14533. };
  14534. MultiLinePoint.prototype._translatePoint = function () {
  14535. if (this._mesh != null) {
  14536. return this._multiLine._host.getProjectedPositionWithZ(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  14537. }
  14538. else if (this._control != null) {
  14539. 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"]);
  14540. }
  14541. else {
  14542. var host = this._multiLine._host;
  14543. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  14544. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  14545. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](xValue, yValue, 1. - babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]);
  14546. }
  14547. };
  14548. /** Release associated resources */
  14549. MultiLinePoint.prototype.dispose = function () {
  14550. this.resetLinks();
  14551. };
  14552. return MultiLinePoint;
  14553. }());
  14554. /***/ }),
  14555. /***/ "./2D/style.ts":
  14556. /*!*********************!*\
  14557. !*** ./2D/style.ts ***!
  14558. \*********************/
  14559. /*! exports provided: Style */
  14560. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14561. "use strict";
  14562. __webpack_require__.r(__webpack_exports__);
  14563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  14564. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  14565. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14566. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  14567. /**
  14568. * Define a style used by control to automatically setup properties based on a template.
  14569. * Only support font related properties so far
  14570. */
  14571. var Style = /** @class */ (function () {
  14572. /**
  14573. * Creates a new style object
  14574. * @param host defines the AdvancedDynamicTexture which hosts this style
  14575. */
  14576. function Style(host) {
  14577. this._fontFamily = "Arial";
  14578. this._fontStyle = "";
  14579. this._fontWeight = "";
  14580. /** @hidden */
  14581. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  14582. /**
  14583. * Observable raised when the style values are changed
  14584. */
  14585. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14586. this._host = host;
  14587. }
  14588. Object.defineProperty(Style.prototype, "fontSize", {
  14589. /**
  14590. * Gets or sets the font size
  14591. */
  14592. get: function () {
  14593. return this._fontSize.toString(this._host);
  14594. },
  14595. set: function (value) {
  14596. if (this._fontSize.toString(this._host) === value) {
  14597. return;
  14598. }
  14599. if (this._fontSize.fromString(value)) {
  14600. this.onChangedObservable.notifyObservers(this);
  14601. }
  14602. },
  14603. enumerable: false,
  14604. configurable: true
  14605. });
  14606. Object.defineProperty(Style.prototype, "fontFamily", {
  14607. /**
  14608. * Gets or sets the font family
  14609. */
  14610. get: function () {
  14611. return this._fontFamily;
  14612. },
  14613. set: function (value) {
  14614. if (this._fontFamily === value) {
  14615. return;
  14616. }
  14617. this._fontFamily = value;
  14618. this.onChangedObservable.notifyObservers(this);
  14619. },
  14620. enumerable: false,
  14621. configurable: true
  14622. });
  14623. Object.defineProperty(Style.prototype, "fontStyle", {
  14624. /**
  14625. * Gets or sets the font style
  14626. */
  14627. get: function () {
  14628. return this._fontStyle;
  14629. },
  14630. set: function (value) {
  14631. if (this._fontStyle === value) {
  14632. return;
  14633. }
  14634. this._fontStyle = value;
  14635. this.onChangedObservable.notifyObservers(this);
  14636. },
  14637. enumerable: false,
  14638. configurable: true
  14639. });
  14640. Object.defineProperty(Style.prototype, "fontWeight", {
  14641. /** Gets or sets font weight */
  14642. get: function () {
  14643. return this._fontWeight;
  14644. },
  14645. set: function (value) {
  14646. if (this._fontWeight === value) {
  14647. return;
  14648. }
  14649. this._fontWeight = value;
  14650. this.onChangedObservable.notifyObservers(this);
  14651. },
  14652. enumerable: false,
  14653. configurable: true
  14654. });
  14655. /** Dispose all associated resources */
  14656. Style.prototype.dispose = function () {
  14657. this.onChangedObservable.clear();
  14658. };
  14659. return Style;
  14660. }());
  14661. /***/ }),
  14662. /***/ "./2D/valueAndUnit.ts":
  14663. /*!****************************!*\
  14664. !*** ./2D/valueAndUnit.ts ***!
  14665. \****************************/
  14666. /*! exports provided: ValueAndUnit */
  14667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14668. "use strict";
  14669. __webpack_require__.r(__webpack_exports__);
  14670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  14671. /**
  14672. * Class used to specific a value and its associated unit
  14673. */
  14674. var ValueAndUnit = /** @class */ (function () {
  14675. /**
  14676. * Creates a new ValueAndUnit
  14677. * @param value defines the value to store
  14678. * @param unit defines the unit to store
  14679. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  14680. */
  14681. function ValueAndUnit(value,
  14682. /** defines the unit to store */
  14683. unit,
  14684. /** defines a boolean indicating if the value can be negative */
  14685. negativeValueAllowed) {
  14686. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  14687. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  14688. this.unit = unit;
  14689. this.negativeValueAllowed = negativeValueAllowed;
  14690. this._value = 1;
  14691. /**
  14692. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  14693. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  14694. */
  14695. this.ignoreAdaptiveScaling = false;
  14696. this._value = value;
  14697. this._originalUnit = unit;
  14698. }
  14699. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  14700. /** Gets a boolean indicating if the value is a percentage */
  14701. get: function () {
  14702. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  14703. },
  14704. enumerable: false,
  14705. configurable: true
  14706. });
  14707. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  14708. /** Gets a boolean indicating if the value is store as pixel */
  14709. get: function () {
  14710. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  14711. },
  14712. enumerable: false,
  14713. configurable: true
  14714. });
  14715. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  14716. /** Gets direct internal value */
  14717. get: function () {
  14718. return this._value;
  14719. },
  14720. enumerable: false,
  14721. configurable: true
  14722. });
  14723. /**
  14724. * Gets value as pixel
  14725. * @param host defines the root host
  14726. * @param refValue defines the reference value for percentages
  14727. * @returns the value as pixel
  14728. */
  14729. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  14730. if (this.isPixel) {
  14731. return this.getValue(host);
  14732. }
  14733. return this.getValue(host) * refValue;
  14734. };
  14735. /**
  14736. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  14737. * @param value defines the value to store
  14738. * @param unit defines the unit to store
  14739. * @returns the current ValueAndUnit
  14740. */
  14741. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  14742. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  14743. this._value = value;
  14744. this.unit = unit;
  14745. return this;
  14746. };
  14747. /**
  14748. * Gets the value accordingly to its unit
  14749. * @param host defines the root host
  14750. * @returns the value
  14751. */
  14752. ValueAndUnit.prototype.getValue = function (host) {
  14753. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  14754. var width = 0;
  14755. var height = 0;
  14756. if (host.idealWidth) {
  14757. width = (this._value * host.getSize().width) / host.idealWidth;
  14758. }
  14759. if (host.idealHeight) {
  14760. height = (this._value * host.getSize().height) / host.idealHeight;
  14761. }
  14762. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  14763. return window.innerWidth < window.innerHeight ? width : height;
  14764. }
  14765. if (host.idealWidth) { // horizontal
  14766. return width;
  14767. }
  14768. if (host.idealHeight) { // vertical
  14769. return height;
  14770. }
  14771. }
  14772. return this._value;
  14773. };
  14774. /**
  14775. * Gets a string representation of the value
  14776. * @param host defines the root host
  14777. * @param decimals defines an optional number of decimals to display
  14778. * @returns a string
  14779. */
  14780. ValueAndUnit.prototype.toString = function (host, decimals) {
  14781. switch (this.unit) {
  14782. case ValueAndUnit.UNITMODE_PERCENTAGE:
  14783. var percentage = this.getValue(host) * 100;
  14784. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  14785. case ValueAndUnit.UNITMODE_PIXEL:
  14786. var pixels = this.getValue(host);
  14787. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  14788. }
  14789. return this.unit.toString();
  14790. };
  14791. /**
  14792. * Store a value parsed from a string
  14793. * @param source defines the source string
  14794. * @returns true if the value was successfully parsed
  14795. */
  14796. ValueAndUnit.prototype.fromString = function (source) {
  14797. var match = ValueAndUnit._Regex.exec(source.toString());
  14798. if (!match || match.length === 0) {
  14799. return false;
  14800. }
  14801. var sourceValue = parseFloat(match[1]);
  14802. var sourceUnit = this._originalUnit;
  14803. if (!this.negativeValueAllowed) {
  14804. if (sourceValue < 0) {
  14805. sourceValue = 0;
  14806. }
  14807. }
  14808. if (match.length === 4) {
  14809. switch (match[3]) {
  14810. case "px":
  14811. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  14812. break;
  14813. case "%":
  14814. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  14815. sourceValue /= 100.0;
  14816. break;
  14817. }
  14818. }
  14819. if (sourceValue === this._value && sourceUnit === this.unit) {
  14820. return false;
  14821. }
  14822. this._value = sourceValue;
  14823. this.unit = sourceUnit;
  14824. return true;
  14825. };
  14826. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  14827. /** UNITMODE_PERCENTAGE */
  14828. get: function () {
  14829. return ValueAndUnit._UNITMODE_PERCENTAGE;
  14830. },
  14831. enumerable: false,
  14832. configurable: true
  14833. });
  14834. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  14835. /** UNITMODE_PIXEL */
  14836. get: function () {
  14837. return ValueAndUnit._UNITMODE_PIXEL;
  14838. },
  14839. enumerable: false,
  14840. configurable: true
  14841. });
  14842. // Static
  14843. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  14844. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  14845. ValueAndUnit._UNITMODE_PIXEL = 1;
  14846. return ValueAndUnit;
  14847. }());
  14848. /***/ }),
  14849. /***/ "./2D/xmlLoader.ts":
  14850. /*!*************************!*\
  14851. !*** ./2D/xmlLoader.ts ***!
  14852. \*************************/
  14853. /*! exports provided: XmlLoader */
  14854. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14855. "use strict";
  14856. __webpack_require__.r(__webpack_exports__);
  14857. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  14858. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  14859. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  14860. /**
  14861. * Class used to load GUI via XML.
  14862. */
  14863. var XmlLoader = /** @class */ (function () {
  14864. /**
  14865. * Create a new xml loader
  14866. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  14867. */
  14868. function XmlLoader(parentClass) {
  14869. if (parentClass === void 0) { parentClass = null; }
  14870. this._nodes = {};
  14871. this._nodeTypes = {
  14872. element: 1,
  14873. attribute: 2,
  14874. text: 3
  14875. };
  14876. this._isLoaded = false;
  14877. this._objectAttributes = {
  14878. "textHorizontalAlignment": 1,
  14879. "textVerticalAlignment": 2,
  14880. "horizontalAlignment": 3,
  14881. "verticalAlignment": 4,
  14882. "stretch": 5,
  14883. };
  14884. if (parentClass) {
  14885. this._parentClass = parentClass;
  14886. }
  14887. }
  14888. XmlLoader.prototype._getChainElement = function (attributeValue) {
  14889. var element = window;
  14890. if (this._parentClass) {
  14891. element = this._parentClass;
  14892. }
  14893. var value = attributeValue;
  14894. value = value.split(".");
  14895. for (var i = 0; i < value.length; i++) {
  14896. element = element[value[i]];
  14897. }
  14898. return element;
  14899. };
  14900. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  14901. var attribute = attributeName.split(".");
  14902. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  14903. return className[attribute[1]];
  14904. };
  14905. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  14906. if (linkParent === void 0) { linkParent = true; }
  14907. try {
  14908. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  14909. var guiNode = new className();
  14910. if (parent && linkParent) {
  14911. parent.addControl(guiNode);
  14912. }
  14913. for (var i = 0; i < node.attributes.length; i++) {
  14914. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  14915. continue;
  14916. }
  14917. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  14918. var element = this._getChainElement(node.attributes[i].value);
  14919. guiNode[node.attributes[i].name].add(element);
  14920. continue;
  14921. }
  14922. else if (node.attributes[i].name == "linkWithMesh") {
  14923. if (this._parentClass) {
  14924. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  14925. }
  14926. else {
  14927. guiNode.linkWithMesh(window[node.attributes[i].value]);
  14928. }
  14929. }
  14930. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  14931. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  14932. guiNode[node.attributes[i].name] = element;
  14933. }
  14934. else if (!this._objectAttributes[node.attributes[i].name]) {
  14935. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  14936. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  14937. }
  14938. else {
  14939. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  14940. }
  14941. }
  14942. else {
  14943. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  14944. }
  14945. }
  14946. if (!node.attributes.getNamedItem("id")) {
  14947. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  14948. return guiNode;
  14949. }
  14950. var id = node.attributes.getNamedItem("id").value;
  14951. if (id.startsWith("{{") && id.endsWith("}}")) {
  14952. id = this._getChainElement(id.substring(2, id.length - 2));
  14953. }
  14954. if (!this._nodes[id]) {
  14955. this._nodes[id] = guiNode;
  14956. }
  14957. else {
  14958. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  14959. }
  14960. return guiNode;
  14961. }
  14962. catch (e) {
  14963. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  14964. }
  14965. };
  14966. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  14967. var width;
  14968. var height;
  14969. var columns;
  14970. var rows = node.children;
  14971. var cells;
  14972. var isPixel = false;
  14973. var cellNode;
  14974. var rowNumber = -1;
  14975. var columnNumber = -1;
  14976. var totalColumnsNumber = 0;
  14977. for (var i = 0; i < rows.length; i++) {
  14978. if (rows[i].nodeType != this._nodeTypes.element) {
  14979. continue;
  14980. }
  14981. if (rows[i].nodeName != "Row") {
  14982. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  14983. }
  14984. rowNumber += 1;
  14985. columns = rows[i].children;
  14986. if (!rows[i].attributes.getNamedItem("height")) {
  14987. throw "XmlLoader Exception : Height must be defined for grid rows";
  14988. }
  14989. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  14990. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  14991. guiNode.addRowDefinition(height, isPixel);
  14992. for (var j = 0; j < columns.length; j++) {
  14993. if (columns[j].nodeType != this._nodeTypes.element) {
  14994. continue;
  14995. }
  14996. if (columns[j].nodeName != "Column") {
  14997. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  14998. }
  14999. columnNumber += 1;
  15000. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  15001. 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.";
  15002. }
  15003. if (rowNumber == 0) {
  15004. if (!columns[j].attributes.getNamedItem("width")) {
  15005. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  15006. }
  15007. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  15008. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  15009. guiNode.addColumnDefinition(width, isPixel);
  15010. }
  15011. cells = columns[j].children;
  15012. for (var k = 0; k < cells.length; k++) {
  15013. if (cells[k].nodeType != this._nodeTypes.element) {
  15014. continue;
  15015. }
  15016. cellNode = this._createGuiElement(cells[k], guiNode, false);
  15017. guiNode.addControl(cellNode, rowNumber, columnNumber);
  15018. if (cells[k].firstChild) {
  15019. this._parseXml(cells[k].firstChild, cellNode);
  15020. }
  15021. }
  15022. }
  15023. if (rowNumber == 0) {
  15024. totalColumnsNumber = columnNumber;
  15025. }
  15026. columnNumber = -1;
  15027. }
  15028. if (node.nextSibling) {
  15029. this._parseXml(node.nextSibling, parent);
  15030. }
  15031. };
  15032. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  15033. if (node.firstChild) {
  15034. this._parseXml(node.firstChild, guiNode);
  15035. }
  15036. if (node.nextSibling) {
  15037. this._parseXml(node.nextSibling, parent);
  15038. }
  15039. };
  15040. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  15041. if (this._parentClass) {
  15042. this._parentClass[variable] = source[iterator];
  15043. }
  15044. else {
  15045. window[variable] = source[iterator];
  15046. }
  15047. if (node.firstChild) {
  15048. this._parseXml(node.firstChild, guiNode, true);
  15049. }
  15050. };
  15051. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  15052. var dataSource = node.attributes.getNamedItem("dataSource").value;
  15053. if (!dataSource.includes(" in ")) {
  15054. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  15055. }
  15056. else {
  15057. var isArray = true;
  15058. var splittedSource = dataSource.split(" in ");
  15059. if (splittedSource.length < 2) {
  15060. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  15061. }
  15062. var source = splittedSource[1];
  15063. if (source.startsWith("{") && source.endsWith("}")) {
  15064. isArray = false;
  15065. }
  15066. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  15067. source = source.substring(1, source.length - 1);
  15068. }
  15069. if (this._parentClass) {
  15070. source = this._parentClass[source];
  15071. }
  15072. else {
  15073. source = window[source];
  15074. }
  15075. if (isArray) {
  15076. for (var i = 0; i < source.length; i++) {
  15077. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  15078. }
  15079. }
  15080. else {
  15081. for (var i in source) {
  15082. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  15083. }
  15084. }
  15085. if (node.nextSibling) {
  15086. this._parseXml(node.nextSibling, parent);
  15087. }
  15088. }
  15089. };
  15090. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  15091. if (generated === void 0) { generated = false; }
  15092. if (node.nodeType != this._nodeTypes.element) {
  15093. if (node.nextSibling) {
  15094. this._parseXml(node.nextSibling, parent, generated);
  15095. }
  15096. return;
  15097. }
  15098. if (generated) {
  15099. node.setAttribute("id", parent.id + (parent._children.length + 1));
  15100. }
  15101. var guiNode = this._createGuiElement(node, parent);
  15102. if (node.nodeName == "Grid") {
  15103. this._parseGrid(node, guiNode, parent);
  15104. }
  15105. else if (!node.attributes.getNamedItem("dataSource")) {
  15106. this._parseElement(node, guiNode, parent);
  15107. }
  15108. else {
  15109. this._parseElementsFromSource(node, guiNode, parent);
  15110. }
  15111. };
  15112. /**
  15113. * Gets if the loading has finished.
  15114. * @returns whether the loading has finished or not
  15115. */
  15116. XmlLoader.prototype.isLoaded = function () {
  15117. return this._isLoaded;
  15118. };
  15119. /**
  15120. * Gets a loaded node / control by id.
  15121. * @param id the Controls id set in the xml
  15122. * @returns element of type Control
  15123. */
  15124. XmlLoader.prototype.getNodeById = function (id) {
  15125. return this._nodes[id];
  15126. };
  15127. /**
  15128. * Gets all loaded nodes / controls
  15129. * @returns Array of controls
  15130. */
  15131. XmlLoader.prototype.getNodes = function () {
  15132. return this._nodes;
  15133. };
  15134. /**
  15135. * Initiates the xml layout loading
  15136. * @param xmlFile defines the xml layout to load
  15137. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  15138. * @param callback defines the callback called on layout load.
  15139. */
  15140. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  15141. var xhttp = new XMLHttpRequest();
  15142. xhttp.onreadystatechange = function () {
  15143. if (xhttp.readyState == 4 && xhttp.status == 200) {
  15144. if (!xhttp.responseXML) {
  15145. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  15146. }
  15147. var xmlDoc = xhttp.responseXML.documentElement;
  15148. this._parseXml(xmlDoc.firstChild, rootNode);
  15149. this._isLoaded = true;
  15150. if (callback) {
  15151. callback();
  15152. }
  15153. }
  15154. }.bind(this);
  15155. xhttp.open("GET", xmlFile, true);
  15156. xhttp.send();
  15157. };
  15158. return XmlLoader;
  15159. }());
  15160. /***/ }),
  15161. /***/ "./3D/controls/abstractButton3D.ts":
  15162. /*!*****************************************!*\
  15163. !*** ./3D/controls/abstractButton3D.ts ***!
  15164. \*****************************************/
  15165. /*! exports provided: AbstractButton3D */
  15166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15167. "use strict";
  15168. __webpack_require__.r(__webpack_exports__);
  15169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  15170. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15171. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  15172. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  15173. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  15174. /**
  15175. * Class used as a root to all buttons
  15176. */
  15177. var AbstractButton3D = /** @class */ (function (_super) {
  15178. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  15179. /**
  15180. * Creates a new button
  15181. * @param name defines the control name
  15182. */
  15183. function AbstractButton3D(name) {
  15184. return _super.call(this, name) || this;
  15185. }
  15186. AbstractButton3D.prototype._getTypeName = function () {
  15187. return "AbstractButton3D";
  15188. };
  15189. // Mesh association
  15190. AbstractButton3D.prototype._createNode = function (scene) {
  15191. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  15192. };
  15193. return AbstractButton3D;
  15194. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  15195. /***/ }),
  15196. /***/ "./3D/controls/button3D.ts":
  15197. /*!*********************************!*\
  15198. !*** ./3D/controls/button3D.ts ***!
  15199. \*********************************/
  15200. /*! exports provided: Button3D */
  15201. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15202. "use strict";
  15203. __webpack_require__.r(__webpack_exports__);
  15204. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  15205. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15206. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  15207. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  15208. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  15209. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  15210. /**
  15211. * Class used to create a button in 3D
  15212. */
  15213. var Button3D = /** @class */ (function (_super) {
  15214. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  15215. /**
  15216. * Creates a new button
  15217. * @param name defines the control name
  15218. */
  15219. function Button3D(name) {
  15220. var _this = _super.call(this, name) || this;
  15221. _this._contentResolution = 512;
  15222. _this._contentScaleRatio = 2;
  15223. // Default animations
  15224. _this.pointerEnterAnimation = function () {
  15225. if (!_this.mesh) {
  15226. return;
  15227. }
  15228. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  15229. };
  15230. _this.pointerOutAnimation = function () {
  15231. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  15232. };
  15233. _this.pointerDownAnimation = function () {
  15234. if (!_this.mesh) {
  15235. return;
  15236. }
  15237. _this.mesh.scaling.scaleInPlace(0.95);
  15238. };
  15239. _this.pointerUpAnimation = function () {
  15240. if (!_this.mesh) {
  15241. return;
  15242. }
  15243. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  15244. };
  15245. return _this;
  15246. }
  15247. Object.defineProperty(Button3D.prototype, "contentResolution", {
  15248. /**
  15249. * Gets or sets the texture resolution used to render content (512 by default)
  15250. */
  15251. get: function () {
  15252. return this._contentResolution;
  15253. },
  15254. set: function (value) {
  15255. if (this._contentResolution === value) {
  15256. return;
  15257. }
  15258. this._contentResolution = value;
  15259. this._resetContent();
  15260. },
  15261. enumerable: false,
  15262. configurable: true
  15263. });
  15264. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  15265. /**
  15266. * Gets or sets the texture scale ratio used to render content (2 by default)
  15267. */
  15268. get: function () {
  15269. return this._contentScaleRatio;
  15270. },
  15271. set: function (value) {
  15272. if (this._contentScaleRatio === value) {
  15273. return;
  15274. }
  15275. this._contentScaleRatio = value;
  15276. this._resetContent();
  15277. },
  15278. enumerable: false,
  15279. configurable: true
  15280. });
  15281. Button3D.prototype._disposeFacadeTexture = function () {
  15282. if (this._facadeTexture) {
  15283. this._facadeTexture.dispose();
  15284. this._facadeTexture = null;
  15285. }
  15286. };
  15287. Button3D.prototype._resetContent = function () {
  15288. this._disposeFacadeTexture();
  15289. this.content = this._content;
  15290. };
  15291. Object.defineProperty(Button3D.prototype, "content", {
  15292. /**
  15293. * Gets or sets the GUI 2D content used to display the button's facade
  15294. */
  15295. get: function () {
  15296. return this._content;
  15297. },
  15298. set: function (value) {
  15299. this._content = value;
  15300. if (!this._host || !this._host.utilityLayer) {
  15301. return;
  15302. }
  15303. if (!this._facadeTexture) {
  15304. 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);
  15305. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  15306. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  15307. this._facadeTexture.premulAlpha = true;
  15308. }
  15309. else {
  15310. this._facadeTexture.rootContainer.clearControls();
  15311. }
  15312. this._facadeTexture.addControl(value);
  15313. this._applyFacade(this._facadeTexture);
  15314. },
  15315. enumerable: false,
  15316. configurable: true
  15317. });
  15318. /**
  15319. * Apply the facade texture (created from the content property).
  15320. * This function can be overloaded by child classes
  15321. * @param facadeTexture defines the AdvancedDynamicTexture to use
  15322. */
  15323. Button3D.prototype._applyFacade = function (facadeTexture) {
  15324. this._currentMaterial.emissiveTexture = facadeTexture;
  15325. };
  15326. Button3D.prototype._getTypeName = function () {
  15327. return "Button3D";
  15328. };
  15329. // Mesh association
  15330. Button3D.prototype._createNode = function (scene) {
  15331. var faceUV = new Array(6);
  15332. for (var i = 0; i < 6; i++) {
  15333. faceUV[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  15334. }
  15335. faceUV[1] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  15336. var mesh = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  15337. width: 1.0,
  15338. height: 1.0,
  15339. depth: 0.08,
  15340. faceUV: faceUV
  15341. }, scene);
  15342. return mesh;
  15343. };
  15344. Button3D.prototype._affectMaterial = function (mesh) {
  15345. var material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  15346. material.specularColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  15347. mesh.material = material;
  15348. this._currentMaterial = material;
  15349. this._resetContent();
  15350. };
  15351. /**
  15352. * Releases all associated resources
  15353. */
  15354. Button3D.prototype.dispose = function () {
  15355. _super.prototype.dispose.call(this);
  15356. this._disposeFacadeTexture();
  15357. if (this._currentMaterial) {
  15358. this._currentMaterial.dispose();
  15359. }
  15360. };
  15361. return Button3D;
  15362. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  15363. /***/ }),
  15364. /***/ "./3D/controls/container3D.ts":
  15365. /*!************************************!*\
  15366. !*** ./3D/controls/container3D.ts ***!
  15367. \************************************/
  15368. /*! exports provided: Container3D */
  15369. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15370. "use strict";
  15371. __webpack_require__.r(__webpack_exports__);
  15372. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  15373. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15374. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  15375. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  15376. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  15377. /**
  15378. * Class used to create containers for controls
  15379. */
  15380. var Container3D = /** @class */ (function (_super) {
  15381. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  15382. /**
  15383. * Creates a new container
  15384. * @param name defines the container name
  15385. */
  15386. function Container3D(name) {
  15387. var _this = _super.call(this, name) || this;
  15388. _this._blockLayout = false;
  15389. /**
  15390. * Gets the list of child controls
  15391. */
  15392. _this._children = new Array();
  15393. return _this;
  15394. }
  15395. Object.defineProperty(Container3D.prototype, "children", {
  15396. /**
  15397. * Gets the list of child controls
  15398. */
  15399. get: function () {
  15400. return this._children;
  15401. },
  15402. enumerable: false,
  15403. configurable: true
  15404. });
  15405. Object.defineProperty(Container3D.prototype, "blockLayout", {
  15406. /**
  15407. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  15408. * This is helpful to optimize layout operation when adding multiple children in a row
  15409. */
  15410. get: function () {
  15411. return this._blockLayout;
  15412. },
  15413. set: function (value) {
  15414. if (this._blockLayout === value) {
  15415. return;
  15416. }
  15417. this._blockLayout = value;
  15418. if (!this._blockLayout) {
  15419. this._arrangeChildren();
  15420. }
  15421. },
  15422. enumerable: false,
  15423. configurable: true
  15424. });
  15425. /**
  15426. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  15427. * @returns the current container
  15428. */
  15429. Container3D.prototype.updateLayout = function () {
  15430. this._arrangeChildren();
  15431. return this;
  15432. };
  15433. /**
  15434. * Gets a boolean indicating if the given control is in the children of this control
  15435. * @param control defines the control to check
  15436. * @returns true if the control is in the child list
  15437. */
  15438. Container3D.prototype.containsControl = function (control) {
  15439. return this._children.indexOf(control) !== -1;
  15440. };
  15441. /**
  15442. * Adds a control to the children of this control
  15443. * @param control defines the control to add
  15444. * @returns the current container
  15445. */
  15446. Container3D.prototype.addControl = function (control) {
  15447. var index = this._children.indexOf(control);
  15448. if (index !== -1) {
  15449. return this;
  15450. }
  15451. control.parent = this;
  15452. control._host = this._host;
  15453. this._children.push(control);
  15454. if (this._host.utilityLayer) {
  15455. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  15456. if (control.node) {
  15457. control.node.parent = this.node;
  15458. }
  15459. if (!this.blockLayout) {
  15460. this._arrangeChildren();
  15461. }
  15462. }
  15463. return this;
  15464. };
  15465. /**
  15466. * This function will be called everytime a new control is added
  15467. */
  15468. Container3D.prototype._arrangeChildren = function () {
  15469. };
  15470. Container3D.prototype._createNode = function (scene) {
  15471. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  15472. };
  15473. /**
  15474. * Removes a control from the children of this control
  15475. * @param control defines the control to remove
  15476. * @returns the current container
  15477. */
  15478. Container3D.prototype.removeControl = function (control) {
  15479. var index = this._children.indexOf(control);
  15480. if (index !== -1) {
  15481. this._children.splice(index, 1);
  15482. control.parent = null;
  15483. control._disposeNode();
  15484. }
  15485. return this;
  15486. };
  15487. Container3D.prototype._getTypeName = function () {
  15488. return "Container3D";
  15489. };
  15490. /**
  15491. * Releases all associated resources
  15492. */
  15493. Container3D.prototype.dispose = function () {
  15494. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15495. var control = _a[_i];
  15496. control.dispose();
  15497. }
  15498. this._children = [];
  15499. _super.prototype.dispose.call(this);
  15500. };
  15501. /** Control rotation will remain unchanged */
  15502. Container3D.UNSET_ORIENTATION = 0;
  15503. /** Control will rotate to make it look at sphere central axis */
  15504. Container3D.FACEORIGIN_ORIENTATION = 1;
  15505. /** Control will rotate to make it look back at sphere central axis */
  15506. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  15507. /** Control will rotate to look at z axis (0, 0, 1) */
  15508. Container3D.FACEFORWARD_ORIENTATION = 3;
  15509. /** Control will rotate to look at negative z axis (0, 0, -1) */
  15510. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  15511. return Container3D;
  15512. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  15513. /***/ }),
  15514. /***/ "./3D/controls/control3D.ts":
  15515. /*!**********************************!*\
  15516. !*** ./3D/controls/control3D.ts ***!
  15517. \**********************************/
  15518. /*! exports provided: Control3D */
  15519. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15520. "use strict";
  15521. __webpack_require__.r(__webpack_exports__);
  15522. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  15523. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  15524. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15525. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  15526. /**
  15527. * Class used as base class for controls
  15528. */
  15529. var Control3D = /** @class */ (function () {
  15530. /**
  15531. * Creates a new control
  15532. * @param name defines the control name
  15533. */
  15534. function Control3D(
  15535. /** Defines the control name */
  15536. name) {
  15537. this.name = name;
  15538. this._downCount = 0;
  15539. this._enterCount = -1;
  15540. this._downPointerIds = {};
  15541. this._isVisible = true;
  15542. /**
  15543. * An event triggered when the pointer move over the control
  15544. */
  15545. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15546. /**
  15547. * An event triggered when the pointer move out of the control
  15548. */
  15549. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15550. /**
  15551. * An event triggered when the pointer taps the control
  15552. */
  15553. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15554. /**
  15555. * An event triggered when pointer is up
  15556. */
  15557. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15558. /**
  15559. * An event triggered when a control is clicked on (with a mouse)
  15560. */
  15561. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15562. /**
  15563. * An event triggered when pointer enters the control
  15564. */
  15565. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15566. // Behaviors
  15567. this._behaviors = new Array();
  15568. }
  15569. Object.defineProperty(Control3D.prototype, "position", {
  15570. /** Gets or sets the control position in world space */
  15571. get: function () {
  15572. if (!this._node) {
  15573. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  15574. }
  15575. return this._node.position;
  15576. },
  15577. set: function (value) {
  15578. if (!this._node) {
  15579. return;
  15580. }
  15581. this._node.position = value;
  15582. },
  15583. enumerable: false,
  15584. configurable: true
  15585. });
  15586. Object.defineProperty(Control3D.prototype, "scaling", {
  15587. /** Gets or sets the control scaling in world space */
  15588. get: function () {
  15589. if (!this._node) {
  15590. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  15591. }
  15592. return this._node.scaling;
  15593. },
  15594. set: function (value) {
  15595. if (!this._node) {
  15596. return;
  15597. }
  15598. this._node.scaling = value;
  15599. },
  15600. enumerable: false,
  15601. configurable: true
  15602. });
  15603. Object.defineProperty(Control3D.prototype, "behaviors", {
  15604. /**
  15605. * Gets the list of attached behaviors
  15606. * @see https://doc.babylonjs.com/features/behaviour
  15607. */
  15608. get: function () {
  15609. return this._behaviors;
  15610. },
  15611. enumerable: false,
  15612. configurable: true
  15613. });
  15614. /**
  15615. * Attach a behavior to the control
  15616. * @see https://doc.babylonjs.com/features/behaviour
  15617. * @param behavior defines the behavior to attach
  15618. * @returns the current control
  15619. */
  15620. Control3D.prototype.addBehavior = function (behavior) {
  15621. var _this = this;
  15622. var index = this._behaviors.indexOf(behavior);
  15623. if (index !== -1) {
  15624. return this;
  15625. }
  15626. behavior.init();
  15627. var scene = this._host.scene;
  15628. if (scene.isLoading) {
  15629. // We defer the attach when the scene will be loaded
  15630. scene.onDataLoadedObservable.addOnce(function () {
  15631. behavior.attach(_this);
  15632. });
  15633. }
  15634. else {
  15635. behavior.attach(this);
  15636. }
  15637. this._behaviors.push(behavior);
  15638. return this;
  15639. };
  15640. /**
  15641. * Remove an attached behavior
  15642. * @see https://doc.babylonjs.com/features/behaviour
  15643. * @param behavior defines the behavior to attach
  15644. * @returns the current control
  15645. */
  15646. Control3D.prototype.removeBehavior = function (behavior) {
  15647. var index = this._behaviors.indexOf(behavior);
  15648. if (index === -1) {
  15649. return this;
  15650. }
  15651. this._behaviors[index].detach();
  15652. this._behaviors.splice(index, 1);
  15653. return this;
  15654. };
  15655. /**
  15656. * Gets an attached behavior by name
  15657. * @param name defines the name of the behavior to look for
  15658. * @see https://doc.babylonjs.com/features/behaviour
  15659. * @returns null if behavior was not found else the requested behavior
  15660. */
  15661. Control3D.prototype.getBehaviorByName = function (name) {
  15662. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  15663. var behavior = _a[_i];
  15664. if (behavior.name === name) {
  15665. return behavior;
  15666. }
  15667. }
  15668. return null;
  15669. };
  15670. Object.defineProperty(Control3D.prototype, "isVisible", {
  15671. /** Gets or sets a boolean indicating if the control is visible */
  15672. get: function () {
  15673. return this._isVisible;
  15674. },
  15675. set: function (value) {
  15676. if (this._isVisible === value) {
  15677. return;
  15678. }
  15679. this._isVisible = value;
  15680. var mesh = this.mesh;
  15681. if (mesh) {
  15682. mesh.setEnabled(value);
  15683. }
  15684. },
  15685. enumerable: false,
  15686. configurable: true
  15687. });
  15688. Object.defineProperty(Control3D.prototype, "typeName", {
  15689. /**
  15690. * Gets a string representing the class name
  15691. */
  15692. get: function () {
  15693. return this._getTypeName();
  15694. },
  15695. enumerable: false,
  15696. configurable: true
  15697. });
  15698. /**
  15699. * Get the current class name of the control.
  15700. * @returns current class name
  15701. */
  15702. Control3D.prototype.getClassName = function () {
  15703. return this._getTypeName();
  15704. };
  15705. Control3D.prototype._getTypeName = function () {
  15706. return "Control3D";
  15707. };
  15708. Object.defineProperty(Control3D.prototype, "node", {
  15709. /**
  15710. * Gets the transform node used by this control
  15711. */
  15712. get: function () {
  15713. return this._node;
  15714. },
  15715. enumerable: false,
  15716. configurable: true
  15717. });
  15718. Object.defineProperty(Control3D.prototype, "mesh", {
  15719. /**
  15720. * Gets the mesh used to render this control
  15721. */
  15722. get: function () {
  15723. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  15724. return this._node;
  15725. }
  15726. return null;
  15727. },
  15728. enumerable: false,
  15729. configurable: true
  15730. });
  15731. /**
  15732. * Link the control as child of the given node
  15733. * @param node defines the node to link to. Use null to unlink the control
  15734. * @returns the current control
  15735. */
  15736. Control3D.prototype.linkToTransformNode = function (node) {
  15737. if (this._node) {
  15738. this._node.parent = node;
  15739. }
  15740. return this;
  15741. };
  15742. /** @hidden **/
  15743. Control3D.prototype._prepareNode = function (scene) {
  15744. if (!this._node) {
  15745. this._node = this._createNode(scene);
  15746. if (!this.node) {
  15747. return;
  15748. }
  15749. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  15750. this._node.position = this.position;
  15751. this._node.scaling = this.scaling;
  15752. var mesh = this.mesh;
  15753. if (mesh) {
  15754. mesh.isPickable = true;
  15755. this._affectMaterial(mesh);
  15756. }
  15757. }
  15758. };
  15759. /**
  15760. * Node creation.
  15761. * Can be overriden by children
  15762. * @param scene defines the scene where the node must be attached
  15763. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  15764. */
  15765. Control3D.prototype._createNode = function (scene) {
  15766. // Do nothing by default
  15767. return null;
  15768. };
  15769. /**
  15770. * Affect a material to the given mesh
  15771. * @param mesh defines the mesh which will represent the control
  15772. */
  15773. Control3D.prototype._affectMaterial = function (mesh) {
  15774. mesh.material = null;
  15775. };
  15776. // Pointers
  15777. /** @hidden */
  15778. Control3D.prototype._onPointerMove = function (target, coordinates) {
  15779. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  15780. };
  15781. /** @hidden */
  15782. Control3D.prototype._onPointerEnter = function (target) {
  15783. if (this._enterCount > 0) {
  15784. return false;
  15785. }
  15786. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  15787. this._enterCount = 0;
  15788. }
  15789. this._enterCount++;
  15790. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  15791. if (this.pointerEnterAnimation) {
  15792. this.pointerEnterAnimation();
  15793. }
  15794. return true;
  15795. };
  15796. /** @hidden */
  15797. Control3D.prototype._onPointerOut = function (target) {
  15798. this._enterCount = 0;
  15799. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  15800. if (this.pointerOutAnimation) {
  15801. this.pointerOutAnimation();
  15802. }
  15803. };
  15804. /** @hidden */
  15805. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  15806. if (this._downCount !== 0) {
  15807. this._downCount++;
  15808. return false;
  15809. }
  15810. this._downCount++;
  15811. this._downPointerIds[pointerId] = true;
  15812. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  15813. if (this.pointerDownAnimation) {
  15814. this.pointerDownAnimation();
  15815. }
  15816. return true;
  15817. };
  15818. /** @hidden */
  15819. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  15820. this._downCount--;
  15821. delete this._downPointerIds[pointerId];
  15822. if (this._downCount < 0) {
  15823. // Handle if forcePointerUp was called prior to this
  15824. this._downCount = 0;
  15825. return;
  15826. }
  15827. if (this._downCount == 0) {
  15828. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  15829. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  15830. }
  15831. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  15832. if (this.pointerUpAnimation) {
  15833. this.pointerUpAnimation();
  15834. }
  15835. }
  15836. };
  15837. /** @hidden */
  15838. Control3D.prototype.forcePointerUp = function (pointerId) {
  15839. if (pointerId === void 0) { pointerId = null; }
  15840. if (pointerId !== null) {
  15841. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  15842. }
  15843. else {
  15844. for (var key in this._downPointerIds) {
  15845. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  15846. }
  15847. if (this._downCount > 0) {
  15848. this._downCount = 1;
  15849. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  15850. }
  15851. }
  15852. };
  15853. /** @hidden */
  15854. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  15855. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15856. this._onPointerMove(this, pickedPoint);
  15857. var previousControlOver = this._host._lastControlOver[pointerId];
  15858. if (previousControlOver && previousControlOver !== this) {
  15859. previousControlOver._onPointerOut(this);
  15860. }
  15861. if (previousControlOver !== this) {
  15862. this._onPointerEnter(this);
  15863. }
  15864. this._host._lastControlOver[pointerId] = this;
  15865. return true;
  15866. }
  15867. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  15868. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  15869. this._host._lastControlDown[pointerId] = this;
  15870. this._host._lastPickedControl = this;
  15871. return true;
  15872. }
  15873. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP || type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP) {
  15874. if (this._host._lastControlDown[pointerId]) {
  15875. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  15876. }
  15877. delete this._host._lastControlDown[pointerId];
  15878. return true;
  15879. }
  15880. return false;
  15881. };
  15882. /** @hidden */
  15883. Control3D.prototype._disposeNode = function () {
  15884. if (this._node) {
  15885. this._node.dispose();
  15886. this._node = null;
  15887. }
  15888. };
  15889. /**
  15890. * Releases all associated resources
  15891. */
  15892. Control3D.prototype.dispose = function () {
  15893. this.onPointerDownObservable.clear();
  15894. this.onPointerEnterObservable.clear();
  15895. this.onPointerMoveObservable.clear();
  15896. this.onPointerOutObservable.clear();
  15897. this.onPointerUpObservable.clear();
  15898. this.onPointerClickObservable.clear();
  15899. this._disposeNode();
  15900. // Behaviors
  15901. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  15902. var behavior = _a[_i];
  15903. behavior.detach();
  15904. }
  15905. };
  15906. return Control3D;
  15907. }());
  15908. /***/ }),
  15909. /***/ "./3D/controls/cylinderPanel.ts":
  15910. /*!**************************************!*\
  15911. !*** ./3D/controls/cylinderPanel.ts ***!
  15912. \**************************************/
  15913. /*! exports provided: CylinderPanel */
  15914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15915. "use strict";
  15916. __webpack_require__.r(__webpack_exports__);
  15917. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  15918. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15919. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15920. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15921. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15922. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15923. /**
  15924. * Class used to create a container panel deployed on the surface of a cylinder
  15925. */
  15926. var CylinderPanel = /** @class */ (function (_super) {
  15927. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  15928. function CylinderPanel() {
  15929. var _this = _super !== null && _super.apply(this, arguments) || this;
  15930. _this._radius = 5.0;
  15931. return _this;
  15932. }
  15933. Object.defineProperty(CylinderPanel.prototype, "radius", {
  15934. /**
  15935. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  15936. */
  15937. get: function () {
  15938. return this._radius;
  15939. },
  15940. set: function (value) {
  15941. var _this = this;
  15942. if (this._radius === value) {
  15943. return;
  15944. }
  15945. this._radius = value;
  15946. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15947. _this._arrangeChildren();
  15948. });
  15949. },
  15950. enumerable: false,
  15951. configurable: true
  15952. });
  15953. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  15954. var mesh = control.mesh;
  15955. if (!mesh) {
  15956. return;
  15957. }
  15958. var newPos = this._cylindricalMapping(nodePosition);
  15959. control.position = newPos;
  15960. switch (this.orientation) {
  15961. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15962. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  15963. break;
  15964. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15965. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  15966. break;
  15967. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15968. break;
  15969. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15970. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  15971. break;
  15972. }
  15973. };
  15974. CylinderPanel.prototype._cylindricalMapping = function (source) {
  15975. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  15976. var yAngle = (source.x / this._radius);
  15977. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15978. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15979. };
  15980. return CylinderPanel;
  15981. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15982. /***/ }),
  15983. /***/ "./3D/controls/holographicButton.ts":
  15984. /*!******************************************!*\
  15985. !*** ./3D/controls/holographicButton.ts ***!
  15986. \******************************************/
  15987. /*! exports provided: HolographicButton */
  15988. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15989. "use strict";
  15990. __webpack_require__.r(__webpack_exports__);
  15991. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  15992. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15993. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15994. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Materials/standardMaterial */ "babylonjs/Misc/perfCounter");
  15995. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__);
  15996. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  15997. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  15998. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  15999. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  16000. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  16001. /**
  16002. * Class used to create a holographic button in 3D
  16003. */
  16004. var HolographicButton = /** @class */ (function (_super) {
  16005. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  16006. /**
  16007. * Creates a new button
  16008. * @param name defines the control name
  16009. */
  16010. function HolographicButton(name, shareMaterials) {
  16011. if (shareMaterials === void 0) { shareMaterials = true; }
  16012. var _this = _super.call(this, name) || this;
  16013. _this._shareMaterials = true;
  16014. _this._shareMaterials = shareMaterials;
  16015. // Default animations
  16016. _this.pointerEnterAnimation = function () {
  16017. if (!_this.mesh) {
  16018. return;
  16019. }
  16020. _this._frontPlate.setEnabled(true);
  16021. };
  16022. _this.pointerOutAnimation = function () {
  16023. if (!_this.mesh) {
  16024. return;
  16025. }
  16026. _this._frontPlate.setEnabled(false);
  16027. };
  16028. return _this;
  16029. }
  16030. HolographicButton.prototype._disposeTooltip = function () {
  16031. this._tooltipFade = null;
  16032. if (this._tooltipTextBlock) {
  16033. this._tooltipTextBlock.dispose();
  16034. }
  16035. if (this._tooltipTexture) {
  16036. this._tooltipTexture.dispose();
  16037. }
  16038. if (this._tooltipMesh) {
  16039. this._tooltipMesh.dispose();
  16040. }
  16041. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  16042. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  16043. };
  16044. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  16045. get: function () {
  16046. return this._backPlate.renderingGroupId;
  16047. },
  16048. /**
  16049. * Rendering ground id of all the mesh in the button
  16050. */
  16051. set: function (id) {
  16052. this._backPlate.renderingGroupId = id;
  16053. this._textPlate.renderingGroupId = id;
  16054. this._frontPlate.renderingGroupId = id;
  16055. if (this._tooltipMesh) {
  16056. this._tooltipMesh.renderingGroupId = id;
  16057. }
  16058. },
  16059. enumerable: false,
  16060. configurable: true
  16061. });
  16062. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  16063. get: function () {
  16064. if (this._tooltipTextBlock) {
  16065. return this._tooltipTextBlock.text;
  16066. }
  16067. return null;
  16068. },
  16069. /**
  16070. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  16071. */
  16072. set: function (text) {
  16073. var _this = this;
  16074. if (!text) {
  16075. this._disposeTooltip();
  16076. return;
  16077. }
  16078. if (!this._tooltipFade) {
  16079. // Create tooltip with mesh and text
  16080. this._tooltipMesh = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  16081. 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);
  16082. var mat = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  16083. mat.diffuseColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  16084. tooltipBackground.material = mat;
  16085. tooltipBackground.isPickable = false;
  16086. this._tooltipMesh.addChild(tooltipBackground);
  16087. tooltipBackground.position.z = 0.05;
  16088. this._tooltipMesh.scaling.y = 1 / 3;
  16089. this._tooltipMesh.position.y = 0.7;
  16090. this._tooltipMesh.position.z = -0.15;
  16091. this._tooltipMesh.isPickable = false;
  16092. this._tooltipMesh.parent = this._backPlate;
  16093. // Create text texture for the tooltip
  16094. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  16095. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  16096. this._tooltipTextBlock.scaleY = 3;
  16097. this._tooltipTextBlock.color = "white";
  16098. this._tooltipTextBlock.fontSize = 130;
  16099. this._tooltipTexture.addControl(this._tooltipTextBlock);
  16100. // Add hover action to tooltip
  16101. this._tooltipFade = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  16102. this._tooltipFade.delay = 500;
  16103. this._tooltipMesh.addBehavior(this._tooltipFade);
  16104. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  16105. if (_this._tooltipFade) {
  16106. _this._tooltipFade.fadeIn(true);
  16107. }
  16108. });
  16109. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  16110. if (_this._tooltipFade) {
  16111. _this._tooltipFade.fadeIn(false);
  16112. }
  16113. });
  16114. }
  16115. if (this._tooltipTextBlock) {
  16116. this._tooltipTextBlock.text = text;
  16117. }
  16118. },
  16119. enumerable: false,
  16120. configurable: true
  16121. });
  16122. Object.defineProperty(HolographicButton.prototype, "text", {
  16123. /**
  16124. * Gets or sets text for the button
  16125. */
  16126. get: function () {
  16127. return this._text;
  16128. },
  16129. set: function (value) {
  16130. if (this._text === value) {
  16131. return;
  16132. }
  16133. this._text = value;
  16134. this._rebuildContent();
  16135. },
  16136. enumerable: false,
  16137. configurable: true
  16138. });
  16139. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  16140. /**
  16141. * Gets or sets the image url for the button
  16142. */
  16143. get: function () {
  16144. return this._imageUrl;
  16145. },
  16146. set: function (value) {
  16147. if (this._imageUrl === value) {
  16148. return;
  16149. }
  16150. this._imageUrl = value;
  16151. this._rebuildContent();
  16152. },
  16153. enumerable: false,
  16154. configurable: true
  16155. });
  16156. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  16157. /**
  16158. * Gets the back material used by this button
  16159. */
  16160. get: function () {
  16161. return this._backMaterial;
  16162. },
  16163. enumerable: false,
  16164. configurable: true
  16165. });
  16166. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  16167. /**
  16168. * Gets the front material used by this button
  16169. */
  16170. get: function () {
  16171. return this._frontMaterial;
  16172. },
  16173. enumerable: false,
  16174. configurable: true
  16175. });
  16176. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  16177. /**
  16178. * Gets the plate material used by this button
  16179. */
  16180. get: function () {
  16181. return this._plateMaterial;
  16182. },
  16183. enumerable: false,
  16184. configurable: true
  16185. });
  16186. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  16187. /**
  16188. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  16189. */
  16190. get: function () {
  16191. return this._shareMaterials;
  16192. },
  16193. enumerable: false,
  16194. configurable: true
  16195. });
  16196. HolographicButton.prototype._getTypeName = function () {
  16197. return "HolographicButton";
  16198. };
  16199. HolographicButton.prototype._rebuildContent = function () {
  16200. this._disposeFacadeTexture();
  16201. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  16202. panel.isVertical = true;
  16203. if (this._imageUrl) {
  16204. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  16205. image.source = this._imageUrl;
  16206. image.paddingTop = "40px";
  16207. image.height = "180px";
  16208. image.width = "100px";
  16209. image.paddingBottom = "40px";
  16210. panel.addControl(image);
  16211. }
  16212. if (this._text) {
  16213. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  16214. text.text = this._text;
  16215. text.color = "white";
  16216. text.height = "30px";
  16217. text.fontSize = 24;
  16218. panel.addControl(text);
  16219. }
  16220. if (this._frontPlate) {
  16221. this.content = panel;
  16222. }
  16223. };
  16224. // Mesh association
  16225. HolographicButton.prototype._createNode = function (scene) {
  16226. this._backPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  16227. width: 1.0,
  16228. height: 1.0,
  16229. depth: 0.08
  16230. }, scene);
  16231. this._frontPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  16232. width: 1.0,
  16233. height: 1.0,
  16234. depth: 0.08
  16235. }, scene);
  16236. this._frontPlate.parent = this._backPlate;
  16237. this._frontPlate.position.z = -0.08;
  16238. this._frontPlate.isPickable = false;
  16239. this._frontPlate.setEnabled(false);
  16240. this._textPlate = _super.prototype._createNode.call(this, scene);
  16241. this._textPlate.parent = this._backPlate;
  16242. this._textPlate.position.z = -0.08;
  16243. this._textPlate.isPickable = false;
  16244. return this._backPlate;
  16245. };
  16246. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  16247. this._plateMaterial.emissiveTexture = facadeTexture;
  16248. this._plateMaterial.opacityTexture = facadeTexture;
  16249. };
  16250. HolographicButton.prototype._createBackMaterial = function (mesh) {
  16251. var _this = this;
  16252. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  16253. this._backMaterial.renderHoverLight = true;
  16254. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  16255. if (pickedPoint) {
  16256. _this._backMaterial.hoverPosition = pickedPoint;
  16257. _this._backMaterial.hoverColor.a = 1.0;
  16258. }
  16259. else {
  16260. _this._backMaterial.hoverColor.a = 0;
  16261. }
  16262. });
  16263. };
  16264. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  16265. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  16266. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  16267. this._frontMaterial.alpha = 0.5; // Additive
  16268. this._frontMaterial.renderBorders = true;
  16269. };
  16270. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  16271. this._plateMaterial = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  16272. this._plateMaterial.specularColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  16273. };
  16274. HolographicButton.prototype._affectMaterial = function (mesh) {
  16275. // Back
  16276. if (this._shareMaterials) {
  16277. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  16278. this._createBackMaterial(mesh);
  16279. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  16280. }
  16281. else {
  16282. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  16283. }
  16284. // Front
  16285. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  16286. this._createFrontMaterial(mesh);
  16287. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  16288. }
  16289. else {
  16290. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  16291. }
  16292. }
  16293. else {
  16294. this._createBackMaterial(mesh);
  16295. this._createFrontMaterial(mesh);
  16296. }
  16297. this._createPlateMaterial(mesh);
  16298. this._backPlate.material = this._backMaterial;
  16299. this._frontPlate.material = this._frontMaterial;
  16300. this._textPlate.material = this._plateMaterial;
  16301. this._rebuildContent();
  16302. };
  16303. /**
  16304. * Releases all associated resources
  16305. */
  16306. HolographicButton.prototype.dispose = function () {
  16307. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  16308. this._disposeTooltip();
  16309. if (!this.shareMaterials) {
  16310. this._backMaterial.dispose();
  16311. this._frontMaterial.dispose();
  16312. this._plateMaterial.dispose();
  16313. if (this._pickedPointObserver) {
  16314. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  16315. this._pickedPointObserver = null;
  16316. }
  16317. }
  16318. };
  16319. return HolographicButton;
  16320. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  16321. /***/ }),
  16322. /***/ "./3D/controls/index.ts":
  16323. /*!******************************!*\
  16324. !*** ./3D/controls/index.ts ***!
  16325. \******************************/
  16326. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  16327. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16328. "use strict";
  16329. __webpack_require__.r(__webpack_exports__);
  16330. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  16331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16332. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  16333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  16334. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  16336. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  16337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  16338. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  16339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  16340. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  16341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  16342. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  16343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  16344. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  16345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  16346. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  16347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  16348. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  16349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  16350. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  16351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  16352. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  16353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  16354. /***/ }),
  16355. /***/ "./3D/controls/meshButton3D.ts":
  16356. /*!*************************************!*\
  16357. !*** ./3D/controls/meshButton3D.ts ***!
  16358. \*************************************/
  16359. /*! exports provided: MeshButton3D */
  16360. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16361. "use strict";
  16362. __webpack_require__.r(__webpack_exports__);
  16363. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  16364. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16365. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  16366. /**
  16367. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  16368. */
  16369. var MeshButton3D = /** @class */ (function (_super) {
  16370. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  16371. /**
  16372. * Creates a new 3D button based on a mesh
  16373. * @param mesh mesh to become a 3D button
  16374. * @param name defines the control name
  16375. */
  16376. function MeshButton3D(mesh, name) {
  16377. var _this = _super.call(this, name) || this;
  16378. _this._currentMesh = mesh;
  16379. /**
  16380. * Provides a default behavior on hover/out & up/down
  16381. * Override those function to create your own desired behavior specific to your mesh
  16382. */
  16383. _this.pointerEnterAnimation = function () {
  16384. if (!_this.mesh) {
  16385. return;
  16386. }
  16387. _this.mesh.scaling.scaleInPlace(1.1);
  16388. };
  16389. _this.pointerOutAnimation = function () {
  16390. if (!_this.mesh) {
  16391. return;
  16392. }
  16393. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  16394. };
  16395. _this.pointerDownAnimation = function () {
  16396. if (!_this.mesh) {
  16397. return;
  16398. }
  16399. _this.mesh.scaling.scaleInPlace(0.95);
  16400. };
  16401. _this.pointerUpAnimation = function () {
  16402. if (!_this.mesh) {
  16403. return;
  16404. }
  16405. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  16406. };
  16407. return _this;
  16408. }
  16409. MeshButton3D.prototype._getTypeName = function () {
  16410. return "MeshButton3D";
  16411. };
  16412. // Mesh association
  16413. MeshButton3D.prototype._createNode = function (scene) {
  16414. var _this = this;
  16415. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  16416. mesh.metadata = _this;
  16417. });
  16418. return this._currentMesh;
  16419. };
  16420. MeshButton3D.prototype._affectMaterial = function (mesh) {
  16421. };
  16422. return MeshButton3D;
  16423. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  16424. /***/ }),
  16425. /***/ "./3D/controls/planePanel.ts":
  16426. /*!***********************************!*\
  16427. !*** ./3D/controls/planePanel.ts ***!
  16428. \***********************************/
  16429. /*! exports provided: PlanePanel */
  16430. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16431. "use strict";
  16432. __webpack_require__.r(__webpack_exports__);
  16433. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  16434. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16435. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  16436. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  16437. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16438. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  16439. /**
  16440. * Class used to create a container panel deployed on the surface of a plane
  16441. */
  16442. var PlanePanel = /** @class */ (function (_super) {
  16443. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  16444. function PlanePanel() {
  16445. return _super !== null && _super.apply(this, arguments) || this;
  16446. }
  16447. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  16448. var mesh = control.mesh;
  16449. if (!mesh) {
  16450. return;
  16451. }
  16452. control.position = nodePosition.clone();
  16453. var target = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  16454. target.copyFrom(nodePosition);
  16455. switch (this.orientation) {
  16456. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  16457. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  16458. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  16459. mesh.lookAt(target);
  16460. break;
  16461. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  16462. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  16463. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  16464. mesh.lookAt(target);
  16465. break;
  16466. }
  16467. };
  16468. return PlanePanel;
  16469. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  16470. /***/ }),
  16471. /***/ "./3D/controls/scatterPanel.ts":
  16472. /*!*************************************!*\
  16473. !*** ./3D/controls/scatterPanel.ts ***!
  16474. \*************************************/
  16475. /*! exports provided: ScatterPanel */
  16476. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16477. "use strict";
  16478. __webpack_require__.r(__webpack_exports__);
  16479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  16480. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16481. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  16482. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  16483. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  16484. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16485. /**
  16486. * Class used to create a container panel where items get randomized planar mapping
  16487. */
  16488. var ScatterPanel = /** @class */ (function (_super) {
  16489. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  16490. function ScatterPanel() {
  16491. var _this = _super !== null && _super.apply(this, arguments) || this;
  16492. _this._iteration = 100.0;
  16493. return _this;
  16494. }
  16495. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  16496. /**
  16497. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  16498. */
  16499. get: function () {
  16500. return this._iteration;
  16501. },
  16502. set: function (value) {
  16503. var _this = this;
  16504. if (this._iteration === value) {
  16505. return;
  16506. }
  16507. this._iteration = value;
  16508. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16509. _this._arrangeChildren();
  16510. });
  16511. },
  16512. enumerable: false,
  16513. configurable: true
  16514. });
  16515. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  16516. var mesh = control.mesh;
  16517. var newPos = this._scatterMapping(nodePosition);
  16518. if (!mesh) {
  16519. return;
  16520. }
  16521. switch (this.orientation) {
  16522. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  16523. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  16524. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  16525. break;
  16526. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  16527. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  16528. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  16529. break;
  16530. }
  16531. control.position = newPos;
  16532. };
  16533. ScatterPanel.prototype._scatterMapping = function (source) {
  16534. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  16535. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  16536. return source;
  16537. };
  16538. ScatterPanel.prototype._finalProcessing = function () {
  16539. var meshes = [];
  16540. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  16541. var child = _a[_i];
  16542. if (!child.mesh) {
  16543. continue;
  16544. }
  16545. meshes.push(child.mesh);
  16546. }
  16547. for (var count = 0; count < this._iteration; count++) {
  16548. meshes.sort(function (a, b) {
  16549. var distance1 = a.position.lengthSquared();
  16550. var distance2 = b.position.lengthSquared();
  16551. if (distance1 < distance2) {
  16552. return 1;
  16553. }
  16554. else if (distance1 > distance2) {
  16555. return -1;
  16556. }
  16557. return 0;
  16558. });
  16559. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  16560. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  16561. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  16562. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  16563. for (var i = 0; i < meshes.length - 1; i++) {
  16564. for (var j = i + 1; j < meshes.length; j++) {
  16565. if (i != j) {
  16566. meshes[j].position.subtractToRef(meshes[i].position, difference);
  16567. // Ignore Z axis
  16568. difference2D.x = difference.x;
  16569. difference2D.y = difference.y;
  16570. var combinedRadius = cellSize;
  16571. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  16572. var minSeparation = Math.min(distance, radiusPaddingSquared);
  16573. distance -= minSeparation;
  16574. if (distance < (Math.pow(combinedRadius, 2.0))) {
  16575. difference2D.normalize();
  16576. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  16577. meshes[j].position.addInPlace(difference);
  16578. meshes[i].position.subtractInPlace(difference);
  16579. }
  16580. }
  16581. }
  16582. }
  16583. }
  16584. };
  16585. return ScatterPanel;
  16586. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  16587. /***/ }),
  16588. /***/ "./3D/controls/spherePanel.ts":
  16589. /*!************************************!*\
  16590. !*** ./3D/controls/spherePanel.ts ***!
  16591. \************************************/
  16592. /*! exports provided: SpherePanel */
  16593. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16594. "use strict";
  16595. __webpack_require__.r(__webpack_exports__);
  16596. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  16597. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16598. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  16599. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  16600. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  16601. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16602. /**
  16603. * Class used to create a container panel deployed on the surface of a sphere
  16604. */
  16605. var SpherePanel = /** @class */ (function (_super) {
  16606. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  16607. function SpherePanel() {
  16608. var _this = _super !== null && _super.apply(this, arguments) || this;
  16609. _this._radius = 5.0;
  16610. return _this;
  16611. }
  16612. Object.defineProperty(SpherePanel.prototype, "radius", {
  16613. /**
  16614. * Gets or sets the radius of the sphere where to project controls (5 by default)
  16615. */
  16616. get: function () {
  16617. return this._radius;
  16618. },
  16619. set: function (value) {
  16620. var _this = this;
  16621. if (this._radius === value) {
  16622. return;
  16623. }
  16624. this._radius = value;
  16625. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16626. _this._arrangeChildren();
  16627. });
  16628. },
  16629. enumerable: false,
  16630. configurable: true
  16631. });
  16632. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  16633. var mesh = control.mesh;
  16634. if (!mesh) {
  16635. return;
  16636. }
  16637. var newPos = this._sphericalMapping(nodePosition);
  16638. control.position = newPos;
  16639. switch (this.orientation) {
  16640. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  16641. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  16642. break;
  16643. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  16644. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  16645. break;
  16646. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  16647. break;
  16648. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  16649. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  16650. break;
  16651. }
  16652. };
  16653. SpherePanel.prototype._sphericalMapping = function (source) {
  16654. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  16655. var xAngle = (source.y / this._radius);
  16656. var yAngle = -(source.x / this._radius);
  16657. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16658. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16659. };
  16660. return SpherePanel;
  16661. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  16662. /***/ }),
  16663. /***/ "./3D/controls/stackPanel3D.ts":
  16664. /*!*************************************!*\
  16665. !*** ./3D/controls/stackPanel3D.ts ***!
  16666. \*************************************/
  16667. /*! exports provided: StackPanel3D */
  16668. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16669. "use strict";
  16670. __webpack_require__.r(__webpack_exports__);
  16671. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  16672. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16673. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  16674. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  16675. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16676. /**
  16677. * Class used to create a stack panel in 3D on XY plane
  16678. */
  16679. var StackPanel3D = /** @class */ (function (_super) {
  16680. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  16681. /**
  16682. * Creates new StackPanel
  16683. * @param isVertical
  16684. */
  16685. function StackPanel3D(isVertical) {
  16686. if (isVertical === void 0) { isVertical = false; }
  16687. var _this = _super.call(this) || this;
  16688. _this._isVertical = false;
  16689. /**
  16690. * Gets or sets the distance between elements
  16691. */
  16692. _this.margin = 0.1;
  16693. _this._isVertical = isVertical;
  16694. return _this;
  16695. }
  16696. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  16697. /**
  16698. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  16699. */
  16700. get: function () {
  16701. return this._isVertical;
  16702. },
  16703. set: function (value) {
  16704. var _this = this;
  16705. if (this._isVertical === value) {
  16706. return;
  16707. }
  16708. this._isVertical = value;
  16709. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16710. _this._arrangeChildren();
  16711. });
  16712. },
  16713. enumerable: false,
  16714. configurable: true
  16715. });
  16716. StackPanel3D.prototype._arrangeChildren = function () {
  16717. var width = 0;
  16718. var height = 0;
  16719. var controlCount = 0;
  16720. var extendSizes = [];
  16721. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  16722. // Measure
  16723. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  16724. var child = _a[_i];
  16725. if (!child.mesh) {
  16726. continue;
  16727. }
  16728. controlCount++;
  16729. child.mesh.computeWorldMatrix(true);
  16730. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16731. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  16732. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16733. extendSizes.push(extendSize);
  16734. if (this._isVertical) {
  16735. height += extendSize.y;
  16736. }
  16737. else {
  16738. width += extendSize.x;
  16739. }
  16740. }
  16741. if (this._isVertical) {
  16742. height += (controlCount - 1) * this.margin / 2;
  16743. }
  16744. else {
  16745. width += (controlCount - 1) * this.margin / 2;
  16746. }
  16747. // Arrange
  16748. var offset;
  16749. if (this._isVertical) {
  16750. offset = -height;
  16751. }
  16752. else {
  16753. offset = -width;
  16754. }
  16755. var index = 0;
  16756. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  16757. var child = _c[_b];
  16758. if (!child.mesh) {
  16759. continue;
  16760. }
  16761. controlCount--;
  16762. var extendSize = extendSizes[index++];
  16763. if (this._isVertical) {
  16764. child.position.y = offset + extendSize.y;
  16765. child.position.x = 0;
  16766. offset += extendSize.y * 2;
  16767. }
  16768. else {
  16769. child.position.x = offset + extendSize.x;
  16770. child.position.y = 0;
  16771. offset += extendSize.x * 2;
  16772. }
  16773. offset += (controlCount > 0 ? this.margin : 0);
  16774. }
  16775. };
  16776. return StackPanel3D;
  16777. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  16778. /***/ }),
  16779. /***/ "./3D/controls/volumeBasedPanel.ts":
  16780. /*!*****************************************!*\
  16781. !*** ./3D/controls/volumeBasedPanel.ts ***!
  16782. \*****************************************/
  16783. /*! exports provided: VolumeBasedPanel */
  16784. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16785. "use strict";
  16786. __webpack_require__.r(__webpack_exports__);
  16787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  16788. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16789. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  16790. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  16791. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16792. /**
  16793. * Abstract class used to create a container panel deployed on the surface of a volume
  16794. */
  16795. var VolumeBasedPanel = /** @class */ (function (_super) {
  16796. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  16797. /**
  16798. * Creates new VolumeBasedPanel
  16799. */
  16800. function VolumeBasedPanel() {
  16801. var _this = _super.call(this) || this;
  16802. _this._columns = 10;
  16803. _this._rows = 0;
  16804. _this._rowThenColum = true;
  16805. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  16806. /**
  16807. * Gets or sets the distance between elements
  16808. */
  16809. _this.margin = 0;
  16810. return _this;
  16811. }
  16812. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  16813. /**
  16814. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  16815. * | Value | Type | Description |
  16816. * | ----- | ----------------------------------- | ----------- |
  16817. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  16818. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  16819. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  16820. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  16821. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  16822. */
  16823. get: function () {
  16824. return this._orientation;
  16825. },
  16826. set: function (value) {
  16827. var _this = this;
  16828. if (this._orientation === value) {
  16829. return;
  16830. }
  16831. this._orientation = value;
  16832. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16833. _this._arrangeChildren();
  16834. });
  16835. },
  16836. enumerable: false,
  16837. configurable: true
  16838. });
  16839. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  16840. /**
  16841. * Gets or sets the number of columns requested (10 by default).
  16842. * The panel will automatically compute the number of rows based on number of child controls.
  16843. */
  16844. get: function () {
  16845. return this._columns;
  16846. },
  16847. set: function (value) {
  16848. var _this = this;
  16849. if (this._columns === value) {
  16850. return;
  16851. }
  16852. this._columns = value;
  16853. this._rowThenColum = true;
  16854. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16855. _this._arrangeChildren();
  16856. });
  16857. },
  16858. enumerable: false,
  16859. configurable: true
  16860. });
  16861. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  16862. /**
  16863. * Gets or sets a the number of rows requested.
  16864. * The panel will automatically compute the number of columns based on number of child controls.
  16865. */
  16866. get: function () {
  16867. return this._rows;
  16868. },
  16869. set: function (value) {
  16870. var _this = this;
  16871. if (this._rows === value) {
  16872. return;
  16873. }
  16874. this._rows = value;
  16875. this._rowThenColum = false;
  16876. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16877. _this._arrangeChildren();
  16878. });
  16879. },
  16880. enumerable: false,
  16881. configurable: true
  16882. });
  16883. VolumeBasedPanel.prototype._arrangeChildren = function () {
  16884. this._cellWidth = 0;
  16885. this._cellHeight = 0;
  16886. var rows = 0;
  16887. var columns = 0;
  16888. var controlCount = 0;
  16889. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  16890. // Measure
  16891. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  16892. var child = _a[_i];
  16893. if (!child.mesh) {
  16894. continue;
  16895. }
  16896. controlCount++;
  16897. child.mesh.computeWorldMatrix(true);
  16898. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  16899. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  16900. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  16901. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  16902. boundingBox.max.subtractToRef(boundingBox.min, diff);
  16903. diff.scaleInPlace(0.5);
  16904. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  16905. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  16906. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  16907. }
  16908. this._cellWidth += this.margin * 2;
  16909. this._cellHeight += this.margin * 2;
  16910. // Arrange
  16911. if (this._rowThenColum) {
  16912. columns = this._columns;
  16913. rows = Math.ceil(controlCount / this._columns);
  16914. }
  16915. else {
  16916. rows = this._rows;
  16917. columns = Math.ceil(controlCount / this._rows);
  16918. }
  16919. var startOffsetX = (columns * 0.5) * this._cellWidth;
  16920. var startOffsetY = (rows * 0.5) * this._cellHeight;
  16921. var nodeGrid = [];
  16922. var cellCounter = 0;
  16923. if (this._rowThenColum) {
  16924. for (var r = 0; r < rows; r++) {
  16925. for (var c = 0; c < columns; c++) {
  16926. 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));
  16927. cellCounter++;
  16928. if (cellCounter > controlCount) {
  16929. break;
  16930. }
  16931. }
  16932. }
  16933. }
  16934. else {
  16935. for (var c = 0; c < columns; c++) {
  16936. for (var r = 0; r < rows; r++) {
  16937. 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));
  16938. cellCounter++;
  16939. if (cellCounter > controlCount) {
  16940. break;
  16941. }
  16942. }
  16943. }
  16944. }
  16945. cellCounter = 0;
  16946. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  16947. var child = _c[_b];
  16948. if (!child.mesh) {
  16949. continue;
  16950. }
  16951. this._mapGridNode(child, nodeGrid[cellCounter]);
  16952. cellCounter++;
  16953. }
  16954. this._finalProcessing();
  16955. };
  16956. /** Child classes can implement this function to provide additional processing */
  16957. VolumeBasedPanel.prototype._finalProcessing = function () {
  16958. };
  16959. return VolumeBasedPanel;
  16960. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  16961. /***/ }),
  16962. /***/ "./3D/gui3DManager.ts":
  16963. /*!****************************!*\
  16964. !*** ./3D/gui3DManager.ts ***!
  16965. \****************************/
  16966. /*! exports provided: GUI3DManager */
  16967. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16968. "use strict";
  16969. __webpack_require__.r(__webpack_exports__);
  16970. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  16971. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  16972. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  16973. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  16974. /**
  16975. * Class used to manage 3D user interface
  16976. * @see https://doc.babylonjs.com/how_to/gui3d
  16977. */
  16978. var GUI3DManager = /** @class */ (function () {
  16979. /**
  16980. * Creates a new GUI3DManager
  16981. * @param scene
  16982. */
  16983. function GUI3DManager(scene) {
  16984. var _this = this;
  16985. /** @hidden */
  16986. this._lastControlOver = {};
  16987. /** @hidden */
  16988. this._lastControlDown = {};
  16989. /**
  16990. * Observable raised when the point picked by the pointer events changed
  16991. */
  16992. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  16993. // Shared resources
  16994. /** @hidden */
  16995. this._sharedMaterials = {};
  16996. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  16997. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  16998. _this._sceneDisposeObserver = null;
  16999. _this._utilityLayer = null;
  17000. _this.dispose();
  17001. });
  17002. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  17003. this._utilityLayer.onlyCheckPointerDownEvents = false;
  17004. this._utilityLayer.pickUtilitySceneFirst = false;
  17005. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  17006. return mesh && mesh.metadata && mesh.metadata._node;
  17007. };
  17008. // Root
  17009. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  17010. this._rootContainer._host = this;
  17011. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  17012. // Events
  17013. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  17014. _this._handlePointerOut(pointerId, true);
  17015. });
  17016. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  17017. _this._doPicking(pi);
  17018. });
  17019. // Scene
  17020. this._utilityLayer.utilityLayerScene.autoClear = false;
  17021. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  17022. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  17023. }
  17024. Object.defineProperty(GUI3DManager.prototype, "scene", {
  17025. /** Gets the hosting scene */
  17026. get: function () {
  17027. return this._scene;
  17028. },
  17029. enumerable: false,
  17030. configurable: true
  17031. });
  17032. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  17033. /** Gets associated utility layer */
  17034. get: function () {
  17035. return this._utilityLayer;
  17036. },
  17037. enumerable: false,
  17038. configurable: true
  17039. });
  17040. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  17041. var previousControlOver = this._lastControlOver[pointerId];
  17042. if (previousControlOver) {
  17043. previousControlOver._onPointerOut(previousControlOver);
  17044. delete this._lastControlOver[pointerId];
  17045. }
  17046. if (isPointerUp) {
  17047. if (this._lastControlDown[pointerId]) {
  17048. this._lastControlDown[pointerId].forcePointerUp();
  17049. delete this._lastControlDown[pointerId];
  17050. }
  17051. }
  17052. this.onPickedPointChangedObservable.notifyObservers(null);
  17053. };
  17054. GUI3DManager.prototype._doPicking = function (pi) {
  17055. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  17056. return false;
  17057. }
  17058. var pointerEvent = (pi.event);
  17059. var pointerId = pointerEvent.pointerId || 0;
  17060. var buttonIndex = pointerEvent.button;
  17061. var pickingInfo = pi.pickInfo;
  17062. if (!pickingInfo || !pickingInfo.hit) {
  17063. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  17064. return false;
  17065. }
  17066. var control = (pickingInfo.pickedMesh.metadata);
  17067. if (pickingInfo.pickedPoint) {
  17068. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  17069. }
  17070. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  17071. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  17072. if (this._lastControlOver[pointerId]) {
  17073. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  17074. }
  17075. delete this._lastControlOver[pointerId];
  17076. }
  17077. }
  17078. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  17079. if (this._lastControlDown[pointerEvent.pointerId]) {
  17080. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  17081. delete this._lastControlDown[pointerEvent.pointerId];
  17082. }
  17083. if (pointerEvent.pointerType === "touch") {
  17084. this._handlePointerOut(pointerId, false);
  17085. }
  17086. }
  17087. return true;
  17088. };
  17089. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  17090. /**
  17091. * Gets the root container
  17092. */
  17093. get: function () {
  17094. return this._rootContainer;
  17095. },
  17096. enumerable: false,
  17097. configurable: true
  17098. });
  17099. /**
  17100. * Gets a boolean indicating if the given control is in the root child list
  17101. * @param control defines the control to check
  17102. * @returns true if the control is in the root child list
  17103. */
  17104. GUI3DManager.prototype.containsControl = function (control) {
  17105. return this._rootContainer.containsControl(control);
  17106. };
  17107. /**
  17108. * Adds a control to the root child list
  17109. * @param control defines the control to add
  17110. * @returns the current manager
  17111. */
  17112. GUI3DManager.prototype.addControl = function (control) {
  17113. this._rootContainer.addControl(control);
  17114. return this;
  17115. };
  17116. /**
  17117. * Removes a control from the root child list
  17118. * @param control defines the control to remove
  17119. * @returns the current container
  17120. */
  17121. GUI3DManager.prototype.removeControl = function (control) {
  17122. this._rootContainer.removeControl(control);
  17123. return this;
  17124. };
  17125. /**
  17126. * Releases all associated resources
  17127. */
  17128. GUI3DManager.prototype.dispose = function () {
  17129. this._rootContainer.dispose();
  17130. for (var materialName in this._sharedMaterials) {
  17131. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  17132. continue;
  17133. }
  17134. this._sharedMaterials[materialName].dispose();
  17135. }
  17136. this._sharedMaterials = {};
  17137. if (this._pointerOutObserver && this._utilityLayer) {
  17138. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  17139. this._pointerOutObserver = null;
  17140. }
  17141. this.onPickedPointChangedObservable.clear();
  17142. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  17143. if (utilityLayerScene) {
  17144. if (this._pointerObserver) {
  17145. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  17146. this._pointerObserver = null;
  17147. }
  17148. }
  17149. if (this._scene) {
  17150. if (this._sceneDisposeObserver) {
  17151. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  17152. this._sceneDisposeObserver = null;
  17153. }
  17154. }
  17155. if (this._utilityLayer) {
  17156. this._utilityLayer.dispose();
  17157. }
  17158. };
  17159. return GUI3DManager;
  17160. }());
  17161. /***/ }),
  17162. /***/ "./3D/index.ts":
  17163. /*!*********************!*\
  17164. !*** ./3D/index.ts ***!
  17165. \*********************/
  17166. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  17167. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17168. "use strict";
  17169. __webpack_require__.r(__webpack_exports__);
  17170. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  17171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  17172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  17173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  17174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  17175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  17176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  17177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  17178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  17179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  17180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  17181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  17182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  17183. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  17184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  17185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  17186. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  17187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  17188. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  17189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  17190. /***/ }),
  17191. /***/ "./3D/materials/fluentMaterial.ts":
  17192. /*!****************************************!*\
  17193. !*** ./3D/materials/fluentMaterial.ts ***!
  17194. \****************************************/
  17195. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  17196. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17197. "use strict";
  17198. __webpack_require__.r(__webpack_exports__);
  17199. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  17200. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  17201. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  17202. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  17203. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  17204. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  17205. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  17206. /** @hidden */
  17207. var FluentMaterialDefines = /** @class */ (function (_super) {
  17208. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  17209. function FluentMaterialDefines() {
  17210. var _this = _super.call(this) || this;
  17211. _this.INNERGLOW = false;
  17212. _this.BORDER = false;
  17213. _this.HOVERLIGHT = false;
  17214. _this.TEXTURE = false;
  17215. _this.rebuild();
  17216. return _this;
  17217. }
  17218. return FluentMaterialDefines;
  17219. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  17220. /**
  17221. * Class used to render controls with fluent desgin
  17222. */
  17223. var FluentMaterial = /** @class */ (function (_super) {
  17224. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  17225. /**
  17226. * Creates a new Fluent material
  17227. * @param name defines the name of the material
  17228. * @param scene defines the hosting scene
  17229. */
  17230. function FluentMaterial(name, scene) {
  17231. var _this = _super.call(this, name, scene) || this;
  17232. /**
  17233. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  17234. */
  17235. _this.innerGlowColorIntensity = 0.5;
  17236. /**
  17237. * Gets or sets the inner glow color (white by default)
  17238. */
  17239. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  17240. /**
  17241. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  17242. */
  17243. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  17244. /**
  17245. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  17246. */
  17247. _this.renderBorders = false;
  17248. /**
  17249. * Gets or sets border width (default is 0.5)
  17250. */
  17251. _this.borderWidth = 0.5;
  17252. /**
  17253. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  17254. */
  17255. _this.edgeSmoothingValue = 0.02;
  17256. /**
  17257. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  17258. */
  17259. _this.borderMinValue = 0.1;
  17260. /**
  17261. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  17262. */
  17263. _this.renderHoverLight = false;
  17264. /**
  17265. * Gets or sets the radius used to render the hover light (default is 1.0)
  17266. */
  17267. _this.hoverRadius = 1.0;
  17268. /**
  17269. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  17270. */
  17271. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  17272. /**
  17273. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  17274. */
  17275. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  17276. return _this;
  17277. }
  17278. FluentMaterial.prototype.needAlphaBlending = function () {
  17279. return this.alpha !== 1.0;
  17280. };
  17281. FluentMaterial.prototype.needAlphaTesting = function () {
  17282. return false;
  17283. };
  17284. FluentMaterial.prototype.getAlphaTestTexture = function () {
  17285. return null;
  17286. };
  17287. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  17288. if (this.isFrozen) {
  17289. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  17290. return true;
  17291. }
  17292. }
  17293. if (!subMesh._materialDefines) {
  17294. subMesh._materialDefines = new FluentMaterialDefines();
  17295. }
  17296. var scene = this.getScene();
  17297. var defines = subMesh._materialDefines;
  17298. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  17299. if (defines._renderId === scene.getRenderId()) {
  17300. return true;
  17301. }
  17302. }
  17303. if (defines._areTexturesDirty) {
  17304. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  17305. defines.BORDER = this.renderBorders;
  17306. defines.HOVERLIGHT = this.renderHoverLight;
  17307. if (this._albedoTexture) {
  17308. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  17309. return false;
  17310. }
  17311. else {
  17312. defines.TEXTURE = true;
  17313. }
  17314. }
  17315. else {
  17316. defines.TEXTURE = false;
  17317. }
  17318. }
  17319. var engine = scene.getEngine();
  17320. // Get correct effect
  17321. if (defines.isDirty) {
  17322. defines.markAsProcessed();
  17323. scene.resetCachedMaterial();
  17324. //Attributes
  17325. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  17326. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  17327. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  17328. var shaderName = "fluent";
  17329. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  17330. "hoverColor", "hoverPosition", "hoverRadius"
  17331. ];
  17332. var samplers = ["albedoSampler"];
  17333. var uniformBuffers = new Array();
  17334. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  17335. uniformsNames: uniforms,
  17336. uniformBuffersNames: uniformBuffers,
  17337. samplers: samplers,
  17338. defines: defines,
  17339. maxSimultaneousLights: 4
  17340. });
  17341. var join = defines.toString();
  17342. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  17343. attributes: attribs,
  17344. uniformsNames: uniforms,
  17345. uniformBuffersNames: uniformBuffers,
  17346. samplers: samplers,
  17347. defines: join,
  17348. fallbacks: null,
  17349. onCompiled: this.onCompiled,
  17350. onError: this.onError,
  17351. indexParameters: { maxSimultaneousLights: 4 }
  17352. }, engine));
  17353. }
  17354. if (!subMesh.effect || !subMesh.effect.isReady()) {
  17355. return false;
  17356. }
  17357. defines._renderId = scene.getRenderId();
  17358. subMesh.effect._wasPreviouslyReady = true;
  17359. return true;
  17360. };
  17361. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  17362. var scene = this.getScene();
  17363. var defines = subMesh._materialDefines;
  17364. if (!defines) {
  17365. return;
  17366. }
  17367. var effect = subMesh.effect;
  17368. if (!effect) {
  17369. return;
  17370. }
  17371. this._activeEffect = effect;
  17372. // Matrices
  17373. this.bindOnlyWorldMatrix(world);
  17374. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  17375. if (this._mustRebind(scene, effect)) {
  17376. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  17377. if (defines.INNERGLOW) {
  17378. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  17379. }
  17380. if (defines.BORDER) {
  17381. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  17382. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  17383. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  17384. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  17385. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  17386. }
  17387. if (defines.HOVERLIGHT) {
  17388. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  17389. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  17390. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  17391. }
  17392. if (defines.TEXTURE) {
  17393. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  17394. }
  17395. }
  17396. this._afterBind(mesh, this._activeEffect);
  17397. };
  17398. FluentMaterial.prototype.getActiveTextures = function () {
  17399. var activeTextures = _super.prototype.getActiveTextures.call(this);
  17400. return activeTextures;
  17401. };
  17402. FluentMaterial.prototype.hasTexture = function (texture) {
  17403. if (_super.prototype.hasTexture.call(this, texture)) {
  17404. return true;
  17405. }
  17406. return false;
  17407. };
  17408. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  17409. _super.prototype.dispose.call(this, forceDisposeEffect);
  17410. };
  17411. FluentMaterial.prototype.clone = function (name) {
  17412. var _this = this;
  17413. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  17414. };
  17415. FluentMaterial.prototype.serialize = function () {
  17416. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  17417. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  17418. return serializationObject;
  17419. };
  17420. FluentMaterial.prototype.getClassName = function () {
  17421. return "FluentMaterial";
  17422. };
  17423. // Statics
  17424. FluentMaterial.Parse = function (source, scene, rootUrl) {
  17425. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  17426. };
  17427. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17428. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  17429. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  17430. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  17431. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17432. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  17433. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  17434. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17435. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  17436. ], FluentMaterial.prototype, "albedoColor", void 0);
  17437. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17438. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  17439. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  17440. ], FluentMaterial.prototype, "renderBorders", void 0);
  17441. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17442. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  17443. ], FluentMaterial.prototype, "borderWidth", void 0);
  17444. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17445. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  17446. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  17447. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17448. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  17449. ], FluentMaterial.prototype, "borderMinValue", void 0);
  17450. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17451. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  17452. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  17453. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  17454. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17455. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  17456. ], FluentMaterial.prototype, "hoverRadius", void 0);
  17457. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17458. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  17459. ], FluentMaterial.prototype, "hoverColor", void 0);
  17460. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17461. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  17462. ], FluentMaterial.prototype, "hoverPosition", void 0);
  17463. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17464. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  17465. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  17466. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  17467. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  17468. ], FluentMaterial.prototype, "albedoTexture", void 0);
  17469. return FluentMaterial;
  17470. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  17471. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  17472. /***/ }),
  17473. /***/ "./3D/materials/index.ts":
  17474. /*!*******************************!*\
  17475. !*** ./3D/materials/index.ts ***!
  17476. \*******************************/
  17477. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  17478. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17479. "use strict";
  17480. __webpack_require__.r(__webpack_exports__);
  17481. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  17482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  17483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  17484. /***/ }),
  17485. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  17486. /*!*************************************************!*\
  17487. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  17488. \*************************************************/
  17489. /*! exports provided: fluentPixelShader */
  17490. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17491. "use strict";
  17492. __webpack_require__.r(__webpack_exports__);
  17493. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  17494. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  17495. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  17496. var name = 'fluentPixelShader';
  17497. 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}";
  17498. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  17499. /** @hidden */
  17500. var fluentPixelShader = { name: name, shader: shader };
  17501. /***/ }),
  17502. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  17503. /*!***********************************************!*\
  17504. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  17505. \***********************************************/
  17506. /*! exports provided: fluentVertexShader */
  17507. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17508. "use strict";
  17509. __webpack_require__.r(__webpack_exports__);
  17510. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  17511. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  17512. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  17513. var name = 'fluentVertexShader';
  17514. 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";
  17515. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  17516. /** @hidden */
  17517. var fluentVertexShader = { name: name, shader: shader };
  17518. /***/ }),
  17519. /***/ "./3D/vector3WithInfo.ts":
  17520. /*!*******************************!*\
  17521. !*** ./3D/vector3WithInfo.ts ***!
  17522. \*******************************/
  17523. /*! exports provided: Vector3WithInfo */
  17524. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17525. "use strict";
  17526. __webpack_require__.r(__webpack_exports__);
  17527. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  17528. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  17529. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  17530. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  17531. /**
  17532. * Class used to transport Vector3 information for pointer events
  17533. */
  17534. var Vector3WithInfo = /** @class */ (function (_super) {
  17535. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  17536. /**
  17537. * Creates a new Vector3WithInfo
  17538. * @param source defines the vector3 data to transport
  17539. * @param buttonIndex defines the current mouse button index
  17540. */
  17541. function Vector3WithInfo(source,
  17542. /** defines the current mouse button index */
  17543. buttonIndex) {
  17544. if (buttonIndex === void 0) { buttonIndex = 0; }
  17545. var _this = _super.call(this, source.x, source.y, source.z) || this;
  17546. _this.buttonIndex = buttonIndex;
  17547. return _this;
  17548. }
  17549. return Vector3WithInfo;
  17550. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  17551. /***/ }),
  17552. /***/ "./index.ts":
  17553. /*!******************!*\
  17554. !*** ./index.ts ***!
  17555. \******************/
  17556. /*! 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 */
  17557. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17558. "use strict";
  17559. __webpack_require__.r(__webpack_exports__);
  17560. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  17561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  17562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  17563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  17564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  17565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  17566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  17567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["FocusableButton"]; });
  17568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  17569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  17570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  17571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  17572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  17573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  17574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  17575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  17576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  17577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  17578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  17579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  17580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  17581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  17582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  17583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  17584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapper"]; });
  17585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ToggleButton"]; });
  17586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  17587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  17588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  17589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  17590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  17591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  17592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  17593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  17594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  17595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  17596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  17597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  17598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  17599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  17600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  17601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  17602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  17603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  17604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  17605. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  17606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  17607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  17608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  17609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  17610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  17611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  17612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  17613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  17614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  17615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  17616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  17617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  17618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  17619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  17620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  17621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  17622. /***/ }),
  17623. /***/ "./legacy/legacy.ts":
  17624. /*!**************************!*\
  17625. !*** ./legacy/legacy.ts ***!
  17626. \**************************/
  17627. /*! 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 */
  17628. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17629. "use strict";
  17630. __webpack_require__.r(__webpack_exports__);
  17631. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  17632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  17633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  17634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  17635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  17636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  17637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  17638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FocusableButton"]; });
  17639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  17640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  17641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  17642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  17643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  17644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  17645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  17646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  17647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  17648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  17649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  17650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  17651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  17652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  17653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  17654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  17655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapper"]; });
  17656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToggleButton"]; });
  17657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  17658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  17659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  17660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  17661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  17662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  17663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  17664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  17665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  17666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  17667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  17668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  17669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  17670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  17671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  17672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  17673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  17674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  17675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  17676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  17677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  17678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  17679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  17680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  17681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  17682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  17683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  17684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  17685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  17686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  17687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  17688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  17689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  17690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  17691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  17692. /**
  17693. * Legacy support, defining window.BABYLON.GUI (global variable).
  17694. *
  17695. * This is the entry point for the UMD module.
  17696. * The entry point for a future ESM package should be index.ts
  17697. */
  17698. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  17699. if (typeof globalObject !== "undefined") {
  17700. globalObject.BABYLON = globalObject.BABYLON || {};
  17701. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  17702. }
  17703. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  17704. /***/ }),
  17705. /***/ "babylonjs/Misc/perfCounter":
  17706. /*!****************************************************************************************************!*\
  17707. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  17708. \****************************************************************************************************/
  17709. /*! no static exports found */
  17710. /***/ (function(module, exports) {
  17711. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__;
  17712. /***/ })
  17713. /******/ });
  17714. });
  17715. //# sourceMappingURL=babylon.gui.js.map