babylon.gui.js 749 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-gui", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-gui"] = factory(require("babylonjs"));
  8. else
  9. root["BABYLON"] = root["BABYLON"] || {}, root["BABYLON"]["GUI"] = factory(root["BABYLON"]);
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!***********************************************************!*\
  100. !*** C:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  126. /*! *****************************************************************************
  127. Copyright (c) Microsoft Corporation. All rights reserved.
  128. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  129. this file except in compliance with the License. You may obtain a copy of the
  130. License at http://www.apache.org/licenses/LICENSE-2.0
  131. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  132. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  133. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  134. MERCHANTABLITY OR NON-INFRINGEMENT.
  135. See the Apache Version 2.0 License for specific language governing permissions
  136. and limitations under the License.
  137. ***************************************************************************** */
  138. /* global Reflect, Promise */
  139. var extendStatics = function(d, b) {
  140. extendStatics = Object.setPrototypeOf ||
  141. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  142. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  143. return extendStatics(d, b);
  144. };
  145. function __extends(d, b) {
  146. extendStatics(d, b);
  147. function __() { this.constructor = d; }
  148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  149. }
  150. var __assign = function() {
  151. __assign = Object.assign || function __assign(t) {
  152. for (var s, i = 1, n = arguments.length; i < n; i++) {
  153. s = arguments[i];
  154. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  155. }
  156. return t;
  157. }
  158. return __assign.apply(this, arguments);
  159. }
  160. function __rest(s, e) {
  161. var t = {};
  162. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  163. t[p] = s[p];
  164. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  165. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  166. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  167. t[p[i]] = s[p[i]];
  168. }
  169. return t;
  170. }
  171. function __decorate(decorators, target, key, desc) {
  172. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  173. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  174. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  175. return c > 3 && r && Object.defineProperty(target, key, r), r;
  176. }
  177. function __param(paramIndex, decorator) {
  178. return function (target, key) { decorator(target, key, paramIndex); }
  179. }
  180. function __metadata(metadataKey, metadataValue) {
  181. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  182. }
  183. function __awaiter(thisArg, _arguments, P, generator) {
  184. return new (P || (P = Promise))(function (resolve, reject) {
  185. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  186. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  187. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  188. step((generator = generator.apply(thisArg, _arguments || [])).next());
  189. });
  190. }
  191. function __generator(thisArg, body) {
  192. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  193. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  194. function verb(n) { return function (v) { return step([n, v]); }; }
  195. function step(op) {
  196. if (f) throw new TypeError("Generator is already executing.");
  197. while (_) try {
  198. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  199. if (y = 0, t) op = [op[0] & 2, t.value];
  200. switch (op[0]) {
  201. case 0: case 1: t = op; break;
  202. case 4: _.label++; return { value: op[1], done: false };
  203. case 5: _.label++; y = op[1]; op = [0]; continue;
  204. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  205. default:
  206. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  207. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  208. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  209. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  210. if (t[2]) _.ops.pop();
  211. _.trys.pop(); continue;
  212. }
  213. op = body.call(thisArg, _);
  214. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  215. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  216. }
  217. }
  218. function __exportStar(m, exports) {
  219. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  220. }
  221. function __values(o) {
  222. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  223. if (m) return m.call(o);
  224. return {
  225. next: function () {
  226. if (o && i >= o.length) o = void 0;
  227. return { value: o && o[i++], done: !o };
  228. }
  229. };
  230. }
  231. function __read(o, n) {
  232. var m = typeof Symbol === "function" && o[Symbol.iterator];
  233. if (!m) return o;
  234. var i = m.call(o), r, ar = [], e;
  235. try {
  236. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  237. }
  238. catch (error) { e = { error: error }; }
  239. finally {
  240. try {
  241. if (r && !r.done && (m = i["return"])) m.call(i);
  242. }
  243. finally { if (e) throw e.error; }
  244. }
  245. return ar;
  246. }
  247. function __spread() {
  248. for (var ar = [], i = 0; i < arguments.length; i++)
  249. ar = ar.concat(__read(arguments[i]));
  250. return ar;
  251. }
  252. function __spreadArrays() {
  253. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  254. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  255. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  256. r[k] = a[j];
  257. return r;
  258. };
  259. function __await(v) {
  260. return this instanceof __await ? (this.v = v, this) : new __await(v);
  261. }
  262. function __asyncGenerator(thisArg, _arguments, generator) {
  263. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  264. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  265. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  266. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  267. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  268. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  269. function fulfill(value) { resume("next", value); }
  270. function reject(value) { resume("throw", value); }
  271. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  272. }
  273. function __asyncDelegator(o) {
  274. var i, p;
  275. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  276. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  277. }
  278. function __asyncValues(o) {
  279. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  280. var m = o[Symbol.asyncIterator], i;
  281. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  282. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  283. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  284. }
  285. function __makeTemplateObject(cooked, raw) {
  286. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  287. return cooked;
  288. };
  289. function __importStar(mod) {
  290. if (mod && mod.__esModule) return mod;
  291. var result = {};
  292. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  293. result.default = mod;
  294. return result;
  295. }
  296. function __importDefault(mod) {
  297. return (mod && mod.__esModule) ? mod : { default: mod };
  298. }
  299. /***/ }),
  300. /***/ "../../node_modules/webpack/buildin/global.js":
  301. /*!***********************************!*\
  302. !*** (webpack)/buildin/global.js ***!
  303. \***********************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports) {
  306. var g;
  307. // This works in non-strict mode
  308. g = (function() {
  309. return this;
  310. })();
  311. try {
  312. // This works if eval is allowed (see CSP)
  313. g = g || new Function("return this")();
  314. } catch (e) {
  315. // This works if the window reference is available
  316. if (typeof window === "object") g = window;
  317. }
  318. // g can still be undefined, but nothing to do about it...
  319. // We return undefined, instead of nothing here, so it's
  320. // easier to handle this case. if(!global) { ...}
  321. module.exports = g;
  322. /***/ }),
  323. /***/ "./2D/adtInstrumentation.ts":
  324. /*!**********************************!*\
  325. !*** ./2D/adtInstrumentation.ts ***!
  326. \**********************************/
  327. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  329. "use strict";
  330. __webpack_require__.r(__webpack_exports__);
  331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  332. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Misc/perfCounter");
  333. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  334. /**
  335. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  336. */
  337. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  338. /**
  339. * Instantiates a new advanced dynamic texture instrumentation.
  340. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  341. * @param texture Defines the AdvancedDynamicTexture to instrument
  342. */
  343. function AdvancedDynamicTextureInstrumentation(
  344. /**
  345. * Define the instrumented AdvancedDynamicTexture.
  346. */
  347. texture) {
  348. this.texture = texture;
  349. this._captureRenderTime = false;
  350. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  351. this._captureLayoutTime = false;
  352. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  353. // Observers
  354. this._onBeginRenderObserver = null;
  355. this._onEndRenderObserver = null;
  356. this._onBeginLayoutObserver = null;
  357. this._onEndLayoutObserver = null;
  358. }
  359. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  360. // Properties
  361. /**
  362. * Gets the perf counter used to capture render time
  363. */
  364. get: function () {
  365. return this._renderTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  371. /**
  372. * Gets the perf counter used to capture layout time
  373. */
  374. get: function () {
  375. return this._layoutTime;
  376. },
  377. enumerable: true,
  378. configurable: true
  379. });
  380. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  381. /**
  382. * Enable or disable the render time capture
  383. */
  384. get: function () {
  385. return this._captureRenderTime;
  386. },
  387. set: function (value) {
  388. var _this = this;
  389. if (value === this._captureRenderTime) {
  390. return;
  391. }
  392. this._captureRenderTime = value;
  393. if (value) {
  394. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  395. _this._renderTime.beginMonitoring();
  396. });
  397. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  398. _this._renderTime.endMonitoring(true);
  399. });
  400. }
  401. else {
  402. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  403. this._onBeginRenderObserver = null;
  404. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  405. this._onEndRenderObserver = null;
  406. }
  407. },
  408. enumerable: true,
  409. configurable: true
  410. });
  411. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  412. /**
  413. * Enable or disable the layout time capture
  414. */
  415. get: function () {
  416. return this._captureLayoutTime;
  417. },
  418. set: function (value) {
  419. var _this = this;
  420. if (value === this._captureLayoutTime) {
  421. return;
  422. }
  423. this._captureLayoutTime = value;
  424. if (value) {
  425. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  426. _this._layoutTime.beginMonitoring();
  427. });
  428. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  429. _this._layoutTime.endMonitoring(true);
  430. });
  431. }
  432. else {
  433. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  434. this._onBeginLayoutObserver = null;
  435. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  436. this._onEndLayoutObserver = null;
  437. }
  438. },
  439. enumerable: true,
  440. configurable: true
  441. });
  442. /**
  443. * Dispose and release associated resources.
  444. */
  445. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  446. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  447. this._onBeginRenderObserver = null;
  448. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  449. this._onEndRenderObserver = null;
  450. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  451. this._onBeginLayoutObserver = null;
  452. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  453. this._onEndLayoutObserver = null;
  454. this.texture = null;
  455. };
  456. return AdvancedDynamicTextureInstrumentation;
  457. }());
  458. /***/ }),
  459. /***/ "./2D/advancedDynamicTexture.ts":
  460. /*!**************************************!*\
  461. !*** ./2D/advancedDynamicTexture.ts ***!
  462. \**************************************/
  463. /*! exports provided: AdvancedDynamicTexture */
  464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  465. "use strict";
  466. __webpack_require__.r(__webpack_exports__);
  467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  469. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  470. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  471. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  472. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  473. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  474. /**
  475. * Class used to create texture to support 2D GUI elements
  476. * @see http://doc.babylonjs.com/how_to/gui
  477. */
  478. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  479. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AdvancedDynamicTexture, _super);
  480. /**
  481. * Creates a new AdvancedDynamicTexture
  482. * @param name defines the name of the texture
  483. * @param width defines the width of the texture
  484. * @param height defines the height of the texture
  485. * @param scene defines the hosting scene
  486. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  487. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  488. */
  489. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  490. if (width === void 0) { width = 0; }
  491. if (height === void 0) { height = 0; }
  492. if (generateMipMaps === void 0) { generateMipMaps = false; }
  493. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  494. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA) || this;
  495. _this._isDirty = false;
  496. /** @hidden */
  497. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  498. /** @hidden */
  499. _this._lastControlOver = {};
  500. /** @hidden */
  501. _this._lastControlDown = {};
  502. /** @hidden */
  503. _this._capturingControl = {};
  504. /** @hidden */
  505. _this._linkedControls = new Array();
  506. _this._isFullscreen = false;
  507. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  508. _this._idealWidth = 0;
  509. _this._idealHeight = 0;
  510. _this._useSmallestIdeal = false;
  511. _this._renderAtIdealSize = false;
  512. _this._blockNextFocusCheck = false;
  513. _this._renderScale = 1;
  514. _this._cursorChanged = false;
  515. _this._defaultMousePointerId = 0;
  516. /** @hidden */
  517. _this._numLayoutCalls = 0;
  518. /** @hidden */
  519. _this._numRenderCalls = 0;
  520. /**
  521. * Define type to string to ensure compatibility across browsers
  522. * Safari doesn't support DataTransfer constructor
  523. */
  524. _this._clipboardData = "";
  525. /**
  526. * Observable event triggered each time an clipboard event is received from the rendering canvas
  527. */
  528. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  529. /**
  530. * Observable event triggered each time a pointer down is intercepted by a control
  531. */
  532. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  533. /**
  534. * Observable event triggered before layout is evaluated
  535. */
  536. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  537. /**
  538. * Observable event triggered after the layout was evaluated
  539. */
  540. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  541. /**
  542. * Observable event triggered before the texture is rendered
  543. */
  544. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  545. /**
  546. * Observable event triggered after the texture was rendered
  547. */
  548. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  549. /**
  550. * Gets or sets a boolean defining if alpha is stored as premultiplied
  551. */
  552. _this.premulAlpha = false;
  553. _this._useInvalidateRectOptimization = true;
  554. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  555. _this._invalidatedRectangle = null;
  556. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  557. /** @hidden */
  558. _this.onClipboardCopy = function (rawEvt) {
  559. var evt = rawEvt;
  560. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  561. _this.onClipboardObservable.notifyObservers(ev);
  562. evt.preventDefault();
  563. };
  564. /** @hidden */
  565. _this.onClipboardCut = function (rawEvt) {
  566. var evt = rawEvt;
  567. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  568. _this.onClipboardObservable.notifyObservers(ev);
  569. evt.preventDefault();
  570. };
  571. /** @hidden */
  572. _this.onClipboardPaste = function (rawEvt) {
  573. var evt = rawEvt;
  574. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  575. _this.onClipboardObservable.notifyObservers(ev);
  576. evt.preventDefault();
  577. };
  578. scene = _this.getScene();
  579. if (!scene || !_this._texture) {
  580. return _this;
  581. }
  582. _this._rootElement = scene.getEngine().getInputElement();
  583. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  584. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  585. if (!_this._focusedControl) {
  586. return;
  587. }
  588. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  589. _this._focusedControl.processKeyboard(info.event);
  590. }
  591. info.skipOnPointerObservable = true;
  592. });
  593. _this._rootContainer._link(_this);
  594. _this.hasAlpha = true;
  595. if (!width || !height) {
  596. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  597. _this._onResize();
  598. }
  599. _this._texture.isReady = true;
  600. return _this;
  601. }
  602. Object.defineProperty(AdvancedDynamicTexture.prototype, "numLayoutCalls", {
  603. /** Gets the number of layout calls made the last time the ADT has been rendered */
  604. get: function () {
  605. return this._numLayoutCalls;
  606. },
  607. enumerable: true,
  608. configurable: true
  609. });
  610. Object.defineProperty(AdvancedDynamicTexture.prototype, "numRenderCalls", {
  611. /** Gets the number of render calls made the last time the ADT has been rendered */
  612. get: function () {
  613. return this._numRenderCalls;
  614. },
  615. enumerable: true,
  616. configurable: true
  617. });
  618. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  619. /**
  620. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  621. * Useful when you want more antialiasing
  622. */
  623. get: function () {
  624. return this._renderScale;
  625. },
  626. set: function (value) {
  627. if (value === this._renderScale) {
  628. return;
  629. }
  630. this._renderScale = value;
  631. this._onResize();
  632. },
  633. enumerable: true,
  634. configurable: true
  635. });
  636. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  637. /** Gets or sets the background color */
  638. get: function () {
  639. return this._background;
  640. },
  641. set: function (value) {
  642. if (this._background === value) {
  643. return;
  644. }
  645. this._background = value;
  646. this.markAsDirty();
  647. },
  648. enumerable: true,
  649. configurable: true
  650. });
  651. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  652. /**
  653. * Gets or sets the ideal width used to design controls.
  654. * The GUI will then rescale everything accordingly
  655. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  656. */
  657. get: function () {
  658. return this._idealWidth;
  659. },
  660. set: function (value) {
  661. if (this._idealWidth === value) {
  662. return;
  663. }
  664. this._idealWidth = value;
  665. this.markAsDirty();
  666. this._rootContainer._markAllAsDirty();
  667. },
  668. enumerable: true,
  669. configurable: true
  670. });
  671. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  672. /**
  673. * Gets or sets the ideal height used to design controls.
  674. * The GUI will then rescale everything accordingly
  675. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  676. */
  677. get: function () {
  678. return this._idealHeight;
  679. },
  680. set: function (value) {
  681. if (this._idealHeight === value) {
  682. return;
  683. }
  684. this._idealHeight = value;
  685. this.markAsDirty();
  686. this._rootContainer._markAllAsDirty();
  687. },
  688. enumerable: true,
  689. configurable: true
  690. });
  691. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  692. /**
  693. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  694. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  695. */
  696. get: function () {
  697. return this._useSmallestIdeal;
  698. },
  699. set: function (value) {
  700. if (this._useSmallestIdeal === value) {
  701. return;
  702. }
  703. this._useSmallestIdeal = value;
  704. this.markAsDirty();
  705. this._rootContainer._markAllAsDirty();
  706. },
  707. enumerable: true,
  708. configurable: true
  709. });
  710. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  711. /**
  712. * Gets or sets a boolean indicating if adaptive scaling must be used
  713. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  714. */
  715. get: function () {
  716. return this._renderAtIdealSize;
  717. },
  718. set: function (value) {
  719. if (this._renderAtIdealSize === value) {
  720. return;
  721. }
  722. this._renderAtIdealSize = value;
  723. this._onResize();
  724. },
  725. enumerable: true,
  726. configurable: true
  727. });
  728. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealRatio", {
  729. /**
  730. * Gets the ratio used when in "ideal mode"
  731. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  732. * */
  733. get: function () {
  734. var rwidth = 0;
  735. var rheight = 0;
  736. if (this._idealWidth) {
  737. rwidth = (this.getSize().width) / this._idealWidth;
  738. }
  739. if (this._idealHeight) {
  740. rheight = (this.getSize().height) / this._idealHeight;
  741. }
  742. if (this._useSmallestIdeal && this._idealWidth && this._idealHeight) {
  743. return window.innerWidth < window.innerHeight ? rwidth : rheight;
  744. }
  745. if (this._idealWidth) { // horizontal
  746. return rwidth;
  747. }
  748. if (this._idealHeight) { // vertical
  749. return rheight;
  750. }
  751. return 1;
  752. },
  753. enumerable: true,
  754. configurable: true
  755. });
  756. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  757. /**
  758. * Gets the underlying layer used to render the texture when in fullscreen mode
  759. */
  760. get: function () {
  761. return this._layerToDispose;
  762. },
  763. enumerable: true,
  764. configurable: true
  765. });
  766. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  767. /**
  768. * Gets the root container control
  769. */
  770. get: function () {
  771. return this._rootContainer;
  772. },
  773. enumerable: true,
  774. configurable: true
  775. });
  776. /**
  777. * Returns an array containing the root container.
  778. * This is mostly used to let the Inspector introspects the ADT
  779. * @returns an array containing the rootContainer
  780. */
  781. AdvancedDynamicTexture.prototype.getChildren = function () {
  782. return [this._rootContainer];
  783. };
  784. /**
  785. * Will return all controls that are inside this texture
  786. * @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
  787. * @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
  788. * @return all child controls
  789. */
  790. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  791. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  792. };
  793. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  794. /**
  795. * Gets or sets the current focused control
  796. */
  797. get: function () {
  798. return this._focusedControl;
  799. },
  800. set: function (control) {
  801. if (this._focusedControl == control) {
  802. return;
  803. }
  804. if (this._focusedControl) {
  805. this._focusedControl.onBlur();
  806. }
  807. if (control) {
  808. control.onFocus();
  809. }
  810. this._focusedControl = control;
  811. },
  812. enumerable: true,
  813. configurable: true
  814. });
  815. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  816. /**
  817. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  818. */
  819. get: function () {
  820. if (!this.layer) {
  821. return true;
  822. }
  823. return (!this.layer.isBackground);
  824. },
  825. set: function (value) {
  826. if (!this.layer) {
  827. return;
  828. }
  829. if (this.layer.isBackground === !value) {
  830. return;
  831. }
  832. this.layer.isBackground = !value;
  833. },
  834. enumerable: true,
  835. configurable: true
  836. });
  837. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  838. /**
  839. * Gets or set information about clipboardData
  840. */
  841. get: function () {
  842. return this._clipboardData;
  843. },
  844. set: function (value) {
  845. this._clipboardData = value;
  846. },
  847. enumerable: true,
  848. configurable: true
  849. });
  850. /**
  851. * Get the current class name of the texture useful for serialization or dynamic coding.
  852. * @returns "AdvancedDynamicTexture"
  853. */
  854. AdvancedDynamicTexture.prototype.getClassName = function () {
  855. return "AdvancedDynamicTexture";
  856. };
  857. /**
  858. * Function used to execute a function on all controls
  859. * @param func defines the function to execute
  860. * @param container defines the container where controls belong. If null the root container will be used
  861. */
  862. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  863. if (!container) {
  864. container = this._rootContainer;
  865. }
  866. func(container);
  867. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  868. var child = _a[_i];
  869. if (child.children) {
  870. this.executeOnAllControls(func, child);
  871. continue;
  872. }
  873. func(child);
  874. }
  875. };
  876. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  877. /**
  878. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  879. */
  880. get: function () {
  881. return this._useInvalidateRectOptimization;
  882. },
  883. set: function (value) {
  884. this._useInvalidateRectOptimization = value;
  885. },
  886. enumerable: true,
  887. configurable: true
  888. });
  889. /**
  890. * Invalidates a rectangle area on the gui texture
  891. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  892. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  893. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  894. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  895. */
  896. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  897. if (!this._useInvalidateRectOptimization) {
  898. return;
  899. }
  900. if (!this._invalidatedRectangle) {
  901. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  902. }
  903. else {
  904. // Compute intersection
  905. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  906. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  907. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  908. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  909. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  910. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  911. }
  912. };
  913. /**
  914. * Marks the texture as dirty forcing a complete update
  915. */
  916. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  917. this._isDirty = true;
  918. };
  919. /**
  920. * Helper function used to create a new style
  921. * @returns a new style
  922. * @see http://doc.babylonjs.com/how_to/gui#styles
  923. */
  924. AdvancedDynamicTexture.prototype.createStyle = function () {
  925. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  926. };
  927. /**
  928. * Adds a new control to the root container
  929. * @param control defines the control to add
  930. * @returns the current texture
  931. */
  932. AdvancedDynamicTexture.prototype.addControl = function (control) {
  933. this._rootContainer.addControl(control);
  934. return this;
  935. };
  936. /**
  937. * Removes a control from the root container
  938. * @param control defines the control to remove
  939. * @returns the current texture
  940. */
  941. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  942. this._rootContainer.removeControl(control);
  943. return this;
  944. };
  945. /**
  946. * Release all resources
  947. */
  948. AdvancedDynamicTexture.prototype.dispose = function () {
  949. var scene = this.getScene();
  950. if (!scene) {
  951. return;
  952. }
  953. this._rootElement = null;
  954. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  955. if (this._resizeObserver) {
  956. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  957. }
  958. if (this._pointerMoveObserver) {
  959. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  960. }
  961. if (this._pointerObserver) {
  962. scene.onPointerObservable.remove(this._pointerObserver);
  963. }
  964. if (this._preKeyboardObserver) {
  965. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  966. }
  967. if (this._canvasPointerOutObserver) {
  968. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  969. }
  970. if (this._layerToDispose) {
  971. this._layerToDispose.texture = null;
  972. this._layerToDispose.dispose();
  973. this._layerToDispose = null;
  974. }
  975. this._rootContainer.dispose();
  976. this.onClipboardObservable.clear();
  977. this.onControlPickedObservable.clear();
  978. this.onBeginRenderObservable.clear();
  979. this.onEndRenderObservable.clear();
  980. this.onBeginLayoutObservable.clear();
  981. this.onEndLayoutObservable.clear();
  982. _super.prototype.dispose.call(this);
  983. };
  984. AdvancedDynamicTexture.prototype._onResize = function () {
  985. var scene = this.getScene();
  986. if (!scene) {
  987. return;
  988. }
  989. // Check size
  990. var engine = scene.getEngine();
  991. var textureSize = this.getSize();
  992. var renderWidth = engine.getRenderWidth() * this._renderScale;
  993. var renderHeight = engine.getRenderHeight() * this._renderScale;
  994. if (this._renderAtIdealSize) {
  995. if (this._idealWidth) {
  996. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  997. renderWidth = this._idealWidth;
  998. }
  999. else if (this._idealHeight) {
  1000. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  1001. renderHeight = this._idealHeight;
  1002. }
  1003. }
  1004. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  1005. this.scaleTo(renderWidth, renderHeight);
  1006. this.markAsDirty();
  1007. if (this._idealWidth || this._idealHeight) {
  1008. this._rootContainer._markAllAsDirty();
  1009. }
  1010. }
  1011. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  1012. };
  1013. /** @hidden */
  1014. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  1015. var engine = scene.getEngine();
  1016. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  1017. };
  1018. /**
  1019. * Get screen coordinates for a vector3
  1020. * @param position defines the position to project
  1021. * @param worldMatrix defines the world matrix to use
  1022. * @returns the projected position
  1023. */
  1024. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  1025. var scene = this.getScene();
  1026. if (!scene) {
  1027. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  1028. }
  1029. var globalViewport = this._getGlobalViewport(scene);
  1030. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1031. projectedPosition.scaleInPlace(this.renderScale);
  1032. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  1033. };
  1034. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  1035. if (this._layerToDispose) {
  1036. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  1037. return;
  1038. }
  1039. }
  1040. if (this._isFullscreen && this._linkedControls.length) {
  1041. var scene = this.getScene();
  1042. if (!scene) {
  1043. return;
  1044. }
  1045. var globalViewport = this._getGlobalViewport(scene);
  1046. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  1047. var control = _a[_i];
  1048. if (!control.isVisible) {
  1049. continue;
  1050. }
  1051. var mesh = control._linkedMesh;
  1052. if (!mesh || mesh.isDisposed()) {
  1053. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1054. control.linkWithMesh(null);
  1055. });
  1056. continue;
  1057. }
  1058. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1059. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1060. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1061. control.notRenderable = true;
  1062. continue;
  1063. }
  1064. control.notRenderable = false;
  1065. // Account for RenderScale.
  1066. projectedPosition.scaleInPlace(this.renderScale);
  1067. control._moveToProjectedPosition(projectedPosition);
  1068. }
  1069. }
  1070. if (!this._isDirty && !this._rootContainer.isDirty) {
  1071. return;
  1072. }
  1073. this._isDirty = false;
  1074. this._render();
  1075. this.update(true, this.premulAlpha);
  1076. };
  1077. AdvancedDynamicTexture.prototype._render = function () {
  1078. var textureSize = this.getSize();
  1079. var renderWidth = textureSize.width;
  1080. var renderHeight = textureSize.height;
  1081. var context = this.getContext();
  1082. context.font = "18px Arial";
  1083. context.strokeStyle = "white";
  1084. // Layout
  1085. this.onBeginLayoutObservable.notifyObservers(this);
  1086. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1087. this._numLayoutCalls = 0;
  1088. this._rootContainer._layout(measure, context);
  1089. this.onEndLayoutObservable.notifyObservers(this);
  1090. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1091. // Clear
  1092. if (this._invalidatedRectangle) {
  1093. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1094. }
  1095. else {
  1096. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1097. }
  1098. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1099. if (this._background) {
  1100. context.save();
  1101. context.fillStyle = this._background;
  1102. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1103. context.restore();
  1104. }
  1105. // Render
  1106. this.onBeginRenderObservable.notifyObservers(this);
  1107. this._numRenderCalls = 0;
  1108. this._rootContainer._render(context, this._invalidatedRectangle);
  1109. this.onEndRenderObservable.notifyObservers(this);
  1110. this._invalidatedRectangle = null;
  1111. };
  1112. /** @hidden */
  1113. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1114. if (this._rootElement) {
  1115. this._rootElement.style.cursor = cursor;
  1116. this._cursorChanged = true;
  1117. }
  1118. };
  1119. /** @hidden */
  1120. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1121. this._lastControlDown[pointerId] = control;
  1122. this.onControlPickedObservable.notifyObservers(control);
  1123. };
  1124. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  1125. var scene = this.getScene();
  1126. if (!scene) {
  1127. return;
  1128. }
  1129. var engine = scene.getEngine();
  1130. var textureSize = this.getSize();
  1131. if (this._isFullscreen) {
  1132. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1133. var viewport = camera.viewport;
  1134. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1135. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1136. }
  1137. if (this._capturingControl[pointerId]) {
  1138. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1139. return;
  1140. }
  1141. this._cursorChanged = false;
  1142. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex, deltaX, deltaY)) {
  1143. this._changeCursor("");
  1144. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1145. if (this._lastControlOver[pointerId]) {
  1146. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1147. delete this._lastControlOver[pointerId];
  1148. }
  1149. }
  1150. }
  1151. if (!this._cursorChanged) {
  1152. this._changeCursor("");
  1153. }
  1154. this._manageFocus();
  1155. };
  1156. /** @hidden */
  1157. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1158. for (var pointerId in list) {
  1159. if (!list.hasOwnProperty(pointerId)) {
  1160. continue;
  1161. }
  1162. var lastControlOver = list[pointerId];
  1163. if (lastControlOver === control) {
  1164. delete list[pointerId];
  1165. }
  1166. }
  1167. };
  1168. /** @hidden */
  1169. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1170. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1171. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1172. };
  1173. /** Attach to all scene events required to support pointer events */
  1174. AdvancedDynamicTexture.prototype.attach = function () {
  1175. var _this = this;
  1176. var scene = this.getScene();
  1177. if (!scene) {
  1178. return;
  1179. }
  1180. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1181. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1182. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1183. return;
  1184. }
  1185. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1186. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1187. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN
  1188. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  1189. return;
  1190. }
  1191. if (!scene) {
  1192. return;
  1193. }
  1194. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE && pi.event.pointerId) {
  1195. _this._defaultMousePointerId = pi.event.pointerId; // This is required to make sure we have the correct pointer ID for wheel
  1196. }
  1197. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1198. var engine = scene.getEngine();
  1199. if (!camera) {
  1200. tempViewport.x = 0;
  1201. tempViewport.y = 0;
  1202. tempViewport.width = engine.getRenderWidth();
  1203. tempViewport.height = engine.getRenderHeight();
  1204. }
  1205. else {
  1206. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1207. }
  1208. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1209. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1210. _this._shouldBlockPointer = false;
  1211. // Do picking modifies _shouldBlockPointer
  1212. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1213. _this._doPicking(x, y, pi.type, pointerId, pi.event.button, pi.event.deltaX, pi.event.deltaY);
  1214. // Avoid overwriting a true skipOnPointerObservable to false
  1215. if (_this._shouldBlockPointer) {
  1216. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1217. }
  1218. });
  1219. this._attachToOnPointerOut(scene);
  1220. };
  1221. /**
  1222. * Register the clipboard Events onto the canvas
  1223. */
  1224. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1225. self.addEventListener("copy", this.onClipboardCopy, false);
  1226. self.addEventListener("cut", this.onClipboardCut, false);
  1227. self.addEventListener("paste", this.onClipboardPaste, false);
  1228. };
  1229. /**
  1230. * Unregister the clipboard Events from the canvas
  1231. */
  1232. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1233. self.removeEventListener("copy", this.onClipboardCopy);
  1234. self.removeEventListener("cut", this.onClipboardCut);
  1235. self.removeEventListener("paste", this.onClipboardPaste);
  1236. };
  1237. /**
  1238. * Connect the texture to a hosting mesh to enable interactions
  1239. * @param mesh defines the mesh to attach to
  1240. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1241. */
  1242. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1243. var _this = this;
  1244. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1245. var scene = this.getScene();
  1246. if (!scene) {
  1247. return;
  1248. }
  1249. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1250. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1251. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1252. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1253. return;
  1254. }
  1255. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1256. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1257. var uv = pi.pickInfo.getTextureCoordinates();
  1258. if (uv) {
  1259. var size = _this.getSize();
  1260. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1261. }
  1262. }
  1263. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1264. if (_this._lastControlDown[pointerId]) {
  1265. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1266. }
  1267. delete _this._lastControlDown[pointerId];
  1268. if (_this.focusedControl) {
  1269. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1270. var canMoveFocus = true;
  1271. if (friendlyControls) {
  1272. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1273. var control = friendlyControls_1[_i];
  1274. // Same host, no need to keep the focus
  1275. if (_this === control._host) {
  1276. continue;
  1277. }
  1278. // Different hosts
  1279. var otherHost = control._host;
  1280. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1281. canMoveFocus = false;
  1282. break;
  1283. }
  1284. }
  1285. }
  1286. if (canMoveFocus) {
  1287. _this.focusedControl = null;
  1288. }
  1289. }
  1290. }
  1291. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1292. if (_this._lastControlOver[pointerId]) {
  1293. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1294. }
  1295. delete _this._lastControlOver[pointerId];
  1296. }
  1297. });
  1298. mesh.enablePointerMoveEvents = supportPointerMove;
  1299. this._attachToOnPointerOut(scene);
  1300. };
  1301. /**
  1302. * Move the focus to a specific control
  1303. * @param control defines the control which will receive the focus
  1304. */
  1305. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1306. this.focusedControl = control;
  1307. this._lastPickedControl = control;
  1308. this._blockNextFocusCheck = true;
  1309. };
  1310. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1311. if (this._blockNextFocusCheck) {
  1312. this._blockNextFocusCheck = false;
  1313. this._lastPickedControl = this._focusedControl;
  1314. return;
  1315. }
  1316. // Focus management
  1317. if (this._focusedControl) {
  1318. if (this._focusedControl !== this._lastPickedControl) {
  1319. if (this._lastPickedControl.isFocusInvisible) {
  1320. return;
  1321. }
  1322. this.focusedControl = null;
  1323. }
  1324. }
  1325. };
  1326. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1327. var _this = this;
  1328. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1329. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1330. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1331. }
  1332. delete _this._lastControlOver[pointerEvent.pointerId];
  1333. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1334. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1335. delete _this._lastControlDown[pointerEvent.pointerId];
  1336. }
  1337. });
  1338. };
  1339. // Statics
  1340. /**
  1341. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1342. * @param mesh defines the mesh which will receive the texture
  1343. * @param width defines the texture width (1024 by default)
  1344. * @param height defines the texture height (1024 by default)
  1345. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1346. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1347. * @returns a new AdvancedDynamicTexture
  1348. */
  1349. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1350. if (width === void 0) { width = 1024; }
  1351. if (height === void 0) { height = 1024; }
  1352. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1353. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1354. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1355. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1356. material.backFaceCulling = false;
  1357. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1358. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1359. if (onlyAlphaTesting) {
  1360. material.diffuseTexture = result;
  1361. material.emissiveTexture = result;
  1362. result.hasAlpha = true;
  1363. }
  1364. else {
  1365. material.emissiveTexture = result;
  1366. material.opacityTexture = result;
  1367. }
  1368. mesh.material = material;
  1369. result.attachToMesh(mesh, supportPointerMove);
  1370. return result;
  1371. };
  1372. /**
  1373. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1374. * In this mode the texture will rely on a layer for its rendering.
  1375. * This allows it to be treated like any other layer.
  1376. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1377. * LayerMask is set through advancedTexture.layer.layerMask
  1378. * @param name defines name for the texture
  1379. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1380. * @param scene defines the hsoting scene
  1381. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1382. * @returns a new AdvancedDynamicTexture
  1383. */
  1384. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1385. if (foreground === void 0) { foreground = true; }
  1386. if (scene === void 0) { scene = null; }
  1387. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1388. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1389. // Display
  1390. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1391. layer.texture = result;
  1392. result._layerToDispose = layer;
  1393. result._isFullscreen = true;
  1394. // Attach
  1395. result.attach();
  1396. return result;
  1397. };
  1398. return AdvancedDynamicTexture;
  1399. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1400. /***/ }),
  1401. /***/ "./2D/controls/button.ts":
  1402. /*!*******************************!*\
  1403. !*** ./2D/controls/button.ts ***!
  1404. \*******************************/
  1405. /*! exports provided: Button */
  1406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1407. "use strict";
  1408. __webpack_require__.r(__webpack_exports__);
  1409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1410. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1411. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1412. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1413. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1414. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1415. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  1416. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1417. /**
  1418. * Class used to create 2D buttons
  1419. */
  1420. var Button = /** @class */ (function (_super) {
  1421. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1422. /**
  1423. * Creates a new Button
  1424. * @param name defines the name of the button
  1425. */
  1426. function Button(name) {
  1427. var _this = _super.call(this, name) || this;
  1428. _this.name = name;
  1429. /**
  1430. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1431. */
  1432. _this.delegatePickingToChildren = false;
  1433. _this.thickness = 1;
  1434. _this.isPointerBlocker = true;
  1435. var alphaStore = null;
  1436. _this.pointerEnterAnimation = function () {
  1437. alphaStore = _this.alpha;
  1438. _this.alpha -= 0.1;
  1439. };
  1440. _this.pointerOutAnimation = function () {
  1441. if (alphaStore !== null) {
  1442. _this.alpha = alphaStore;
  1443. }
  1444. };
  1445. _this.pointerDownAnimation = function () {
  1446. _this.scaleX -= 0.05;
  1447. _this.scaleY -= 0.05;
  1448. };
  1449. _this.pointerUpAnimation = function () {
  1450. _this.scaleX += 0.05;
  1451. _this.scaleY += 0.05;
  1452. };
  1453. return _this;
  1454. }
  1455. Object.defineProperty(Button.prototype, "image", {
  1456. /**
  1457. * Returns the image part of the button (if any)
  1458. */
  1459. get: function () {
  1460. return this._image;
  1461. },
  1462. enumerable: true,
  1463. configurable: true
  1464. });
  1465. Object.defineProperty(Button.prototype, "textBlock", {
  1466. /**
  1467. * Returns the image part of the button (if any)
  1468. */
  1469. get: function () {
  1470. return this._textBlock;
  1471. },
  1472. enumerable: true,
  1473. configurable: true
  1474. });
  1475. Button.prototype._getTypeName = function () {
  1476. return "Button";
  1477. };
  1478. // While being a container, the button behaves like a control.
  1479. /** @hidden */
  1480. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  1481. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1482. return false;
  1483. }
  1484. if (!_super.prototype.contains.call(this, x, y)) {
  1485. return false;
  1486. }
  1487. if (this.delegatePickingToChildren) {
  1488. var contains = false;
  1489. for (var index = this._children.length - 1; index >= 0; index--) {
  1490. var child = this._children[index];
  1491. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1492. contains = true;
  1493. break;
  1494. }
  1495. }
  1496. if (!contains) {
  1497. return false;
  1498. }
  1499. }
  1500. this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  1501. return true;
  1502. };
  1503. /** @hidden */
  1504. Button.prototype._onPointerEnter = function (target) {
  1505. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1506. return false;
  1507. }
  1508. if (this.pointerEnterAnimation) {
  1509. this.pointerEnterAnimation();
  1510. }
  1511. return true;
  1512. };
  1513. /** @hidden */
  1514. Button.prototype._onPointerOut = function (target, force) {
  1515. if (force === void 0) { force = false; }
  1516. if (this.pointerOutAnimation) {
  1517. this.pointerOutAnimation();
  1518. }
  1519. _super.prototype._onPointerOut.call(this, target, force);
  1520. };
  1521. /** @hidden */
  1522. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1523. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1524. return false;
  1525. }
  1526. if (this.pointerDownAnimation) {
  1527. this.pointerDownAnimation();
  1528. }
  1529. return true;
  1530. };
  1531. /** @hidden */
  1532. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1533. if (this.pointerUpAnimation) {
  1534. this.pointerUpAnimation();
  1535. }
  1536. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1537. };
  1538. // Statics
  1539. /**
  1540. * Creates a new button made with an image and a text
  1541. * @param name defines the name of the button
  1542. * @param text defines the text of the button
  1543. * @param imageUrl defines the url of the image
  1544. * @returns a new Button
  1545. */
  1546. Button.CreateImageButton = function (name, text, imageUrl) {
  1547. var result = new Button(name);
  1548. // Adding text
  1549. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1550. textBlock.textWrapping = true;
  1551. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1552. textBlock.paddingLeft = "20%";
  1553. result.addControl(textBlock);
  1554. // Adding image
  1555. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1556. iconImage.width = "20%";
  1557. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1558. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1559. result.addControl(iconImage);
  1560. // Store
  1561. result._image = iconImage;
  1562. result._textBlock = textBlock;
  1563. return result;
  1564. };
  1565. /**
  1566. * Creates a new button made with an image
  1567. * @param name defines the name of the button
  1568. * @param imageUrl defines the url of the image
  1569. * @returns a new Button
  1570. */
  1571. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1572. var result = new Button(name);
  1573. // Adding image
  1574. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1575. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1576. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1577. result.addControl(iconImage);
  1578. // Store
  1579. result._image = iconImage;
  1580. return result;
  1581. };
  1582. /**
  1583. * Creates a new button made with a text
  1584. * @param name defines the name of the button
  1585. * @param text defines the text of the button
  1586. * @returns a new Button
  1587. */
  1588. Button.CreateSimpleButton = function (name, text) {
  1589. var result = new Button(name);
  1590. // Adding text
  1591. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1592. textBlock.textWrapping = true;
  1593. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1594. result.addControl(textBlock);
  1595. // Store
  1596. result._textBlock = textBlock;
  1597. return result;
  1598. };
  1599. /**
  1600. * Creates a new button made with an image and a centered text
  1601. * @param name defines the name of the button
  1602. * @param text defines the text of the button
  1603. * @param imageUrl defines the url of the image
  1604. * @returns a new Button
  1605. */
  1606. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1607. var result = new Button(name);
  1608. // Adding image
  1609. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1610. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1611. result.addControl(iconImage);
  1612. // Adding text
  1613. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1614. textBlock.textWrapping = true;
  1615. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1616. result.addControl(textBlock);
  1617. // Store
  1618. result._image = iconImage;
  1619. result._textBlock = textBlock;
  1620. return result;
  1621. };
  1622. return Button;
  1623. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1624. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1625. /***/ }),
  1626. /***/ "./2D/controls/checkbox.ts":
  1627. /*!*********************************!*\
  1628. !*** ./2D/controls/checkbox.ts ***!
  1629. \*********************************/
  1630. /*! exports provided: Checkbox */
  1631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1632. "use strict";
  1633. __webpack_require__.r(__webpack_exports__);
  1634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1635. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1636. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1637. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1638. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1639. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1640. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1641. /**
  1642. * Class used to represent a 2D checkbox
  1643. */
  1644. var Checkbox = /** @class */ (function (_super) {
  1645. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1646. /**
  1647. * Creates a new CheckBox
  1648. * @param name defines the control name
  1649. */
  1650. function Checkbox(name) {
  1651. var _this = _super.call(this, name) || this;
  1652. _this.name = name;
  1653. _this._isChecked = false;
  1654. _this._background = "black";
  1655. _this._checkSizeRatio = 0.8;
  1656. _this._thickness = 1;
  1657. /**
  1658. * Observable raised when isChecked property changes
  1659. */
  1660. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1661. _this.isPointerBlocker = true;
  1662. return _this;
  1663. }
  1664. Object.defineProperty(Checkbox.prototype, "thickness", {
  1665. /** Gets or sets border thickness */
  1666. get: function () {
  1667. return this._thickness;
  1668. },
  1669. set: function (value) {
  1670. if (this._thickness === value) {
  1671. return;
  1672. }
  1673. this._thickness = value;
  1674. this._markAsDirty();
  1675. },
  1676. enumerable: true,
  1677. configurable: true
  1678. });
  1679. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1680. /** Gets or sets a value indicating the ratio between overall size and check size */
  1681. get: function () {
  1682. return this._checkSizeRatio;
  1683. },
  1684. set: function (value) {
  1685. value = Math.max(Math.min(1, value), 0);
  1686. if (this._checkSizeRatio === value) {
  1687. return;
  1688. }
  1689. this._checkSizeRatio = value;
  1690. this._markAsDirty();
  1691. },
  1692. enumerable: true,
  1693. configurable: true
  1694. });
  1695. Object.defineProperty(Checkbox.prototype, "background", {
  1696. /** Gets or sets background color */
  1697. get: function () {
  1698. return this._background;
  1699. },
  1700. set: function (value) {
  1701. if (this._background === value) {
  1702. return;
  1703. }
  1704. this._background = value;
  1705. this._markAsDirty();
  1706. },
  1707. enumerable: true,
  1708. configurable: true
  1709. });
  1710. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1711. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1712. get: function () {
  1713. return this._isChecked;
  1714. },
  1715. set: function (value) {
  1716. if (this._isChecked === value) {
  1717. return;
  1718. }
  1719. this._isChecked = value;
  1720. this._markAsDirty();
  1721. this.onIsCheckedChangedObservable.notifyObservers(value);
  1722. },
  1723. enumerable: true,
  1724. configurable: true
  1725. });
  1726. Checkbox.prototype._getTypeName = function () {
  1727. return "Checkbox";
  1728. };
  1729. /** @hidden */
  1730. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1731. context.save();
  1732. this._applyStates(context);
  1733. var actualWidth = this._currentMeasure.width - this._thickness;
  1734. var actualHeight = this._currentMeasure.height - this._thickness;
  1735. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1736. context.shadowColor = this.shadowColor;
  1737. context.shadowBlur = this.shadowBlur;
  1738. context.shadowOffsetX = this.shadowOffsetX;
  1739. context.shadowOffsetY = this.shadowOffsetY;
  1740. }
  1741. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1742. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1743. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1744. context.shadowBlur = 0;
  1745. context.shadowOffsetX = 0;
  1746. context.shadowOffsetY = 0;
  1747. }
  1748. if (this._isChecked) {
  1749. context.fillStyle = this._isEnabled ? this.color : this._disabledColorItem;
  1750. var offsetWidth = actualWidth * this._checkSizeRatio;
  1751. var offseHeight = actualHeight * this._checkSizeRatio;
  1752. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1753. }
  1754. context.strokeStyle = this.color;
  1755. context.lineWidth = this._thickness;
  1756. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1757. context.restore();
  1758. };
  1759. // Events
  1760. /** @hidden */
  1761. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1762. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1763. return false;
  1764. }
  1765. this.isChecked = !this.isChecked;
  1766. return true;
  1767. };
  1768. /**
  1769. * Utility function to easily create a checkbox with a header
  1770. * @param title defines the label to use for the header
  1771. * @param onValueChanged defines the callback to call when value changes
  1772. * @returns a StackPanel containing the checkbox and a textBlock
  1773. */
  1774. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1775. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1776. panel.isVertical = false;
  1777. panel.height = "30px";
  1778. var checkbox = new Checkbox();
  1779. checkbox.width = "20px";
  1780. checkbox.height = "20px";
  1781. checkbox.isChecked = true;
  1782. checkbox.color = "green";
  1783. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1784. panel.addControl(checkbox);
  1785. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1786. header.text = title;
  1787. header.width = "180px";
  1788. header.paddingLeft = "5px";
  1789. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1790. header.color = "white";
  1791. panel.addControl(header);
  1792. return panel;
  1793. };
  1794. return Checkbox;
  1795. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1796. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1797. /***/ }),
  1798. /***/ "./2D/controls/colorpicker.ts":
  1799. /*!************************************!*\
  1800. !*** ./2D/controls/colorpicker.ts ***!
  1801. \************************************/
  1802. /*! exports provided: ColorPicker */
  1803. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1804. "use strict";
  1805. __webpack_require__.r(__webpack_exports__);
  1806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1807. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1808. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1809. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1810. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1811. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1812. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1813. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1814. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1815. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1816. /** Class used to create color pickers */
  1817. var ColorPicker = /** @class */ (function (_super) {
  1818. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1819. /**
  1820. * Creates a new ColorPicker
  1821. * @param name defines the control name
  1822. */
  1823. function ColorPicker(name) {
  1824. var _this = _super.call(this, name) || this;
  1825. _this.name = name;
  1826. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1827. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1828. _this._pointerStartedOnSquare = false;
  1829. _this._pointerStartedOnWheel = false;
  1830. _this._squareLeft = 0;
  1831. _this._squareTop = 0;
  1832. _this._squareSize = 0;
  1833. _this._h = 360;
  1834. _this._s = 1;
  1835. _this._v = 1;
  1836. _this._lastPointerDownID = -1;
  1837. /**
  1838. * Observable raised when the value changes
  1839. */
  1840. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1841. // Events
  1842. _this._pointerIsDown = false;
  1843. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1844. _this.size = "200px";
  1845. _this.isPointerBlocker = true;
  1846. return _this;
  1847. }
  1848. Object.defineProperty(ColorPicker.prototype, "value", {
  1849. /** Gets or sets the color of the color picker */
  1850. get: function () {
  1851. return this._value;
  1852. },
  1853. set: function (value) {
  1854. if (this._value.equals(value)) {
  1855. return;
  1856. }
  1857. this._value.copyFrom(value);
  1858. this._value.toHSVToRef(this._tmpColor);
  1859. this._h = this._tmpColor.r;
  1860. this._s = Math.max(this._tmpColor.g, 0.00001);
  1861. this._v = Math.max(this._tmpColor.b, 0.00001);
  1862. this._markAsDirty();
  1863. if (this._value.r <= ColorPicker._Epsilon) {
  1864. this._value.r = 0;
  1865. }
  1866. if (this._value.g <= ColorPicker._Epsilon) {
  1867. this._value.g = 0;
  1868. }
  1869. if (this._value.b <= ColorPicker._Epsilon) {
  1870. this._value.b = 0;
  1871. }
  1872. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1873. this._value.r = 1.0;
  1874. }
  1875. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1876. this._value.g = 1.0;
  1877. }
  1878. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1879. this._value.b = 1.0;
  1880. }
  1881. this.onValueChangedObservable.notifyObservers(this._value);
  1882. },
  1883. enumerable: true,
  1884. configurable: true
  1885. });
  1886. Object.defineProperty(ColorPicker.prototype, "width", {
  1887. /**
  1888. * Gets or sets control width
  1889. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1890. */
  1891. get: function () {
  1892. return this._width.toString(this._host);
  1893. },
  1894. set: function (value) {
  1895. if (this._width.toString(this._host) === value) {
  1896. return;
  1897. }
  1898. if (this._width.fromString(value)) {
  1899. this._height.fromString(value);
  1900. this._markAsDirty();
  1901. }
  1902. },
  1903. enumerable: true,
  1904. configurable: true
  1905. });
  1906. Object.defineProperty(ColorPicker.prototype, "height", {
  1907. /**
  1908. * Gets or sets control height
  1909. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1910. */
  1911. get: function () {
  1912. return this._height.toString(this._host);
  1913. },
  1914. /** Gets or sets control height */
  1915. set: function (value) {
  1916. if (this._height.toString(this._host) === value) {
  1917. return;
  1918. }
  1919. if (this._height.fromString(value)) {
  1920. this._width.fromString(value);
  1921. this._markAsDirty();
  1922. }
  1923. },
  1924. enumerable: true,
  1925. configurable: true
  1926. });
  1927. Object.defineProperty(ColorPicker.prototype, "size", {
  1928. /** Gets or sets control size */
  1929. get: function () {
  1930. return this.width;
  1931. },
  1932. set: function (value) {
  1933. this.width = value;
  1934. },
  1935. enumerable: true,
  1936. configurable: true
  1937. });
  1938. ColorPicker.prototype._getTypeName = function () {
  1939. return "ColorPicker";
  1940. };
  1941. /** @hidden */
  1942. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1943. if (parentMeasure.width < parentMeasure.height) {
  1944. this._currentMeasure.height = parentMeasure.width;
  1945. }
  1946. else {
  1947. this._currentMeasure.width = parentMeasure.height;
  1948. }
  1949. };
  1950. ColorPicker.prototype._updateSquareProps = function () {
  1951. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1952. var wheelThickness = radius * .2;
  1953. var innerDiameter = (radius - wheelThickness) * 2;
  1954. var squareSize = innerDiameter / (Math.sqrt(2));
  1955. var offset = radius - squareSize * .5;
  1956. this._squareLeft = this._currentMeasure.left + offset;
  1957. this._squareTop = this._currentMeasure.top + offset;
  1958. this._squareSize = squareSize;
  1959. };
  1960. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1961. var lgh = context.createLinearGradient(left, top, width + left, top);
  1962. lgh.addColorStop(0, '#fff');
  1963. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1964. context.fillStyle = lgh;
  1965. context.fillRect(left, top, width, height);
  1966. var lgv = context.createLinearGradient(left, top, left, height + top);
  1967. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1968. lgv.addColorStop(1, '#000');
  1969. context.fillStyle = lgv;
  1970. context.fillRect(left, top, width, height);
  1971. };
  1972. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1973. context.beginPath();
  1974. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1975. context.lineWidth = 3;
  1976. context.strokeStyle = '#333333';
  1977. context.stroke();
  1978. context.beginPath();
  1979. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1980. context.lineWidth = 3;
  1981. context.strokeStyle = '#ffffff';
  1982. context.stroke();
  1983. };
  1984. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1985. var canvas = document.createElement("canvas");
  1986. canvas.width = radius * 2;
  1987. canvas.height = radius * 2;
  1988. var context = canvas.getContext("2d");
  1989. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1990. var data = image.data;
  1991. var color = this._tmpColor;
  1992. var maxDistSq = radius * radius;
  1993. var innerRadius = radius - thickness;
  1994. var minDistSq = innerRadius * innerRadius;
  1995. for (var x = -radius; x < radius; x++) {
  1996. for (var y = -radius; y < radius; y++) {
  1997. var distSq = x * x + y * y;
  1998. if (distSq > maxDistSq || distSq < minDistSq) {
  1999. continue;
  2000. }
  2001. var dist = Math.sqrt(distSq);
  2002. var ang = Math.atan2(y, x);
  2003. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  2004. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  2005. data[index] = color.r * 255;
  2006. data[index + 1] = color.g * 255;
  2007. data[index + 2] = color.b * 255;
  2008. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2009. //apply less alpha to bigger color pickers
  2010. var alphaAmount = .2;
  2011. var maxAlpha = .2;
  2012. var minAlpha = .04;
  2013. var lowerRadius = 50;
  2014. var upperRadius = 150;
  2015. if (radius < lowerRadius) {
  2016. alphaAmount = maxAlpha;
  2017. }
  2018. else if (radius > upperRadius) {
  2019. alphaAmount = minAlpha;
  2020. }
  2021. else {
  2022. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  2023. }
  2024. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2025. if (alphaRatio < alphaAmount) {
  2026. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  2027. }
  2028. else if (alphaRatio > 1 - alphaAmount) {
  2029. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  2030. }
  2031. else {
  2032. data[index + 3] = 255;
  2033. }
  2034. }
  2035. }
  2036. context.putImageData(image, 0, 0);
  2037. return canvas;
  2038. };
  2039. /** @hidden */
  2040. ColorPicker.prototype._draw = function (context) {
  2041. context.save();
  2042. this._applyStates(context);
  2043. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2044. var wheelThickness = radius * .2;
  2045. var left = this._currentMeasure.left;
  2046. var top = this._currentMeasure.top;
  2047. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2048. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2049. }
  2050. this._updateSquareProps();
  2051. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2052. context.shadowColor = this.shadowColor;
  2053. context.shadowBlur = this.shadowBlur;
  2054. context.shadowOffsetX = this.shadowOffsetX;
  2055. context.shadowOffsetY = this.shadowOffsetY;
  2056. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2057. }
  2058. context.drawImage(this._colorWheelCanvas, left, top);
  2059. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2060. context.shadowBlur = 0;
  2061. context.shadowOffsetX = 0;
  2062. context.shadowOffsetY = 0;
  2063. }
  2064. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2065. var cx = this._squareLeft + this._squareSize * this._s;
  2066. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2067. this._drawCircle(cx, cy, radius * .04, context);
  2068. var dist = radius - wheelThickness * .5;
  2069. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2070. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2071. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2072. context.restore();
  2073. };
  2074. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2075. if (this._pointerStartedOnWheel) {
  2076. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2077. var centerX = radius + this._currentMeasure.left;
  2078. var centerY = radius + this._currentMeasure.top;
  2079. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2080. }
  2081. else if (this._pointerStartedOnSquare) {
  2082. this._updateSquareProps();
  2083. this._s = (x - this._squareLeft) / this._squareSize;
  2084. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2085. this._s = Math.min(this._s, 1);
  2086. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2087. this._v = Math.min(this._v, 1);
  2088. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2089. }
  2090. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2091. this.value = this._tmpColor;
  2092. };
  2093. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2094. this._updateSquareProps();
  2095. var left = this._squareLeft;
  2096. var top = this._squareTop;
  2097. var size = this._squareSize;
  2098. if (x >= left && x <= left + size &&
  2099. y >= top && y <= top + size) {
  2100. return true;
  2101. }
  2102. return false;
  2103. };
  2104. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2105. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2106. var centerX = radius + this._currentMeasure.left;
  2107. var centerY = radius + this._currentMeasure.top;
  2108. var wheelThickness = radius * .2;
  2109. var innerRadius = radius - wheelThickness;
  2110. var radiusSq = radius * radius;
  2111. var innerRadiusSq = innerRadius * innerRadius;
  2112. var dx = x - centerX;
  2113. var dy = y - centerY;
  2114. var distSq = dx * dx + dy * dy;
  2115. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2116. return true;
  2117. }
  2118. return false;
  2119. };
  2120. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2121. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2122. return false;
  2123. }
  2124. this._pointerIsDown = true;
  2125. this._pointerStartedOnSquare = false;
  2126. this._pointerStartedOnWheel = false;
  2127. // Invert transform
  2128. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2129. var x = this._transformedPosition.x;
  2130. var y = this._transformedPosition.y;
  2131. if (this._isPointOnSquare(x, y)) {
  2132. this._pointerStartedOnSquare = true;
  2133. }
  2134. else if (this._isPointOnWheel(x, y)) {
  2135. this._pointerStartedOnWheel = true;
  2136. }
  2137. this._updateValueFromPointer(x, y);
  2138. this._host._capturingControl[pointerId] = this;
  2139. this._lastPointerDownID = pointerId;
  2140. return true;
  2141. };
  2142. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2143. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2144. if (pointerId != this._lastPointerDownID) {
  2145. return;
  2146. }
  2147. // Invert transform
  2148. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2149. var x = this._transformedPosition.x;
  2150. var y = this._transformedPosition.y;
  2151. if (this._pointerIsDown) {
  2152. this._updateValueFromPointer(x, y);
  2153. }
  2154. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2155. };
  2156. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2157. this._pointerIsDown = false;
  2158. delete this._host._capturingControl[pointerId];
  2159. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2160. };
  2161. /**
  2162. * This function expands the color picker by creating a color picker dialog with manual
  2163. * color value input and the ability to save colors into an array to be used later in
  2164. * subsequent launches of the dialogue.
  2165. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2166. * @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.
  2167. * @returns picked color as a hex string and the saved colors array as hex strings.
  2168. */
  2169. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2170. return new Promise(function (resolve, reject) {
  2171. // Default options
  2172. options.pickerWidth = options.pickerWidth || "640px";
  2173. options.pickerHeight = options.pickerHeight || "400px";
  2174. options.headerHeight = options.headerHeight || "35px";
  2175. options.lastColor = options.lastColor || "#000000";
  2176. options.swatchLimit = options.swatchLimit || 20;
  2177. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2178. // Window size settings
  2179. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2180. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2181. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2182. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2183. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2184. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2185. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2186. // Button Colors
  2187. var buttonColor = "#c0c0c0";
  2188. var buttonBackgroundColor = "#535353";
  2189. var buttonBackgroundHoverColor = "#414141";
  2190. var buttonBackgroundClickColor = "515151";
  2191. var buttonDisabledColor = "#555555";
  2192. var buttonDisabledBackgroundColor = "#454545";
  2193. var currentSwatchesOutlineColor = "#404040";
  2194. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2195. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2196. var iconColorDark = "#aaaaaa";
  2197. var iconColorLight = "#ffffff";
  2198. var closeIconColor;
  2199. // Button settings
  2200. var buttonFontSize;
  2201. var butEdit;
  2202. var buttonWidth;
  2203. var buttonHeight;
  2204. // Input Text Colors
  2205. var inputFieldLabels = ["R", "G", "B"];
  2206. var inputTextBackgroundColor = "#454545";
  2207. var inputTextColor = "#f0f0f0";
  2208. // This is the current color as set by either the picker or by entering a value
  2209. var currentColor;
  2210. // This int is used for naming swatches and serves as the index for calling them from the list
  2211. var swatchNumber;
  2212. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2213. var swatchDrawer;
  2214. var editSwatchMode = false;
  2215. // Color InputText fields that will be updated upon value change
  2216. var picker;
  2217. var rValInt;
  2218. var gValInt;
  2219. var bValInt;
  2220. var rValDec;
  2221. var gValDec;
  2222. var bValDec;
  2223. var hexVal;
  2224. var newSwatch;
  2225. var lastVal;
  2226. var activeField;
  2227. /**
  2228. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2229. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2230. * are will receive no update. This is to prevent the input from the user being overwritten.
  2231. */
  2232. function updateValues(value, inputField) {
  2233. activeField = inputField;
  2234. var pickedColor = value.toHexString();
  2235. newSwatch.background = pickedColor;
  2236. if (rValInt.name != activeField) {
  2237. rValInt.text = Math.floor(value.r * 255).toString();
  2238. }
  2239. if (gValInt.name != activeField) {
  2240. gValInt.text = Math.floor(value.g * 255).toString();
  2241. }
  2242. if (bValInt.name != activeField) {
  2243. bValInt.text = Math.floor(value.b * 255).toString();
  2244. }
  2245. if (rValDec.name != activeField) {
  2246. rValDec.text = value.r.toString();
  2247. }
  2248. if (gValDec.name != activeField) {
  2249. gValDec.text = value.g.toString();
  2250. }
  2251. if (bValDec.name != activeField) {
  2252. bValDec.text = value.b.toString();
  2253. }
  2254. if (hexVal.name != activeField) {
  2255. var minusPound = pickedColor.split("#");
  2256. hexVal.text = minusPound[1];
  2257. }
  2258. if (picker.name != activeField) {
  2259. picker.value = value;
  2260. }
  2261. }
  2262. // 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.
  2263. function updateInt(field, channel) {
  2264. var newValue = field.text;
  2265. var checkVal = /[^0-9]/g.test(newValue);
  2266. if (checkVal) {
  2267. field.text = lastVal;
  2268. return;
  2269. }
  2270. else {
  2271. if (newValue != "") {
  2272. if (Math.floor(parseInt(newValue)) < 0) {
  2273. newValue = "0";
  2274. }
  2275. else if (Math.floor(parseInt(newValue)) > 255) {
  2276. newValue = "255";
  2277. }
  2278. else if (isNaN(parseInt(newValue))) {
  2279. newValue = "0";
  2280. }
  2281. }
  2282. if (activeField == field.name) {
  2283. lastVal = newValue;
  2284. }
  2285. }
  2286. if (newValue != "") {
  2287. newValue = parseInt(newValue).toString();
  2288. field.text = newValue;
  2289. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2290. if (activeField == field.name) {
  2291. if (channel == "r") {
  2292. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2293. }
  2294. else if (channel == "g") {
  2295. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2296. }
  2297. else {
  2298. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2299. }
  2300. }
  2301. }
  2302. }
  2303. // 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.
  2304. function updateFloat(field, channel) {
  2305. var newValue = field.text;
  2306. var checkVal = /[^0-9\.]/g.test(newValue);
  2307. if (checkVal) {
  2308. field.text = lastVal;
  2309. return;
  2310. }
  2311. else {
  2312. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2313. if (parseFloat(newValue) < 0.0) {
  2314. newValue = "0.0";
  2315. }
  2316. else if (parseFloat(newValue) > 1.0) {
  2317. newValue = "1.0";
  2318. }
  2319. else if (isNaN(parseFloat(newValue))) {
  2320. newValue = "0.0";
  2321. }
  2322. }
  2323. if (activeField == field.name) {
  2324. lastVal = newValue;
  2325. }
  2326. }
  2327. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2328. newValue = parseFloat(newValue).toString();
  2329. field.text = newValue;
  2330. }
  2331. else {
  2332. newValue = "0.0";
  2333. }
  2334. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2335. if (activeField == field.name) {
  2336. if (channel == "r") {
  2337. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2338. }
  2339. else if (channel == "g") {
  2340. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2341. }
  2342. else {
  2343. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2344. }
  2345. }
  2346. }
  2347. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2348. function deleteSwatch(index) {
  2349. if (options.savedColors) {
  2350. options.savedColors.splice(index, 1);
  2351. }
  2352. if (options.savedColors && options.savedColors.length == 0) {
  2353. setEditButtonVisibility(false);
  2354. editSwatchMode = false;
  2355. }
  2356. }
  2357. // Creates and styles an individual swatch when updateSwatches is called.
  2358. function createSwatch() {
  2359. if (options.savedColors && options.savedColors[swatchNumber]) {
  2360. if (editSwatchMode) {
  2361. var icon = "b";
  2362. }
  2363. else {
  2364. var icon = "";
  2365. }
  2366. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2367. swatch.fontFamily = "BabylonJSglyphs";
  2368. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2369. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2370. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2371. if (swatchLuminence > luminanceLimit) {
  2372. swatch.color = iconColorDark;
  2373. }
  2374. else {
  2375. swatch.color = iconColorLight;
  2376. }
  2377. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2378. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2379. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2380. swatch.background = options.savedColors[swatchNumber];
  2381. swatch.thickness = 2;
  2382. var metadata_1 = swatchNumber;
  2383. swatch.pointerDownAnimation = function () {
  2384. swatch.thickness = 4;
  2385. };
  2386. swatch.pointerUpAnimation = function () {
  2387. swatch.thickness = 3;
  2388. };
  2389. swatch.pointerEnterAnimation = function () {
  2390. swatch.thickness = 3;
  2391. };
  2392. swatch.pointerOutAnimation = function () {
  2393. swatch.thickness = 2;
  2394. };
  2395. swatch.onPointerClickObservable.add(function () {
  2396. if (!editSwatchMode) {
  2397. if (options.savedColors) {
  2398. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2399. }
  2400. }
  2401. else {
  2402. deleteSwatch(metadata_1);
  2403. updateSwatches("", butSave);
  2404. }
  2405. });
  2406. return swatch;
  2407. }
  2408. else {
  2409. return null;
  2410. }
  2411. }
  2412. // Mode switch to render button text and close symbols on swatch controls
  2413. function editSwatches(mode) {
  2414. if (mode !== undefined) {
  2415. editSwatchMode = mode;
  2416. }
  2417. if (editSwatchMode) {
  2418. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2419. var thisButton = swatchDrawer.children[i];
  2420. thisButton.textBlock.text = "b";
  2421. }
  2422. if (butEdit !== undefined) {
  2423. butEdit.textBlock.text = "Done";
  2424. }
  2425. }
  2426. else {
  2427. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2428. var thisButton = swatchDrawer.children[i];
  2429. thisButton.textBlock.text = "";
  2430. }
  2431. if (butEdit !== undefined) {
  2432. butEdit.textBlock.text = "Edit";
  2433. }
  2434. }
  2435. }
  2436. /**
  2437. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2438. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2439. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2440. * saved colors there are and how many can be stored per row.
  2441. */
  2442. function updateSwatches(color, button) {
  2443. if (options.savedColors) {
  2444. if (color != "") {
  2445. options.savedColors.push(color);
  2446. }
  2447. swatchNumber = 0;
  2448. swatchDrawer.clearControls();
  2449. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2450. if (rowCount == 0) {
  2451. var gutterCount = 0;
  2452. }
  2453. else {
  2454. var gutterCount = rowCount + 1;
  2455. }
  2456. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2457. var currentRows = swatchDrawer.rowCount;
  2458. for (var i = 0; i < currentRows; i++) {
  2459. swatchDrawer.removeRowDefinition(0);
  2460. }
  2461. for (var i = 0; i < rowCount + gutterCount; i++) {
  2462. if (i % 2) {
  2463. swatchDrawer.addRowDefinition(swatchSize, true);
  2464. }
  2465. else {
  2466. swatchDrawer.addRowDefinition(gutterSize, true);
  2467. }
  2468. }
  2469. }
  2470. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2471. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2472. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2473. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2474. var totalButtonsThisRow = options.numSwatchesPerLine;
  2475. }
  2476. else {
  2477. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2478. }
  2479. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2480. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2481. if (x > options.numSwatchesPerLine) {
  2482. continue;
  2483. }
  2484. var swatch = createSwatch();
  2485. if (swatch != null) {
  2486. swatchDrawer.addControl(swatch, y, w);
  2487. w += 2;
  2488. swatchNumber++;
  2489. }
  2490. else {
  2491. continue;
  2492. }
  2493. }
  2494. }
  2495. if (options.savedColors.length >= options.swatchLimit) {
  2496. disableButton(button, true);
  2497. }
  2498. else {
  2499. disableButton(button, false);
  2500. }
  2501. }
  2502. }
  2503. // Shows or hides edit swatches button depending on if there are saved swatches
  2504. function setEditButtonVisibility(enableButton) {
  2505. if (enableButton) {
  2506. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2507. butEdit.width = buttonWidth;
  2508. butEdit.height = buttonHeight;
  2509. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2510. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2511. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2512. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2513. butEdit.thickness = 2;
  2514. butEdit.color = buttonColor;
  2515. butEdit.fontSize = buttonFontSize;
  2516. butEdit.background = buttonBackgroundColor;
  2517. butEdit.onPointerEnterObservable.add(function () {
  2518. butEdit.background = buttonBackgroundHoverColor;
  2519. });
  2520. butEdit.onPointerOutObservable.add(function () {
  2521. butEdit.background = buttonBackgroundColor;
  2522. });
  2523. butEdit.pointerDownAnimation = function () {
  2524. butEdit.background = buttonBackgroundClickColor;
  2525. };
  2526. butEdit.pointerUpAnimation = function () {
  2527. butEdit.background = buttonBackgroundHoverColor;
  2528. };
  2529. butEdit.onPointerClickObservable.add(function () {
  2530. if (editSwatchMode) {
  2531. editSwatchMode = false;
  2532. }
  2533. else {
  2534. editSwatchMode = true;
  2535. }
  2536. editSwatches();
  2537. });
  2538. pickerGrid.addControl(butEdit, 1, 0);
  2539. }
  2540. else {
  2541. pickerGrid.removeControl(butEdit);
  2542. }
  2543. }
  2544. // Called when the user hits the limit of saved colors in the drawer.
  2545. function disableButton(button, disabled) {
  2546. if (disabled) {
  2547. button.color = buttonDisabledColor;
  2548. button.background = buttonDisabledBackgroundColor;
  2549. }
  2550. else {
  2551. button.color = buttonColor;
  2552. button.background = buttonBackgroundColor;
  2553. }
  2554. }
  2555. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2556. function closePicker(color) {
  2557. if (options.savedColors && options.savedColors.length > 0) {
  2558. resolve({
  2559. savedColors: options.savedColors,
  2560. pickedColor: color
  2561. });
  2562. }
  2563. else {
  2564. resolve({
  2565. pickedColor: color
  2566. });
  2567. }
  2568. advancedTexture.removeControl(dialogContainer);
  2569. }
  2570. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2571. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2572. dialogContainer.name = "Dialog Container";
  2573. dialogContainer.width = options.pickerWidth;
  2574. if (options.savedColors) {
  2575. dialogContainer.height = containerSize;
  2576. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2577. dialogContainer.addRowDefinition(topRow, false);
  2578. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2579. }
  2580. else {
  2581. dialogContainer.height = options.pickerHeight;
  2582. dialogContainer.addRowDefinition(1.0, false);
  2583. }
  2584. advancedTexture.addControl(dialogContainer);
  2585. // Swatch drawer which contains all saved color buttons
  2586. if (options.savedColors) {
  2587. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2588. swatchDrawer.name = "Swatch Drawer";
  2589. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2590. swatchDrawer.background = buttonBackgroundColor;
  2591. swatchDrawer.width = options.pickerWidth;
  2592. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2593. if (initialRows == 0) {
  2594. var gutterCount = 0;
  2595. }
  2596. else {
  2597. var gutterCount = initialRows + 1;
  2598. }
  2599. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2600. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2601. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2602. if (i % 2 != 0) {
  2603. swatchDrawer.addRowDefinition(swatchSize, true);
  2604. }
  2605. else {
  2606. swatchDrawer.addRowDefinition(gutterSize, true);
  2607. }
  2608. }
  2609. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2610. if (i % 2 != 0) {
  2611. swatchDrawer.addColumnDefinition(swatchSize, true);
  2612. }
  2613. else {
  2614. swatchDrawer.addColumnDefinition(gutterSize, true);
  2615. }
  2616. }
  2617. dialogContainer.addControl(swatchDrawer, 1, 0);
  2618. }
  2619. // Picker container
  2620. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2621. pickerPanel.name = "Picker Panel";
  2622. pickerPanel.height = options.pickerHeight;
  2623. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2624. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2625. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2626. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2627. dialogContainer.addControl(pickerPanel, 0, 0);
  2628. // Picker container header
  2629. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2630. header.name = "Dialogue Header Bar";
  2631. header.background = "#cccccc";
  2632. header.thickness = 0;
  2633. pickerPanel.addControl(header, 0, 0);
  2634. // Header close button
  2635. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2636. closeButton.fontFamily = "BabylonJSglyphs";
  2637. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2638. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2639. closeButton.color = closeIconColor.toHexString();
  2640. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2641. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2642. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2643. closeButton.height = closeButton.width = options.headerHeight;
  2644. closeButton.background = header.background;
  2645. closeButton.thickness = 0;
  2646. closeButton.pointerDownAnimation = function () {
  2647. };
  2648. closeButton.pointerUpAnimation = function () {
  2649. closeButton.background = header.background;
  2650. };
  2651. closeButton.pointerEnterAnimation = function () {
  2652. closeButton.color = header.background;
  2653. closeButton.background = "red";
  2654. };
  2655. closeButton.pointerOutAnimation = function () {
  2656. closeButton.color = closeIconColor.toHexString();
  2657. closeButton.background = header.background;
  2658. };
  2659. closeButton.onPointerClickObservable.add(function () {
  2660. closePicker(currentSwatch.background);
  2661. });
  2662. pickerPanel.addControl(closeButton, 0, 0);
  2663. // Dialog container body
  2664. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2665. dialogBody.name = "Dialogue Body";
  2666. dialogBody.background = buttonBackgroundColor;
  2667. var dialogBodyCols = [0.4375, 0.5625];
  2668. dialogBody.addRowDefinition(1.0, false);
  2669. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2670. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2671. pickerPanel.addControl(dialogBody, 1, 0);
  2672. // Picker grid
  2673. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2674. pickerGrid.name = "Picker Grid";
  2675. pickerGrid.addRowDefinition(0.85, false);
  2676. pickerGrid.addRowDefinition(0.15, false);
  2677. dialogBody.addControl(pickerGrid, 0, 0);
  2678. // Picker control
  2679. picker = new ColorPicker();
  2680. picker.name = "GUI Color Picker";
  2681. if (options.pickerHeight < options.pickerWidth) {
  2682. picker.width = 0.89;
  2683. }
  2684. else {
  2685. picker.height = 0.89;
  2686. }
  2687. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2688. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2689. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2690. picker.onPointerDownObservable.add(function () {
  2691. activeField = picker.name;
  2692. lastVal = "";
  2693. editSwatches(false);
  2694. });
  2695. picker.onValueChangedObservable.add(function (value) {
  2696. if (activeField == picker.name) {
  2697. updateValues(value, picker.name);
  2698. }
  2699. });
  2700. pickerGrid.addControl(picker, 0, 0);
  2701. // Picker body right quarant
  2702. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2703. pickerBodyRight.name = "Dialogue Right Half";
  2704. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2705. var pickerBodyRightRows = [0.514, 0.486];
  2706. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2707. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2708. dialogBody.addControl(pickerBodyRight, 1, 1);
  2709. // Picker container swatches and buttons
  2710. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2711. pickerSwatchesButtons.name = "Swatches and Buttons";
  2712. var pickerButtonsCol = [0.417, 0.583];
  2713. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2714. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2715. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2716. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2717. // Picker Swatches quadrant
  2718. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2719. pickerSwatches.name = "New and Current Swatches";
  2720. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2721. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2722. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2723. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2724. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2725. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2726. // Active swatches
  2727. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2728. activeSwatches.name = "Active Swatches";
  2729. activeSwatches.width = 0.67;
  2730. activeSwatches.addRowDefinition(0.5, false);
  2731. activeSwatches.addRowDefinition(0.5, false);
  2732. pickerSwatches.addControl(activeSwatches, 2, 0);
  2733. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2734. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2735. if (options.pickerWidth > options.pickerHeight) {
  2736. var labelTextSize = labelHeight;
  2737. }
  2738. else {
  2739. var labelTextSize = labelWidth;
  2740. }
  2741. // New color swatch and previous color button
  2742. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2743. newText.text = "new";
  2744. newText.name = "New Color Label";
  2745. newText.color = buttonColor;
  2746. newText.fontSize = labelTextSize;
  2747. pickerSwatches.addControl(newText, 1, 0);
  2748. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2749. newSwatch.name = "New Color Swatch";
  2750. newSwatch.background = options.lastColor;
  2751. newSwatch.thickness = 0;
  2752. activeSwatches.addControl(newSwatch, 0, 0);
  2753. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2754. currentSwatch.background = options.lastColor;
  2755. currentSwatch.thickness = 0;
  2756. currentSwatch.onPointerClickObservable.add(function () {
  2757. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2758. updateValues(revertColor, currentSwatch.name);
  2759. editSwatches(false);
  2760. });
  2761. currentSwatch.pointerDownAnimation = function () { };
  2762. currentSwatch.pointerUpAnimation = function () { };
  2763. currentSwatch.pointerEnterAnimation = function () { };
  2764. currentSwatch.pointerOutAnimation = function () { };
  2765. activeSwatches.addControl(currentSwatch, 1, 0);
  2766. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2767. swatchOutline.name = "Swatch Outline";
  2768. swatchOutline.width = 0.67;
  2769. swatchOutline.thickness = 2;
  2770. swatchOutline.color = currentSwatchesOutlineColor;
  2771. swatchOutline.isHitTestVisible = false;
  2772. pickerSwatches.addControl(swatchOutline, 2, 0);
  2773. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2774. currentText.name = "Current Color Label";
  2775. currentText.text = "current";
  2776. currentText.color = buttonColor;
  2777. currentText.fontSize = labelTextSize;
  2778. pickerSwatches.addControl(currentText, 3, 0);
  2779. // Buttons grid
  2780. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2781. buttonGrid.name = "Button Grid";
  2782. buttonGrid.height = 0.8;
  2783. var buttonGridRows = 1 / 3;
  2784. buttonGrid.addRowDefinition(buttonGridRows, false);
  2785. buttonGrid.addRowDefinition(buttonGridRows, false);
  2786. buttonGrid.addRowDefinition(buttonGridRows, false);
  2787. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2788. // Determine pixel width and height for all buttons from overall panel dimensions
  2789. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2790. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2791. // Determine button type size
  2792. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2793. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2794. }
  2795. else {
  2796. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2797. }
  2798. // Panel Buttons
  2799. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2800. butOK.width = buttonWidth;
  2801. butOK.height = buttonHeight;
  2802. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2803. butOK.thickness = 2;
  2804. butOK.color = buttonColor;
  2805. butOK.fontSize = buttonFontSize;
  2806. butOK.background = buttonBackgroundColor;
  2807. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2808. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2809. butOK.pointerDownAnimation = function () {
  2810. butOK.background = buttonBackgroundClickColor;
  2811. };
  2812. butOK.pointerUpAnimation = function () {
  2813. butOK.background = buttonBackgroundHoverColor;
  2814. };
  2815. butOK.onPointerClickObservable.add(function () {
  2816. editSwatches(false);
  2817. closePicker(newSwatch.background);
  2818. });
  2819. buttonGrid.addControl(butOK, 0, 0);
  2820. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2821. butCancel.width = buttonWidth;
  2822. butCancel.height = buttonHeight;
  2823. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2824. butCancel.thickness = 2;
  2825. butCancel.color = buttonColor;
  2826. butCancel.fontSize = buttonFontSize;
  2827. butCancel.background = buttonBackgroundColor;
  2828. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2829. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2830. butCancel.pointerDownAnimation = function () {
  2831. butCancel.background = buttonBackgroundClickColor;
  2832. };
  2833. butCancel.pointerUpAnimation = function () {
  2834. butCancel.background = buttonBackgroundHoverColor;
  2835. };
  2836. butCancel.onPointerClickObservable.add(function () {
  2837. editSwatches(false);
  2838. closePicker(currentSwatch.background);
  2839. });
  2840. buttonGrid.addControl(butCancel, 1, 0);
  2841. if (options.savedColors) {
  2842. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2843. butSave.width = buttonWidth;
  2844. butSave.height = buttonHeight;
  2845. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2846. butSave.thickness = 2;
  2847. butSave.fontSize = buttonFontSize;
  2848. if (options.savedColors.length < options.swatchLimit) {
  2849. butSave.color = buttonColor;
  2850. butSave.background = buttonBackgroundColor;
  2851. }
  2852. else {
  2853. disableButton(butSave, true);
  2854. }
  2855. butSave.onPointerEnterObservable.add(function () {
  2856. if (options.savedColors) {
  2857. if (options.savedColors.length < options.swatchLimit) {
  2858. butSave.background = buttonBackgroundHoverColor;
  2859. }
  2860. }
  2861. });
  2862. butSave.onPointerOutObservable.add(function () {
  2863. if (options.savedColors) {
  2864. if (options.savedColors.length < options.swatchLimit) {
  2865. butSave.background = buttonBackgroundColor;
  2866. }
  2867. }
  2868. });
  2869. butSave.pointerDownAnimation = function () {
  2870. if (options.savedColors) {
  2871. if (options.savedColors.length < options.swatchLimit) {
  2872. butSave.background = buttonBackgroundClickColor;
  2873. }
  2874. }
  2875. };
  2876. butSave.pointerUpAnimation = function () {
  2877. if (options.savedColors) {
  2878. if (options.savedColors.length < options.swatchLimit) {
  2879. butSave.background = buttonBackgroundHoverColor;
  2880. }
  2881. }
  2882. };
  2883. butSave.onPointerClickObservable.add(function () {
  2884. if (options.savedColors) {
  2885. if (options.savedColors.length == 0) {
  2886. setEditButtonVisibility(true);
  2887. }
  2888. if (options.savedColors.length < options.swatchLimit) {
  2889. updateSwatches(newSwatch.background, butSave);
  2890. }
  2891. editSwatches(false);
  2892. }
  2893. });
  2894. if (options.savedColors.length > 0) {
  2895. setEditButtonVisibility(true);
  2896. }
  2897. buttonGrid.addControl(butSave, 2, 0);
  2898. }
  2899. // Picker color values input
  2900. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2901. pickerColorValues.name = "Dialog Lower Right";
  2902. pickerColorValues.addRowDefinition(0.02, false);
  2903. pickerColorValues.addRowDefinition(0.63, false);
  2904. pickerColorValues.addRowDefinition(0.21, false);
  2905. pickerColorValues.addRowDefinition(0.14, false);
  2906. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2907. // RGB values text boxes
  2908. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2909. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2910. rgbValuesQuadrant.name = "RGB Values";
  2911. rgbValuesQuadrant.width = 0.82;
  2912. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2913. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2914. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2915. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2916. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2917. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2918. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2919. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2920. for (var i = 0; i < inputFieldLabels.length; i++) {
  2921. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2922. labelText.text = inputFieldLabels[i];
  2923. labelText.color = buttonColor;
  2924. labelText.fontSize = buttonFontSize;
  2925. rgbValuesQuadrant.addControl(labelText, i, 0);
  2926. }
  2927. // Input fields for RGB values
  2928. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2929. rValInt.width = 0.83;
  2930. rValInt.height = 0.72;
  2931. rValInt.name = "rIntField";
  2932. rValInt.fontSize = buttonFontSize;
  2933. rValInt.text = (currentColor.r * 255).toString();
  2934. rValInt.color = inputTextColor;
  2935. rValInt.background = inputTextBackgroundColor;
  2936. rValInt.onFocusObservable.add(function () {
  2937. activeField = rValInt.name;
  2938. lastVal = rValInt.text;
  2939. editSwatches(false);
  2940. });
  2941. rValInt.onBlurObservable.add(function () {
  2942. if (rValInt.text == "") {
  2943. rValInt.text = "0";
  2944. }
  2945. updateInt(rValInt, "r");
  2946. if (activeField == rValInt.name) {
  2947. activeField = "";
  2948. }
  2949. });
  2950. rValInt.onTextChangedObservable.add(function () {
  2951. if (activeField == rValInt.name) {
  2952. updateInt(rValInt, "r");
  2953. }
  2954. });
  2955. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2956. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2957. gValInt.width = 0.83;
  2958. gValInt.height = 0.72;
  2959. gValInt.name = "gIntField";
  2960. gValInt.fontSize = buttonFontSize;
  2961. gValInt.text = (currentColor.g * 255).toString();
  2962. gValInt.color = inputTextColor;
  2963. gValInt.background = inputTextBackgroundColor;
  2964. gValInt.onFocusObservable.add(function () {
  2965. activeField = gValInt.name;
  2966. lastVal = gValInt.text;
  2967. editSwatches(false);
  2968. });
  2969. gValInt.onBlurObservable.add(function () {
  2970. if (gValInt.text == "") {
  2971. gValInt.text = "0";
  2972. }
  2973. updateInt(gValInt, "g");
  2974. if (activeField == gValInt.name) {
  2975. activeField = "";
  2976. }
  2977. });
  2978. gValInt.onTextChangedObservable.add(function () {
  2979. if (activeField == gValInt.name) {
  2980. updateInt(gValInt, "g");
  2981. }
  2982. });
  2983. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2984. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2985. bValInt.width = 0.83;
  2986. bValInt.height = 0.72;
  2987. bValInt.name = "bIntField";
  2988. bValInt.fontSize = buttonFontSize;
  2989. bValInt.text = (currentColor.b * 255).toString();
  2990. bValInt.color = inputTextColor;
  2991. bValInt.background = inputTextBackgroundColor;
  2992. bValInt.onFocusObservable.add(function () {
  2993. activeField = bValInt.name;
  2994. lastVal = bValInt.text;
  2995. editSwatches(false);
  2996. });
  2997. bValInt.onBlurObservable.add(function () {
  2998. if (bValInt.text == "") {
  2999. bValInt.text = "0";
  3000. }
  3001. updateInt(bValInt, "b");
  3002. if (activeField == bValInt.name) {
  3003. activeField = "";
  3004. }
  3005. });
  3006. bValInt.onTextChangedObservable.add(function () {
  3007. if (activeField == bValInt.name) {
  3008. updateInt(bValInt, "b");
  3009. }
  3010. });
  3011. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  3012. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3013. rValDec.width = 0.95;
  3014. rValDec.height = 0.72;
  3015. rValDec.name = "rDecField";
  3016. rValDec.fontSize = buttonFontSize;
  3017. rValDec.text = currentColor.r.toString();
  3018. rValDec.color = inputTextColor;
  3019. rValDec.background = inputTextBackgroundColor;
  3020. rValDec.onFocusObservable.add(function () {
  3021. activeField = rValDec.name;
  3022. lastVal = rValDec.text;
  3023. editSwatches(false);
  3024. });
  3025. rValDec.onBlurObservable.add(function () {
  3026. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3027. rValDec.text = "0";
  3028. updateFloat(rValDec, "r");
  3029. }
  3030. if (activeField == rValDec.name) {
  3031. activeField = "";
  3032. }
  3033. });
  3034. rValDec.onTextChangedObservable.add(function () {
  3035. if (activeField == rValDec.name) {
  3036. updateFloat(rValDec, "r");
  3037. }
  3038. });
  3039. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3040. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3041. gValDec.width = 0.95;
  3042. gValDec.height = 0.72;
  3043. gValDec.name = "gDecField";
  3044. gValDec.fontSize = buttonFontSize;
  3045. gValDec.text = currentColor.g.toString();
  3046. gValDec.color = inputTextColor;
  3047. gValDec.background = inputTextBackgroundColor;
  3048. gValDec.onFocusObservable.add(function () {
  3049. activeField = gValDec.name;
  3050. lastVal = gValDec.text;
  3051. editSwatches(false);
  3052. });
  3053. gValDec.onBlurObservable.add(function () {
  3054. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3055. gValDec.text = "0";
  3056. updateFloat(gValDec, "g");
  3057. }
  3058. if (activeField == gValDec.name) {
  3059. activeField = "";
  3060. }
  3061. });
  3062. gValDec.onTextChangedObservable.add(function () {
  3063. if (activeField == gValDec.name) {
  3064. updateFloat(gValDec, "g");
  3065. }
  3066. });
  3067. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3068. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3069. bValDec.width = 0.95;
  3070. bValDec.height = 0.72;
  3071. bValDec.name = "bDecField";
  3072. bValDec.fontSize = buttonFontSize;
  3073. bValDec.text = currentColor.b.toString();
  3074. bValDec.color = inputTextColor;
  3075. bValDec.background = inputTextBackgroundColor;
  3076. bValDec.onFocusObservable.add(function () {
  3077. activeField = bValDec.name;
  3078. lastVal = bValDec.text;
  3079. editSwatches(false);
  3080. });
  3081. bValDec.onBlurObservable.add(function () {
  3082. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3083. bValDec.text = "0";
  3084. updateFloat(bValDec, "b");
  3085. }
  3086. if (activeField == bValDec.name) {
  3087. activeField = "";
  3088. }
  3089. });
  3090. bValDec.onTextChangedObservable.add(function () {
  3091. if (activeField == bValDec.name) {
  3092. updateFloat(bValDec, "b");
  3093. }
  3094. });
  3095. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3096. // Hex value input
  3097. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3098. hexValueQuadrant.name = "Hex Value";
  3099. hexValueQuadrant.width = 0.82;
  3100. hexValueQuadrant.addRowDefinition(1.0, false);
  3101. hexValueQuadrant.addColumnDefinition(0.1, false);
  3102. hexValueQuadrant.addColumnDefinition(0.9, false);
  3103. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3104. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3105. labelText.text = "#";
  3106. labelText.color = buttonColor;
  3107. labelText.fontSize = buttonFontSize;
  3108. hexValueQuadrant.addControl(labelText, 0, 0);
  3109. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3110. hexVal.width = 0.96;
  3111. hexVal.height = 0.72;
  3112. hexVal.name = "hexField";
  3113. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3114. hexVal.fontSize = buttonFontSize;
  3115. var minusPound = options.lastColor.split("#");
  3116. hexVal.text = minusPound[1];
  3117. hexVal.color = inputTextColor;
  3118. hexVal.background = inputTextBackgroundColor;
  3119. hexVal.onFocusObservable.add(function () {
  3120. activeField = hexVal.name;
  3121. lastVal = hexVal.text;
  3122. editSwatches(false);
  3123. });
  3124. hexVal.onBlurObservable.add(function () {
  3125. if (hexVal.text.length == 3) {
  3126. var val = hexVal.text.split("");
  3127. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3128. }
  3129. if (hexVal.text == "") {
  3130. hexVal.text = "000000";
  3131. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3132. }
  3133. if (activeField == hexVal.name) {
  3134. activeField = "";
  3135. }
  3136. });
  3137. hexVal.onTextChangedObservable.add(function () {
  3138. var newHexValue = hexVal.text;
  3139. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3140. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3141. hexVal.text = lastVal;
  3142. }
  3143. else {
  3144. if (hexVal.text.length < 6) {
  3145. var leadingZero = 6 - hexVal.text.length;
  3146. for (var i = 0; i < leadingZero; i++) {
  3147. newHexValue = "0" + newHexValue;
  3148. }
  3149. }
  3150. if (hexVal.text.length == 3) {
  3151. var val = hexVal.text.split("");
  3152. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3153. }
  3154. newHexValue = "#" + newHexValue;
  3155. if (activeField == hexVal.name) {
  3156. lastVal = hexVal.text;
  3157. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3158. }
  3159. }
  3160. });
  3161. hexValueQuadrant.addControl(hexVal, 0, 1);
  3162. if (options.savedColors && options.savedColors.length > 0) {
  3163. updateSwatches("", butSave);
  3164. }
  3165. });
  3166. };
  3167. ColorPicker._Epsilon = 0.000001;
  3168. return ColorPicker;
  3169. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3170. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3171. /***/ }),
  3172. /***/ "./2D/controls/container.ts":
  3173. /*!**********************************!*\
  3174. !*** ./2D/controls/container.ts ***!
  3175. \**********************************/
  3176. /*! exports provided: Container */
  3177. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3178. "use strict";
  3179. __webpack_require__.r(__webpack_exports__);
  3180. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3181. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3182. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/perfCounter");
  3183. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3184. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3185. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3186. /**
  3187. * Root class for 2D containers
  3188. * @see http://doc.babylonjs.com/how_to/gui#containers
  3189. */
  3190. var Container = /** @class */ (function (_super) {
  3191. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3192. /**
  3193. * Creates a new Container
  3194. * @param name defines the name of the container
  3195. */
  3196. function Container(name) {
  3197. var _this = _super.call(this, name) || this;
  3198. _this.name = name;
  3199. /** @hidden */
  3200. _this._children = new Array();
  3201. /** @hidden */
  3202. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3203. /** @hidden */
  3204. _this._background = "";
  3205. /** @hidden */
  3206. _this._adaptWidthToChildren = false;
  3207. /** @hidden */
  3208. _this._adaptHeightToChildren = false;
  3209. /**
  3210. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3211. */
  3212. _this.logLayoutCycleErrors = false;
  3213. /**
  3214. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3215. */
  3216. _this.maxLayoutCycle = 3;
  3217. return _this;
  3218. }
  3219. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3220. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3221. get: function () {
  3222. return this._adaptHeightToChildren;
  3223. },
  3224. set: function (value) {
  3225. if (this._adaptHeightToChildren === value) {
  3226. return;
  3227. }
  3228. this._adaptHeightToChildren = value;
  3229. if (value) {
  3230. this.height = "100%";
  3231. }
  3232. this._markAsDirty();
  3233. },
  3234. enumerable: true,
  3235. configurable: true
  3236. });
  3237. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3238. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3239. get: function () {
  3240. return this._adaptWidthToChildren;
  3241. },
  3242. set: function (value) {
  3243. if (this._adaptWidthToChildren === value) {
  3244. return;
  3245. }
  3246. this._adaptWidthToChildren = value;
  3247. if (value) {
  3248. this.width = "100%";
  3249. }
  3250. this._markAsDirty();
  3251. },
  3252. enumerable: true,
  3253. configurable: true
  3254. });
  3255. Object.defineProperty(Container.prototype, "background", {
  3256. /** Gets or sets background color */
  3257. get: function () {
  3258. return this._background;
  3259. },
  3260. set: function (value) {
  3261. if (this._background === value) {
  3262. return;
  3263. }
  3264. this._background = value;
  3265. this._markAsDirty();
  3266. },
  3267. enumerable: true,
  3268. configurable: true
  3269. });
  3270. Object.defineProperty(Container.prototype, "children", {
  3271. /** Gets the list of children */
  3272. get: function () {
  3273. return this._children;
  3274. },
  3275. enumerable: true,
  3276. configurable: true
  3277. });
  3278. Container.prototype._getTypeName = function () {
  3279. return "Container";
  3280. };
  3281. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3282. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3283. var child = _a[_i];
  3284. child._markMatrixAsDirty();
  3285. }
  3286. };
  3287. /**
  3288. * Gets a child using its name
  3289. * @param name defines the child name to look for
  3290. * @returns the child control if found
  3291. */
  3292. Container.prototype.getChildByName = function (name) {
  3293. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3294. var child = _a[_i];
  3295. if (child.name === name) {
  3296. return child;
  3297. }
  3298. }
  3299. return null;
  3300. };
  3301. /**
  3302. * Gets a child using its type and its name
  3303. * @param name defines the child name to look for
  3304. * @param type defines the child type to look for
  3305. * @returns the child control if found
  3306. */
  3307. Container.prototype.getChildByType = function (name, type) {
  3308. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3309. var child = _a[_i];
  3310. if (child.typeName === type) {
  3311. return child;
  3312. }
  3313. }
  3314. return null;
  3315. };
  3316. /**
  3317. * Search for a specific control in children
  3318. * @param control defines the control to look for
  3319. * @returns true if the control is in child list
  3320. */
  3321. Container.prototype.containsControl = function (control) {
  3322. return this.children.indexOf(control) !== -1;
  3323. };
  3324. /**
  3325. * Adds a new control to the current container
  3326. * @param control defines the control to add
  3327. * @returns the current container
  3328. */
  3329. Container.prototype.addControl = function (control) {
  3330. if (!control) {
  3331. return this;
  3332. }
  3333. var index = this._children.indexOf(control);
  3334. if (index !== -1) {
  3335. return this;
  3336. }
  3337. control._link(this._host);
  3338. control._markAllAsDirty();
  3339. this._reOrderControl(control);
  3340. this._markAsDirty();
  3341. return this;
  3342. };
  3343. /**
  3344. * Removes all controls from the current container
  3345. * @returns the current container
  3346. */
  3347. Container.prototype.clearControls = function () {
  3348. var children = this.children.slice();
  3349. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3350. var child = children_1[_i];
  3351. this.removeControl(child);
  3352. }
  3353. return this;
  3354. };
  3355. /**
  3356. * Removes a control from the current container
  3357. * @param control defines the control to remove
  3358. * @returns the current container
  3359. */
  3360. Container.prototype.removeControl = function (control) {
  3361. var index = this._children.indexOf(control);
  3362. if (index !== -1) {
  3363. this._children.splice(index, 1);
  3364. control.parent = null;
  3365. }
  3366. control.linkWithMesh(null);
  3367. if (this._host) {
  3368. this._host._cleanControlAfterRemoval(control);
  3369. }
  3370. this._markAsDirty();
  3371. return this;
  3372. };
  3373. /** @hidden */
  3374. Container.prototype._reOrderControl = function (control) {
  3375. this.removeControl(control);
  3376. var wasAdded = false;
  3377. for (var index = 0; index < this._children.length; index++) {
  3378. if (this._children[index].zIndex > control.zIndex) {
  3379. this._children.splice(index, 0, control);
  3380. wasAdded = true;
  3381. break;
  3382. }
  3383. }
  3384. if (!wasAdded) {
  3385. this._children.push(control);
  3386. }
  3387. control.parent = this;
  3388. this._markAsDirty();
  3389. };
  3390. /** @hidden */
  3391. Container.prototype._offsetLeft = function (offset) {
  3392. _super.prototype._offsetLeft.call(this, offset);
  3393. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3394. var child = _a[_i];
  3395. child._offsetLeft(offset);
  3396. }
  3397. };
  3398. /** @hidden */
  3399. Container.prototype._offsetTop = function (offset) {
  3400. _super.prototype._offsetTop.call(this, offset);
  3401. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3402. var child = _a[_i];
  3403. child._offsetTop(offset);
  3404. }
  3405. };
  3406. /** @hidden */
  3407. Container.prototype._markAllAsDirty = function () {
  3408. _super.prototype._markAllAsDirty.call(this);
  3409. for (var index = 0; index < this._children.length; index++) {
  3410. this._children[index]._markAllAsDirty();
  3411. }
  3412. };
  3413. /** @hidden */
  3414. Container.prototype._localDraw = function (context) {
  3415. if (this._background) {
  3416. context.save();
  3417. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3418. context.shadowColor = this.shadowColor;
  3419. context.shadowBlur = this.shadowBlur;
  3420. context.shadowOffsetX = this.shadowOffsetX;
  3421. context.shadowOffsetY = this.shadowOffsetY;
  3422. }
  3423. context.fillStyle = this._background;
  3424. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3425. context.restore();
  3426. }
  3427. };
  3428. /** @hidden */
  3429. Container.prototype._link = function (host) {
  3430. _super.prototype._link.call(this, host);
  3431. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3432. var child = _a[_i];
  3433. child._link(host);
  3434. }
  3435. };
  3436. /** @hidden */
  3437. Container.prototype._beforeLayout = function () {
  3438. // Do nothing
  3439. };
  3440. /** @hidden */
  3441. Container.prototype._processMeasures = function (parentMeasure, context) {
  3442. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3443. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3444. this._evaluateClippingState(parentMeasure);
  3445. }
  3446. };
  3447. /** @hidden */
  3448. Container.prototype._layout = function (parentMeasure, context) {
  3449. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3450. return false;
  3451. }
  3452. this.host._numLayoutCalls++;
  3453. if (this._isDirty) {
  3454. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3455. }
  3456. var rebuildCount = 0;
  3457. context.save();
  3458. this._applyStates(context);
  3459. this._beforeLayout();
  3460. do {
  3461. var computedWidth = -1;
  3462. var computedHeight = -1;
  3463. this._rebuildLayout = false;
  3464. this._processMeasures(parentMeasure, context);
  3465. if (!this._isClipped) {
  3466. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3467. var child = _a[_i];
  3468. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3469. if (child._layout(this._measureForChildren, context)) {
  3470. if (this.adaptWidthToChildren && child._width.isPixel) {
  3471. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3472. }
  3473. if (this.adaptHeightToChildren && child._height.isPixel) {
  3474. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3475. }
  3476. }
  3477. }
  3478. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3479. if (this.width !== computedWidth + "px") {
  3480. this.width = computedWidth + "px";
  3481. this._rebuildLayout = true;
  3482. }
  3483. }
  3484. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3485. if (this.height !== computedHeight + "px") {
  3486. this.height = computedHeight + "px";
  3487. this._rebuildLayout = true;
  3488. }
  3489. }
  3490. this._postMeasure();
  3491. }
  3492. rebuildCount++;
  3493. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3494. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3495. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3496. }
  3497. context.restore();
  3498. if (this._isDirty) {
  3499. this.invalidateRect();
  3500. this._isDirty = false;
  3501. }
  3502. return true;
  3503. };
  3504. Container.prototype._postMeasure = function () {
  3505. // Do nothing by default
  3506. };
  3507. /** @hidden */
  3508. Container.prototype._draw = function (context, invalidatedRectangle) {
  3509. this._localDraw(context);
  3510. if (this.clipChildren) {
  3511. this._clipForChildren(context);
  3512. }
  3513. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3514. var child = _a[_i];
  3515. // Only redraw parts of the screen that are invalidated
  3516. if (invalidatedRectangle) {
  3517. if (!child._intersectsRect(invalidatedRectangle)) {
  3518. continue;
  3519. }
  3520. }
  3521. child._render(context, invalidatedRectangle);
  3522. }
  3523. };
  3524. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3525. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3526. if (!this.children) {
  3527. return;
  3528. }
  3529. for (var index = 0; index < this.children.length; index++) {
  3530. var item = this.children[index];
  3531. if (!predicate || predicate(item)) {
  3532. results.push(item);
  3533. }
  3534. if (!directDescendantsOnly) {
  3535. item.getDescendantsToRef(results, false, predicate);
  3536. }
  3537. }
  3538. };
  3539. /** @hidden */
  3540. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  3541. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3542. return false;
  3543. }
  3544. if (!_super.prototype.contains.call(this, x, y)) {
  3545. return false;
  3546. }
  3547. // Checking backwards to pick closest first
  3548. for (var index = this._children.length - 1; index >= 0; index--) {
  3549. var child = this._children[index];
  3550. if (child._processPicking(x, y, type, pointerId, buttonIndex, deltaX, deltaY)) {
  3551. if (child.hoverCursor) {
  3552. this._host._changeCursor(child.hoverCursor);
  3553. }
  3554. return true;
  3555. }
  3556. }
  3557. if (!this.isHitTestVisible) {
  3558. return false;
  3559. }
  3560. return this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  3561. };
  3562. /** @hidden */
  3563. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3564. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3565. this._measureForChildren.copyFrom(this._currentMeasure);
  3566. };
  3567. /** Releases associated resources */
  3568. Container.prototype.dispose = function () {
  3569. _super.prototype.dispose.call(this);
  3570. for (var index = this.children.length - 1; index >= 0; index--) {
  3571. this.children[index].dispose();
  3572. }
  3573. };
  3574. return Container;
  3575. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3576. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3577. /***/ }),
  3578. /***/ "./2D/controls/control.ts":
  3579. /*!********************************!*\
  3580. !*** ./2D/controls/control.ts ***!
  3581. \********************************/
  3582. /*! exports provided: Control */
  3583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3584. "use strict";
  3585. __webpack_require__.r(__webpack_exports__);
  3586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3587. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  3588. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3589. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3590. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3591. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3592. /**
  3593. * Root class used for all 2D controls
  3594. * @see http://doc.babylonjs.com/how_to/gui#controls
  3595. */
  3596. var Control = /** @class */ (function () {
  3597. // Functions
  3598. /**
  3599. * Creates a new control
  3600. * @param name defines the name of the control
  3601. */
  3602. function Control(
  3603. /** defines the name of the control */
  3604. name) {
  3605. this.name = name;
  3606. this._alpha = 1;
  3607. this._alphaSet = false;
  3608. this._zIndex = 0;
  3609. /** @hidden */
  3610. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3611. this._fontFamily = "Arial";
  3612. this._fontStyle = "";
  3613. this._fontWeight = "";
  3614. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3615. /** @hidden */
  3616. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3617. /** @hidden */
  3618. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3619. this._color = "";
  3620. this._style = null;
  3621. /** @hidden */
  3622. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3623. /** @hidden */
  3624. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3625. /** @hidden */
  3626. this._isDirty = true;
  3627. /** @hidden */
  3628. this._wasDirty = false;
  3629. /** @hidden */
  3630. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3631. /** @hidden */
  3632. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3633. /** @hidden */
  3634. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3635. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3636. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3637. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3638. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3639. /** @hidden */
  3640. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3641. /** @hidden */
  3642. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3643. this._scaleX = 1.0;
  3644. this._scaleY = 1.0;
  3645. this._rotation = 0;
  3646. this._transformCenterX = 0.5;
  3647. this._transformCenterY = 0.5;
  3648. /** @hidden */
  3649. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3650. /** @hidden */
  3651. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3652. /** @hidden */
  3653. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3654. this._isMatrixDirty = true;
  3655. this._isVisible = true;
  3656. this._isHighlighted = false;
  3657. this._fontSet = false;
  3658. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3659. this._downCount = 0;
  3660. this._enterCount = -1;
  3661. this._doNotRender = false;
  3662. this._downPointerIds = {};
  3663. this._isEnabled = true;
  3664. this._disabledColor = "#9a9a9a";
  3665. this._disabledColorItem = "#6a6a6a";
  3666. /** @hidden */
  3667. this._rebuildLayout = false;
  3668. /** @hidden */
  3669. this._customData = {};
  3670. /** @hidden */
  3671. this._isClipped = false;
  3672. /** @hidden */
  3673. this._automaticSize = false;
  3674. /**
  3675. * Gets or sets an object used to store user defined information for the node
  3676. */
  3677. this.metadata = null;
  3678. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3679. this.isHitTestVisible = true;
  3680. /** Gets or sets a boolean indicating if the control can block pointer events */
  3681. this.isPointerBlocker = false;
  3682. /** Gets or sets a boolean indicating if the control can be focusable */
  3683. this.isFocusInvisible = false;
  3684. /**
  3685. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3686. * 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
  3687. */
  3688. this.clipChildren = true;
  3689. /**
  3690. * Gets or sets a boolean indicating that control content must be clipped
  3691. * 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
  3692. */
  3693. this.clipContent = true;
  3694. /**
  3695. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3696. */
  3697. this.useBitmapCache = false;
  3698. this._shadowOffsetX = 0;
  3699. this._shadowOffsetY = 0;
  3700. this._shadowBlur = 0;
  3701. this._shadowColor = 'black';
  3702. /** Gets or sets the cursor to use when the control is hovered */
  3703. this.hoverCursor = "";
  3704. /** @hidden */
  3705. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3706. /** @hidden */
  3707. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3708. /**
  3709. * An event triggered when pointer wheel is scrolled
  3710. */
  3711. this.onWheelObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3712. /**
  3713. * An event triggered when the pointer move over the control.
  3714. */
  3715. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3716. /**
  3717. * An event triggered when the pointer move out of the control.
  3718. */
  3719. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3720. /**
  3721. * An event triggered when the pointer taps the control
  3722. */
  3723. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3724. /**
  3725. * An event triggered when pointer up
  3726. */
  3727. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3728. /**
  3729. * An event triggered when a control is clicked on
  3730. */
  3731. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3732. /**
  3733. * An event triggered when pointer enters the control
  3734. */
  3735. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3736. /**
  3737. * An event triggered when the control is marked as dirty
  3738. */
  3739. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3740. /**
  3741. * An event triggered before drawing the control
  3742. */
  3743. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3744. /**
  3745. * An event triggered after the control was drawn
  3746. */
  3747. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3748. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3749. }
  3750. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3751. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3752. get: function () {
  3753. return this._shadowOffsetX;
  3754. },
  3755. set: function (value) {
  3756. if (this._shadowOffsetX === value) {
  3757. return;
  3758. }
  3759. this._shadowOffsetX = value;
  3760. this._markAsDirty();
  3761. },
  3762. enumerable: true,
  3763. configurable: true
  3764. });
  3765. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3766. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3767. get: function () {
  3768. return this._shadowOffsetY;
  3769. },
  3770. set: function (value) {
  3771. if (this._shadowOffsetY === value) {
  3772. return;
  3773. }
  3774. this._shadowOffsetY = value;
  3775. this._markAsDirty();
  3776. },
  3777. enumerable: true,
  3778. configurable: true
  3779. });
  3780. Object.defineProperty(Control.prototype, "shadowBlur", {
  3781. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3782. get: function () {
  3783. return this._shadowBlur;
  3784. },
  3785. set: function (value) {
  3786. if (this._shadowBlur === value) {
  3787. return;
  3788. }
  3789. this._shadowBlur = value;
  3790. this._markAsDirty();
  3791. },
  3792. enumerable: true,
  3793. configurable: true
  3794. });
  3795. Object.defineProperty(Control.prototype, "shadowColor", {
  3796. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3797. get: function () {
  3798. return this._shadowColor;
  3799. },
  3800. set: function (value) {
  3801. if (this._shadowColor === value) {
  3802. return;
  3803. }
  3804. this._shadowColor = value;
  3805. this._markAsDirty();
  3806. },
  3807. enumerable: true,
  3808. configurable: true
  3809. });
  3810. Object.defineProperty(Control.prototype, "typeName", {
  3811. // Properties
  3812. /** Gets the control type name */
  3813. get: function () {
  3814. return this._getTypeName();
  3815. },
  3816. enumerable: true,
  3817. configurable: true
  3818. });
  3819. /**
  3820. * Get the current class name of the control.
  3821. * @returns current class name
  3822. */
  3823. Control.prototype.getClassName = function () {
  3824. return this._getTypeName();
  3825. };
  3826. Object.defineProperty(Control.prototype, "host", {
  3827. /**
  3828. * Get the hosting AdvancedDynamicTexture
  3829. */
  3830. get: function () {
  3831. return this._host;
  3832. },
  3833. enumerable: true,
  3834. configurable: true
  3835. });
  3836. Object.defineProperty(Control.prototype, "fontOffset", {
  3837. /** Gets or set information about font offsets (used to render and align text) */
  3838. get: function () {
  3839. return this._fontOffset;
  3840. },
  3841. set: function (offset) {
  3842. this._fontOffset = offset;
  3843. },
  3844. enumerable: true,
  3845. configurable: true
  3846. });
  3847. Object.defineProperty(Control.prototype, "alpha", {
  3848. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3849. get: function () {
  3850. return this._alpha;
  3851. },
  3852. set: function (value) {
  3853. if (this._alpha === value) {
  3854. return;
  3855. }
  3856. this._alphaSet = true;
  3857. this._alpha = value;
  3858. this._markAsDirty();
  3859. },
  3860. enumerable: true,
  3861. configurable: true
  3862. });
  3863. Object.defineProperty(Control.prototype, "isHighlighted", {
  3864. /**
  3865. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3866. */
  3867. get: function () {
  3868. return this._isHighlighted;
  3869. },
  3870. set: function (value) {
  3871. if (this._isHighlighted === value) {
  3872. return;
  3873. }
  3874. this._isHighlighted = value;
  3875. this._markAsDirty();
  3876. },
  3877. enumerable: true,
  3878. configurable: true
  3879. });
  3880. Object.defineProperty(Control.prototype, "scaleX", {
  3881. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3882. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3883. */
  3884. get: function () {
  3885. return this._scaleX;
  3886. },
  3887. set: function (value) {
  3888. if (this._scaleX === value) {
  3889. return;
  3890. }
  3891. this._scaleX = value;
  3892. this._markAsDirty();
  3893. this._markMatrixAsDirty();
  3894. },
  3895. enumerable: true,
  3896. configurable: true
  3897. });
  3898. Object.defineProperty(Control.prototype, "scaleY", {
  3899. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3900. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3901. */
  3902. get: function () {
  3903. return this._scaleY;
  3904. },
  3905. set: function (value) {
  3906. if (this._scaleY === value) {
  3907. return;
  3908. }
  3909. this._scaleY = value;
  3910. this._markAsDirty();
  3911. this._markMatrixAsDirty();
  3912. },
  3913. enumerable: true,
  3914. configurable: true
  3915. });
  3916. Object.defineProperty(Control.prototype, "rotation", {
  3917. /** Gets or sets the rotation angle (0 by default)
  3918. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3919. */
  3920. get: function () {
  3921. return this._rotation;
  3922. },
  3923. set: function (value) {
  3924. if (this._rotation === value) {
  3925. return;
  3926. }
  3927. this._rotation = value;
  3928. this._markAsDirty();
  3929. this._markMatrixAsDirty();
  3930. },
  3931. enumerable: true,
  3932. configurable: true
  3933. });
  3934. Object.defineProperty(Control.prototype, "transformCenterY", {
  3935. /** Gets or sets the transformation center on Y axis (0 by default)
  3936. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3937. */
  3938. get: function () {
  3939. return this._transformCenterY;
  3940. },
  3941. set: function (value) {
  3942. if (this._transformCenterY === value) {
  3943. return;
  3944. }
  3945. this._transformCenterY = value;
  3946. this._markAsDirty();
  3947. this._markMatrixAsDirty();
  3948. },
  3949. enumerable: true,
  3950. configurable: true
  3951. });
  3952. Object.defineProperty(Control.prototype, "transformCenterX", {
  3953. /** Gets or sets the transformation center on X axis (0 by default)
  3954. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3955. */
  3956. get: function () {
  3957. return this._transformCenterX;
  3958. },
  3959. set: function (value) {
  3960. if (this._transformCenterX === value) {
  3961. return;
  3962. }
  3963. this._transformCenterX = value;
  3964. this._markAsDirty();
  3965. this._markMatrixAsDirty();
  3966. },
  3967. enumerable: true,
  3968. configurable: true
  3969. });
  3970. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3971. /**
  3972. * Gets or sets the horizontal alignment
  3973. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3974. */
  3975. get: function () {
  3976. return this._horizontalAlignment;
  3977. },
  3978. set: function (value) {
  3979. if (this._horizontalAlignment === value) {
  3980. return;
  3981. }
  3982. this._horizontalAlignment = value;
  3983. this._markAsDirty();
  3984. },
  3985. enumerable: true,
  3986. configurable: true
  3987. });
  3988. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3989. /**
  3990. * Gets or sets the vertical alignment
  3991. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3992. */
  3993. get: function () {
  3994. return this._verticalAlignment;
  3995. },
  3996. set: function (value) {
  3997. if (this._verticalAlignment === value) {
  3998. return;
  3999. }
  4000. this._verticalAlignment = value;
  4001. this._markAsDirty();
  4002. },
  4003. enumerable: true,
  4004. configurable: true
  4005. });
  4006. Object.defineProperty(Control.prototype, "width", {
  4007. /**
  4008. * Gets or sets control width
  4009. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4010. */
  4011. get: function () {
  4012. return this._width.toString(this._host);
  4013. },
  4014. set: function (value) {
  4015. if (this._width.toString(this._host) === value) {
  4016. return;
  4017. }
  4018. if (this._width.fromString(value)) {
  4019. this._markAsDirty();
  4020. }
  4021. },
  4022. enumerable: true,
  4023. configurable: true
  4024. });
  4025. Object.defineProperty(Control.prototype, "widthInPixels", {
  4026. /**
  4027. * Gets or sets the control width in pixel
  4028. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4029. */
  4030. get: function () {
  4031. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4032. },
  4033. set: function (value) {
  4034. if (isNaN(value)) {
  4035. return;
  4036. }
  4037. this.width = value + "px";
  4038. },
  4039. enumerable: true,
  4040. configurable: true
  4041. });
  4042. Object.defineProperty(Control.prototype, "height", {
  4043. /**
  4044. * Gets or sets control height
  4045. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4046. */
  4047. get: function () {
  4048. return this._height.toString(this._host);
  4049. },
  4050. set: function (value) {
  4051. if (this._height.toString(this._host) === value) {
  4052. return;
  4053. }
  4054. if (this._height.fromString(value)) {
  4055. this._markAsDirty();
  4056. }
  4057. },
  4058. enumerable: true,
  4059. configurable: true
  4060. });
  4061. Object.defineProperty(Control.prototype, "heightInPixels", {
  4062. /**
  4063. * Gets or sets control height in pixel
  4064. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4065. */
  4066. get: function () {
  4067. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4068. },
  4069. set: function (value) {
  4070. if (isNaN(value)) {
  4071. return;
  4072. }
  4073. this.height = value + "px";
  4074. },
  4075. enumerable: true,
  4076. configurable: true
  4077. });
  4078. Object.defineProperty(Control.prototype, "fontFamily", {
  4079. /** Gets or set font family */
  4080. get: function () {
  4081. if (!this._fontSet) {
  4082. return "";
  4083. }
  4084. return this._fontFamily;
  4085. },
  4086. set: function (value) {
  4087. if (this._fontFamily === value) {
  4088. return;
  4089. }
  4090. this._fontFamily = value;
  4091. this._resetFontCache();
  4092. },
  4093. enumerable: true,
  4094. configurable: true
  4095. });
  4096. Object.defineProperty(Control.prototype, "fontStyle", {
  4097. /** Gets or sets font style */
  4098. get: function () {
  4099. return this._fontStyle;
  4100. },
  4101. set: function (value) {
  4102. if (this._fontStyle === value) {
  4103. return;
  4104. }
  4105. this._fontStyle = value;
  4106. this._resetFontCache();
  4107. },
  4108. enumerable: true,
  4109. configurable: true
  4110. });
  4111. Object.defineProperty(Control.prototype, "fontWeight", {
  4112. /** Gets or sets font weight */
  4113. get: function () {
  4114. return this._fontWeight;
  4115. },
  4116. set: function (value) {
  4117. if (this._fontWeight === value) {
  4118. return;
  4119. }
  4120. this._fontWeight = value;
  4121. this._resetFontCache();
  4122. },
  4123. enumerable: true,
  4124. configurable: true
  4125. });
  4126. Object.defineProperty(Control.prototype, "style", {
  4127. /**
  4128. * Gets or sets style
  4129. * @see http://doc.babylonjs.com/how_to/gui#styles
  4130. */
  4131. get: function () {
  4132. return this._style;
  4133. },
  4134. set: function (value) {
  4135. var _this = this;
  4136. if (this._style) {
  4137. this._style.onChangedObservable.remove(this._styleObserver);
  4138. this._styleObserver = null;
  4139. }
  4140. this._style = value;
  4141. if (this._style) {
  4142. this._styleObserver = this._style.onChangedObservable.add(function () {
  4143. _this._markAsDirty();
  4144. _this._resetFontCache();
  4145. });
  4146. }
  4147. this._markAsDirty();
  4148. this._resetFontCache();
  4149. },
  4150. enumerable: true,
  4151. configurable: true
  4152. });
  4153. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4154. /** @hidden */
  4155. get: function () {
  4156. return this._fontSize.isPercentage;
  4157. },
  4158. enumerable: true,
  4159. configurable: true
  4160. });
  4161. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4162. /** Gets or sets font size in pixels */
  4163. get: function () {
  4164. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4165. if (fontSizeToUse.isPixel) {
  4166. return fontSizeToUse.getValue(this._host);
  4167. }
  4168. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4169. },
  4170. set: function (value) {
  4171. if (isNaN(value)) {
  4172. return;
  4173. }
  4174. this.fontSize = value + "px";
  4175. },
  4176. enumerable: true,
  4177. configurable: true
  4178. });
  4179. Object.defineProperty(Control.prototype, "fontSize", {
  4180. /** Gets or sets font size */
  4181. get: function () {
  4182. return this._fontSize.toString(this._host);
  4183. },
  4184. set: function (value) {
  4185. if (this._fontSize.toString(this._host) === value) {
  4186. return;
  4187. }
  4188. if (this._fontSize.fromString(value)) {
  4189. this._markAsDirty();
  4190. this._resetFontCache();
  4191. }
  4192. },
  4193. enumerable: true,
  4194. configurable: true
  4195. });
  4196. Object.defineProperty(Control.prototype, "color", {
  4197. /** Gets or sets foreground color */
  4198. get: function () {
  4199. return this._color;
  4200. },
  4201. set: function (value) {
  4202. if (this._color === value) {
  4203. return;
  4204. }
  4205. this._color = value;
  4206. this._markAsDirty();
  4207. },
  4208. enumerable: true,
  4209. configurable: true
  4210. });
  4211. Object.defineProperty(Control.prototype, "zIndex", {
  4212. /** Gets or sets z index which is used to reorder controls on the z axis */
  4213. get: function () {
  4214. return this._zIndex;
  4215. },
  4216. set: function (value) {
  4217. if (this.zIndex === value) {
  4218. return;
  4219. }
  4220. this._zIndex = value;
  4221. if (this.parent) {
  4222. this.parent._reOrderControl(this);
  4223. }
  4224. },
  4225. enumerable: true,
  4226. configurable: true
  4227. });
  4228. Object.defineProperty(Control.prototype, "notRenderable", {
  4229. /** Gets or sets a boolean indicating if the control can be rendered */
  4230. get: function () {
  4231. return this._doNotRender;
  4232. },
  4233. set: function (value) {
  4234. if (this._doNotRender === value) {
  4235. return;
  4236. }
  4237. this._doNotRender = value;
  4238. this._markAsDirty();
  4239. },
  4240. enumerable: true,
  4241. configurable: true
  4242. });
  4243. Object.defineProperty(Control.prototype, "isVisible", {
  4244. /** Gets or sets a boolean indicating if the control is visible */
  4245. get: function () {
  4246. return this._isVisible;
  4247. },
  4248. set: function (value) {
  4249. if (this._isVisible === value) {
  4250. return;
  4251. }
  4252. this._isVisible = value;
  4253. this._markAsDirty(true);
  4254. },
  4255. enumerable: true,
  4256. configurable: true
  4257. });
  4258. Object.defineProperty(Control.prototype, "isDirty", {
  4259. /** Gets a boolean indicating that the control needs to update its rendering */
  4260. get: function () {
  4261. return this._isDirty;
  4262. },
  4263. enumerable: true,
  4264. configurable: true
  4265. });
  4266. Object.defineProperty(Control.prototype, "linkedMesh", {
  4267. /**
  4268. * Gets the current linked mesh (or null if none)
  4269. */
  4270. get: function () {
  4271. return this._linkedMesh;
  4272. },
  4273. enumerable: true,
  4274. configurable: true
  4275. });
  4276. Object.defineProperty(Control.prototype, "paddingLeft", {
  4277. /**
  4278. * Gets or sets a value indicating the padding to use on the left of the control
  4279. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4280. */
  4281. get: function () {
  4282. return this._paddingLeft.toString(this._host);
  4283. },
  4284. set: function (value) {
  4285. if (this._paddingLeft.fromString(value)) {
  4286. this._markAsDirty();
  4287. }
  4288. },
  4289. enumerable: true,
  4290. configurable: true
  4291. });
  4292. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4293. /**
  4294. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4295. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4296. */
  4297. get: function () {
  4298. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4299. },
  4300. set: function (value) {
  4301. if (isNaN(value)) {
  4302. return;
  4303. }
  4304. this.paddingLeft = value + "px";
  4305. },
  4306. enumerable: true,
  4307. configurable: true
  4308. });
  4309. Object.defineProperty(Control.prototype, "paddingRight", {
  4310. /**
  4311. * Gets or sets a value indicating the padding to use on the right of the control
  4312. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4313. */
  4314. get: function () {
  4315. return this._paddingRight.toString(this._host);
  4316. },
  4317. set: function (value) {
  4318. if (this._paddingRight.fromString(value)) {
  4319. this._markAsDirty();
  4320. }
  4321. },
  4322. enumerable: true,
  4323. configurable: true
  4324. });
  4325. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4326. /**
  4327. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4328. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4329. */
  4330. get: function () {
  4331. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4332. },
  4333. set: function (value) {
  4334. if (isNaN(value)) {
  4335. return;
  4336. }
  4337. this.paddingRight = value + "px";
  4338. },
  4339. enumerable: true,
  4340. configurable: true
  4341. });
  4342. Object.defineProperty(Control.prototype, "paddingTop", {
  4343. /**
  4344. * Gets or sets a value indicating the padding to use on the top of the control
  4345. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4346. */
  4347. get: function () {
  4348. return this._paddingTop.toString(this._host);
  4349. },
  4350. set: function (value) {
  4351. if (this._paddingTop.fromString(value)) {
  4352. this._markAsDirty();
  4353. }
  4354. },
  4355. enumerable: true,
  4356. configurable: true
  4357. });
  4358. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4359. /**
  4360. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4361. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4362. */
  4363. get: function () {
  4364. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4365. },
  4366. set: function (value) {
  4367. if (isNaN(value)) {
  4368. return;
  4369. }
  4370. this.paddingTop = value + "px";
  4371. },
  4372. enumerable: true,
  4373. configurable: true
  4374. });
  4375. Object.defineProperty(Control.prototype, "paddingBottom", {
  4376. /**
  4377. * Gets or sets a value indicating the padding to use on the bottom of the control
  4378. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4379. */
  4380. get: function () {
  4381. return this._paddingBottom.toString(this._host);
  4382. },
  4383. set: function (value) {
  4384. if (this._paddingBottom.fromString(value)) {
  4385. this._markAsDirty();
  4386. }
  4387. },
  4388. enumerable: true,
  4389. configurable: true
  4390. });
  4391. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4392. /**
  4393. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4394. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4395. */
  4396. get: function () {
  4397. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4398. },
  4399. set: function (value) {
  4400. if (isNaN(value)) {
  4401. return;
  4402. }
  4403. this.paddingBottom = value + "px";
  4404. },
  4405. enumerable: true,
  4406. configurable: true
  4407. });
  4408. Object.defineProperty(Control.prototype, "left", {
  4409. /**
  4410. * Gets or sets a value indicating the left coordinate of the control
  4411. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4412. */
  4413. get: function () {
  4414. return this._left.toString(this._host);
  4415. },
  4416. set: function (value) {
  4417. if (this._left.fromString(value)) {
  4418. this._markAsDirty();
  4419. }
  4420. },
  4421. enumerable: true,
  4422. configurable: true
  4423. });
  4424. Object.defineProperty(Control.prototype, "leftInPixels", {
  4425. /**
  4426. * Gets or sets a value indicating the left coordinate in pixels of the control
  4427. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4428. */
  4429. get: function () {
  4430. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4431. },
  4432. set: function (value) {
  4433. if (isNaN(value)) {
  4434. return;
  4435. }
  4436. this.left = value + "px";
  4437. },
  4438. enumerable: true,
  4439. configurable: true
  4440. });
  4441. Object.defineProperty(Control.prototype, "top", {
  4442. /**
  4443. * Gets or sets a value indicating the top coordinate of the control
  4444. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4445. */
  4446. get: function () {
  4447. return this._top.toString(this._host);
  4448. },
  4449. set: function (value) {
  4450. if (this._top.fromString(value)) {
  4451. this._markAsDirty();
  4452. }
  4453. },
  4454. enumerable: true,
  4455. configurable: true
  4456. });
  4457. Object.defineProperty(Control.prototype, "topInPixels", {
  4458. /**
  4459. * Gets or sets a value indicating the top coordinate in pixels of the control
  4460. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4461. */
  4462. get: function () {
  4463. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4464. },
  4465. set: function (value) {
  4466. if (isNaN(value)) {
  4467. return;
  4468. }
  4469. this.top = value + "px";
  4470. },
  4471. enumerable: true,
  4472. configurable: true
  4473. });
  4474. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4475. /**
  4476. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4477. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4478. */
  4479. get: function () {
  4480. return this._linkOffsetX.toString(this._host);
  4481. },
  4482. set: function (value) {
  4483. if (this._linkOffsetX.fromString(value)) {
  4484. this._markAsDirty();
  4485. }
  4486. },
  4487. enumerable: true,
  4488. configurable: true
  4489. });
  4490. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4491. /**
  4492. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4493. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4494. */
  4495. get: function () {
  4496. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4497. },
  4498. set: function (value) {
  4499. if (isNaN(value)) {
  4500. return;
  4501. }
  4502. this.linkOffsetX = value + "px";
  4503. },
  4504. enumerable: true,
  4505. configurable: true
  4506. });
  4507. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4508. /**
  4509. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4510. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4511. */
  4512. get: function () {
  4513. return this._linkOffsetY.toString(this._host);
  4514. },
  4515. set: function (value) {
  4516. if (this._linkOffsetY.fromString(value)) {
  4517. this._markAsDirty();
  4518. }
  4519. },
  4520. enumerable: true,
  4521. configurable: true
  4522. });
  4523. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4524. /**
  4525. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4526. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4527. */
  4528. get: function () {
  4529. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4530. },
  4531. set: function (value) {
  4532. if (isNaN(value)) {
  4533. return;
  4534. }
  4535. this.linkOffsetY = value + "px";
  4536. },
  4537. enumerable: true,
  4538. configurable: true
  4539. });
  4540. Object.defineProperty(Control.prototype, "centerX", {
  4541. /** Gets the center coordinate on X axis */
  4542. get: function () {
  4543. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4544. },
  4545. enumerable: true,
  4546. configurable: true
  4547. });
  4548. Object.defineProperty(Control.prototype, "centerY", {
  4549. /** Gets the center coordinate on Y axis */
  4550. get: function () {
  4551. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4552. },
  4553. enumerable: true,
  4554. configurable: true
  4555. });
  4556. Object.defineProperty(Control.prototype, "isEnabled", {
  4557. /** Gets or sets if control is Enabled*/
  4558. get: function () {
  4559. return this._isEnabled;
  4560. },
  4561. set: function (value) {
  4562. if (this._isEnabled === value) {
  4563. return;
  4564. }
  4565. this._isEnabled = value;
  4566. this._markAsDirty();
  4567. },
  4568. enumerable: true,
  4569. configurable: true
  4570. });
  4571. Object.defineProperty(Control.prototype, "disabledColor", {
  4572. /** Gets or sets background color of control if it's disabled*/
  4573. get: function () {
  4574. return this._disabledColor;
  4575. },
  4576. set: function (value) {
  4577. if (this._disabledColor === value) {
  4578. return;
  4579. }
  4580. this._disabledColor = value;
  4581. this._markAsDirty();
  4582. },
  4583. enumerable: true,
  4584. configurable: true
  4585. });
  4586. Object.defineProperty(Control.prototype, "disabledColorItem", {
  4587. /** Gets or sets front color of control if it's disabled*/
  4588. get: function () {
  4589. return this._disabledColorItem;
  4590. },
  4591. set: function (value) {
  4592. if (this._disabledColorItem === value) {
  4593. return;
  4594. }
  4595. this._disabledColorItem = value;
  4596. this._markAsDirty();
  4597. },
  4598. enumerable: true,
  4599. configurable: true
  4600. });
  4601. /** @hidden */
  4602. Control.prototype._getTypeName = function () {
  4603. return "Control";
  4604. };
  4605. /**
  4606. * Gets the first ascendant in the hierarchy of the given type
  4607. * @param className defines the required type
  4608. * @returns the ascendant or null if not found
  4609. */
  4610. Control.prototype.getAscendantOfClass = function (className) {
  4611. if (!this.parent) {
  4612. return null;
  4613. }
  4614. if (this.parent.getClassName() === className) {
  4615. return this.parent;
  4616. }
  4617. return this.parent.getAscendantOfClass(className);
  4618. };
  4619. /** @hidden */
  4620. Control.prototype._resetFontCache = function () {
  4621. this._fontSet = true;
  4622. this._markAsDirty();
  4623. };
  4624. /**
  4625. * Determines if a container is an ascendant of the current control
  4626. * @param container defines the container to look for
  4627. * @returns true if the container is one of the ascendant of the control
  4628. */
  4629. Control.prototype.isAscendant = function (container) {
  4630. if (!this.parent) {
  4631. return false;
  4632. }
  4633. if (this.parent === container) {
  4634. return true;
  4635. }
  4636. return this.parent.isAscendant(container);
  4637. };
  4638. /**
  4639. * Gets coordinates in local control space
  4640. * @param globalCoordinates defines the coordinates to transform
  4641. * @returns the new coordinates in local space
  4642. */
  4643. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4644. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4645. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4646. return result;
  4647. };
  4648. /**
  4649. * Gets coordinates in local control space
  4650. * @param globalCoordinates defines the coordinates to transform
  4651. * @param result defines the target vector2 where to store the result
  4652. * @returns the current control
  4653. */
  4654. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4655. result.x = globalCoordinates.x - this._currentMeasure.left;
  4656. result.y = globalCoordinates.y - this._currentMeasure.top;
  4657. return this;
  4658. };
  4659. /**
  4660. * Gets coordinates in parent local control space
  4661. * @param globalCoordinates defines the coordinates to transform
  4662. * @returns the new coordinates in parent local space
  4663. */
  4664. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4665. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4666. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4667. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4668. return result;
  4669. };
  4670. /**
  4671. * Move the current control to a vector3 position projected onto the screen.
  4672. * @param position defines the target position
  4673. * @param scene defines the hosting scene
  4674. */
  4675. Control.prototype.moveToVector3 = function (position, scene) {
  4676. if (!this._host || this.parent !== this._host._rootContainer) {
  4677. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4678. return;
  4679. }
  4680. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4681. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4682. var globalViewport = this._host._getGlobalViewport(scene);
  4683. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4684. this._moveToProjectedPosition(projectedPosition);
  4685. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4686. this.notRenderable = true;
  4687. return;
  4688. }
  4689. this.notRenderable = false;
  4690. };
  4691. /**
  4692. * Will store all controls that have this control as ascendant in a given array
  4693. * @param results defines the array where to store the descendants
  4694. * @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
  4695. * @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
  4696. */
  4697. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4698. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4699. // Do nothing by default
  4700. };
  4701. /**
  4702. * Will return all controls that have this control as ascendant
  4703. * @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
  4704. * @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
  4705. * @return all child controls
  4706. */
  4707. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4708. var results = new Array();
  4709. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4710. return results;
  4711. };
  4712. /**
  4713. * Link current control with a target mesh
  4714. * @param mesh defines the mesh to link with
  4715. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4716. */
  4717. Control.prototype.linkWithMesh = function (mesh) {
  4718. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4719. if (mesh) {
  4720. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4721. }
  4722. return;
  4723. }
  4724. var index = this._host._linkedControls.indexOf(this);
  4725. if (index !== -1) {
  4726. this._linkedMesh = mesh;
  4727. if (!mesh) {
  4728. this._host._linkedControls.splice(index, 1);
  4729. }
  4730. return;
  4731. }
  4732. else if (!mesh) {
  4733. return;
  4734. }
  4735. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4736. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4737. this._linkedMesh = mesh;
  4738. this._host._linkedControls.push(this);
  4739. };
  4740. /** @hidden */
  4741. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4742. var oldLeft = this._left.getValue(this._host);
  4743. var oldTop = this._top.getValue(this._host);
  4744. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4745. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4746. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4747. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4748. newLeft = oldLeft;
  4749. }
  4750. if (Math.abs(newTop - oldTop) < 0.5) {
  4751. newTop = oldTop;
  4752. }
  4753. }
  4754. this.left = newLeft + "px";
  4755. this.top = newTop + "px";
  4756. this._left.ignoreAdaptiveScaling = true;
  4757. this._top.ignoreAdaptiveScaling = true;
  4758. this._markAsDirty();
  4759. };
  4760. /** @hidden */
  4761. Control.prototype._offsetLeft = function (offset) {
  4762. this._isDirty = true;
  4763. this._currentMeasure.left += offset;
  4764. };
  4765. /** @hidden */
  4766. Control.prototype._offsetTop = function (offset) {
  4767. this._isDirty = true;
  4768. this._currentMeasure.top += offset;
  4769. };
  4770. /** @hidden */
  4771. Control.prototype._markMatrixAsDirty = function () {
  4772. this._isMatrixDirty = true;
  4773. this._flagDescendantsAsMatrixDirty();
  4774. };
  4775. /** @hidden */
  4776. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4777. // No child
  4778. };
  4779. /** @hidden */
  4780. Control.prototype._intersectsRect = function (rect) {
  4781. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4782. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4783. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4784. return false;
  4785. }
  4786. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4787. return false;
  4788. }
  4789. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4790. return false;
  4791. }
  4792. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4793. return false;
  4794. }
  4795. return true;
  4796. };
  4797. /** @hidden */
  4798. Control.prototype.invalidateRect = function () {
  4799. this._transform();
  4800. if (this.host && this.host.useInvalidateRectOptimization) {
  4801. // Rotate by transform to get the measure transformed to global space
  4802. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4803. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4804. // the previous measure is used to properly clear a control that is scaled down
  4805. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4806. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4807. // Expand rect based on shadows
  4808. var shadowOffsetX = this.shadowOffsetX;
  4809. var shadowOffsetY = this.shadowOffsetY;
  4810. var shadowBlur = this.shadowBlur;
  4811. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4812. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4813. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4814. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4815. 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));
  4816. }
  4817. else {
  4818. 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));
  4819. }
  4820. }
  4821. };
  4822. /** @hidden */
  4823. Control.prototype._markAsDirty = function (force) {
  4824. if (force === void 0) { force = false; }
  4825. if (!this._isVisible && !force) {
  4826. return;
  4827. }
  4828. this._isDirty = true;
  4829. // Redraw only this rectangle
  4830. if (this._host) {
  4831. this._host.markAsDirty();
  4832. }
  4833. };
  4834. /** @hidden */
  4835. Control.prototype._markAllAsDirty = function () {
  4836. this._markAsDirty();
  4837. if (this._font) {
  4838. this._prepareFont();
  4839. }
  4840. };
  4841. /** @hidden */
  4842. Control.prototype._link = function (host) {
  4843. this._host = host;
  4844. if (this._host) {
  4845. this.uniqueId = this._host.getScene().getUniqueId();
  4846. }
  4847. };
  4848. /** @hidden */
  4849. Control.prototype._transform = function (context) {
  4850. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4851. return;
  4852. }
  4853. // postTranslate
  4854. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4855. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4856. if (context) {
  4857. context.translate(offsetX, offsetY);
  4858. // rotate
  4859. context.rotate(this._rotation);
  4860. // scale
  4861. context.scale(this._scaleX, this._scaleY);
  4862. // preTranslate
  4863. context.translate(-offsetX, -offsetY);
  4864. }
  4865. // Need to update matrices?
  4866. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4867. this._cachedOffsetX = offsetX;
  4868. this._cachedOffsetY = offsetY;
  4869. this._isMatrixDirty = false;
  4870. this._flagDescendantsAsMatrixDirty();
  4871. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4872. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4873. }
  4874. };
  4875. /** @hidden */
  4876. Control.prototype._renderHighlight = function (context) {
  4877. if (!this.isHighlighted) {
  4878. return;
  4879. }
  4880. context.save();
  4881. context.strokeStyle = "#4affff";
  4882. context.lineWidth = 2;
  4883. this._renderHighlightSpecific(context);
  4884. context.restore();
  4885. };
  4886. /** @hidden */
  4887. Control.prototype._renderHighlightSpecific = function (context) {
  4888. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4889. };
  4890. /** @hidden */
  4891. Control.prototype._applyStates = function (context) {
  4892. if (this._isFontSizeInPercentage) {
  4893. this._fontSet = true;
  4894. }
  4895. if (this._fontSet) {
  4896. this._prepareFont();
  4897. this._fontSet = false;
  4898. }
  4899. if (this._font) {
  4900. context.font = this._font;
  4901. }
  4902. if (this._color) {
  4903. context.fillStyle = this._color;
  4904. }
  4905. if (Control.AllowAlphaInheritance) {
  4906. context.globalAlpha *= this._alpha;
  4907. }
  4908. else if (this._alphaSet) {
  4909. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4910. }
  4911. };
  4912. /** @hidden */
  4913. Control.prototype._layout = function (parentMeasure, context) {
  4914. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4915. return false;
  4916. }
  4917. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4918. this.host._numLayoutCalls++;
  4919. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4920. context.save();
  4921. this._applyStates(context);
  4922. var rebuildCount = 0;
  4923. do {
  4924. this._rebuildLayout = false;
  4925. this._processMeasures(parentMeasure, context);
  4926. rebuildCount++;
  4927. } while (this._rebuildLayout && rebuildCount < 3);
  4928. if (rebuildCount >= 3) {
  4929. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4930. }
  4931. context.restore();
  4932. this.invalidateRect();
  4933. this._evaluateClippingState(parentMeasure);
  4934. }
  4935. this._wasDirty = this._isDirty;
  4936. this._isDirty = false;
  4937. return true;
  4938. };
  4939. /** @hidden */
  4940. Control.prototype._processMeasures = function (parentMeasure, context) {
  4941. this._currentMeasure.copyFrom(parentMeasure);
  4942. // Let children take some pre-measurement actions
  4943. this._preMeasure(parentMeasure, context);
  4944. this._measure();
  4945. this._computeAlignment(parentMeasure, context);
  4946. // Convert to int values
  4947. this._currentMeasure.left = this._currentMeasure.left | 0;
  4948. this._currentMeasure.top = this._currentMeasure.top | 0;
  4949. this._currentMeasure.width = this._currentMeasure.width | 0;
  4950. this._currentMeasure.height = this._currentMeasure.height | 0;
  4951. // Let children add more features
  4952. this._additionalProcessing(parentMeasure, context);
  4953. this._cachedParentMeasure.copyFrom(parentMeasure);
  4954. if (this.onDirtyObservable.hasObservers()) {
  4955. this.onDirtyObservable.notifyObservers(this);
  4956. }
  4957. };
  4958. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4959. if (this.parent && this.parent.clipChildren) {
  4960. // Early clip
  4961. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4962. this._isClipped = true;
  4963. return;
  4964. }
  4965. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4966. this._isClipped = true;
  4967. return;
  4968. }
  4969. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4970. this._isClipped = true;
  4971. return;
  4972. }
  4973. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4974. this._isClipped = true;
  4975. return;
  4976. }
  4977. }
  4978. this._isClipped = false;
  4979. };
  4980. /** @hidden */
  4981. Control.prototype._measure = function () {
  4982. // Width / Height
  4983. if (this._width.isPixel) {
  4984. this._currentMeasure.width = this._width.getValue(this._host);
  4985. }
  4986. else {
  4987. this._currentMeasure.width *= this._width.getValue(this._host);
  4988. }
  4989. if (this._height.isPixel) {
  4990. this._currentMeasure.height = this._height.getValue(this._host);
  4991. }
  4992. else {
  4993. this._currentMeasure.height *= this._height.getValue(this._host);
  4994. }
  4995. };
  4996. /** @hidden */
  4997. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4998. var width = this._currentMeasure.width;
  4999. var height = this._currentMeasure.height;
  5000. var parentWidth = parentMeasure.width;
  5001. var parentHeight = parentMeasure.height;
  5002. // Left / top
  5003. var x = 0;
  5004. var y = 0;
  5005. switch (this.horizontalAlignment) {
  5006. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  5007. x = 0;
  5008. break;
  5009. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  5010. x = parentWidth - width;
  5011. break;
  5012. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  5013. x = (parentWidth - width) / 2;
  5014. break;
  5015. }
  5016. switch (this.verticalAlignment) {
  5017. case Control.VERTICAL_ALIGNMENT_TOP:
  5018. y = 0;
  5019. break;
  5020. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  5021. y = parentHeight - height;
  5022. break;
  5023. case Control.VERTICAL_ALIGNMENT_CENTER:
  5024. y = (parentHeight - height) / 2;
  5025. break;
  5026. }
  5027. if (this._paddingLeft.isPixel) {
  5028. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  5029. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  5030. }
  5031. else {
  5032. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  5033. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  5034. }
  5035. if (this._paddingRight.isPixel) {
  5036. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  5037. }
  5038. else {
  5039. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  5040. }
  5041. if (this._paddingTop.isPixel) {
  5042. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  5043. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  5044. }
  5045. else {
  5046. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  5047. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  5048. }
  5049. if (this._paddingBottom.isPixel) {
  5050. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  5051. }
  5052. else {
  5053. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  5054. }
  5055. if (this._left.isPixel) {
  5056. this._currentMeasure.left += this._left.getValue(this._host);
  5057. }
  5058. else {
  5059. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  5060. }
  5061. if (this._top.isPixel) {
  5062. this._currentMeasure.top += this._top.getValue(this._host);
  5063. }
  5064. else {
  5065. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5066. }
  5067. this._currentMeasure.left += x;
  5068. this._currentMeasure.top += y;
  5069. };
  5070. /** @hidden */
  5071. Control.prototype._preMeasure = function (parentMeasure, context) {
  5072. // Do nothing
  5073. };
  5074. /** @hidden */
  5075. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5076. // Do nothing
  5077. };
  5078. /** @hidden */
  5079. Control.prototype._clipForChildren = function (context) {
  5080. // DO nothing
  5081. };
  5082. Control.prototype._clip = function (context, invalidatedRectangle) {
  5083. context.beginPath();
  5084. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5085. if (invalidatedRectangle) {
  5086. // Rotate the invalidated rect into the control's space
  5087. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5088. // Get the intersection of the rect in context space and the current context
  5089. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5090. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5091. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5092. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5093. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5094. Control._ClipMeasure.copyFrom(intersection);
  5095. }
  5096. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5097. var shadowOffsetX = this.shadowOffsetX;
  5098. var shadowOffsetY = this.shadowOffsetY;
  5099. var shadowBlur = this.shadowBlur;
  5100. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5101. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5102. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5103. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5104. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5105. }
  5106. else {
  5107. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5108. }
  5109. context.clip();
  5110. };
  5111. /** @hidden */
  5112. Control.prototype._render = function (context, invalidatedRectangle) {
  5113. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5114. this._isDirty = false;
  5115. return false;
  5116. }
  5117. this.host._numRenderCalls++;
  5118. context.save();
  5119. this._applyStates(context);
  5120. // Transform
  5121. this._transform(context);
  5122. // Clip
  5123. if (this.clipContent) {
  5124. this._clip(context, invalidatedRectangle);
  5125. }
  5126. if (this.onBeforeDrawObservable.hasObservers()) {
  5127. this.onBeforeDrawObservable.notifyObservers(this);
  5128. }
  5129. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5130. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5131. }
  5132. else {
  5133. this._draw(context, invalidatedRectangle);
  5134. }
  5135. if (this.useBitmapCache && this._wasDirty) {
  5136. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5137. }
  5138. this._renderHighlight(context);
  5139. if (this.onAfterDrawObservable.hasObservers()) {
  5140. this.onAfterDrawObservable.notifyObservers(this);
  5141. }
  5142. context.restore();
  5143. return true;
  5144. };
  5145. /** @hidden */
  5146. Control.prototype._draw = function (context, invalidatedRectangle) {
  5147. // Do nothing
  5148. };
  5149. /**
  5150. * Tests if a given coordinates belong to the current control
  5151. * @param x defines x coordinate to test
  5152. * @param y defines y coordinate to test
  5153. * @returns true if the coordinates are inside the control
  5154. */
  5155. Control.prototype.contains = function (x, y) {
  5156. // Invert transform
  5157. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5158. x = this._transformedPosition.x;
  5159. y = this._transformedPosition.y;
  5160. // Check
  5161. if (x < this._currentMeasure.left) {
  5162. return false;
  5163. }
  5164. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5165. return false;
  5166. }
  5167. if (y < this._currentMeasure.top) {
  5168. return false;
  5169. }
  5170. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5171. return false;
  5172. }
  5173. if (this.isPointerBlocker) {
  5174. this._host._shouldBlockPointer = true;
  5175. }
  5176. return true;
  5177. };
  5178. /** @hidden */
  5179. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  5180. if (!this._isEnabled) {
  5181. return false;
  5182. }
  5183. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5184. return false;
  5185. }
  5186. if (!this.contains(x, y)) {
  5187. return false;
  5188. }
  5189. this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  5190. return true;
  5191. };
  5192. /** @hidden */
  5193. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5194. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5195. if (canNotify && this.parent != null) {
  5196. this.parent._onPointerMove(target, coordinates, pointerId);
  5197. }
  5198. };
  5199. /** @hidden */
  5200. Control.prototype._onPointerEnter = function (target) {
  5201. if (!this._isEnabled) {
  5202. return false;
  5203. }
  5204. if (this._enterCount > 0) {
  5205. return false;
  5206. }
  5207. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5208. this._enterCount = 0;
  5209. }
  5210. this._enterCount++;
  5211. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5212. if (canNotify && this.parent != null) {
  5213. this.parent._onPointerEnter(target);
  5214. }
  5215. return true;
  5216. };
  5217. /** @hidden */
  5218. Control.prototype._onPointerOut = function (target, force) {
  5219. if (force === void 0) { force = false; }
  5220. if (!force && (!this._isEnabled || target === this)) {
  5221. return;
  5222. }
  5223. this._enterCount = 0;
  5224. var canNotify = true;
  5225. if (!target.isAscendant(this)) {
  5226. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5227. }
  5228. if (canNotify && this.parent != null) {
  5229. this.parent._onPointerOut(target, force);
  5230. }
  5231. };
  5232. /** @hidden */
  5233. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5234. // Prevent pointerout to lose control context.
  5235. // Event redundancy is checked inside the function.
  5236. this._onPointerEnter(this);
  5237. if (this._downCount !== 0) {
  5238. return false;
  5239. }
  5240. this._downCount++;
  5241. this._downPointerIds[pointerId] = true;
  5242. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5243. if (canNotify && this.parent != null) {
  5244. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5245. }
  5246. return true;
  5247. };
  5248. /** @hidden */
  5249. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5250. if (!this._isEnabled) {
  5251. return;
  5252. }
  5253. this._downCount = 0;
  5254. delete this._downPointerIds[pointerId];
  5255. var canNotifyClick = notifyClick;
  5256. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5257. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5258. }
  5259. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5260. if (canNotify && this.parent != null) {
  5261. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5262. }
  5263. };
  5264. /** @hidden */
  5265. Control.prototype._forcePointerUp = function (pointerId) {
  5266. if (pointerId === void 0) { pointerId = null; }
  5267. if (pointerId !== null) {
  5268. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5269. }
  5270. else {
  5271. for (var key in this._downPointerIds) {
  5272. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5273. }
  5274. }
  5275. };
  5276. /** @hidden */
  5277. Control.prototype._onWheelScroll = function (deltaX, deltaY) {
  5278. if (!this._isEnabled) {
  5279. return;
  5280. }
  5281. var canNotify = this.onWheelObservable.notifyObservers(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"](deltaX, deltaY));
  5282. if (canNotify && this.parent != null) {
  5283. this.parent._onWheelScroll(deltaX, deltaY);
  5284. }
  5285. };
  5286. /** @hidden */
  5287. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex, deltaX, deltaY) {
  5288. if (!this._isEnabled) {
  5289. return false;
  5290. }
  5291. this._dummyVector2.copyFromFloats(x, y);
  5292. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5293. this._onPointerMove(this, this._dummyVector2, pointerId);
  5294. var previousControlOver = this._host._lastControlOver[pointerId];
  5295. if (previousControlOver && previousControlOver !== this) {
  5296. previousControlOver._onPointerOut(this);
  5297. }
  5298. if (previousControlOver !== this) {
  5299. this._onPointerEnter(this);
  5300. }
  5301. this._host._lastControlOver[pointerId] = this;
  5302. return true;
  5303. }
  5304. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5305. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5306. this._host._registerLastControlDown(this, pointerId);
  5307. this._host._lastPickedControl = this;
  5308. return true;
  5309. }
  5310. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5311. if (this._host._lastControlDown[pointerId]) {
  5312. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5313. }
  5314. delete this._host._lastControlDown[pointerId];
  5315. return true;
  5316. }
  5317. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERWHEEL) {
  5318. if (this._host._lastControlOver[pointerId]) {
  5319. this._host._lastControlOver[pointerId]._onWheelScroll(deltaX, deltaY);
  5320. return true;
  5321. }
  5322. }
  5323. return false;
  5324. };
  5325. Control.prototype._prepareFont = function () {
  5326. if (!this._font && !this._fontSet) {
  5327. return;
  5328. }
  5329. if (this._style) {
  5330. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5331. }
  5332. else {
  5333. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5334. }
  5335. this._fontOffset = Control._GetFontOffset(this._font);
  5336. };
  5337. /** Releases associated resources */
  5338. Control.prototype.dispose = function () {
  5339. this.onDirtyObservable.clear();
  5340. this.onBeforeDrawObservable.clear();
  5341. this.onAfterDrawObservable.clear();
  5342. this.onPointerDownObservable.clear();
  5343. this.onPointerEnterObservable.clear();
  5344. this.onPointerMoveObservable.clear();
  5345. this.onPointerOutObservable.clear();
  5346. this.onPointerUpObservable.clear();
  5347. this.onPointerClickObservable.clear();
  5348. this.onWheelObservable.clear();
  5349. if (this._styleObserver && this._style) {
  5350. this._style.onChangedObservable.remove(this._styleObserver);
  5351. this._styleObserver = null;
  5352. }
  5353. if (this.parent) {
  5354. this.parent.removeControl(this);
  5355. this.parent = null;
  5356. }
  5357. if (this._host) {
  5358. var index = this._host._linkedControls.indexOf(this);
  5359. if (index > -1) {
  5360. this.linkWithMesh(null);
  5361. }
  5362. }
  5363. };
  5364. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5365. /** HORIZONTAL_ALIGNMENT_LEFT */
  5366. get: function () {
  5367. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5368. },
  5369. enumerable: true,
  5370. configurable: true
  5371. });
  5372. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5373. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5374. get: function () {
  5375. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5376. },
  5377. enumerable: true,
  5378. configurable: true
  5379. });
  5380. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5381. /** HORIZONTAL_ALIGNMENT_CENTER */
  5382. get: function () {
  5383. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5384. },
  5385. enumerable: true,
  5386. configurable: true
  5387. });
  5388. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5389. /** VERTICAL_ALIGNMENT_TOP */
  5390. get: function () {
  5391. return Control._VERTICAL_ALIGNMENT_TOP;
  5392. },
  5393. enumerable: true,
  5394. configurable: true
  5395. });
  5396. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5397. /** VERTICAL_ALIGNMENT_BOTTOM */
  5398. get: function () {
  5399. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5400. },
  5401. enumerable: true,
  5402. configurable: true
  5403. });
  5404. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5405. /** VERTICAL_ALIGNMENT_CENTER */
  5406. get: function () {
  5407. return Control._VERTICAL_ALIGNMENT_CENTER;
  5408. },
  5409. enumerable: true,
  5410. configurable: true
  5411. });
  5412. /** @hidden */
  5413. Control._GetFontOffset = function (font) {
  5414. if (Control._FontHeightSizes[font]) {
  5415. return Control._FontHeightSizes[font];
  5416. }
  5417. var text = document.createElement("span");
  5418. text.innerHTML = "Hg";
  5419. text.style.font = font;
  5420. var block = document.createElement("div");
  5421. block.style.display = "inline-block";
  5422. block.style.width = "1px";
  5423. block.style.height = "0px";
  5424. block.style.verticalAlign = "bottom";
  5425. var div = document.createElement("div");
  5426. div.appendChild(text);
  5427. div.appendChild(block);
  5428. document.body.appendChild(div);
  5429. var fontAscent = 0;
  5430. var fontHeight = 0;
  5431. try {
  5432. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5433. block.style.verticalAlign = "baseline";
  5434. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5435. }
  5436. finally {
  5437. document.body.removeChild(div);
  5438. }
  5439. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5440. Control._FontHeightSizes[font] = result;
  5441. return result;
  5442. };
  5443. /** @hidden */
  5444. Control.drawEllipse = function (x, y, width, height, context) {
  5445. context.translate(x, y);
  5446. context.scale(width, height);
  5447. context.beginPath();
  5448. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5449. context.closePath();
  5450. context.scale(1 / width, 1 / height);
  5451. context.translate(-x, -y);
  5452. };
  5453. /**
  5454. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5455. */
  5456. Control.AllowAlphaInheritance = false;
  5457. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5458. // Statics
  5459. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5460. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5461. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5462. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5463. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5464. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5465. Control._FontHeightSizes = {};
  5466. /**
  5467. * Creates a stack panel that can be used to render headers
  5468. * @param control defines the control to associate with the header
  5469. * @param text defines the text of the header
  5470. * @param size defines the size of the header
  5471. * @param options defines options used to configure the header
  5472. * @returns a new StackPanel
  5473. * @ignore
  5474. * @hidden
  5475. */
  5476. Control.AddHeader = function () { };
  5477. return Control;
  5478. }());
  5479. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5480. /***/ }),
  5481. /***/ "./2D/controls/displayGrid.ts":
  5482. /*!************************************!*\
  5483. !*** ./2D/controls/displayGrid.ts ***!
  5484. \************************************/
  5485. /*! exports provided: DisplayGrid */
  5486. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5487. "use strict";
  5488. __webpack_require__.r(__webpack_exports__);
  5489. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5490. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5491. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5492. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5493. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5494. /** Class used to render a grid */
  5495. var DisplayGrid = /** @class */ (function (_super) {
  5496. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5497. /**
  5498. * Creates a new GridDisplayRectangle
  5499. * @param name defines the control name
  5500. */
  5501. function DisplayGrid(name) {
  5502. var _this = _super.call(this, name) || this;
  5503. _this.name = name;
  5504. _this._cellWidth = 20;
  5505. _this._cellHeight = 20;
  5506. _this._minorLineTickness = 1;
  5507. _this._minorLineColor = "DarkGray";
  5508. _this._majorLineTickness = 2;
  5509. _this._majorLineColor = "White";
  5510. _this._majorLineFrequency = 5;
  5511. _this._background = "Black";
  5512. _this._displayMajorLines = true;
  5513. _this._displayMinorLines = true;
  5514. return _this;
  5515. }
  5516. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5517. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5518. get: function () {
  5519. return this._displayMinorLines;
  5520. },
  5521. set: function (value) {
  5522. if (this._displayMinorLines === value) {
  5523. return;
  5524. }
  5525. this._displayMinorLines = value;
  5526. this._markAsDirty();
  5527. },
  5528. enumerable: true,
  5529. configurable: true
  5530. });
  5531. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5532. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5533. get: function () {
  5534. return this._displayMajorLines;
  5535. },
  5536. set: function (value) {
  5537. if (this._displayMajorLines === value) {
  5538. return;
  5539. }
  5540. this._displayMajorLines = value;
  5541. this._markAsDirty();
  5542. },
  5543. enumerable: true,
  5544. configurable: true
  5545. });
  5546. Object.defineProperty(DisplayGrid.prototype, "background", {
  5547. /** Gets or sets background color (Black by default) */
  5548. get: function () {
  5549. return this._background;
  5550. },
  5551. set: function (value) {
  5552. if (this._background === value) {
  5553. return;
  5554. }
  5555. this._background = value;
  5556. this._markAsDirty();
  5557. },
  5558. enumerable: true,
  5559. configurable: true
  5560. });
  5561. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5562. /** Gets or sets the width of each cell (20 by default) */
  5563. get: function () {
  5564. return this._cellWidth;
  5565. },
  5566. set: function (value) {
  5567. this._cellWidth = value;
  5568. this._markAsDirty();
  5569. },
  5570. enumerable: true,
  5571. configurable: true
  5572. });
  5573. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5574. /** Gets or sets the height of each cell (20 by default) */
  5575. get: function () {
  5576. return this._cellHeight;
  5577. },
  5578. set: function (value) {
  5579. this._cellHeight = value;
  5580. this._markAsDirty();
  5581. },
  5582. enumerable: true,
  5583. configurable: true
  5584. });
  5585. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5586. /** Gets or sets the tickness of minor lines (1 by default) */
  5587. get: function () {
  5588. return this._minorLineTickness;
  5589. },
  5590. set: function (value) {
  5591. this._minorLineTickness = value;
  5592. this._markAsDirty();
  5593. },
  5594. enumerable: true,
  5595. configurable: true
  5596. });
  5597. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5598. /** Gets or sets the color of minor lines (DarkGray by default) */
  5599. get: function () {
  5600. return this._minorLineColor;
  5601. },
  5602. set: function (value) {
  5603. this._minorLineColor = value;
  5604. this._markAsDirty();
  5605. },
  5606. enumerable: true,
  5607. configurable: true
  5608. });
  5609. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5610. /** Gets or sets the tickness of major lines (2 by default) */
  5611. get: function () {
  5612. return this._majorLineTickness;
  5613. },
  5614. set: function (value) {
  5615. this._majorLineTickness = value;
  5616. this._markAsDirty();
  5617. },
  5618. enumerable: true,
  5619. configurable: true
  5620. });
  5621. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5622. /** Gets or sets the color of major lines (White by default) */
  5623. get: function () {
  5624. return this._majorLineColor;
  5625. },
  5626. set: function (value) {
  5627. this._majorLineColor = value;
  5628. this._markAsDirty();
  5629. },
  5630. enumerable: true,
  5631. configurable: true
  5632. });
  5633. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5634. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5635. get: function () {
  5636. return this._majorLineFrequency;
  5637. },
  5638. set: function (value) {
  5639. this._majorLineFrequency = value;
  5640. this._markAsDirty();
  5641. },
  5642. enumerable: true,
  5643. configurable: true
  5644. });
  5645. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5646. context.save();
  5647. this._applyStates(context);
  5648. if (this._isEnabled) {
  5649. if (this._background) {
  5650. context.fillStyle = this._background;
  5651. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5652. }
  5653. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5654. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5655. // Minor lines
  5656. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5657. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5658. if (this._displayMinorLines) {
  5659. context.strokeStyle = this._minorLineColor;
  5660. context.lineWidth = this._minorLineTickness;
  5661. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5662. var cellX = left + x * this.cellWidth;
  5663. context.beginPath();
  5664. context.moveTo(cellX, this._currentMeasure.top);
  5665. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5666. context.stroke();
  5667. }
  5668. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5669. var cellY = top_1 + y * this.cellHeight;
  5670. context.beginPath();
  5671. context.moveTo(this._currentMeasure.left, cellY);
  5672. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5673. context.stroke();
  5674. }
  5675. }
  5676. // Major lines
  5677. if (this._displayMajorLines) {
  5678. context.strokeStyle = this._majorLineColor;
  5679. context.lineWidth = this._majorLineTickness;
  5680. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5681. var cellX = left + x * this.cellWidth;
  5682. context.beginPath();
  5683. context.moveTo(cellX, this._currentMeasure.top);
  5684. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5685. context.stroke();
  5686. }
  5687. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5688. var cellY = top_1 + y * this.cellHeight;
  5689. context.moveTo(this._currentMeasure.left, cellY);
  5690. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5691. context.closePath();
  5692. context.stroke();
  5693. }
  5694. }
  5695. }
  5696. context.restore();
  5697. };
  5698. DisplayGrid.prototype._getTypeName = function () {
  5699. return "DisplayGrid";
  5700. };
  5701. return DisplayGrid;
  5702. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5703. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5704. /***/ }),
  5705. /***/ "./2D/controls/ellipse.ts":
  5706. /*!********************************!*\
  5707. !*** ./2D/controls/ellipse.ts ***!
  5708. \********************************/
  5709. /*! exports provided: Ellipse */
  5710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5711. "use strict";
  5712. __webpack_require__.r(__webpack_exports__);
  5713. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5714. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5715. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5716. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5717. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5718. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5719. /** Class used to create 2D ellipse containers */
  5720. var Ellipse = /** @class */ (function (_super) {
  5721. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5722. /**
  5723. * Creates a new Ellipse
  5724. * @param name defines the control name
  5725. */
  5726. function Ellipse(name) {
  5727. var _this = _super.call(this, name) || this;
  5728. _this.name = name;
  5729. _this._thickness = 1;
  5730. return _this;
  5731. }
  5732. Object.defineProperty(Ellipse.prototype, "thickness", {
  5733. /** Gets or sets border thickness */
  5734. get: function () {
  5735. return this._thickness;
  5736. },
  5737. set: function (value) {
  5738. if (this._thickness === value) {
  5739. return;
  5740. }
  5741. this._thickness = value;
  5742. this._markAsDirty();
  5743. },
  5744. enumerable: true,
  5745. configurable: true
  5746. });
  5747. Ellipse.prototype._getTypeName = function () {
  5748. return "Ellipse";
  5749. };
  5750. Ellipse.prototype._localDraw = function (context) {
  5751. context.save();
  5752. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5753. context.shadowColor = this.shadowColor;
  5754. context.shadowBlur = this.shadowBlur;
  5755. context.shadowOffsetX = this.shadowOffsetX;
  5756. context.shadowOffsetY = this.shadowOffsetY;
  5757. }
  5758. _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);
  5759. if (this._background) {
  5760. context.fillStyle = this._background;
  5761. context.fill();
  5762. }
  5763. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5764. context.shadowBlur = 0;
  5765. context.shadowOffsetX = 0;
  5766. context.shadowOffsetY = 0;
  5767. }
  5768. if (this._thickness) {
  5769. if (this.color) {
  5770. context.strokeStyle = this.color;
  5771. }
  5772. context.lineWidth = this._thickness;
  5773. context.stroke();
  5774. }
  5775. context.restore();
  5776. };
  5777. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5778. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5779. this._measureForChildren.width -= 2 * this._thickness;
  5780. this._measureForChildren.height -= 2 * this._thickness;
  5781. this._measureForChildren.left += this._thickness;
  5782. this._measureForChildren.top += this._thickness;
  5783. };
  5784. Ellipse.prototype._clipForChildren = function (context) {
  5785. _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);
  5786. context.clip();
  5787. };
  5788. return Ellipse;
  5789. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5790. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5791. /***/ }),
  5792. /***/ "./2D/controls/grid.ts":
  5793. /*!*****************************!*\
  5794. !*** ./2D/controls/grid.ts ***!
  5795. \*****************************/
  5796. /*! exports provided: Grid */
  5797. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5798. "use strict";
  5799. __webpack_require__.r(__webpack_exports__);
  5800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5801. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5802. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5803. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5804. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5805. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  5806. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5807. /**
  5808. * Class used to create a 2D grid container
  5809. */
  5810. var Grid = /** @class */ (function (_super) {
  5811. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5812. /**
  5813. * Creates a new Grid
  5814. * @param name defines control name
  5815. */
  5816. function Grid(name) {
  5817. var _this = _super.call(this, name) || this;
  5818. _this.name = name;
  5819. _this._rowDefinitions = new Array();
  5820. _this._columnDefinitions = new Array();
  5821. _this._cells = {};
  5822. _this._childControls = new Array();
  5823. return _this;
  5824. }
  5825. Object.defineProperty(Grid.prototype, "columnCount", {
  5826. /**
  5827. * Gets the number of columns
  5828. */
  5829. get: function () {
  5830. return this._columnDefinitions.length;
  5831. },
  5832. enumerable: true,
  5833. configurable: true
  5834. });
  5835. Object.defineProperty(Grid.prototype, "rowCount", {
  5836. /**
  5837. * Gets the number of rows
  5838. */
  5839. get: function () {
  5840. return this._rowDefinitions.length;
  5841. },
  5842. enumerable: true,
  5843. configurable: true
  5844. });
  5845. Object.defineProperty(Grid.prototype, "children", {
  5846. /** Gets the list of children */
  5847. get: function () {
  5848. return this._childControls;
  5849. },
  5850. enumerable: true,
  5851. configurable: true
  5852. });
  5853. Object.defineProperty(Grid.prototype, "cells", {
  5854. /** Gets the list of cells (e.g. the containers) */
  5855. get: function () {
  5856. return this._cells;
  5857. },
  5858. enumerable: true,
  5859. configurable: true
  5860. });
  5861. /**
  5862. * Gets the definition of a specific row
  5863. * @param index defines the index of the row
  5864. * @returns the row definition
  5865. */
  5866. Grid.prototype.getRowDefinition = function (index) {
  5867. if (index < 0 || index >= this._rowDefinitions.length) {
  5868. return null;
  5869. }
  5870. return this._rowDefinitions[index];
  5871. };
  5872. /**
  5873. * Gets the definition of a specific column
  5874. * @param index defines the index of the column
  5875. * @returns the column definition
  5876. */
  5877. Grid.prototype.getColumnDefinition = function (index) {
  5878. if (index < 0 || index >= this._columnDefinitions.length) {
  5879. return null;
  5880. }
  5881. return this._columnDefinitions[index];
  5882. };
  5883. /**
  5884. * Adds a new row to the grid
  5885. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5886. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5887. * @returns the current grid
  5888. */
  5889. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5890. if (isPixel === void 0) { isPixel = false; }
  5891. 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));
  5892. this._markAsDirty();
  5893. return this;
  5894. };
  5895. /**
  5896. * Adds a new column to the grid
  5897. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5898. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5899. * @returns the current grid
  5900. */
  5901. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5902. if (isPixel === void 0) { isPixel = false; }
  5903. 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));
  5904. this._markAsDirty();
  5905. return this;
  5906. };
  5907. /**
  5908. * Update a row definition
  5909. * @param index defines the index of the row to update
  5910. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5911. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5912. * @returns the current grid
  5913. */
  5914. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5915. if (isPixel === void 0) { isPixel = false; }
  5916. if (index < 0 || index >= this._rowDefinitions.length) {
  5917. return this;
  5918. }
  5919. var current = this._rowDefinitions[index];
  5920. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5921. return this;
  5922. }
  5923. 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);
  5924. this._markAsDirty();
  5925. return this;
  5926. };
  5927. /**
  5928. * Update a column definition
  5929. * @param index defines the index of the column to update
  5930. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5931. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5932. * @returns the current grid
  5933. */
  5934. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5935. if (isPixel === void 0) { isPixel = false; }
  5936. if (index < 0 || index >= this._columnDefinitions.length) {
  5937. return this;
  5938. }
  5939. var current = this._columnDefinitions[index];
  5940. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5941. return this;
  5942. }
  5943. 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);
  5944. this._markAsDirty();
  5945. return this;
  5946. };
  5947. /**
  5948. * Gets the list of children stored in a specific cell
  5949. * @param row defines the row to check
  5950. * @param column defines the column to check
  5951. * @returns the list of controls
  5952. */
  5953. Grid.prototype.getChildrenAt = function (row, column) {
  5954. var cell = this._cells[row + ":" + column];
  5955. if (!cell) {
  5956. return null;
  5957. }
  5958. return cell.children;
  5959. };
  5960. /**
  5961. * Gets a string representing the child cell info (row x column)
  5962. * @param child defines the control to get info from
  5963. * @returns a string containing the child cell info (row x column)
  5964. */
  5965. Grid.prototype.getChildCellInfo = function (child) {
  5966. return child._tag;
  5967. };
  5968. Grid.prototype._removeCell = function (cell, key) {
  5969. if (!cell) {
  5970. return;
  5971. }
  5972. _super.prototype.removeControl.call(this, cell);
  5973. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5974. var control = _a[_i];
  5975. var childIndex = this._childControls.indexOf(control);
  5976. if (childIndex !== -1) {
  5977. this._childControls.splice(childIndex, 1);
  5978. }
  5979. }
  5980. delete this._cells[key];
  5981. };
  5982. Grid.prototype._offsetCell = function (previousKey, key) {
  5983. if (!this._cells[key]) {
  5984. return;
  5985. }
  5986. this._cells[previousKey] = this._cells[key];
  5987. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5988. var control = _a[_i];
  5989. control._tag = previousKey;
  5990. }
  5991. delete this._cells[key];
  5992. };
  5993. /**
  5994. * Remove a column definition at specified index
  5995. * @param index defines the index of the column to remove
  5996. * @returns the current grid
  5997. */
  5998. Grid.prototype.removeColumnDefinition = function (index) {
  5999. if (index < 0 || index >= this._columnDefinitions.length) {
  6000. return this;
  6001. }
  6002. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6003. var key = x + ":" + index;
  6004. var cell = this._cells[key];
  6005. this._removeCell(cell, key);
  6006. }
  6007. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6008. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  6009. var previousKey = x + ":" + (y - 1);
  6010. var key = x + ":" + y;
  6011. this._offsetCell(previousKey, key);
  6012. }
  6013. }
  6014. this._columnDefinitions.splice(index, 1);
  6015. this._markAsDirty();
  6016. return this;
  6017. };
  6018. /**
  6019. * Remove a row definition at specified index
  6020. * @param index defines the index of the row to remove
  6021. * @returns the current grid
  6022. */
  6023. Grid.prototype.removeRowDefinition = function (index) {
  6024. if (index < 0 || index >= this._rowDefinitions.length) {
  6025. return this;
  6026. }
  6027. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6028. var key = index + ":" + y;
  6029. var cell = this._cells[key];
  6030. this._removeCell(cell, key);
  6031. }
  6032. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6033. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  6034. var previousKey = x - 1 + ":" + y;
  6035. var key = x + ":" + y;
  6036. this._offsetCell(previousKey, key);
  6037. }
  6038. }
  6039. this._rowDefinitions.splice(index, 1);
  6040. this._markAsDirty();
  6041. return this;
  6042. };
  6043. /**
  6044. * Adds a new control to the current grid
  6045. * @param control defines the control to add
  6046. * @param row defines the row where to add the control (0 by default)
  6047. * @param column defines the column where to add the control (0 by default)
  6048. * @returns the current grid
  6049. */
  6050. Grid.prototype.addControl = function (control, row, column) {
  6051. if (row === void 0) { row = 0; }
  6052. if (column === void 0) { column = 0; }
  6053. if (this._rowDefinitions.length === 0) {
  6054. // Add default row definition
  6055. this.addRowDefinition(1, false);
  6056. }
  6057. if (this._columnDefinitions.length === 0) {
  6058. // Add default column definition
  6059. this.addColumnDefinition(1, false);
  6060. }
  6061. if (this._childControls.indexOf(control) !== -1) {
  6062. 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");
  6063. return this;
  6064. }
  6065. var x = Math.min(row, this._rowDefinitions.length - 1);
  6066. var y = Math.min(column, this._columnDefinitions.length - 1);
  6067. var key = x + ":" + y;
  6068. var goodContainer = this._cells[key];
  6069. if (!goodContainer) {
  6070. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6071. this._cells[key] = goodContainer;
  6072. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6073. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6074. _super.prototype.addControl.call(this, goodContainer);
  6075. }
  6076. goodContainer.addControl(control);
  6077. this._childControls.push(control);
  6078. control._tag = key;
  6079. control.parent = this;
  6080. this._markAsDirty();
  6081. return this;
  6082. };
  6083. /**
  6084. * Removes a control from the current container
  6085. * @param control defines the control to remove
  6086. * @returns the current container
  6087. */
  6088. Grid.prototype.removeControl = function (control) {
  6089. var index = this._childControls.indexOf(control);
  6090. if (index !== -1) {
  6091. this._childControls.splice(index, 1);
  6092. }
  6093. var cell = this._cells[control._tag];
  6094. if (cell) {
  6095. cell.removeControl(control);
  6096. control._tag = null;
  6097. }
  6098. this._markAsDirty();
  6099. return this;
  6100. };
  6101. Grid.prototype._getTypeName = function () {
  6102. return "Grid";
  6103. };
  6104. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6105. var widths = [];
  6106. var heights = [];
  6107. var lefts = [];
  6108. var tops = [];
  6109. var availableWidth = this._currentMeasure.width;
  6110. var globalWidthPercentage = 0;
  6111. var availableHeight = this._currentMeasure.height;
  6112. var globalHeightPercentage = 0;
  6113. // Heights
  6114. var index = 0;
  6115. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6116. var value = _a[_i];
  6117. if (value.isPixel) {
  6118. var height = value.getValue(this._host);
  6119. availableHeight -= height;
  6120. heights[index] = height;
  6121. }
  6122. else {
  6123. globalHeightPercentage += value.internalValue;
  6124. }
  6125. index++;
  6126. }
  6127. var top = 0;
  6128. index = 0;
  6129. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6130. var value = _c[_b];
  6131. tops.push(top);
  6132. if (!value.isPixel) {
  6133. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6134. top += height;
  6135. heights[index] = height;
  6136. }
  6137. else {
  6138. top += value.getValue(this._host);
  6139. }
  6140. index++;
  6141. }
  6142. // Widths
  6143. index = 0;
  6144. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6145. var value = _e[_d];
  6146. if (value.isPixel) {
  6147. var width = value.getValue(this._host);
  6148. availableWidth -= width;
  6149. widths[index] = width;
  6150. }
  6151. else {
  6152. globalWidthPercentage += value.internalValue;
  6153. }
  6154. index++;
  6155. }
  6156. var left = 0;
  6157. index = 0;
  6158. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6159. var value = _g[_f];
  6160. lefts.push(left);
  6161. if (!value.isPixel) {
  6162. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6163. left += width;
  6164. widths[index] = width;
  6165. }
  6166. else {
  6167. left += value.getValue(this._host);
  6168. }
  6169. index++;
  6170. }
  6171. definitionCallback(lefts, tops, widths, heights);
  6172. };
  6173. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6174. var _this = this;
  6175. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6176. // Setting child sizes
  6177. for (var key in _this._cells) {
  6178. if (!_this._cells.hasOwnProperty(key)) {
  6179. continue;
  6180. }
  6181. var split = key.split(":");
  6182. var x = parseInt(split[0]);
  6183. var y = parseInt(split[1]);
  6184. var cell = _this._cells[key];
  6185. cell.left = lefts[y] + "px";
  6186. cell.top = tops[x] + "px";
  6187. cell.width = widths[y] + "px";
  6188. cell.height = heights[x] + "px";
  6189. cell._left.ignoreAdaptiveScaling = true;
  6190. cell._top.ignoreAdaptiveScaling = true;
  6191. cell._width.ignoreAdaptiveScaling = true;
  6192. cell._height.ignoreAdaptiveScaling = true;
  6193. }
  6194. });
  6195. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6196. };
  6197. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6198. for (var key in this._cells) {
  6199. if (!this._cells.hasOwnProperty(key)) {
  6200. continue;
  6201. }
  6202. var child = this._cells[key];
  6203. child._markMatrixAsDirty();
  6204. }
  6205. };
  6206. Grid.prototype._renderHighlightSpecific = function (context) {
  6207. var _this = this;
  6208. _super.prototype._renderHighlightSpecific.call(this, context);
  6209. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6210. // Columns
  6211. for (var index = 0; index < lefts.length; index++) {
  6212. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6213. context.beginPath();
  6214. context.moveTo(left, _this._currentMeasure.top);
  6215. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6216. context.stroke();
  6217. }
  6218. // Rows
  6219. for (var index = 0; index < tops.length; index++) {
  6220. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6221. context.beginPath();
  6222. context.moveTo(_this._currentMeasure.left, top_1);
  6223. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6224. context.stroke();
  6225. }
  6226. });
  6227. context.restore();
  6228. };
  6229. /** Releases associated resources */
  6230. Grid.prototype.dispose = function () {
  6231. _super.prototype.dispose.call(this);
  6232. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6233. var control = _a[_i];
  6234. control.dispose();
  6235. }
  6236. this._childControls = [];
  6237. };
  6238. return Grid;
  6239. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6240. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6241. /***/ }),
  6242. /***/ "./2D/controls/image.ts":
  6243. /*!******************************!*\
  6244. !*** ./2D/controls/image.ts ***!
  6245. \******************************/
  6246. /*! exports provided: Image */
  6247. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6248. "use strict";
  6249. __webpack_require__.r(__webpack_exports__);
  6250. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6251. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6252. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6253. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6254. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6255. /**
  6256. * Class used to create 2D images
  6257. */
  6258. var Image = /** @class */ (function (_super) {
  6259. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6260. /**
  6261. * Creates a new Image
  6262. * @param name defines the control name
  6263. * @param url defines the image url
  6264. */
  6265. function Image(name, url) {
  6266. if (url === void 0) { url = null; }
  6267. var _this = _super.call(this, name) || this;
  6268. _this.name = name;
  6269. _this._workingCanvas = null;
  6270. _this._loaded = false;
  6271. _this._stretch = Image.STRETCH_FILL;
  6272. _this._autoScale = false;
  6273. _this._sourceLeft = 0;
  6274. _this._sourceTop = 0;
  6275. _this._sourceWidth = 0;
  6276. _this._sourceHeight = 0;
  6277. _this._svgAttributesComputationCompleted = false;
  6278. _this._isSVG = false;
  6279. _this._cellWidth = 0;
  6280. _this._cellHeight = 0;
  6281. _this._cellId = -1;
  6282. _this._populateNinePatchSlicesFromImage = false;
  6283. /**
  6284. * Observable notified when the content is loaded
  6285. */
  6286. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6287. /**
  6288. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6289. */
  6290. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6291. _this.source = url;
  6292. return _this;
  6293. }
  6294. Object.defineProperty(Image.prototype, "isLoaded", {
  6295. /**
  6296. * Gets a boolean indicating that the content is loaded
  6297. */
  6298. get: function () {
  6299. return this._loaded;
  6300. },
  6301. enumerable: true,
  6302. configurable: true
  6303. });
  6304. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6305. /**
  6306. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6307. */
  6308. get: function () {
  6309. return this._populateNinePatchSlicesFromImage;
  6310. },
  6311. set: function (value) {
  6312. if (this._populateNinePatchSlicesFromImage === value) {
  6313. return;
  6314. }
  6315. this._populateNinePatchSlicesFromImage = value;
  6316. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6317. this._extractNinePatchSliceDataFromImage();
  6318. }
  6319. },
  6320. enumerable: true,
  6321. configurable: true
  6322. });
  6323. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6324. /**
  6325. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6326. * Beware using this as this will comsume more memory as the image has to be stored twice
  6327. */
  6328. get: function () {
  6329. return this._detectPointerOnOpaqueOnly;
  6330. },
  6331. set: function (value) {
  6332. if (this._detectPointerOnOpaqueOnly === value) {
  6333. return;
  6334. }
  6335. this._detectPointerOnOpaqueOnly = value;
  6336. },
  6337. enumerable: true,
  6338. configurable: true
  6339. });
  6340. Object.defineProperty(Image.prototype, "sliceLeft", {
  6341. /**
  6342. * Gets or sets the left value for slicing (9-patch)
  6343. */
  6344. get: function () {
  6345. return this._sliceLeft;
  6346. },
  6347. set: function (value) {
  6348. if (this._sliceLeft === value) {
  6349. return;
  6350. }
  6351. this._sliceLeft = value;
  6352. this._markAsDirty();
  6353. },
  6354. enumerable: true,
  6355. configurable: true
  6356. });
  6357. Object.defineProperty(Image.prototype, "sliceRight", {
  6358. /**
  6359. * Gets or sets the right value for slicing (9-patch)
  6360. */
  6361. get: function () {
  6362. return this._sliceRight;
  6363. },
  6364. set: function (value) {
  6365. if (this._sliceRight === value) {
  6366. return;
  6367. }
  6368. this._sliceRight = value;
  6369. this._markAsDirty();
  6370. },
  6371. enumerable: true,
  6372. configurable: true
  6373. });
  6374. Object.defineProperty(Image.prototype, "sliceTop", {
  6375. /**
  6376. * Gets or sets the top value for slicing (9-patch)
  6377. */
  6378. get: function () {
  6379. return this._sliceTop;
  6380. },
  6381. set: function (value) {
  6382. if (this._sliceTop === value) {
  6383. return;
  6384. }
  6385. this._sliceTop = value;
  6386. this._markAsDirty();
  6387. },
  6388. enumerable: true,
  6389. configurable: true
  6390. });
  6391. Object.defineProperty(Image.prototype, "sliceBottom", {
  6392. /**
  6393. * Gets or sets the bottom value for slicing (9-patch)
  6394. */
  6395. get: function () {
  6396. return this._sliceBottom;
  6397. },
  6398. set: function (value) {
  6399. if (this._sliceBottom === value) {
  6400. return;
  6401. }
  6402. this._sliceBottom = value;
  6403. this._markAsDirty();
  6404. },
  6405. enumerable: true,
  6406. configurable: true
  6407. });
  6408. Object.defineProperty(Image.prototype, "sourceLeft", {
  6409. /**
  6410. * Gets or sets the left coordinate in the source image
  6411. */
  6412. get: function () {
  6413. return this._sourceLeft;
  6414. },
  6415. set: function (value) {
  6416. if (this._sourceLeft === value) {
  6417. return;
  6418. }
  6419. this._sourceLeft = value;
  6420. this._markAsDirty();
  6421. },
  6422. enumerable: true,
  6423. configurable: true
  6424. });
  6425. Object.defineProperty(Image.prototype, "sourceTop", {
  6426. /**
  6427. * Gets or sets the top coordinate in the source image
  6428. */
  6429. get: function () {
  6430. return this._sourceTop;
  6431. },
  6432. set: function (value) {
  6433. if (this._sourceTop === value) {
  6434. return;
  6435. }
  6436. this._sourceTop = value;
  6437. this._markAsDirty();
  6438. },
  6439. enumerable: true,
  6440. configurable: true
  6441. });
  6442. Object.defineProperty(Image.prototype, "sourceWidth", {
  6443. /**
  6444. * Gets or sets the width to capture in the source image
  6445. */
  6446. get: function () {
  6447. return this._sourceWidth;
  6448. },
  6449. set: function (value) {
  6450. if (this._sourceWidth === value) {
  6451. return;
  6452. }
  6453. this._sourceWidth = value;
  6454. this._markAsDirty();
  6455. },
  6456. enumerable: true,
  6457. configurable: true
  6458. });
  6459. Object.defineProperty(Image.prototype, "sourceHeight", {
  6460. /**
  6461. * Gets or sets the height to capture in the source image
  6462. */
  6463. get: function () {
  6464. return this._sourceHeight;
  6465. },
  6466. set: function (value) {
  6467. if (this._sourceHeight === value) {
  6468. return;
  6469. }
  6470. this._sourceHeight = value;
  6471. this._markAsDirty();
  6472. },
  6473. enumerable: true,
  6474. configurable: true
  6475. });
  6476. Object.defineProperty(Image.prototype, "isSVG", {
  6477. /** Indicates if the format of the image is SVG */
  6478. get: function () {
  6479. return this._isSVG;
  6480. },
  6481. enumerable: true,
  6482. configurable: true
  6483. });
  6484. Object.defineProperty(Image.prototype, "svgAttributesComputationCompleted", {
  6485. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  6486. get: function () {
  6487. return this._svgAttributesComputationCompleted;
  6488. },
  6489. enumerable: true,
  6490. configurable: true
  6491. });
  6492. Object.defineProperty(Image.prototype, "autoScale", {
  6493. /**
  6494. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6495. * @see http://doc.babylonjs.com/how_to/gui#image
  6496. */
  6497. get: function () {
  6498. return this._autoScale;
  6499. },
  6500. set: function (value) {
  6501. if (this._autoScale === value) {
  6502. return;
  6503. }
  6504. this._autoScale = value;
  6505. if (value && this._loaded) {
  6506. this.synchronizeSizeWithContent();
  6507. }
  6508. },
  6509. enumerable: true,
  6510. configurable: true
  6511. });
  6512. Object.defineProperty(Image.prototype, "stretch", {
  6513. /** Gets or sets the streching mode used by the image */
  6514. get: function () {
  6515. return this._stretch;
  6516. },
  6517. set: function (value) {
  6518. if (this._stretch === value) {
  6519. return;
  6520. }
  6521. this._stretch = value;
  6522. this._markAsDirty();
  6523. },
  6524. enumerable: true,
  6525. configurable: true
  6526. });
  6527. /** @hidden */
  6528. Image.prototype._rotate90 = function (n, preserveProperties) {
  6529. if (preserveProperties === void 0) { preserveProperties = false; }
  6530. var canvas = document.createElement('canvas');
  6531. var context = canvas.getContext('2d');
  6532. var width = this._domImage.width;
  6533. var height = this._domImage.height;
  6534. canvas.width = height;
  6535. canvas.height = width;
  6536. context.translate(canvas.width / 2, canvas.height / 2);
  6537. context.rotate(n * Math.PI / 2);
  6538. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  6539. var dataUrl = canvas.toDataURL("image/jpg");
  6540. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  6541. if (preserveProperties) {
  6542. rotatedImage._stretch = this._stretch;
  6543. rotatedImage._autoScale = this._autoScale;
  6544. rotatedImage._cellId = this._cellId;
  6545. rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;
  6546. rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;
  6547. }
  6548. this._handleRotationForSVGImage(this, rotatedImage, n);
  6549. return rotatedImage;
  6550. };
  6551. Image.prototype._handleRotationForSVGImage = function (srcImage, dstImage, n) {
  6552. var _this = this;
  6553. if (!srcImage._isSVG) {
  6554. return;
  6555. }
  6556. if (srcImage._svgAttributesComputationCompleted) {
  6557. this._rotate90SourceProperties(srcImage, dstImage, n);
  6558. this._markAsDirty();
  6559. }
  6560. else {
  6561. srcImage.onSVGAttributesComputedObservable.addOnce(function () {
  6562. _this._rotate90SourceProperties(srcImage, dstImage, n);
  6563. _this._markAsDirty();
  6564. });
  6565. }
  6566. };
  6567. Image.prototype._rotate90SourceProperties = function (srcImage, dstImage, n) {
  6568. var _a, _b;
  6569. var srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
  6570. var dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
  6571. if (n != 0) {
  6572. var mult = n < 0 ? -1 : 1;
  6573. n = n % 4;
  6574. for (var i = 0; i < Math.abs(n); ++i) {
  6575. dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;
  6576. dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;
  6577. _a = [dstHeight, dstWidth], dstWidth = _a[0], dstHeight = _a[1];
  6578. if (n < 0) {
  6579. dstTop -= dstHeight;
  6580. }
  6581. else {
  6582. dstLeft -= dstWidth;
  6583. }
  6584. srcLeft = dstLeft;
  6585. srcTop = dstTop;
  6586. _b = [srcHeight, srcWidth], srcWidth = _b[0], srcHeight = _b[1];
  6587. }
  6588. }
  6589. dstImage.sourceLeft = dstLeft;
  6590. dstImage.sourceTop = dstTop;
  6591. dstImage.sourceWidth = dstWidth;
  6592. dstImage.sourceHeight = dstHeight;
  6593. };
  6594. Object.defineProperty(Image.prototype, "domImage", {
  6595. get: function () {
  6596. return this._domImage;
  6597. },
  6598. /**
  6599. * Gets or sets the internal DOM image used to render the control
  6600. */
  6601. set: function (value) {
  6602. var _this = this;
  6603. this._domImage = value;
  6604. this._loaded = false;
  6605. if (this._domImage.width) {
  6606. this._onImageLoaded();
  6607. }
  6608. else {
  6609. this._domImage.onload = function () {
  6610. _this._onImageLoaded();
  6611. };
  6612. }
  6613. },
  6614. enumerable: true,
  6615. configurable: true
  6616. });
  6617. Image.prototype._onImageLoaded = function () {
  6618. this._imageWidth = this._domImage.width;
  6619. this._imageHeight = this._domImage.height;
  6620. this._loaded = true;
  6621. if (this._populateNinePatchSlicesFromImage) {
  6622. this._extractNinePatchSliceDataFromImage();
  6623. }
  6624. if (this._autoScale) {
  6625. this.synchronizeSizeWithContent();
  6626. }
  6627. this.onImageLoadedObservable.notifyObservers(this);
  6628. this._markAsDirty();
  6629. };
  6630. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6631. if (!this._workingCanvas) {
  6632. this._workingCanvas = document.createElement('canvas');
  6633. }
  6634. var canvas = this._workingCanvas;
  6635. var context = canvas.getContext('2d');
  6636. var width = this._domImage.width;
  6637. var height = this._domImage.height;
  6638. canvas.width = width;
  6639. canvas.height = height;
  6640. context.drawImage(this._domImage, 0, 0, width, height);
  6641. var imageData = context.getImageData(0, 0, width, height);
  6642. // Left and right
  6643. this._sliceLeft = -1;
  6644. this._sliceRight = -1;
  6645. for (var x = 0; x < width; x++) {
  6646. var alpha = imageData.data[x * 4 + 3];
  6647. if (alpha > 127 && this._sliceLeft === -1) {
  6648. this._sliceLeft = x;
  6649. continue;
  6650. }
  6651. if (alpha < 127 && this._sliceLeft > -1) {
  6652. this._sliceRight = x;
  6653. break;
  6654. }
  6655. }
  6656. // top and bottom
  6657. this._sliceTop = -1;
  6658. this._sliceBottom = -1;
  6659. for (var y = 0; y < height; y++) {
  6660. var alpha = imageData.data[y * width * 4 + 3];
  6661. if (alpha > 127 && this._sliceTop === -1) {
  6662. this._sliceTop = y;
  6663. continue;
  6664. }
  6665. if (alpha < 127 && this._sliceTop > -1) {
  6666. this._sliceBottom = y;
  6667. break;
  6668. }
  6669. }
  6670. };
  6671. Object.defineProperty(Image.prototype, "source", {
  6672. /**
  6673. * Gets or sets image source url
  6674. */
  6675. set: function (value) {
  6676. var _this = this;
  6677. if (this._source === value) {
  6678. return;
  6679. }
  6680. this._loaded = false;
  6681. this._source = value;
  6682. if (value) {
  6683. value = this._svgCheck(value);
  6684. }
  6685. this._domImage = document.createElement("img");
  6686. this._domImage.onload = function () {
  6687. _this._onImageLoaded();
  6688. };
  6689. if (value) {
  6690. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6691. this._domImage.src = value;
  6692. }
  6693. },
  6694. enumerable: true,
  6695. configurable: true
  6696. });
  6697. /**
  6698. * Checks for svg document with icon id present
  6699. */
  6700. Image.prototype._svgCheck = function (value) {
  6701. var _this = this;
  6702. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6703. this._isSVG = true;
  6704. var svgsrc = value.split('#')[0];
  6705. var elemid = value.split('#')[1];
  6706. // check if object alr exist in document
  6707. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6708. if (svgExist) {
  6709. var svgDoc = svgExist.contentDocument;
  6710. // get viewbox width and height, get svg document width and height in px
  6711. if (svgDoc && svgDoc.documentElement) {
  6712. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6713. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6714. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6715. var elem = svgDoc.getElementById(elemid);
  6716. if (elem && vb && docwidth && docheight) {
  6717. this._getSVGAttribs(svgExist, elemid);
  6718. return value;
  6719. }
  6720. }
  6721. // wait for object to load
  6722. svgExist.addEventListener("load", function () {
  6723. _this._getSVGAttribs(svgExist, elemid);
  6724. });
  6725. }
  6726. else {
  6727. // create document object
  6728. var svgImage = document.createElement("object");
  6729. svgImage.data = svgsrc;
  6730. svgImage.type = "image/svg+xml";
  6731. svgImage.width = "0%";
  6732. svgImage.height = "0%";
  6733. document.body.appendChild(svgImage);
  6734. // when the object has loaded, get the element attribs
  6735. svgImage.onload = function () {
  6736. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6737. if (svgobj) {
  6738. _this._getSVGAttribs(svgobj, elemid);
  6739. }
  6740. };
  6741. }
  6742. return svgsrc;
  6743. }
  6744. else {
  6745. return value;
  6746. }
  6747. };
  6748. /**
  6749. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6750. * given external svg file and icon id
  6751. */
  6752. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6753. var svgDoc = svgsrc.contentDocument;
  6754. // get viewbox width and height, get svg document width and height in px
  6755. if (svgDoc && svgDoc.documentElement) {
  6756. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6757. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6758. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6759. // get element bbox and matrix transform
  6760. var elem = svgDoc.getElementById(elemid);
  6761. if (vb && docwidth && docheight && elem) {
  6762. var vb_width = Number(vb.split(" ")[2]);
  6763. var vb_height = Number(vb.split(" ")[3]);
  6764. var elem_bbox = elem.getBBox();
  6765. var elem_matrix_a = 1;
  6766. var elem_matrix_d = 1;
  6767. var elem_matrix_e = 0;
  6768. var elem_matrix_f = 0;
  6769. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6770. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6771. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6772. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6773. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6774. }
  6775. // compute source coordinates and dimensions
  6776. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6777. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6778. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6779. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6780. this._svgAttributesComputationCompleted = true;
  6781. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6782. }
  6783. }
  6784. };
  6785. Object.defineProperty(Image.prototype, "cellWidth", {
  6786. /**
  6787. * Gets or sets the cell width to use when animation sheet is enabled
  6788. * @see http://doc.babylonjs.com/how_to/gui#image
  6789. */
  6790. get: function () {
  6791. return this._cellWidth;
  6792. },
  6793. set: function (value) {
  6794. if (this._cellWidth === value) {
  6795. return;
  6796. }
  6797. this._cellWidth = value;
  6798. this._markAsDirty();
  6799. },
  6800. enumerable: true,
  6801. configurable: true
  6802. });
  6803. Object.defineProperty(Image.prototype, "cellHeight", {
  6804. /**
  6805. * Gets or sets the cell height to use when animation sheet is enabled
  6806. * @see http://doc.babylonjs.com/how_to/gui#image
  6807. */
  6808. get: function () {
  6809. return this._cellHeight;
  6810. },
  6811. set: function (value) {
  6812. if (this._cellHeight === value) {
  6813. return;
  6814. }
  6815. this._cellHeight = value;
  6816. this._markAsDirty();
  6817. },
  6818. enumerable: true,
  6819. configurable: true
  6820. });
  6821. Object.defineProperty(Image.prototype, "cellId", {
  6822. /**
  6823. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6824. * @see http://doc.babylonjs.com/how_to/gui#image
  6825. */
  6826. get: function () {
  6827. return this._cellId;
  6828. },
  6829. set: function (value) {
  6830. if (this._cellId === value) {
  6831. return;
  6832. }
  6833. this._cellId = value;
  6834. this._markAsDirty();
  6835. },
  6836. enumerable: true,
  6837. configurable: true
  6838. });
  6839. /**
  6840. * Tests if a given coordinates belong to the current control
  6841. * @param x defines x coordinate to test
  6842. * @param y defines y coordinate to test
  6843. * @returns true if the coordinates are inside the control
  6844. */
  6845. Image.prototype.contains = function (x, y) {
  6846. if (!_super.prototype.contains.call(this, x, y)) {
  6847. return false;
  6848. }
  6849. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6850. return true;
  6851. }
  6852. var canvas = this._workingCanvas;
  6853. var context = canvas.getContext("2d");
  6854. var width = this._currentMeasure.width | 0;
  6855. var height = this._currentMeasure.height | 0;
  6856. var imageData = context.getImageData(0, 0, width, height).data;
  6857. x = (x - this._currentMeasure.left) | 0;
  6858. y = (y - this._currentMeasure.top) | 0;
  6859. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6860. return pickedPixel > 0;
  6861. };
  6862. Image.prototype._getTypeName = function () {
  6863. return "Image";
  6864. };
  6865. /** Force the control to synchronize with its content */
  6866. Image.prototype.synchronizeSizeWithContent = function () {
  6867. if (!this._loaded) {
  6868. return;
  6869. }
  6870. this.width = this._domImage.width + "px";
  6871. this.height = this._domImage.height + "px";
  6872. };
  6873. Image.prototype._processMeasures = function (parentMeasure, context) {
  6874. if (this._loaded) {
  6875. switch (this._stretch) {
  6876. case Image.STRETCH_NONE:
  6877. break;
  6878. case Image.STRETCH_FILL:
  6879. break;
  6880. case Image.STRETCH_UNIFORM:
  6881. break;
  6882. case Image.STRETCH_NINE_PATCH:
  6883. break;
  6884. case Image.STRETCH_EXTEND:
  6885. if (this._autoScale) {
  6886. this.synchronizeSizeWithContent();
  6887. }
  6888. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6889. this.parent.adaptWidthToChildren = true;
  6890. this.parent.adaptHeightToChildren = true;
  6891. }
  6892. break;
  6893. }
  6894. }
  6895. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6896. };
  6897. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6898. if (!this._detectPointerOnOpaqueOnly) {
  6899. return;
  6900. }
  6901. if (!this._workingCanvas) {
  6902. this._workingCanvas = document.createElement('canvas');
  6903. }
  6904. var canvas = this._workingCanvas;
  6905. var width = this._currentMeasure.width;
  6906. var height = this._currentMeasure.height;
  6907. var context = canvas.getContext("2d");
  6908. canvas.width = width;
  6909. canvas.height = height;
  6910. context.clearRect(0, 0, width, height);
  6911. };
  6912. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6913. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6914. if (!this._detectPointerOnOpaqueOnly) {
  6915. return;
  6916. }
  6917. var canvas = this._workingCanvas;
  6918. context = canvas.getContext("2d");
  6919. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6920. };
  6921. Image.prototype._draw = function (context) {
  6922. context.save();
  6923. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6924. context.shadowColor = this.shadowColor;
  6925. context.shadowBlur = this.shadowBlur;
  6926. context.shadowOffsetX = this.shadowOffsetX;
  6927. context.shadowOffsetY = this.shadowOffsetY;
  6928. }
  6929. var x, y, width, height;
  6930. if (this.cellId == -1) {
  6931. x = this._sourceLeft;
  6932. y = this._sourceTop;
  6933. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6934. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6935. }
  6936. else {
  6937. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6938. var column = (this.cellId / rowCount) >> 0;
  6939. var row = this.cellId % rowCount;
  6940. x = this.cellWidth * row;
  6941. y = this.cellHeight * column;
  6942. width = this.cellWidth;
  6943. height = this.cellHeight;
  6944. }
  6945. this._prepareWorkingCanvasForOpaqueDetection();
  6946. this._applyStates(context);
  6947. if (this._loaded) {
  6948. switch (this._stretch) {
  6949. case Image.STRETCH_NONE:
  6950. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6951. break;
  6952. case Image.STRETCH_FILL:
  6953. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6954. break;
  6955. case Image.STRETCH_UNIFORM:
  6956. var hRatio = this._currentMeasure.width / width;
  6957. var vRatio = this._currentMeasure.height / height;
  6958. var ratio = Math.min(hRatio, vRatio);
  6959. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6960. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6961. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6962. break;
  6963. case Image.STRETCH_EXTEND:
  6964. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6965. break;
  6966. case Image.STRETCH_NINE_PATCH:
  6967. this._renderNinePatch(context);
  6968. break;
  6969. }
  6970. }
  6971. context.restore();
  6972. };
  6973. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6974. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6975. };
  6976. Image.prototype._renderNinePatch = function (context) {
  6977. var height = this._imageHeight;
  6978. var leftWidth = this._sliceLeft;
  6979. var topHeight = this._sliceTop;
  6980. var bottomHeight = this._imageHeight - this._sliceBottom;
  6981. var rightWidth = this._imageWidth - this._sliceRight;
  6982. var left = 0;
  6983. var top = 0;
  6984. if (this._populateNinePatchSlicesFromImage) {
  6985. left = 1;
  6986. top = 1;
  6987. height -= 2;
  6988. leftWidth -= 1;
  6989. topHeight -= 1;
  6990. bottomHeight -= 1;
  6991. rightWidth -= 1;
  6992. }
  6993. var centerWidth = this._sliceRight - this._sliceLeft;
  6994. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft;
  6995. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6996. // Corners
  6997. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6998. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6999. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  7000. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  7001. // Center
  7002. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight);
  7003. // Borders
  7004. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  7005. 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);
  7006. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  7007. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  7008. };
  7009. Image.prototype.dispose = function () {
  7010. _super.prototype.dispose.call(this);
  7011. this.onImageLoadedObservable.clear();
  7012. this.onSVGAttributesComputedObservable.clear();
  7013. };
  7014. // Static
  7015. /** STRETCH_NONE */
  7016. Image.STRETCH_NONE = 0;
  7017. /** STRETCH_FILL */
  7018. Image.STRETCH_FILL = 1;
  7019. /** STRETCH_UNIFORM */
  7020. Image.STRETCH_UNIFORM = 2;
  7021. /** STRETCH_EXTEND */
  7022. Image.STRETCH_EXTEND = 3;
  7023. /** NINE_PATCH */
  7024. Image.STRETCH_NINE_PATCH = 4;
  7025. return Image;
  7026. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7027. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  7028. /***/ }),
  7029. /***/ "./2D/controls/index.ts":
  7030. /*!******************************!*\
  7031. !*** ./2D/controls/index.ts ***!
  7032. \******************************/
  7033. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  7034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7035. "use strict";
  7036. __webpack_require__.r(__webpack_exports__);
  7037. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  7038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  7039. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  7040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  7041. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  7042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  7043. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  7044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  7045. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  7047. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  7048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  7049. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  7050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  7051. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  7052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  7053. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  7055. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  7056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  7057. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  7058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  7059. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  7060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  7061. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  7062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  7063. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  7064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  7065. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  7066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  7067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  7068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  7069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  7070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  7071. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  7072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  7073. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  7074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  7075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  7076. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  7077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  7078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  7079. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  7080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  7081. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  7082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  7083. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  7084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  7085. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  7086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  7087. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  7088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  7089. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  7090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  7091. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  7092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__["ImageScrollBar"]; });
  7093. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  7094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_25__["name"]; });
  7095. /***/ }),
  7096. /***/ "./2D/controls/inputPassword.ts":
  7097. /*!**************************************!*\
  7098. !*** ./2D/controls/inputPassword.ts ***!
  7099. \**************************************/
  7100. /*! exports provided: InputPassword */
  7101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7102. "use strict";
  7103. __webpack_require__.r(__webpack_exports__);
  7104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  7105. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7106. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7107. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  7108. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  7109. /**
  7110. * Class used to create a password control
  7111. */
  7112. var InputPassword = /** @class */ (function (_super) {
  7113. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  7114. function InputPassword() {
  7115. return _super !== null && _super.apply(this, arguments) || this;
  7116. }
  7117. InputPassword.prototype._beforeRenderText = function (text) {
  7118. var txt = "";
  7119. for (var i = 0; i < text.length; i++) {
  7120. txt += "\u2022";
  7121. }
  7122. return txt;
  7123. };
  7124. return InputPassword;
  7125. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  7126. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  7127. /***/ }),
  7128. /***/ "./2D/controls/inputText.ts":
  7129. /*!**********************************!*\
  7130. !*** ./2D/controls/inputText.ts ***!
  7131. \**********************************/
  7132. /*! exports provided: InputText */
  7133. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7134. "use strict";
  7135. __webpack_require__.r(__webpack_exports__);
  7136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  7137. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7138. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  7139. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  7140. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7141. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7142. /**
  7143. * Class used to create input text control
  7144. */
  7145. var InputText = /** @class */ (function (_super) {
  7146. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7147. /**
  7148. * Creates a new InputText
  7149. * @param name defines the control name
  7150. * @param text defines the text of the control
  7151. */
  7152. function InputText(name, text) {
  7153. if (text === void 0) { text = ""; }
  7154. var _this = _super.call(this, name) || this;
  7155. _this.name = name;
  7156. _this._text = "";
  7157. _this._placeholderText = "";
  7158. _this._background = "#222222";
  7159. _this._focusedBackground = "#000000";
  7160. _this._focusedColor = "white";
  7161. _this._placeholderColor = "gray";
  7162. _this._thickness = 1;
  7163. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7164. _this._autoStretchWidth = true;
  7165. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7166. _this._isFocused = false;
  7167. _this._blinkIsEven = false;
  7168. _this._cursorOffset = 0;
  7169. _this._deadKey = false;
  7170. _this._addKey = true;
  7171. _this._currentKey = "";
  7172. _this._isTextHighlightOn = false;
  7173. _this._textHighlightColor = "#d5e0ff";
  7174. _this._highligherOpacity = 0.4;
  7175. _this._highlightedText = "";
  7176. _this._startHighlightIndex = 0;
  7177. _this._endHighlightIndex = 0;
  7178. _this._cursorIndex = -1;
  7179. _this._onFocusSelectAll = false;
  7180. _this._isPointerDown = false;
  7181. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7182. _this.promptMessage = "Please enter text:";
  7183. /** Force disable prompt on mobile device */
  7184. _this.disableMobilePrompt = false;
  7185. /** Observable raised when the text changes */
  7186. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7187. /** Observable raised just before an entered character is to be added */
  7188. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7189. /** Observable raised when the control gets the focus */
  7190. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7191. /** Observable raised when the control loses the focus */
  7192. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7193. /**Observable raised when the text is highlighted */
  7194. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7195. /**Observable raised when copy event is triggered */
  7196. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7197. /** Observable raised when cut event is triggered */
  7198. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7199. /** Observable raised when paste event is triggered */
  7200. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7201. /** Observable raised when a key event was processed */
  7202. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7203. _this.text = text;
  7204. _this.isPointerBlocker = true;
  7205. return _this;
  7206. }
  7207. Object.defineProperty(InputText.prototype, "maxWidth", {
  7208. /** Gets or sets the maximum width allowed by the control */
  7209. get: function () {
  7210. return this._maxWidth.toString(this._host);
  7211. },
  7212. set: function (value) {
  7213. if (this._maxWidth.toString(this._host) === value) {
  7214. return;
  7215. }
  7216. if (this._maxWidth.fromString(value)) {
  7217. this._markAsDirty();
  7218. }
  7219. },
  7220. enumerable: true,
  7221. configurable: true
  7222. });
  7223. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7224. /** Gets the maximum width allowed by the control in pixels */
  7225. get: function () {
  7226. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7227. },
  7228. enumerable: true,
  7229. configurable: true
  7230. });
  7231. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7232. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7233. get: function () {
  7234. return this._highligherOpacity;
  7235. },
  7236. set: function (value) {
  7237. if (this._highligherOpacity === value) {
  7238. return;
  7239. }
  7240. this._highligherOpacity = value;
  7241. this._markAsDirty();
  7242. },
  7243. enumerable: true,
  7244. configurable: true
  7245. });
  7246. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7247. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7248. get: function () {
  7249. return this._onFocusSelectAll;
  7250. },
  7251. set: function (value) {
  7252. if (this._onFocusSelectAll === value) {
  7253. return;
  7254. }
  7255. this._onFocusSelectAll = value;
  7256. this._markAsDirty();
  7257. },
  7258. enumerable: true,
  7259. configurable: true
  7260. });
  7261. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7262. /** Gets or sets the text hightlight color */
  7263. get: function () {
  7264. return this._textHighlightColor;
  7265. },
  7266. set: function (value) {
  7267. if (this._textHighlightColor === value) {
  7268. return;
  7269. }
  7270. this._textHighlightColor = value;
  7271. this._markAsDirty();
  7272. },
  7273. enumerable: true,
  7274. configurable: true
  7275. });
  7276. Object.defineProperty(InputText.prototype, "margin", {
  7277. /** Gets or sets control margin */
  7278. get: function () {
  7279. return this._margin.toString(this._host);
  7280. },
  7281. set: function (value) {
  7282. if (this._margin.toString(this._host) === value) {
  7283. return;
  7284. }
  7285. if (this._margin.fromString(value)) {
  7286. this._markAsDirty();
  7287. }
  7288. },
  7289. enumerable: true,
  7290. configurable: true
  7291. });
  7292. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7293. /** Gets control margin in pixels */
  7294. get: function () {
  7295. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7296. },
  7297. enumerable: true,
  7298. configurable: true
  7299. });
  7300. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7301. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7302. get: function () {
  7303. return this._autoStretchWidth;
  7304. },
  7305. set: function (value) {
  7306. if (this._autoStretchWidth === value) {
  7307. return;
  7308. }
  7309. this._autoStretchWidth = value;
  7310. this._markAsDirty();
  7311. },
  7312. enumerable: true,
  7313. configurable: true
  7314. });
  7315. Object.defineProperty(InputText.prototype, "thickness", {
  7316. /** Gets or sets border thickness */
  7317. get: function () {
  7318. return this._thickness;
  7319. },
  7320. set: function (value) {
  7321. if (this._thickness === value) {
  7322. return;
  7323. }
  7324. this._thickness = value;
  7325. this._markAsDirty();
  7326. },
  7327. enumerable: true,
  7328. configurable: true
  7329. });
  7330. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7331. /** Gets or sets the background color when focused */
  7332. get: function () {
  7333. return this._focusedBackground;
  7334. },
  7335. set: function (value) {
  7336. if (this._focusedBackground === value) {
  7337. return;
  7338. }
  7339. this._focusedBackground = value;
  7340. this._markAsDirty();
  7341. },
  7342. enumerable: true,
  7343. configurable: true
  7344. });
  7345. Object.defineProperty(InputText.prototype, "focusedColor", {
  7346. /** Gets or sets the background color when focused */
  7347. get: function () {
  7348. return this._focusedColor;
  7349. },
  7350. set: function (value) {
  7351. if (this._focusedColor === value) {
  7352. return;
  7353. }
  7354. this._focusedColor = value;
  7355. this._markAsDirty();
  7356. },
  7357. enumerable: true,
  7358. configurable: true
  7359. });
  7360. Object.defineProperty(InputText.prototype, "background", {
  7361. /** Gets or sets the background color */
  7362. get: function () {
  7363. return this._background;
  7364. },
  7365. set: function (value) {
  7366. if (this._background === value) {
  7367. return;
  7368. }
  7369. this._background = value;
  7370. this._markAsDirty();
  7371. },
  7372. enumerable: true,
  7373. configurable: true
  7374. });
  7375. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7376. /** Gets or sets the placeholder color */
  7377. get: function () {
  7378. return this._placeholderColor;
  7379. },
  7380. set: function (value) {
  7381. if (this._placeholderColor === value) {
  7382. return;
  7383. }
  7384. this._placeholderColor = value;
  7385. this._markAsDirty();
  7386. },
  7387. enumerable: true,
  7388. configurable: true
  7389. });
  7390. Object.defineProperty(InputText.prototype, "placeholderText", {
  7391. /** Gets or sets the text displayed when the control is empty */
  7392. get: function () {
  7393. return this._placeholderText;
  7394. },
  7395. set: function (value) {
  7396. if (this._placeholderText === value) {
  7397. return;
  7398. }
  7399. this._placeholderText = value;
  7400. this._markAsDirty();
  7401. },
  7402. enumerable: true,
  7403. configurable: true
  7404. });
  7405. Object.defineProperty(InputText.prototype, "deadKey", {
  7406. /** Gets or sets the dead key flag */
  7407. get: function () {
  7408. return this._deadKey;
  7409. },
  7410. set: function (flag) {
  7411. this._deadKey = flag;
  7412. },
  7413. enumerable: true,
  7414. configurable: true
  7415. });
  7416. Object.defineProperty(InputText.prototype, "highlightedText", {
  7417. /** Gets or sets the highlight text */
  7418. get: function () {
  7419. return this._highlightedText;
  7420. },
  7421. set: function (text) {
  7422. if (this._highlightedText === text) {
  7423. return;
  7424. }
  7425. this._highlightedText = text;
  7426. this._markAsDirty();
  7427. },
  7428. enumerable: true,
  7429. configurable: true
  7430. });
  7431. Object.defineProperty(InputText.prototype, "addKey", {
  7432. /** Gets or sets if the current key should be added */
  7433. get: function () {
  7434. return this._addKey;
  7435. },
  7436. set: function (flag) {
  7437. this._addKey = flag;
  7438. },
  7439. enumerable: true,
  7440. configurable: true
  7441. });
  7442. Object.defineProperty(InputText.prototype, "currentKey", {
  7443. /** Gets or sets the value of the current key being entered */
  7444. get: function () {
  7445. return this._currentKey;
  7446. },
  7447. set: function (key) {
  7448. this._currentKey = key;
  7449. },
  7450. enumerable: true,
  7451. configurable: true
  7452. });
  7453. Object.defineProperty(InputText.prototype, "text", {
  7454. /** Gets or sets the text displayed in the control */
  7455. get: function () {
  7456. return this._text;
  7457. },
  7458. set: function (value) {
  7459. var valueAsString = value.toString(); // Forcing convertion
  7460. if (this._text === valueAsString) {
  7461. return;
  7462. }
  7463. this._text = valueAsString;
  7464. this._markAsDirty();
  7465. this.onTextChangedObservable.notifyObservers(this);
  7466. },
  7467. enumerable: true,
  7468. configurable: true
  7469. });
  7470. Object.defineProperty(InputText.prototype, "width", {
  7471. /** Gets or sets control width */
  7472. get: function () {
  7473. return this._width.toString(this._host);
  7474. },
  7475. set: function (value) {
  7476. if (this._width.toString(this._host) === value) {
  7477. return;
  7478. }
  7479. if (this._width.fromString(value)) {
  7480. this._markAsDirty();
  7481. }
  7482. this.autoStretchWidth = false;
  7483. },
  7484. enumerable: true,
  7485. configurable: true
  7486. });
  7487. /** @hidden */
  7488. InputText.prototype.onBlur = function () {
  7489. this._isFocused = false;
  7490. this._scrollLeft = null;
  7491. this._cursorOffset = 0;
  7492. clearTimeout(this._blinkTimeout);
  7493. this._markAsDirty();
  7494. this.onBlurObservable.notifyObservers(this);
  7495. this._host.unRegisterClipboardEvents();
  7496. if (this._onClipboardObserver) {
  7497. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7498. }
  7499. var scene = this._host.getScene();
  7500. if (this._onPointerDblTapObserver && scene) {
  7501. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7502. }
  7503. };
  7504. /** @hidden */
  7505. InputText.prototype.onFocus = function () {
  7506. var _this = this;
  7507. if (!this._isEnabled) {
  7508. return;
  7509. }
  7510. this._scrollLeft = null;
  7511. this._isFocused = true;
  7512. this._blinkIsEven = false;
  7513. this._cursorOffset = 0;
  7514. this._markAsDirty();
  7515. this.onFocusObservable.notifyObservers(this);
  7516. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7517. var value = prompt(this.promptMessage);
  7518. if (value !== null) {
  7519. this.text = value;
  7520. }
  7521. this._host.focusedControl = null;
  7522. return;
  7523. }
  7524. this._host.registerClipboardEvents();
  7525. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7526. // process clipboard event, can be configured.
  7527. switch (clipboardInfo.type) {
  7528. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7529. _this._onCopyText(clipboardInfo.event);
  7530. _this.onTextCopyObservable.notifyObservers(_this);
  7531. break;
  7532. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7533. _this._onCutText(clipboardInfo.event);
  7534. _this.onTextCutObservable.notifyObservers(_this);
  7535. break;
  7536. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7537. _this._onPasteText(clipboardInfo.event);
  7538. _this.onTextPasteObservable.notifyObservers(_this);
  7539. break;
  7540. default: return;
  7541. }
  7542. });
  7543. var scene = this._host.getScene();
  7544. if (scene) {
  7545. //register the pointer double tap event
  7546. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7547. if (!_this._isFocused) {
  7548. return;
  7549. }
  7550. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7551. _this._processDblClick(pointerInfo);
  7552. }
  7553. });
  7554. }
  7555. if (this._onFocusSelectAll) {
  7556. this._selectAllText();
  7557. }
  7558. };
  7559. InputText.prototype._getTypeName = function () {
  7560. return "InputText";
  7561. };
  7562. /**
  7563. * Function called to get the list of controls that should not steal the focus from this control
  7564. * @returns an array of controls
  7565. */
  7566. InputText.prototype.keepsFocusWith = function () {
  7567. if (!this._connectedVirtualKeyboard) {
  7568. return null;
  7569. }
  7570. return [this._connectedVirtualKeyboard];
  7571. };
  7572. /** @hidden */
  7573. InputText.prototype.processKey = function (keyCode, key, evt) {
  7574. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7575. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7576. return;
  7577. }
  7578. //select all
  7579. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7580. this._selectAllText();
  7581. evt.preventDefault();
  7582. return;
  7583. }
  7584. // Specific cases
  7585. switch (keyCode) {
  7586. case 32: //SPACE
  7587. key = " "; //ie11 key for space is "Spacebar"
  7588. break;
  7589. case 191: //SLASH
  7590. if (evt) {
  7591. evt.preventDefault();
  7592. }
  7593. break;
  7594. case 8: // BACKSPACE
  7595. if (this._text && this._text.length > 0) {
  7596. //delete the highlighted text
  7597. if (this._isTextHighlightOn) {
  7598. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7599. this._isTextHighlightOn = false;
  7600. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7601. this._blinkIsEven = false;
  7602. if (evt) {
  7603. evt.preventDefault();
  7604. }
  7605. return;
  7606. }
  7607. //delete single character
  7608. if (this._cursorOffset === 0) {
  7609. this.text = this._text.substr(0, this._text.length - 1);
  7610. }
  7611. else {
  7612. var deletePosition = this._text.length - this._cursorOffset;
  7613. if (deletePosition > 0) {
  7614. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7615. }
  7616. }
  7617. }
  7618. if (evt) {
  7619. evt.preventDefault();
  7620. }
  7621. return;
  7622. case 46: // DELETE
  7623. if (this._isTextHighlightOn) {
  7624. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7625. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7626. while (decrementor > 0 && this._cursorOffset > 0) {
  7627. this._cursorOffset--;
  7628. }
  7629. this._isTextHighlightOn = false;
  7630. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7631. if (evt) {
  7632. evt.preventDefault();
  7633. }
  7634. return;
  7635. }
  7636. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7637. var deletePosition = this._text.length - this._cursorOffset;
  7638. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7639. this._cursorOffset--;
  7640. }
  7641. if (evt) {
  7642. evt.preventDefault();
  7643. }
  7644. return;
  7645. case 13: // RETURN
  7646. this._host.focusedControl = null;
  7647. this._isTextHighlightOn = false;
  7648. return;
  7649. case 35: // END
  7650. this._cursorOffset = 0;
  7651. this._blinkIsEven = false;
  7652. this._isTextHighlightOn = false;
  7653. this._markAsDirty();
  7654. return;
  7655. case 36: // HOME
  7656. this._cursorOffset = this._text.length;
  7657. this._blinkIsEven = false;
  7658. this._isTextHighlightOn = false;
  7659. this._markAsDirty();
  7660. return;
  7661. case 37: // LEFT
  7662. this._cursorOffset++;
  7663. if (this._cursorOffset > this._text.length) {
  7664. this._cursorOffset = this._text.length;
  7665. }
  7666. if (evt && evt.shiftKey) {
  7667. // update the cursor
  7668. this._blinkIsEven = false;
  7669. // shift + ctrl/cmd + <-
  7670. if (evt.ctrlKey || evt.metaKey) {
  7671. if (!this._isTextHighlightOn) {
  7672. if (this._text.length === this._cursorOffset) {
  7673. return;
  7674. }
  7675. else {
  7676. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7677. }
  7678. }
  7679. this._startHighlightIndex = 0;
  7680. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7681. this._cursorOffset = this._text.length;
  7682. this._isTextHighlightOn = true;
  7683. this._markAsDirty();
  7684. return;
  7685. }
  7686. //store the starting point
  7687. if (!this._isTextHighlightOn) {
  7688. this._isTextHighlightOn = true;
  7689. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7690. }
  7691. //if text is already highlighted
  7692. else if (this._cursorIndex === -1) {
  7693. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7694. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7695. }
  7696. //set the highlight indexes
  7697. if (this._cursorIndex < this._cursorOffset) {
  7698. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7699. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7700. }
  7701. else if (this._cursorIndex > this._cursorOffset) {
  7702. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7703. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7704. }
  7705. else {
  7706. this._isTextHighlightOn = false;
  7707. }
  7708. this._markAsDirty();
  7709. return;
  7710. }
  7711. if (this._isTextHighlightOn) {
  7712. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7713. this._isTextHighlightOn = false;
  7714. }
  7715. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7716. this._cursorOffset = this.text.length;
  7717. evt.preventDefault();
  7718. }
  7719. this._blinkIsEven = false;
  7720. this._isTextHighlightOn = false;
  7721. this._cursorIndex = -1;
  7722. this._markAsDirty();
  7723. return;
  7724. case 39: // RIGHT
  7725. this._cursorOffset--;
  7726. if (this._cursorOffset < 0) {
  7727. this._cursorOffset = 0;
  7728. }
  7729. if (evt && evt.shiftKey) {
  7730. //update the cursor
  7731. this._blinkIsEven = false;
  7732. //shift + ctrl/cmd + ->
  7733. if (evt.ctrlKey || evt.metaKey) {
  7734. if (!this._isTextHighlightOn) {
  7735. if (this._cursorOffset === 0) {
  7736. return;
  7737. }
  7738. else {
  7739. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7740. }
  7741. }
  7742. this._endHighlightIndex = this._text.length;
  7743. this._isTextHighlightOn = true;
  7744. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7745. this._cursorOffset = 0;
  7746. this._markAsDirty();
  7747. return;
  7748. }
  7749. if (!this._isTextHighlightOn) {
  7750. this._isTextHighlightOn = true;
  7751. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7752. }
  7753. //if text is already highlighted
  7754. else if (this._cursorIndex === -1) {
  7755. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7756. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7757. }
  7758. //set the highlight indexes
  7759. if (this._cursorIndex < this._cursorOffset) {
  7760. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7761. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7762. }
  7763. else if (this._cursorIndex > this._cursorOffset) {
  7764. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7765. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7766. }
  7767. else {
  7768. this._isTextHighlightOn = false;
  7769. }
  7770. this._markAsDirty();
  7771. return;
  7772. }
  7773. if (this._isTextHighlightOn) {
  7774. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7775. this._isTextHighlightOn = false;
  7776. }
  7777. //ctr + ->
  7778. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7779. this._cursorOffset = 0;
  7780. evt.preventDefault();
  7781. }
  7782. this._blinkIsEven = false;
  7783. this._isTextHighlightOn = false;
  7784. this._cursorIndex = -1;
  7785. this._markAsDirty();
  7786. return;
  7787. case 222: // Dead
  7788. if (evt) {
  7789. evt.preventDefault();
  7790. }
  7791. this._cursorIndex = -1;
  7792. this.deadKey = true;
  7793. break;
  7794. }
  7795. // Printable characters
  7796. if (key &&
  7797. ((keyCode === -1) || // Direct access
  7798. (keyCode === 32) || // Space
  7799. (keyCode > 47 && keyCode < 64) || // Numbers
  7800. (keyCode > 64 && keyCode < 91) || // Letters
  7801. (keyCode > 159 && keyCode < 193) || // Special characters
  7802. (keyCode > 218 && keyCode < 223) || // Special characters
  7803. (keyCode > 95 && keyCode < 112))) { // Numpad
  7804. this._currentKey = key;
  7805. this.onBeforeKeyAddObservable.notifyObservers(this);
  7806. key = this._currentKey;
  7807. if (this._addKey) {
  7808. if (this._isTextHighlightOn) {
  7809. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7810. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7811. this._isTextHighlightOn = false;
  7812. this._blinkIsEven = false;
  7813. this._markAsDirty();
  7814. }
  7815. else if (this._cursorOffset === 0) {
  7816. this.text += key;
  7817. }
  7818. else {
  7819. var insertPosition = this._text.length - this._cursorOffset;
  7820. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7821. }
  7822. }
  7823. }
  7824. };
  7825. /** @hidden */
  7826. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7827. //update the cursor
  7828. this._blinkIsEven = false;
  7829. if (this._cursorIndex === -1) {
  7830. this._cursorIndex = offset;
  7831. }
  7832. else {
  7833. if (this._cursorIndex < this._cursorOffset) {
  7834. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7835. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7836. }
  7837. else if (this._cursorIndex > this._cursorOffset) {
  7838. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7839. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7840. }
  7841. else {
  7842. this._isTextHighlightOn = false;
  7843. this._markAsDirty();
  7844. return;
  7845. }
  7846. }
  7847. this._isTextHighlightOn = true;
  7848. this._markAsDirty();
  7849. };
  7850. /** @hidden */
  7851. InputText.prototype._processDblClick = function (evt) {
  7852. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7853. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7854. this._endHighlightIndex = this._startHighlightIndex;
  7855. var rWord = /\w+/g, moveLeft, moveRight;
  7856. do {
  7857. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7858. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7859. } while (moveLeft || moveRight);
  7860. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7861. this.onTextHighlightObservable.notifyObservers(this);
  7862. this._isTextHighlightOn = true;
  7863. this._clickedCoordinate = null;
  7864. this._blinkIsEven = true;
  7865. this._cursorIndex = -1;
  7866. this._markAsDirty();
  7867. };
  7868. /** @hidden */
  7869. InputText.prototype._selectAllText = function () {
  7870. this._blinkIsEven = true;
  7871. this._isTextHighlightOn = true;
  7872. this._startHighlightIndex = 0;
  7873. this._endHighlightIndex = this._text.length;
  7874. this._cursorOffset = this._text.length;
  7875. this._cursorIndex = -1;
  7876. this._markAsDirty();
  7877. };
  7878. /**
  7879. * Handles the keyboard event
  7880. * @param evt Defines the KeyboardEvent
  7881. */
  7882. InputText.prototype.processKeyboard = function (evt) {
  7883. // process pressed key
  7884. this.processKey(evt.keyCode, evt.key, evt);
  7885. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7886. };
  7887. /** @hidden */
  7888. InputText.prototype._onCopyText = function (ev) {
  7889. this._isTextHighlightOn = false;
  7890. //when write permission to clipbaord data is denied
  7891. try {
  7892. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7893. }
  7894. catch (_a) { } //pass
  7895. this._host.clipboardData = this._highlightedText;
  7896. };
  7897. /** @hidden */
  7898. InputText.prototype._onCutText = function (ev) {
  7899. if (!this._highlightedText) {
  7900. return;
  7901. }
  7902. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7903. this._isTextHighlightOn = false;
  7904. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7905. //when write permission to clipbaord data is denied
  7906. try {
  7907. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7908. }
  7909. catch (_a) { } //pass
  7910. this._host.clipboardData = this._highlightedText;
  7911. this._highlightedText = "";
  7912. };
  7913. /** @hidden */
  7914. InputText.prototype._onPasteText = function (ev) {
  7915. var data = "";
  7916. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7917. data = ev.clipboardData.getData("text/plain");
  7918. }
  7919. else {
  7920. //get the cached data; returns blank string by default
  7921. data = this._host.clipboardData;
  7922. }
  7923. var insertPosition = this._text.length - this._cursorOffset;
  7924. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7925. };
  7926. InputText.prototype._draw = function (context, invalidatedRectangle) {
  7927. var _this = this;
  7928. context.save();
  7929. this._applyStates(context);
  7930. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7931. context.shadowColor = this.shadowColor;
  7932. context.shadowBlur = this.shadowBlur;
  7933. context.shadowOffsetX = this.shadowOffsetX;
  7934. context.shadowOffsetY = this.shadowOffsetY;
  7935. }
  7936. // Background
  7937. if (this._isFocused) {
  7938. if (this._focusedBackground) {
  7939. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7940. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7941. }
  7942. }
  7943. else if (this._background) {
  7944. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7945. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7946. }
  7947. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7948. context.shadowBlur = 0;
  7949. context.shadowOffsetX = 0;
  7950. context.shadowOffsetY = 0;
  7951. }
  7952. if (!this._fontOffset) {
  7953. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7954. }
  7955. // Text
  7956. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7957. if (this.color) {
  7958. context.fillStyle = this.color;
  7959. }
  7960. var text = this._beforeRenderText(this._text);
  7961. if (!this._isFocused && !this._text && this._placeholderText) {
  7962. text = this._placeholderText;
  7963. if (this._placeholderColor) {
  7964. context.fillStyle = this._placeholderColor;
  7965. }
  7966. }
  7967. this._textWidth = context.measureText(text).width;
  7968. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7969. if (this._autoStretchWidth) {
  7970. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7971. }
  7972. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7973. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7974. context.save();
  7975. context.beginPath();
  7976. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7977. context.clip();
  7978. if (this._isFocused && this._textWidth > availableWidth) {
  7979. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7980. if (!this._scrollLeft) {
  7981. this._scrollLeft = textLeft;
  7982. }
  7983. }
  7984. else {
  7985. this._scrollLeft = clipTextLeft;
  7986. }
  7987. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7988. // Cursor
  7989. if (this._isFocused) {
  7990. // Need to move cursor
  7991. if (this._clickedCoordinate) {
  7992. var rightPosition = this._scrollLeft + this._textWidth;
  7993. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7994. var currentSize = 0;
  7995. this._cursorOffset = 0;
  7996. var previousDist = 0;
  7997. do {
  7998. if (this._cursorOffset) {
  7999. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  8000. }
  8001. this._cursorOffset++;
  8002. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  8003. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  8004. // Find closest move
  8005. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  8006. this._cursorOffset--;
  8007. }
  8008. this._blinkIsEven = false;
  8009. this._clickedCoordinate = null;
  8010. }
  8011. // Render cursor
  8012. if (!this._blinkIsEven) {
  8013. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  8014. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  8015. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  8016. if (cursorLeft < clipTextLeft) {
  8017. this._scrollLeft += (clipTextLeft - cursorLeft);
  8018. cursorLeft = clipTextLeft;
  8019. this._markAsDirty();
  8020. }
  8021. else if (cursorLeft > clipTextLeft + availableWidth) {
  8022. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  8023. cursorLeft = clipTextLeft + availableWidth;
  8024. this._markAsDirty();
  8025. }
  8026. if (!this._isTextHighlightOn) {
  8027. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  8028. }
  8029. }
  8030. clearTimeout(this._blinkTimeout);
  8031. this._blinkTimeout = setTimeout(function () {
  8032. _this._blinkIsEven = !_this._blinkIsEven;
  8033. _this._markAsDirty();
  8034. }, 500);
  8035. //show the highlighted text
  8036. if (this._isTextHighlightOn) {
  8037. clearTimeout(this._blinkTimeout);
  8038. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  8039. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  8040. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  8041. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  8042. if (highlightCursorLeft < clipTextLeft) {
  8043. width = width - (clipTextLeft - highlightCursorLeft);
  8044. if (!width) {
  8045. // when using left arrow on text.length > availableWidth;
  8046. // assigns the width of the first letter after clipTextLeft
  8047. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  8048. }
  8049. highlightCursorLeft = clipTextLeft;
  8050. }
  8051. //for transparancy
  8052. context.globalAlpha = this._highligherOpacity;
  8053. context.fillStyle = this._textHighlightColor;
  8054. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  8055. context.globalAlpha = 1.0;
  8056. }
  8057. }
  8058. context.restore();
  8059. // Border
  8060. if (this._thickness) {
  8061. if (this._isFocused) {
  8062. if (this.focusedColor) {
  8063. context.strokeStyle = this.focusedColor;
  8064. }
  8065. }
  8066. else {
  8067. if (this.color) {
  8068. context.strokeStyle = this.color;
  8069. }
  8070. }
  8071. context.lineWidth = this._thickness;
  8072. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8073. }
  8074. context.restore();
  8075. };
  8076. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8077. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8078. return false;
  8079. }
  8080. this._clickedCoordinate = coordinates.x;
  8081. this._isTextHighlightOn = false;
  8082. this._highlightedText = "";
  8083. this._cursorIndex = -1;
  8084. this._isPointerDown = true;
  8085. this._host._capturingControl[pointerId] = this;
  8086. if (this._host.focusedControl === this) {
  8087. // Move cursor
  8088. clearTimeout(this._blinkTimeout);
  8089. this._markAsDirty();
  8090. return true;
  8091. }
  8092. if (!this._isEnabled) {
  8093. return false;
  8094. }
  8095. this._host.focusedControl = this;
  8096. return true;
  8097. };
  8098. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  8099. if (this._host.focusedControl === this && this._isPointerDown) {
  8100. this._clickedCoordinate = coordinates.x;
  8101. this._markAsDirty();
  8102. this._updateValueFromCursorIndex(this._cursorOffset);
  8103. }
  8104. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  8105. };
  8106. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  8107. this._isPointerDown = false;
  8108. delete this._host._capturingControl[pointerId];
  8109. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  8110. };
  8111. InputText.prototype._beforeRenderText = function (text) {
  8112. return text;
  8113. };
  8114. InputText.prototype.dispose = function () {
  8115. _super.prototype.dispose.call(this);
  8116. this.onBlurObservable.clear();
  8117. this.onFocusObservable.clear();
  8118. this.onTextChangedObservable.clear();
  8119. this.onTextCopyObservable.clear();
  8120. this.onTextCutObservable.clear();
  8121. this.onTextPasteObservable.clear();
  8122. this.onTextHighlightObservable.clear();
  8123. this.onKeyboardEventProcessedObservable.clear();
  8124. };
  8125. return InputText;
  8126. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8127. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  8128. /***/ }),
  8129. /***/ "./2D/controls/line.ts":
  8130. /*!*****************************!*\
  8131. !*** ./2D/controls/line.ts ***!
  8132. \*****************************/
  8133. /*! exports provided: Line */
  8134. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8135. "use strict";
  8136. __webpack_require__.r(__webpack_exports__);
  8137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  8138. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8139. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  8140. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  8141. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8142. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  8143. /** Class used to render 2D lines */
  8144. var Line = /** @class */ (function (_super) {
  8145. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8146. /**
  8147. * Creates a new Line
  8148. * @param name defines the control name
  8149. */
  8150. function Line(name) {
  8151. var _this = _super.call(this, name) || this;
  8152. _this.name = name;
  8153. _this._lineWidth = 1;
  8154. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8155. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8156. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8157. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8158. _this._dash = new Array();
  8159. _this._automaticSize = true;
  8160. _this.isHitTestVisible = false;
  8161. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8162. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8163. return _this;
  8164. }
  8165. Object.defineProperty(Line.prototype, "dash", {
  8166. /** Gets or sets the dash pattern */
  8167. get: function () {
  8168. return this._dash;
  8169. },
  8170. set: function (value) {
  8171. if (this._dash === value) {
  8172. return;
  8173. }
  8174. this._dash = value;
  8175. this._markAsDirty();
  8176. },
  8177. enumerable: true,
  8178. configurable: true
  8179. });
  8180. Object.defineProperty(Line.prototype, "connectedControl", {
  8181. /** Gets or sets the control connected with the line end */
  8182. get: function () {
  8183. return this._connectedControl;
  8184. },
  8185. set: function (value) {
  8186. var _this = this;
  8187. if (this._connectedControl === value) {
  8188. return;
  8189. }
  8190. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8191. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8192. this._connectedControlDirtyObserver = null;
  8193. }
  8194. if (value) {
  8195. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8196. }
  8197. this._connectedControl = value;
  8198. this._markAsDirty();
  8199. },
  8200. enumerable: true,
  8201. configurable: true
  8202. });
  8203. Object.defineProperty(Line.prototype, "x1", {
  8204. /** Gets or sets start coordinates on X axis */
  8205. get: function () {
  8206. return this._x1.toString(this._host);
  8207. },
  8208. set: function (value) {
  8209. if (this._x1.toString(this._host) === value) {
  8210. return;
  8211. }
  8212. if (this._x1.fromString(value)) {
  8213. this._markAsDirty();
  8214. }
  8215. },
  8216. enumerable: true,
  8217. configurable: true
  8218. });
  8219. Object.defineProperty(Line.prototype, "y1", {
  8220. /** Gets or sets start coordinates on Y axis */
  8221. get: function () {
  8222. return this._y1.toString(this._host);
  8223. },
  8224. set: function (value) {
  8225. if (this._y1.toString(this._host) === value) {
  8226. return;
  8227. }
  8228. if (this._y1.fromString(value)) {
  8229. this._markAsDirty();
  8230. }
  8231. },
  8232. enumerable: true,
  8233. configurable: true
  8234. });
  8235. Object.defineProperty(Line.prototype, "x2", {
  8236. /** Gets or sets end coordinates on X axis */
  8237. get: function () {
  8238. return this._x2.toString(this._host);
  8239. },
  8240. set: function (value) {
  8241. if (this._x2.toString(this._host) === value) {
  8242. return;
  8243. }
  8244. if (this._x2.fromString(value)) {
  8245. this._markAsDirty();
  8246. }
  8247. },
  8248. enumerable: true,
  8249. configurable: true
  8250. });
  8251. Object.defineProperty(Line.prototype, "y2", {
  8252. /** Gets or sets end coordinates on Y axis */
  8253. get: function () {
  8254. return this._y2.toString(this._host);
  8255. },
  8256. set: function (value) {
  8257. if (this._y2.toString(this._host) === value) {
  8258. return;
  8259. }
  8260. if (this._y2.fromString(value)) {
  8261. this._markAsDirty();
  8262. }
  8263. },
  8264. enumerable: true,
  8265. configurable: true
  8266. });
  8267. Object.defineProperty(Line.prototype, "lineWidth", {
  8268. /** Gets or sets line width */
  8269. get: function () {
  8270. return this._lineWidth;
  8271. },
  8272. set: function (value) {
  8273. if (this._lineWidth === value) {
  8274. return;
  8275. }
  8276. this._lineWidth = value;
  8277. this._markAsDirty();
  8278. },
  8279. enumerable: true,
  8280. configurable: true
  8281. });
  8282. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8283. /** Gets or sets horizontal alignment */
  8284. set: function (value) {
  8285. return;
  8286. },
  8287. enumerable: true,
  8288. configurable: true
  8289. });
  8290. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8291. /** Gets or sets vertical alignment */
  8292. set: function (value) {
  8293. return;
  8294. },
  8295. enumerable: true,
  8296. configurable: true
  8297. });
  8298. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8299. get: function () {
  8300. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8301. },
  8302. enumerable: true,
  8303. configurable: true
  8304. });
  8305. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8306. get: function () {
  8307. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8308. },
  8309. enumerable: true,
  8310. configurable: true
  8311. });
  8312. Line.prototype._getTypeName = function () {
  8313. return "Line";
  8314. };
  8315. Line.prototype._draw = function (context) {
  8316. context.save();
  8317. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8318. context.shadowColor = this.shadowColor;
  8319. context.shadowBlur = this.shadowBlur;
  8320. context.shadowOffsetX = this.shadowOffsetX;
  8321. context.shadowOffsetY = this.shadowOffsetY;
  8322. }
  8323. this._applyStates(context);
  8324. context.strokeStyle = this.color;
  8325. context.lineWidth = this._lineWidth;
  8326. context.setLineDash(this._dash);
  8327. context.beginPath();
  8328. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8329. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8330. context.stroke();
  8331. context.restore();
  8332. };
  8333. Line.prototype._measure = function () {
  8334. // Width / Height
  8335. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8336. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8337. };
  8338. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8339. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8340. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8341. };
  8342. /**
  8343. * Move one end of the line given 3D cartesian coordinates.
  8344. * @param position Targeted world position
  8345. * @param scene Scene
  8346. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8347. */
  8348. Line.prototype.moveToVector3 = function (position, scene, end) {
  8349. if (end === void 0) { end = false; }
  8350. if (!this._host || this.parent !== this._host._rootContainer) {
  8351. 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");
  8352. return;
  8353. }
  8354. var globalViewport = this._host._getGlobalViewport(scene);
  8355. 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);
  8356. this._moveToProjectedPosition(projectedPosition, end);
  8357. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8358. this.notRenderable = true;
  8359. return;
  8360. }
  8361. this.notRenderable = false;
  8362. };
  8363. /**
  8364. * Move one end of the line to a position in screen absolute space.
  8365. * @param projectedPosition Position in screen absolute space (X, Y)
  8366. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8367. */
  8368. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8369. if (end === void 0) { end = false; }
  8370. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8371. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8372. if (end) {
  8373. this.x2 = x;
  8374. this.y2 = y;
  8375. this._x2.ignoreAdaptiveScaling = true;
  8376. this._y2.ignoreAdaptiveScaling = true;
  8377. }
  8378. else {
  8379. this.x1 = x;
  8380. this.y1 = y;
  8381. this._x1.ignoreAdaptiveScaling = true;
  8382. this._y1.ignoreAdaptiveScaling = true;
  8383. }
  8384. };
  8385. return Line;
  8386. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8387. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8388. /***/ }),
  8389. /***/ "./2D/controls/multiLine.ts":
  8390. /*!**********************************!*\
  8391. !*** ./2D/controls/multiLine.ts ***!
  8392. \**********************************/
  8393. /*! exports provided: MultiLine */
  8394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8395. "use strict";
  8396. __webpack_require__.r(__webpack_exports__);
  8397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8398. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8399. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/perfCounter");
  8400. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8401. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8402. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8403. /**
  8404. * Class used to create multi line control
  8405. */
  8406. var MultiLine = /** @class */ (function (_super) {
  8407. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8408. /**
  8409. * Creates a new MultiLine
  8410. * @param name defines the control name
  8411. */
  8412. function MultiLine(name) {
  8413. var _this = _super.call(this, name) || this;
  8414. _this.name = name;
  8415. _this._lineWidth = 1;
  8416. /** Function called when a point is updated */
  8417. _this.onPointUpdate = function () {
  8418. _this._markAsDirty();
  8419. };
  8420. _this._automaticSize = true;
  8421. _this.isHitTestVisible = false;
  8422. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8423. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8424. _this._dash = [];
  8425. _this._points = [];
  8426. return _this;
  8427. }
  8428. Object.defineProperty(MultiLine.prototype, "dash", {
  8429. /** Gets or sets dash pattern */
  8430. get: function () {
  8431. return this._dash;
  8432. },
  8433. set: function (value) {
  8434. if (this._dash === value) {
  8435. return;
  8436. }
  8437. this._dash = value;
  8438. this._markAsDirty();
  8439. },
  8440. enumerable: true,
  8441. configurable: true
  8442. });
  8443. /**
  8444. * Gets point stored at specified index
  8445. * @param index defines the index to look for
  8446. * @returns the requested point if found
  8447. */
  8448. MultiLine.prototype.getAt = function (index) {
  8449. if (!this._points[index]) {
  8450. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8451. }
  8452. return this._points[index];
  8453. };
  8454. /**
  8455. * Adds new points to the point collection
  8456. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8457. * @returns the list of created MultiLinePoint
  8458. */
  8459. MultiLine.prototype.add = function () {
  8460. var _this = this;
  8461. var items = [];
  8462. for (var _i = 0; _i < arguments.length; _i++) {
  8463. items[_i] = arguments[_i];
  8464. }
  8465. return items.map(function (item) { return _this.push(item); });
  8466. };
  8467. /**
  8468. * Adds a new point to the point collection
  8469. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8470. * @returns the created MultiLinePoint
  8471. */
  8472. MultiLine.prototype.push = function (item) {
  8473. var point = this.getAt(this._points.length);
  8474. if (item == null) {
  8475. return point;
  8476. }
  8477. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8478. point.mesh = item;
  8479. }
  8480. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8481. point.control = item;
  8482. }
  8483. else if (item.x != null && item.y != null) {
  8484. point.x = item.x;
  8485. point.y = item.y;
  8486. }
  8487. return point;
  8488. };
  8489. /**
  8490. * Remove a specific value or point from the active point collection
  8491. * @param value defines the value or point to remove
  8492. */
  8493. MultiLine.prototype.remove = function (value) {
  8494. var index;
  8495. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8496. index = this._points.indexOf(value);
  8497. if (index === -1) {
  8498. return;
  8499. }
  8500. }
  8501. else {
  8502. index = value;
  8503. }
  8504. var point = this._points[index];
  8505. if (!point) {
  8506. return;
  8507. }
  8508. point.dispose();
  8509. this._points.splice(index, 1);
  8510. };
  8511. /**
  8512. * Resets this object to initial state (no point)
  8513. */
  8514. MultiLine.prototype.reset = function () {
  8515. while (this._points.length > 0) {
  8516. this.remove(this._points.length - 1);
  8517. }
  8518. };
  8519. /**
  8520. * Resets all links
  8521. */
  8522. MultiLine.prototype.resetLinks = function () {
  8523. this._points.forEach(function (point) {
  8524. if (point != null) {
  8525. point.resetLinks();
  8526. }
  8527. });
  8528. };
  8529. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8530. /** Gets or sets line width */
  8531. get: function () {
  8532. return this._lineWidth;
  8533. },
  8534. set: function (value) {
  8535. if (this._lineWidth === value) {
  8536. return;
  8537. }
  8538. this._lineWidth = value;
  8539. this._markAsDirty();
  8540. },
  8541. enumerable: true,
  8542. configurable: true
  8543. });
  8544. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8545. set: function (value) {
  8546. return;
  8547. },
  8548. enumerable: true,
  8549. configurable: true
  8550. });
  8551. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8552. set: function (value) {
  8553. return;
  8554. },
  8555. enumerable: true,
  8556. configurable: true
  8557. });
  8558. MultiLine.prototype._getTypeName = function () {
  8559. return "MultiLine";
  8560. };
  8561. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8562. context.save();
  8563. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8564. context.shadowColor = this.shadowColor;
  8565. context.shadowBlur = this.shadowBlur;
  8566. context.shadowOffsetX = this.shadowOffsetX;
  8567. context.shadowOffsetY = this.shadowOffsetY;
  8568. }
  8569. this._applyStates(context);
  8570. context.strokeStyle = this.color;
  8571. context.lineWidth = this._lineWidth;
  8572. context.setLineDash(this._dash);
  8573. context.beginPath();
  8574. var first = true; //first index is not necessarily 0
  8575. this._points.forEach(function (point) {
  8576. if (!point) {
  8577. return;
  8578. }
  8579. if (first) {
  8580. context.moveTo(point._point.x, point._point.y);
  8581. first = false;
  8582. }
  8583. else {
  8584. context.lineTo(point._point.x, point._point.y);
  8585. }
  8586. });
  8587. context.stroke();
  8588. context.restore();
  8589. };
  8590. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8591. var _this = this;
  8592. this._minX = null;
  8593. this._minY = null;
  8594. this._maxX = null;
  8595. this._maxY = null;
  8596. this._points.forEach(function (point, index) {
  8597. if (!point) {
  8598. return;
  8599. }
  8600. point.translate();
  8601. if (_this._minX == null || point._point.x < _this._minX) {
  8602. _this._minX = point._point.x;
  8603. }
  8604. if (_this._minY == null || point._point.y < _this._minY) {
  8605. _this._minY = point._point.y;
  8606. }
  8607. if (_this._maxX == null || point._point.x > _this._maxX) {
  8608. _this._maxX = point._point.x;
  8609. }
  8610. if (_this._maxY == null || point._point.y > _this._maxY) {
  8611. _this._maxY = point._point.y;
  8612. }
  8613. });
  8614. if (this._minX == null) {
  8615. this._minX = 0;
  8616. }
  8617. if (this._minY == null) {
  8618. this._minY = 0;
  8619. }
  8620. if (this._maxX == null) {
  8621. this._maxX = 0;
  8622. }
  8623. if (this._maxY == null) {
  8624. this._maxY = 0;
  8625. }
  8626. };
  8627. MultiLine.prototype._measure = function () {
  8628. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8629. return;
  8630. }
  8631. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8632. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8633. };
  8634. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8635. if (this._minX == null || this._minY == null) {
  8636. return;
  8637. }
  8638. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8639. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8640. };
  8641. MultiLine.prototype.dispose = function () {
  8642. this.reset();
  8643. _super.prototype.dispose.call(this);
  8644. };
  8645. return MultiLine;
  8646. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8647. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8648. /***/ }),
  8649. /***/ "./2D/controls/radioButton.ts":
  8650. /*!************************************!*\
  8651. !*** ./2D/controls/radioButton.ts ***!
  8652. \************************************/
  8653. /*! exports provided: RadioButton */
  8654. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8655. "use strict";
  8656. __webpack_require__.r(__webpack_exports__);
  8657. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8658. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8659. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  8660. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8661. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8662. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8663. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8664. /**
  8665. * Class used to create radio button controls
  8666. */
  8667. var RadioButton = /** @class */ (function (_super) {
  8668. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8669. /**
  8670. * Creates a new RadioButton
  8671. * @param name defines the control name
  8672. */
  8673. function RadioButton(name) {
  8674. var _this = _super.call(this, name) || this;
  8675. _this.name = name;
  8676. _this._isChecked = false;
  8677. _this._background = "black";
  8678. _this._checkSizeRatio = 0.8;
  8679. _this._thickness = 1;
  8680. /** Gets or sets group name */
  8681. _this.group = "";
  8682. /** Observable raised when isChecked is changed */
  8683. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8684. _this.isPointerBlocker = true;
  8685. return _this;
  8686. }
  8687. Object.defineProperty(RadioButton.prototype, "thickness", {
  8688. /** Gets or sets border thickness */
  8689. get: function () {
  8690. return this._thickness;
  8691. },
  8692. set: function (value) {
  8693. if (this._thickness === value) {
  8694. return;
  8695. }
  8696. this._thickness = value;
  8697. this._markAsDirty();
  8698. },
  8699. enumerable: true,
  8700. configurable: true
  8701. });
  8702. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8703. /** Gets or sets a value indicating the ratio between overall size and check size */
  8704. get: function () {
  8705. return this._checkSizeRatio;
  8706. },
  8707. set: function (value) {
  8708. value = Math.max(Math.min(1, value), 0);
  8709. if (this._checkSizeRatio === value) {
  8710. return;
  8711. }
  8712. this._checkSizeRatio = value;
  8713. this._markAsDirty();
  8714. },
  8715. enumerable: true,
  8716. configurable: true
  8717. });
  8718. Object.defineProperty(RadioButton.prototype, "background", {
  8719. /** Gets or sets background color */
  8720. get: function () {
  8721. return this._background;
  8722. },
  8723. set: function (value) {
  8724. if (this._background === value) {
  8725. return;
  8726. }
  8727. this._background = value;
  8728. this._markAsDirty();
  8729. },
  8730. enumerable: true,
  8731. configurable: true
  8732. });
  8733. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8734. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8735. get: function () {
  8736. return this._isChecked;
  8737. },
  8738. set: function (value) {
  8739. var _this = this;
  8740. if (this._isChecked === value) {
  8741. return;
  8742. }
  8743. this._isChecked = value;
  8744. this._markAsDirty();
  8745. this.onIsCheckedChangedObservable.notifyObservers(value);
  8746. if (this._isChecked && this._host) {
  8747. // Update all controls from same group
  8748. this._host.executeOnAllControls(function (control) {
  8749. if (control === _this) {
  8750. return;
  8751. }
  8752. if (control.group === undefined) {
  8753. return;
  8754. }
  8755. var childRadio = control;
  8756. if (childRadio.group === _this.group) {
  8757. childRadio.isChecked = false;
  8758. }
  8759. });
  8760. }
  8761. },
  8762. enumerable: true,
  8763. configurable: true
  8764. });
  8765. RadioButton.prototype._getTypeName = function () {
  8766. return "RadioButton";
  8767. };
  8768. RadioButton.prototype._draw = function (context) {
  8769. context.save();
  8770. this._applyStates(context);
  8771. var actualWidth = this._currentMeasure.width - this._thickness;
  8772. var actualHeight = this._currentMeasure.height - this._thickness;
  8773. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8774. context.shadowColor = this.shadowColor;
  8775. context.shadowBlur = this.shadowBlur;
  8776. context.shadowOffsetX = this.shadowOffsetX;
  8777. context.shadowOffsetY = this.shadowOffsetY;
  8778. }
  8779. // Outer
  8780. _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);
  8781. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8782. context.fill();
  8783. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8784. context.shadowBlur = 0;
  8785. context.shadowOffsetX = 0;
  8786. context.shadowOffsetY = 0;
  8787. }
  8788. context.strokeStyle = this.color;
  8789. context.lineWidth = this._thickness;
  8790. context.stroke();
  8791. // Inner
  8792. if (this._isChecked) {
  8793. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8794. var offsetWidth = actualWidth * this._checkSizeRatio;
  8795. var offseHeight = actualHeight * this._checkSizeRatio;
  8796. _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);
  8797. context.fill();
  8798. }
  8799. context.restore();
  8800. };
  8801. // Events
  8802. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8803. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8804. return false;
  8805. }
  8806. if (!this.isChecked) {
  8807. this.isChecked = true;
  8808. }
  8809. return true;
  8810. };
  8811. /**
  8812. * Utility function to easily create a radio button with a header
  8813. * @param title defines the label to use for the header
  8814. * @param group defines the group to use for the radio button
  8815. * @param isChecked defines the initial state of the radio button
  8816. * @param onValueChanged defines the callback to call when value changes
  8817. * @returns a StackPanel containing the radio button and a textBlock
  8818. */
  8819. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8820. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8821. panel.isVertical = false;
  8822. panel.height = "30px";
  8823. var radio = new RadioButton();
  8824. radio.width = "20px";
  8825. radio.height = "20px";
  8826. radio.isChecked = isChecked;
  8827. radio.color = "green";
  8828. radio.group = group;
  8829. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8830. panel.addControl(radio);
  8831. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8832. header.text = title;
  8833. header.width = "180px";
  8834. header.paddingLeft = "5px";
  8835. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8836. header.color = "white";
  8837. panel.addControl(header);
  8838. return panel;
  8839. };
  8840. return RadioButton;
  8841. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8842. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8843. /***/ }),
  8844. /***/ "./2D/controls/rectangle.ts":
  8845. /*!**********************************!*\
  8846. !*** ./2D/controls/rectangle.ts ***!
  8847. \**********************************/
  8848. /*! exports provided: Rectangle */
  8849. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8850. "use strict";
  8851. __webpack_require__.r(__webpack_exports__);
  8852. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8853. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8854. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8855. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  8856. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8857. /** Class used to create rectangle container */
  8858. var Rectangle = /** @class */ (function (_super) {
  8859. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8860. /**
  8861. * Creates a new Rectangle
  8862. * @param name defines the control name
  8863. */
  8864. function Rectangle(name) {
  8865. var _this = _super.call(this, name) || this;
  8866. _this.name = name;
  8867. _this._thickness = 1;
  8868. _this._cornerRadius = 0;
  8869. return _this;
  8870. }
  8871. Object.defineProperty(Rectangle.prototype, "thickness", {
  8872. /** Gets or sets border thickness */
  8873. get: function () {
  8874. return this._thickness;
  8875. },
  8876. set: function (value) {
  8877. if (this._thickness === value) {
  8878. return;
  8879. }
  8880. this._thickness = value;
  8881. this._markAsDirty();
  8882. },
  8883. enumerable: true,
  8884. configurable: true
  8885. });
  8886. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8887. /** Gets or sets the corner radius angle */
  8888. get: function () {
  8889. return this._cornerRadius;
  8890. },
  8891. set: function (value) {
  8892. if (value < 0) {
  8893. value = 0;
  8894. }
  8895. if (this._cornerRadius === value) {
  8896. return;
  8897. }
  8898. this._cornerRadius = value;
  8899. this._markAsDirty();
  8900. },
  8901. enumerable: true,
  8902. configurable: true
  8903. });
  8904. Rectangle.prototype._getTypeName = function () {
  8905. return "Rectangle";
  8906. };
  8907. Rectangle.prototype._localDraw = function (context) {
  8908. context.save();
  8909. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8910. context.shadowColor = this.shadowColor;
  8911. context.shadowBlur = this.shadowBlur;
  8912. context.shadowOffsetX = this.shadowOffsetX;
  8913. context.shadowOffsetY = this.shadowOffsetY;
  8914. }
  8915. if (this._background) {
  8916. context.fillStyle = this._background;
  8917. if (this._cornerRadius) {
  8918. this._drawRoundedRect(context, this._thickness / 2);
  8919. context.fill();
  8920. }
  8921. else {
  8922. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8923. }
  8924. }
  8925. if (this._thickness) {
  8926. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8927. context.shadowBlur = 0;
  8928. context.shadowOffsetX = 0;
  8929. context.shadowOffsetY = 0;
  8930. }
  8931. if (this.color) {
  8932. context.strokeStyle = this.color;
  8933. }
  8934. context.lineWidth = this._thickness;
  8935. if (this._cornerRadius) {
  8936. this._drawRoundedRect(context, this._thickness / 2);
  8937. context.stroke();
  8938. }
  8939. else {
  8940. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8941. }
  8942. }
  8943. context.restore();
  8944. };
  8945. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8946. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8947. this._measureForChildren.width -= 2 * this._thickness;
  8948. this._measureForChildren.height -= 2 * this._thickness;
  8949. this._measureForChildren.left += this._thickness;
  8950. this._measureForChildren.top += this._thickness;
  8951. };
  8952. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8953. if (offset === void 0) { offset = 0; }
  8954. var x = this._currentMeasure.left + offset;
  8955. var y = this._currentMeasure.top + offset;
  8956. var width = this._currentMeasure.width - offset * 2;
  8957. var height = this._currentMeasure.height - offset * 2;
  8958. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8959. context.beginPath();
  8960. context.moveTo(x + radius, y);
  8961. context.lineTo(x + width - radius, y);
  8962. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8963. context.lineTo(x + width, y + height - radius);
  8964. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8965. context.lineTo(x + radius, y + height);
  8966. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8967. context.lineTo(x, y + radius);
  8968. context.quadraticCurveTo(x, y, x + radius, y);
  8969. context.closePath();
  8970. };
  8971. Rectangle.prototype._clipForChildren = function (context) {
  8972. if (this._cornerRadius) {
  8973. this._drawRoundedRect(context, this._thickness);
  8974. context.clip();
  8975. }
  8976. };
  8977. return Rectangle;
  8978. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8979. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  8980. /***/ }),
  8981. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8982. /*!***************************************************!*\
  8983. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8984. \***************************************************/
  8985. /*! exports provided: ScrollViewer */
  8986. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8987. "use strict";
  8988. __webpack_require__.r(__webpack_exports__);
  8989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8990. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8991. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8992. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8993. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8994. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8995. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8996. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  8997. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  8998. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__);
  8999. /**
  9000. * Class used to hold a viewer window and sliders in a grid
  9001. */
  9002. var ScrollViewer = /** @class */ (function (_super) {
  9003. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  9004. /**
  9005. * Creates a new ScrollViewer
  9006. * @param name of ScrollViewer
  9007. */
  9008. function ScrollViewer(name, isImageBased) {
  9009. var _this = _super.call(this, name) || this;
  9010. _this._barSize = 20;
  9011. _this._pointerIsOver = false;
  9012. _this._wheelPrecision = 0.05;
  9013. _this._thumbLength = 0.5;
  9014. _this._thumbHeight = 1;
  9015. _this._barImageHeight = 1;
  9016. _this._horizontalBarImageHeight = 1;
  9017. _this._verticalBarImageHeight = 1;
  9018. _this._forceHorizontalBar = false;
  9019. _this._forceVerticalBar = false;
  9020. _this._useImageBar = isImageBased ? isImageBased : false;
  9021. _this.onDirtyObservable.add(function () {
  9022. _this._horizontalBarSpace.color = _this.color;
  9023. _this._verticalBarSpace.color = _this.color;
  9024. _this._dragSpace.color = _this.color;
  9025. });
  9026. _this.onPointerEnterObservable.add(function () {
  9027. _this._pointerIsOver = true;
  9028. });
  9029. _this.onPointerOutObservable.add(function () {
  9030. _this._pointerIsOver = false;
  9031. });
  9032. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_2__["Grid"]();
  9033. if (_this._useImageBar) {
  9034. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9035. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9036. }
  9037. else {
  9038. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9039. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9040. }
  9041. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__["_ScrollViewerWindow"]("scrollViewer_window");
  9042. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9043. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9044. _this._grid.addColumnDefinition(1);
  9045. _this._grid.addColumnDefinition(0, true);
  9046. _this._grid.addRowDefinition(1);
  9047. _this._grid.addRowDefinition(0, true);
  9048. _super.prototype.addControl.call(_this, _this._grid);
  9049. _this._grid.addControl(_this._window, 0, 0);
  9050. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9051. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9052. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9053. _this._verticalBarSpace.thickness = 1;
  9054. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  9055. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  9056. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9057. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9058. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9059. _this._horizontalBarSpace.thickness = 1;
  9060. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  9061. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  9062. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9063. _this._dragSpace.thickness = 1;
  9064. _this._grid.addControl(_this._dragSpace, 1, 1);
  9065. // Colors
  9066. if (!_this._useImageBar) {
  9067. _this.barColor = "grey";
  9068. _this.barBackground = "transparent";
  9069. }
  9070. return _this;
  9071. }
  9072. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  9073. /**
  9074. * Gets the horizontal scrollbar
  9075. */
  9076. get: function () {
  9077. return this._horizontalBar;
  9078. },
  9079. enumerable: true,
  9080. configurable: true
  9081. });
  9082. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  9083. /**
  9084. * Gets the vertical scrollbar
  9085. */
  9086. get: function () {
  9087. return this._verticalBar;
  9088. },
  9089. enumerable: true,
  9090. configurable: true
  9091. });
  9092. /**
  9093. * Adds a new control to the current container
  9094. * @param control defines the control to add
  9095. * @returns the current container
  9096. */
  9097. ScrollViewer.prototype.addControl = function (control) {
  9098. if (!control) {
  9099. return this;
  9100. }
  9101. this._window.addControl(control);
  9102. return this;
  9103. };
  9104. /**
  9105. * Removes a control from the current container
  9106. * @param control defines the control to remove
  9107. * @returns the current container
  9108. */
  9109. ScrollViewer.prototype.removeControl = function (control) {
  9110. this._window.removeControl(control);
  9111. return this;
  9112. };
  9113. Object.defineProperty(ScrollViewer.prototype, "children", {
  9114. /** Gets the list of children */
  9115. get: function () {
  9116. return this._window.children;
  9117. },
  9118. enumerable: true,
  9119. configurable: true
  9120. });
  9121. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  9122. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9123. var child = _a[_i];
  9124. child._markMatrixAsDirty();
  9125. }
  9126. };
  9127. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  9128. /**
  9129. * Freezes or unfreezes the controls in the window.
  9130. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  9131. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  9132. */
  9133. get: function () {
  9134. return this._window.freezeControls;
  9135. },
  9136. set: function (value) {
  9137. this._window.freezeControls = value;
  9138. },
  9139. enumerable: true,
  9140. configurable: true
  9141. });
  9142. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  9143. /** Gets the bucket width */
  9144. get: function () {
  9145. return this._window.bucketWidth;
  9146. },
  9147. enumerable: true,
  9148. configurable: true
  9149. });
  9150. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9151. /** Gets the bucket height */
  9152. get: function () {
  9153. return this._window.bucketHeight;
  9154. },
  9155. enumerable: true,
  9156. configurable: true
  9157. });
  9158. /**
  9159. * Sets the bucket sizes.
  9160. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9161. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9162. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9163. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9164. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9165. * used), that's why it is not enabled by default.
  9166. * @param width width of the bucket
  9167. * @param height height of the bucket
  9168. */
  9169. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9170. this._window.setBucketSizes(width, height);
  9171. };
  9172. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9173. /**
  9174. * Forces the horizontal scroll bar to be displayed
  9175. */
  9176. get: function () {
  9177. return this._forceHorizontalBar;
  9178. },
  9179. set: function (value) {
  9180. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9181. this._horizontalBar.isVisible = value;
  9182. this._forceHorizontalBar = value;
  9183. },
  9184. enumerable: true,
  9185. configurable: true
  9186. });
  9187. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9188. /**
  9189. * Forces the vertical scroll bar to be displayed
  9190. */
  9191. get: function () {
  9192. return this._forceVerticalBar;
  9193. },
  9194. set: function (value) {
  9195. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9196. this._verticalBar.isVisible = value;
  9197. this._forceVerticalBar = value;
  9198. },
  9199. enumerable: true,
  9200. configurable: true
  9201. });
  9202. /** Reset the scroll viewer window to initial size */
  9203. ScrollViewer.prototype.resetWindow = function () {
  9204. this._window.width = "100%";
  9205. this._window.height = "100%";
  9206. };
  9207. ScrollViewer.prototype._getTypeName = function () {
  9208. return "ScrollViewer";
  9209. };
  9210. ScrollViewer.prototype._buildClientSizes = function () {
  9211. var ratio = this.host.idealRatio;
  9212. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9213. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9214. this._clientWidth = this._window.parentClientWidth;
  9215. this._clientHeight = this._window.parentClientHeight;
  9216. };
  9217. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  9218. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9219. this._buildClientSizes();
  9220. };
  9221. ScrollViewer.prototype._postMeasure = function () {
  9222. _super.prototype._postMeasure.call(this);
  9223. this._updateScroller();
  9224. };
  9225. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  9226. /**
  9227. * Gets or sets the mouse wheel precision
  9228. * from 0 to 1 with a default value of 0.05
  9229. * */
  9230. get: function () {
  9231. return this._wheelPrecision;
  9232. },
  9233. set: function (value) {
  9234. if (this._wheelPrecision === value) {
  9235. return;
  9236. }
  9237. if (value < 0) {
  9238. value = 0;
  9239. }
  9240. if (value > 1) {
  9241. value = 1;
  9242. }
  9243. this._wheelPrecision = value;
  9244. },
  9245. enumerable: true,
  9246. configurable: true
  9247. });
  9248. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  9249. /** Gets or sets the scroll bar container background color */
  9250. get: function () {
  9251. return this._horizontalBarSpace.background;
  9252. },
  9253. set: function (color) {
  9254. if (this._horizontalBarSpace.background === color) {
  9255. return;
  9256. }
  9257. this._horizontalBarSpace.background = color;
  9258. this._verticalBarSpace.background = color;
  9259. },
  9260. enumerable: true,
  9261. configurable: true
  9262. });
  9263. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9264. /** Gets or sets the bar color */
  9265. get: function () {
  9266. return this._barColor;
  9267. },
  9268. set: function (color) {
  9269. if (this._barColor === color) {
  9270. return;
  9271. }
  9272. this._barColor = color;
  9273. this._horizontalBar.color = color;
  9274. this._verticalBar.color = color;
  9275. },
  9276. enumerable: true,
  9277. configurable: true
  9278. });
  9279. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9280. /** Gets or sets the bar image */
  9281. get: function () {
  9282. return this._barImage;
  9283. },
  9284. set: function (value) {
  9285. if (this._barImage === value) {
  9286. return;
  9287. }
  9288. this._barImage = value;
  9289. var hb = this._horizontalBar;
  9290. var vb = this._verticalBar;
  9291. hb.thumbImage = value;
  9292. vb.thumbImage = value;
  9293. },
  9294. enumerable: true,
  9295. configurable: true
  9296. });
  9297. Object.defineProperty(ScrollViewer.prototype, "horizontalThumbImage", {
  9298. /** Gets or sets the horizontal bar image */
  9299. get: function () {
  9300. return this._horizontalBarImage;
  9301. },
  9302. set: function (value) {
  9303. if (this._horizontalBarImage === value) {
  9304. return;
  9305. }
  9306. this._horizontalBarImage = value;
  9307. var hb = this._horizontalBar;
  9308. hb.thumbImage = value;
  9309. },
  9310. enumerable: true,
  9311. configurable: true
  9312. });
  9313. Object.defineProperty(ScrollViewer.prototype, "verticalThumbImage", {
  9314. /** Gets or sets the vertical bar image */
  9315. get: function () {
  9316. return this._verticalBarImage;
  9317. },
  9318. set: function (value) {
  9319. if (this._verticalBarImage === value) {
  9320. return;
  9321. }
  9322. this._verticalBarImage = value;
  9323. var vb = this._verticalBar;
  9324. vb.thumbImage = value;
  9325. },
  9326. enumerable: true,
  9327. configurable: true
  9328. });
  9329. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9330. /** Gets or sets the size of the bar */
  9331. get: function () {
  9332. return this._barSize;
  9333. },
  9334. set: function (value) {
  9335. if (this._barSize === value) {
  9336. return;
  9337. }
  9338. this._barSize = value;
  9339. this._markAsDirty();
  9340. if (this._horizontalBar.isVisible) {
  9341. this._grid.setRowDefinition(1, this._barSize, true);
  9342. }
  9343. if (this._verticalBar.isVisible) {
  9344. this._grid.setColumnDefinition(1, this._barSize, true);
  9345. }
  9346. },
  9347. enumerable: true,
  9348. configurable: true
  9349. });
  9350. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9351. /** Gets or sets the length of the thumb */
  9352. get: function () {
  9353. return this._thumbLength;
  9354. },
  9355. set: function (value) {
  9356. if (this._thumbLength === value) {
  9357. return;
  9358. }
  9359. if (value <= 0) {
  9360. value = 0.1;
  9361. }
  9362. if (value > 1) {
  9363. value = 1;
  9364. }
  9365. this._thumbLength = value;
  9366. var hb = this._horizontalBar;
  9367. var vb = this._verticalBar;
  9368. hb.thumbLength = value;
  9369. vb.thumbLength = value;
  9370. this._markAsDirty();
  9371. },
  9372. enumerable: true,
  9373. configurable: true
  9374. });
  9375. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9376. /** Gets or sets the height of the thumb */
  9377. get: function () {
  9378. return this._thumbHeight;
  9379. },
  9380. set: function (value) {
  9381. if (this._thumbHeight === value) {
  9382. return;
  9383. }
  9384. if (value <= 0) {
  9385. value = 0.1;
  9386. }
  9387. if (value > 1) {
  9388. value = 1;
  9389. }
  9390. this._thumbHeight = value;
  9391. var hb = this._horizontalBar;
  9392. var vb = this._verticalBar;
  9393. hb.thumbHeight = value;
  9394. vb.thumbHeight = value;
  9395. this._markAsDirty();
  9396. },
  9397. enumerable: true,
  9398. configurable: true
  9399. });
  9400. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9401. /** Gets or sets the height of the bar image */
  9402. get: function () {
  9403. return this._barImageHeight;
  9404. },
  9405. set: function (value) {
  9406. if (this._barImageHeight === value) {
  9407. return;
  9408. }
  9409. if (value <= 0) {
  9410. value = 0.1;
  9411. }
  9412. if (value > 1) {
  9413. value = 1;
  9414. }
  9415. this._barImageHeight = value;
  9416. var hb = this._horizontalBar;
  9417. var vb = this._verticalBar;
  9418. hb.barImageHeight = value;
  9419. vb.barImageHeight = value;
  9420. this._markAsDirty();
  9421. },
  9422. enumerable: true,
  9423. configurable: true
  9424. });
  9425. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImageHeight", {
  9426. /** Gets or sets the height of the horizontal bar image */
  9427. get: function () {
  9428. return this._horizontalBarImageHeight;
  9429. },
  9430. set: function (value) {
  9431. if (this._horizontalBarImageHeight === value) {
  9432. return;
  9433. }
  9434. if (value <= 0) {
  9435. value = 0.1;
  9436. }
  9437. if (value > 1) {
  9438. value = 1;
  9439. }
  9440. this._horizontalBarImageHeight = value;
  9441. var hb = this._horizontalBar;
  9442. hb.barImageHeight = value;
  9443. this._markAsDirty();
  9444. },
  9445. enumerable: true,
  9446. configurable: true
  9447. });
  9448. Object.defineProperty(ScrollViewer.prototype, "verticalBarImageHeight", {
  9449. /** Gets or sets the height of the vertical bar image */
  9450. get: function () {
  9451. return this._verticalBarImageHeight;
  9452. },
  9453. set: function (value) {
  9454. if (this._verticalBarImageHeight === value) {
  9455. return;
  9456. }
  9457. if (value <= 0) {
  9458. value = 0.1;
  9459. }
  9460. if (value > 1) {
  9461. value = 1;
  9462. }
  9463. this._verticalBarImageHeight = value;
  9464. var vb = this._verticalBar;
  9465. vb.barImageHeight = value;
  9466. this._markAsDirty();
  9467. },
  9468. enumerable: true,
  9469. configurable: true
  9470. });
  9471. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9472. /** Gets or sets the bar background */
  9473. get: function () {
  9474. return this._barBackground;
  9475. },
  9476. set: function (color) {
  9477. if (this._barBackground === color) {
  9478. return;
  9479. }
  9480. this._barBackground = color;
  9481. var hb = this._horizontalBar;
  9482. var vb = this._verticalBar;
  9483. hb.background = color;
  9484. vb.background = color;
  9485. this._dragSpace.background = color;
  9486. },
  9487. enumerable: true,
  9488. configurable: true
  9489. });
  9490. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9491. /** Gets or sets the bar background image */
  9492. get: function () {
  9493. return this._barBackgroundImage;
  9494. },
  9495. set: function (value) {
  9496. if (this._barBackgroundImage === value) {
  9497. }
  9498. this._barBackgroundImage = value;
  9499. var hb = this._horizontalBar;
  9500. var vb = this._verticalBar;
  9501. hb.backgroundImage = value;
  9502. vb.backgroundImage = value;
  9503. },
  9504. enumerable: true,
  9505. configurable: true
  9506. });
  9507. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImage", {
  9508. /** Gets or sets the horizontal bar background image */
  9509. get: function () {
  9510. return this._horizontalBarBackgroundImage;
  9511. },
  9512. set: function (value) {
  9513. if (this._horizontalBarBackgroundImage === value) {
  9514. }
  9515. this._horizontalBarBackgroundImage = value;
  9516. var hb = this._horizontalBar;
  9517. hb.backgroundImage = value;
  9518. },
  9519. enumerable: true,
  9520. configurable: true
  9521. });
  9522. Object.defineProperty(ScrollViewer.prototype, "verticalBarImage", {
  9523. /** Gets or sets the vertical bar background image */
  9524. get: function () {
  9525. return this._verticalBarBackgroundImage;
  9526. },
  9527. set: function (value) {
  9528. if (this._verticalBarBackgroundImage === value) {
  9529. }
  9530. this._verticalBarBackgroundImage = value;
  9531. var vb = this._verticalBar;
  9532. vb.backgroundImage = value;
  9533. },
  9534. enumerable: true,
  9535. configurable: true
  9536. });
  9537. ScrollViewer.prototype._setWindowPosition = function () {
  9538. var ratio = this.host.idealRatio;
  9539. var windowContentsWidth = this._window._currentMeasure.width;
  9540. var windowContentsHeight = this._window._currentMeasure.height;
  9541. var _endLeft = this._clientWidth - windowContentsWidth;
  9542. var _endTop = this._clientHeight - windowContentsHeight;
  9543. var newLeft = (this._horizontalBar.value / ratio) * _endLeft + "px";
  9544. var newTop = (this._verticalBar.value / ratio) * _endTop + "px";
  9545. if (newLeft !== this._window.left) {
  9546. this._window.left = newLeft;
  9547. if (!this.freezeControls) {
  9548. this._rebuildLayout = true;
  9549. }
  9550. }
  9551. if (newTop !== this._window.top) {
  9552. this._window.top = newTop;
  9553. if (!this.freezeControls) {
  9554. this._rebuildLayout = true;
  9555. }
  9556. }
  9557. };
  9558. /** @hidden */
  9559. ScrollViewer.prototype._updateScroller = function () {
  9560. var windowContentsWidth = this._window._currentMeasure.width;
  9561. var windowContentsHeight = this._window._currentMeasure.height;
  9562. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  9563. this._grid.setRowDefinition(1, 0, true);
  9564. this._horizontalBar.isVisible = false;
  9565. this._horizontalBar.value = 0;
  9566. this._rebuildLayout = true;
  9567. }
  9568. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  9569. this._grid.setRowDefinition(1, this._barSize, true);
  9570. this._horizontalBar.isVisible = true;
  9571. this._rebuildLayout = true;
  9572. }
  9573. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  9574. this._grid.setColumnDefinition(1, 0, true);
  9575. this._verticalBar.isVisible = false;
  9576. this._verticalBar.value = 0;
  9577. this._rebuildLayout = true;
  9578. }
  9579. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  9580. this._grid.setColumnDefinition(1, this._barSize, true);
  9581. this._verticalBar.isVisible = true;
  9582. this._rebuildLayout = true;
  9583. }
  9584. this._buildClientSizes();
  9585. var ratio = this.host.idealRatio;
  9586. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientWidth / ratio) + "px";
  9587. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientHeight / ratio) + "px";
  9588. };
  9589. ScrollViewer.prototype._link = function (host) {
  9590. _super.prototype._link.call(this, host);
  9591. this._attachWheel();
  9592. };
  9593. /** @hidden */
  9594. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9595. var _this = this;
  9596. barControl.paddingLeft = 0;
  9597. barControl.width = "100%";
  9598. barControl.height = "100%";
  9599. barControl.barOffset = 0;
  9600. barControl.value = 0;
  9601. barControl.maximum = 1;
  9602. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9603. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9604. barControl.isVertical = isVertical;
  9605. barControl.rotation = rotation;
  9606. barControl.isVisible = false;
  9607. barContainer.addControl(barControl);
  9608. barControl.onValueChangedObservable.add(function (value) {
  9609. _this._setWindowPosition();
  9610. });
  9611. };
  9612. /** @hidden */
  9613. ScrollViewer.prototype._attachWheel = function () {
  9614. var _this = this;
  9615. if (!this._host || this._onWheelObserver) {
  9616. return;
  9617. }
  9618. this._onWheelObserver = this.onWheelObservable.add(function (pi) {
  9619. if (!_this._pointerIsOver) {
  9620. return;
  9621. }
  9622. if (_this._verticalBar.isVisible == true) {
  9623. if (pi.y < 0 && _this._verticalBar.value > 0) {
  9624. _this._verticalBar.value -= _this._wheelPrecision;
  9625. }
  9626. else if (pi.y > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9627. _this._verticalBar.value += _this._wheelPrecision;
  9628. }
  9629. }
  9630. if (_this._horizontalBar.isVisible == true) {
  9631. if (pi.x < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9632. _this._horizontalBar.value += _this._wheelPrecision;
  9633. }
  9634. else if (pi.x > 0 && _this._horizontalBar.value > 0) {
  9635. _this._horizontalBar.value -= _this._wheelPrecision;
  9636. }
  9637. }
  9638. });
  9639. };
  9640. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9641. if (!this.isHighlighted) {
  9642. return;
  9643. }
  9644. _super.prototype._renderHighlightSpecific.call(this, context);
  9645. this._grid._renderHighlightSpecific(context);
  9646. context.restore();
  9647. };
  9648. /** Releases associated resources */
  9649. ScrollViewer.prototype.dispose = function () {
  9650. this.onWheelObservable.remove(this._onWheelObserver);
  9651. this._onWheelObserver = null;
  9652. _super.prototype.dispose.call(this);
  9653. };
  9654. return ScrollViewer;
  9655. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9656. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9657. /***/ }),
  9658. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9659. /*!*********************************************************!*\
  9660. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9661. \*********************************************************/
  9662. /*! exports provided: _ScrollViewerWindow */
  9663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9664. "use strict";
  9665. __webpack_require__.r(__webpack_exports__);
  9666. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9667. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9668. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9669. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9670. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9671. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9672. /**
  9673. * Class used to hold a the container for ScrollViewer
  9674. * @hidden
  9675. */
  9676. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9677. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9678. /**
  9679. * Creates a new ScrollViewerWindow
  9680. * @param name of ScrollViewerWindow
  9681. */
  9682. function _ScrollViewerWindow(name) {
  9683. var _this = _super.call(this, name) || this;
  9684. _this._freezeControls = false;
  9685. _this._bucketWidth = 0;
  9686. _this._bucketHeight = 0;
  9687. _this._buckets = {};
  9688. return _this;
  9689. }
  9690. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  9691. get: function () {
  9692. return this._freezeControls;
  9693. },
  9694. set: function (value) {
  9695. if (this._freezeControls === value) {
  9696. return;
  9697. }
  9698. // trigger a full normal layout calculation to be sure all children have their measures up to date
  9699. this._freezeControls = false;
  9700. var textureSize = this.host.getSize();
  9701. var renderWidth = textureSize.width;
  9702. var renderHeight = textureSize.height;
  9703. var context = this.host.getContext();
  9704. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  9705. this.host._numLayoutCalls = 0;
  9706. this.host._rootContainer._layout(measure, context);
  9707. // in freeze mode, prepare children measures accordingly
  9708. if (value) {
  9709. this._updateMeasures();
  9710. if (this._useBuckets()) {
  9711. this._makeBuckets();
  9712. }
  9713. }
  9714. this._freezeControls = value;
  9715. this.host.markAsDirty(); // redraw with the (new) current settings
  9716. },
  9717. enumerable: true,
  9718. configurable: true
  9719. });
  9720. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  9721. get: function () {
  9722. return this._bucketWidth;
  9723. },
  9724. enumerable: true,
  9725. configurable: true
  9726. });
  9727. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  9728. get: function () {
  9729. return this._bucketHeight;
  9730. },
  9731. enumerable: true,
  9732. configurable: true
  9733. });
  9734. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  9735. this._bucketWidth = width;
  9736. this._bucketHeight = height;
  9737. if (this._useBuckets()) {
  9738. if (this._freezeControls) {
  9739. this._makeBuckets();
  9740. }
  9741. }
  9742. else {
  9743. this._buckets = {};
  9744. }
  9745. };
  9746. _ScrollViewerWindow.prototype._useBuckets = function () {
  9747. return this._bucketWidth > 0 && this._bucketHeight > 0;
  9748. };
  9749. _ScrollViewerWindow.prototype._makeBuckets = function () {
  9750. this._buckets = {};
  9751. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  9752. this._dispatchInBuckets(this._children);
  9753. };
  9754. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  9755. for (var i = 0; i < children.length; ++i) {
  9756. var child = children[i];
  9757. var bStartX = Math.max(0, Math.floor((child._currentMeasure.left - this._currentMeasure.left) / this._bucketWidth)), bEndX = Math.floor((child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width - 1) / this._bucketWidth), bStartY = Math.max(0, Math.floor((child._currentMeasure.top - this._currentMeasure.top) / this._bucketHeight)), bEndY = Math.floor((child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height - 1) / this._bucketHeight);
  9758. while (bStartY <= bEndY) {
  9759. for (var x = bStartX; x <= bEndX; ++x) {
  9760. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9761. if (!lstc) {
  9762. lstc = [];
  9763. this._buckets[bucket] = lstc;
  9764. }
  9765. lstc.push(child);
  9766. }
  9767. bStartY++;
  9768. }
  9769. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9770. this._dispatchInBuckets(child._children);
  9771. }
  9772. }
  9773. };
  9774. // reset left and top measures for the window and all its children
  9775. _ScrollViewerWindow.prototype._updateMeasures = function () {
  9776. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9777. this._measureForChildren.left -= left;
  9778. this._measureForChildren.top -= top;
  9779. this._currentMeasure.left -= left;
  9780. this._currentMeasure.top -= top;
  9781. this._updateChildrenMeasures(this._children, left, top);
  9782. };
  9783. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  9784. for (var i = 0; i < children.length; ++i) {
  9785. var child = children[i];
  9786. child._currentMeasure.left -= left;
  9787. child._currentMeasure.top -= top;
  9788. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  9789. child._customData._origTop = child._currentMeasure.top;
  9790. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9791. this._updateChildrenMeasures(child._children, left, top);
  9792. }
  9793. }
  9794. };
  9795. _ScrollViewerWindow.prototype._getTypeName = function () {
  9796. return "ScrollViewerWindow";
  9797. };
  9798. /** @hidden */
  9799. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9800. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9801. this._parentMeasure = parentMeasure;
  9802. this._measureForChildren.left = this._currentMeasure.left;
  9803. this._measureForChildren.top = this._currentMeasure.top;
  9804. this._measureForChildren.width = parentMeasure.width;
  9805. this._measureForChildren.height = parentMeasure.height;
  9806. };
  9807. /** @hidden */
  9808. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  9809. if (this._freezeControls) {
  9810. this.invalidateRect(); // will trigger a redraw of the window
  9811. return false;
  9812. }
  9813. return _super.prototype._layout.call(this, parentMeasure, context);
  9814. };
  9815. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  9816. for (var i = 0; i < children.length; ++i) {
  9817. var child = children[i];
  9818. child._currentMeasure.left = child._customData._origLeft + left;
  9819. child._currentMeasure.top = child._customData._origTop + top;
  9820. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9821. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9822. this._scrollChildren(child._children, left, top);
  9823. }
  9824. }
  9825. };
  9826. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  9827. 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);
  9828. while (bStartY <= bEndY) {
  9829. for (var x = bStartX; x <= bEndX; ++x) {
  9830. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9831. if (lstc) {
  9832. for (var i = 0; i < lstc.length; ++i) {
  9833. var child = lstc[i];
  9834. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  9835. child._currentMeasure.top = child._customData._origTop + scrollTop;
  9836. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9837. }
  9838. }
  9839. }
  9840. bStartY++;
  9841. }
  9842. };
  9843. /** @hidden */
  9844. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  9845. if (!this._freezeControls) {
  9846. _super.prototype._draw.call(this, context, invalidatedRectangle);
  9847. return;
  9848. }
  9849. this._localDraw(context);
  9850. if (this.clipChildren) {
  9851. this._clipForChildren(context);
  9852. }
  9853. var left = this.leftInPixels, top = this.topInPixels;
  9854. if (this._useBuckets()) {
  9855. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  9856. this._scrollChildrenWithBuckets(left, top, left, top);
  9857. }
  9858. else {
  9859. this._scrollChildren(this._children, left, top);
  9860. }
  9861. this._oldLeft = left;
  9862. this._oldTop = top;
  9863. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9864. var child = _a[_i];
  9865. if (!child._intersectsRect(this._parentMeasure)) {
  9866. continue;
  9867. }
  9868. child._render(context, this._parentMeasure);
  9869. }
  9870. };
  9871. _ScrollViewerWindow.prototype._postMeasure = function () {
  9872. if (this._freezeControls) {
  9873. _super.prototype._postMeasure.call(this);
  9874. return;
  9875. }
  9876. var maxWidth = this.parentClientWidth;
  9877. var maxHeight = this.parentClientHeight;
  9878. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9879. var child = _a[_i];
  9880. if (!child.isVisible || child.notRenderable) {
  9881. continue;
  9882. }
  9883. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9884. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9885. }
  9886. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9887. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9888. }
  9889. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9890. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9891. }
  9892. if (this._currentMeasure.width !== maxWidth) {
  9893. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9894. this._currentMeasure.width = maxWidth;
  9895. this._rebuildLayout = true;
  9896. this._isDirty = true;
  9897. }
  9898. if (this._currentMeasure.height !== maxHeight) {
  9899. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9900. this._currentMeasure.height = maxHeight;
  9901. this._rebuildLayout = true;
  9902. this._isDirty = true;
  9903. }
  9904. _super.prototype._postMeasure.call(this);
  9905. };
  9906. return _ScrollViewerWindow;
  9907. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  9908. /***/ }),
  9909. /***/ "./2D/controls/selector.ts":
  9910. /*!*********************************!*\
  9911. !*** ./2D/controls/selector.ts ***!
  9912. \*********************************/
  9913. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9915. "use strict";
  9916. __webpack_require__.r(__webpack_exports__);
  9917. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9918. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9919. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9920. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9922. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9923. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9924. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9925. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9926. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9927. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9928. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9929. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9930. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9931. /** Class used to create a RadioGroup
  9932. * which contains groups of radio buttons
  9933. */
  9934. var SelectorGroup = /** @class */ (function () {
  9935. /**
  9936. * Creates a new SelectorGroup
  9937. * @param name of group, used as a group heading
  9938. */
  9939. function SelectorGroup(
  9940. /** name of SelectorGroup */
  9941. name) {
  9942. this.name = name;
  9943. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9944. this._selectors = new Array();
  9945. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9946. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9947. this._groupHeader = this._addGroupHeader(name);
  9948. }
  9949. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9950. /** Gets the groupPanel of the SelectorGroup */
  9951. get: function () {
  9952. return this._groupPanel;
  9953. },
  9954. enumerable: true,
  9955. configurable: true
  9956. });
  9957. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9958. /** Gets the selectors array */
  9959. get: function () {
  9960. return this._selectors;
  9961. },
  9962. enumerable: true,
  9963. configurable: true
  9964. });
  9965. Object.defineProperty(SelectorGroup.prototype, "header", {
  9966. /** Gets and sets the group header */
  9967. get: function () {
  9968. return this._groupHeader.text;
  9969. },
  9970. set: function (label) {
  9971. if (this._groupHeader.text === "label") {
  9972. return;
  9973. }
  9974. this._groupHeader.text = label;
  9975. },
  9976. enumerable: true,
  9977. configurable: true
  9978. });
  9979. /** @hidden */
  9980. SelectorGroup.prototype._addGroupHeader = function (text) {
  9981. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9982. groupHeading.width = 0.9;
  9983. groupHeading.height = "30px";
  9984. groupHeading.textWrapping = true;
  9985. groupHeading.color = "black";
  9986. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9987. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9988. groupHeading.left = "2px";
  9989. this._groupPanel.addControl(groupHeading);
  9990. return groupHeading;
  9991. };
  9992. /** @hidden*/
  9993. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9994. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9995. return;
  9996. }
  9997. return this._selectors[selectorNb];
  9998. };
  9999. /** Removes the selector at the given position
  10000. * @param selectorNb the position of the selector within the group
  10001. */
  10002. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  10003. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10004. return;
  10005. }
  10006. this._groupPanel.removeControl(this._selectors[selectorNb]);
  10007. this._selectors.splice(selectorNb, 1);
  10008. };
  10009. return SelectorGroup;
  10010. }());
  10011. /** Class used to create a CheckboxGroup
  10012. * which contains groups of checkbox buttons
  10013. */
  10014. var CheckboxGroup = /** @class */ (function (_super) {
  10015. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  10016. function CheckboxGroup() {
  10017. return _super !== null && _super.apply(this, arguments) || this;
  10018. }
  10019. /** Adds a checkbox as a control
  10020. * @param text is the label for the selector
  10021. * @param func is the function called when the Selector is checked
  10022. * @param checked is true when Selector is checked
  10023. */
  10024. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  10025. if (func === void 0) { func = function (s) { }; }
  10026. if (checked === void 0) { checked = false; }
  10027. var checked = checked || false;
  10028. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  10029. button.width = "20px";
  10030. button.height = "20px";
  10031. button.color = "#364249";
  10032. button.background = "#CCCCCC";
  10033. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10034. button.onIsCheckedChangedObservable.add(function (state) {
  10035. func(state);
  10036. });
  10037. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  10038. _selector.height = "30px";
  10039. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10040. _selector.left = "4px";
  10041. this.groupPanel.addControl(_selector);
  10042. this.selectors.push(_selector);
  10043. button.isChecked = checked;
  10044. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10045. button.color = this.groupPanel.parent.parent.buttonColor;
  10046. button.background = this.groupPanel.parent.parent.buttonBackground;
  10047. }
  10048. };
  10049. /** @hidden */
  10050. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10051. this.selectors[selectorNb].children[1].text = label;
  10052. };
  10053. /** @hidden */
  10054. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10055. this.selectors[selectorNb].children[1].color = color;
  10056. };
  10057. /** @hidden */
  10058. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10059. this.selectors[selectorNb].children[0].color = color;
  10060. };
  10061. /** @hidden */
  10062. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10063. this.selectors[selectorNb].children[0].background = color;
  10064. };
  10065. return CheckboxGroup;
  10066. }(SelectorGroup));
  10067. /** Class used to create a RadioGroup
  10068. * which contains groups of radio buttons
  10069. */
  10070. var RadioGroup = /** @class */ (function (_super) {
  10071. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  10072. function RadioGroup() {
  10073. var _this = _super !== null && _super.apply(this, arguments) || this;
  10074. _this._selectNb = 0;
  10075. return _this;
  10076. }
  10077. /** Adds a radio button as a control
  10078. * @param label is the label for the selector
  10079. * @param func is the function called when the Selector is checked
  10080. * @param checked is true when Selector is checked
  10081. */
  10082. RadioGroup.prototype.addRadio = function (label, func, checked) {
  10083. if (func === void 0) { func = function (n) { }; }
  10084. if (checked === void 0) { checked = false; }
  10085. var nb = this._selectNb++;
  10086. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  10087. button.name = label;
  10088. button.width = "20px";
  10089. button.height = "20px";
  10090. button.color = "#364249";
  10091. button.background = "#CCCCCC";
  10092. button.group = this.name;
  10093. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10094. button.onIsCheckedChangedObservable.add(function (state) {
  10095. if (state) {
  10096. func(nb);
  10097. }
  10098. });
  10099. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  10100. _selector.height = "30px";
  10101. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10102. _selector.left = "4px";
  10103. this.groupPanel.addControl(_selector);
  10104. this.selectors.push(_selector);
  10105. button.isChecked = checked;
  10106. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10107. button.color = this.groupPanel.parent.parent.buttonColor;
  10108. button.background = this.groupPanel.parent.parent.buttonBackground;
  10109. }
  10110. };
  10111. /** @hidden */
  10112. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10113. this.selectors[selectorNb].children[1].text = label;
  10114. };
  10115. /** @hidden */
  10116. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10117. this.selectors[selectorNb].children[1].color = color;
  10118. };
  10119. /** @hidden */
  10120. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10121. this.selectors[selectorNb].children[0].color = color;
  10122. };
  10123. /** @hidden */
  10124. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10125. this.selectors[selectorNb].children[0].background = color;
  10126. };
  10127. return RadioGroup;
  10128. }(SelectorGroup));
  10129. /** Class used to create a SliderGroup
  10130. * which contains groups of slider buttons
  10131. */
  10132. var SliderGroup = /** @class */ (function (_super) {
  10133. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  10134. function SliderGroup() {
  10135. return _super !== null && _super.apply(this, arguments) || this;
  10136. }
  10137. /**
  10138. * Adds a slider to the SelectorGroup
  10139. * @param label is the label for the SliderBar
  10140. * @param func is the function called when the Slider moves
  10141. * @param unit is a string describing the units used, eg degrees or metres
  10142. * @param min is the minimum value for the Slider
  10143. * @param max is the maximum value for the Slider
  10144. * @param value is the start value for the Slider between min and max
  10145. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  10146. */
  10147. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  10148. if (func === void 0) { func = function (v) { }; }
  10149. if (unit === void 0) { unit = "Units"; }
  10150. if (min === void 0) { min = 0; }
  10151. if (max === void 0) { max = 0; }
  10152. if (value === void 0) { value = 0; }
  10153. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  10154. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  10155. button.name = unit;
  10156. button.value = value;
  10157. button.minimum = min;
  10158. button.maximum = max;
  10159. button.width = 0.9;
  10160. button.height = "20px";
  10161. button.color = "#364249";
  10162. button.background = "#CCCCCC";
  10163. button.borderColor = "black";
  10164. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10165. button.left = "4px";
  10166. button.paddingBottom = "4px";
  10167. button.onValueChangedObservable.add(function (value) {
  10168. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  10169. func(value);
  10170. });
  10171. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  10172. _selector.height = "60px";
  10173. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10174. _selector.left = "4px";
  10175. _selector.children[0].name = label;
  10176. this.groupPanel.addControl(_selector);
  10177. this.selectors.push(_selector);
  10178. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10179. button.color = this.groupPanel.parent.parent.buttonColor;
  10180. button.background = this.groupPanel.parent.parent.buttonBackground;
  10181. }
  10182. };
  10183. /** @hidden */
  10184. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10185. this.selectors[selectorNb].children[0].name = label;
  10186. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  10187. };
  10188. /** @hidden */
  10189. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10190. this.selectors[selectorNb].children[0].color = color;
  10191. };
  10192. /** @hidden */
  10193. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10194. this.selectors[selectorNb].children[1].color = color;
  10195. };
  10196. /** @hidden */
  10197. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10198. this.selectors[selectorNb].children[1].background = color;
  10199. };
  10200. return SliderGroup;
  10201. }(SelectorGroup));
  10202. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  10203. * @see http://doc.babylonjs.com/how_to/selector
  10204. */
  10205. var SelectionPanel = /** @class */ (function (_super) {
  10206. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  10207. /**
  10208. * Creates a new SelectionPanel
  10209. * @param name of SelectionPanel
  10210. * @param groups is an array of SelectionGroups
  10211. */
  10212. function SelectionPanel(
  10213. /** name of SelectionPanel */
  10214. name,
  10215. /** an array of SelectionGroups */
  10216. groups) {
  10217. if (groups === void 0) { groups = []; }
  10218. var _this = _super.call(this, name) || this;
  10219. _this.name = name;
  10220. _this.groups = groups;
  10221. _this._buttonColor = "#364249";
  10222. _this._buttonBackground = "#CCCCCC";
  10223. _this._headerColor = "black";
  10224. _this._barColor = "white";
  10225. _this._barHeight = "2px";
  10226. _this._spacerHeight = "20px";
  10227. _this._bars = new Array();
  10228. _this._groups = groups;
  10229. _this.thickness = 2;
  10230. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10231. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10232. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10233. _this._panel.top = 5;
  10234. _this._panel.left = 5;
  10235. _this._panel.width = 0.95;
  10236. if (groups.length > 0) {
  10237. for (var i = 0; i < groups.length - 1; i++) {
  10238. _this._panel.addControl(groups[i].groupPanel);
  10239. _this._addSpacer();
  10240. }
  10241. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  10242. }
  10243. _this.addControl(_this._panel);
  10244. return _this;
  10245. }
  10246. SelectionPanel.prototype._getTypeName = function () {
  10247. return "SelectionPanel";
  10248. };
  10249. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  10250. /** Gets or sets the headerColor */
  10251. get: function () {
  10252. return this._headerColor;
  10253. },
  10254. set: function (color) {
  10255. if (this._headerColor === color) {
  10256. return;
  10257. }
  10258. this._headerColor = color;
  10259. this._setHeaderColor();
  10260. },
  10261. enumerable: true,
  10262. configurable: true
  10263. });
  10264. SelectionPanel.prototype._setHeaderColor = function () {
  10265. for (var i = 0; i < this._groups.length; i++) {
  10266. this._groups[i].groupPanel.children[0].color = this._headerColor;
  10267. }
  10268. };
  10269. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  10270. /** Gets or sets the button color */
  10271. get: function () {
  10272. return this._buttonColor;
  10273. },
  10274. set: function (color) {
  10275. if (this._buttonColor === color) {
  10276. return;
  10277. }
  10278. this._buttonColor = color;
  10279. this._setbuttonColor();
  10280. },
  10281. enumerable: true,
  10282. configurable: true
  10283. });
  10284. SelectionPanel.prototype._setbuttonColor = function () {
  10285. for (var i = 0; i < this._groups.length; i++) {
  10286. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10287. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  10288. }
  10289. }
  10290. };
  10291. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  10292. /** Gets or sets the label color */
  10293. get: function () {
  10294. return this._labelColor;
  10295. },
  10296. set: function (color) {
  10297. if (this._labelColor === color) {
  10298. return;
  10299. }
  10300. this._labelColor = color;
  10301. this._setLabelColor();
  10302. },
  10303. enumerable: true,
  10304. configurable: true
  10305. });
  10306. SelectionPanel.prototype._setLabelColor = function () {
  10307. for (var i = 0; i < this._groups.length; i++) {
  10308. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10309. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  10310. }
  10311. }
  10312. };
  10313. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  10314. /** Gets or sets the button background */
  10315. get: function () {
  10316. return this._buttonBackground;
  10317. },
  10318. set: function (color) {
  10319. if (this._buttonBackground === color) {
  10320. return;
  10321. }
  10322. this._buttonBackground = color;
  10323. this._setButtonBackground();
  10324. },
  10325. enumerable: true,
  10326. configurable: true
  10327. });
  10328. SelectionPanel.prototype._setButtonBackground = function () {
  10329. for (var i = 0; i < this._groups.length; i++) {
  10330. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10331. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  10332. }
  10333. }
  10334. };
  10335. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  10336. /** Gets or sets the color of separator bar */
  10337. get: function () {
  10338. return this._barColor;
  10339. },
  10340. set: function (color) {
  10341. if (this._barColor === color) {
  10342. return;
  10343. }
  10344. this._barColor = color;
  10345. this._setBarColor();
  10346. },
  10347. enumerable: true,
  10348. configurable: true
  10349. });
  10350. SelectionPanel.prototype._setBarColor = function () {
  10351. for (var i = 0; i < this._bars.length; i++) {
  10352. this._bars[i].children[0].background = this._barColor;
  10353. }
  10354. };
  10355. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  10356. /** Gets or sets the height of separator bar */
  10357. get: function () {
  10358. return this._barHeight;
  10359. },
  10360. set: function (value) {
  10361. if (this._barHeight === value) {
  10362. return;
  10363. }
  10364. this._barHeight = value;
  10365. this._setBarHeight();
  10366. },
  10367. enumerable: true,
  10368. configurable: true
  10369. });
  10370. SelectionPanel.prototype._setBarHeight = function () {
  10371. for (var i = 0; i < this._bars.length; i++) {
  10372. this._bars[i].children[0].height = this._barHeight;
  10373. }
  10374. };
  10375. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  10376. /** Gets or sets the height of spacers*/
  10377. get: function () {
  10378. return this._spacerHeight;
  10379. },
  10380. set: function (value) {
  10381. if (this._spacerHeight === value) {
  10382. return;
  10383. }
  10384. this._spacerHeight = value;
  10385. this._setSpacerHeight();
  10386. },
  10387. enumerable: true,
  10388. configurable: true
  10389. });
  10390. SelectionPanel.prototype._setSpacerHeight = function () {
  10391. for (var i = 0; i < this._bars.length; i++) {
  10392. this._bars[i].height = this._spacerHeight;
  10393. }
  10394. };
  10395. /** Adds a bar between groups */
  10396. SelectionPanel.prototype._addSpacer = function () {
  10397. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  10398. separator.width = 1;
  10399. separator.height = this._spacerHeight;
  10400. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10401. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  10402. bar.width = 1;
  10403. bar.height = this._barHeight;
  10404. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10405. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10406. bar.background = this._barColor;
  10407. bar.color = "transparent";
  10408. separator.addControl(bar);
  10409. this._panel.addControl(separator);
  10410. this._bars.push(separator);
  10411. };
  10412. /** Add a group to the selection panel
  10413. * @param group is the selector group to add
  10414. */
  10415. SelectionPanel.prototype.addGroup = function (group) {
  10416. if (this._groups.length > 0) {
  10417. this._addSpacer();
  10418. }
  10419. this._panel.addControl(group.groupPanel);
  10420. this._groups.push(group);
  10421. group.groupPanel.children[0].color = this._headerColor;
  10422. for (var j = 0; j < group.selectors.length; j++) {
  10423. group._setSelectorButtonColor(j, this._buttonColor);
  10424. group._setSelectorButtonBackground(j, this._buttonBackground);
  10425. }
  10426. };
  10427. /** Remove the group from the given position
  10428. * @param groupNb is the position of the group in the list
  10429. */
  10430. SelectionPanel.prototype.removeGroup = function (groupNb) {
  10431. if (groupNb < 0 || groupNb >= this._groups.length) {
  10432. return;
  10433. }
  10434. var group = this._groups[groupNb];
  10435. this._panel.removeControl(group.groupPanel);
  10436. this._groups.splice(groupNb, 1);
  10437. if (groupNb < this._bars.length) {
  10438. this._panel.removeControl(this._bars[groupNb]);
  10439. this._bars.splice(groupNb, 1);
  10440. }
  10441. };
  10442. /** Change a group header label
  10443. * @param label is the new group header label
  10444. * @param groupNb is the number of the group to relabel
  10445. * */
  10446. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  10447. if (groupNb < 0 || groupNb >= this._groups.length) {
  10448. return;
  10449. }
  10450. var group = this._groups[groupNb];
  10451. group.groupPanel.children[0].text = label;
  10452. };
  10453. /** Change selector label to the one given
  10454. * @param label is the new selector label
  10455. * @param groupNb is the number of the groupcontaining the selector
  10456. * @param selectorNb is the number of the selector within a group to relabel
  10457. * */
  10458. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  10459. if (groupNb < 0 || groupNb >= this._groups.length) {
  10460. return;
  10461. }
  10462. var group = this._groups[groupNb];
  10463. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10464. return;
  10465. }
  10466. group._setSelectorLabel(selectorNb, label);
  10467. };
  10468. /** For a given group position remove the selector at the given position
  10469. * @param groupNb is the number of the group to remove the selector from
  10470. * @param selectorNb is the number of the selector within the group
  10471. */
  10472. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  10473. if (groupNb < 0 || groupNb >= this._groups.length) {
  10474. return;
  10475. }
  10476. var group = this._groups[groupNb];
  10477. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10478. return;
  10479. }
  10480. group.removeSelector(selectorNb);
  10481. };
  10482. /** For a given group position of correct type add a checkbox button
  10483. * @param groupNb is the number of the group to remove the selector from
  10484. * @param label is the label for the selector
  10485. * @param func is the function called when the Selector is checked
  10486. * @param checked is true when Selector is checked
  10487. */
  10488. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  10489. if (func === void 0) { func = function () { }; }
  10490. if (checked === void 0) { checked = false; }
  10491. if (groupNb < 0 || groupNb >= this._groups.length) {
  10492. return;
  10493. }
  10494. var group = this._groups[groupNb];
  10495. group.addCheckbox(label, func, checked);
  10496. };
  10497. /** For a given group position of correct type add a radio button
  10498. * @param groupNb is the number of the group to remove the selector from
  10499. * @param label is the label for the selector
  10500. * @param func is the function called when the Selector is checked
  10501. * @param checked is true when Selector is checked
  10502. */
  10503. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  10504. if (func === void 0) { func = function () { }; }
  10505. if (checked === void 0) { checked = false; }
  10506. if (groupNb < 0 || groupNb >= this._groups.length) {
  10507. return;
  10508. }
  10509. var group = this._groups[groupNb];
  10510. group.addRadio(label, func, checked);
  10511. };
  10512. /**
  10513. * For a given slider group add a slider
  10514. * @param groupNb is the number of the group to add the slider to
  10515. * @param label is the label for the Slider
  10516. * @param func is the function called when the Slider moves
  10517. * @param unit is a string describing the units used, eg degrees or metres
  10518. * @param min is the minimum value for the Slider
  10519. * @param max is the maximum value for the Slider
  10520. * @param value is the start value for the Slider between min and max
  10521. * @param onVal is the function used to format the value displayed, eg radians to degrees
  10522. */
  10523. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  10524. if (func === void 0) { func = function () { }; }
  10525. if (unit === void 0) { unit = "Units"; }
  10526. if (min === void 0) { min = 0; }
  10527. if (max === void 0) { max = 0; }
  10528. if (value === void 0) { value = 0; }
  10529. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  10530. if (groupNb < 0 || groupNb >= this._groups.length) {
  10531. return;
  10532. }
  10533. var group = this._groups[groupNb];
  10534. group.addSlider(label, func, unit, min, max, value, onVal);
  10535. };
  10536. return SelectionPanel;
  10537. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10538. /***/ }),
  10539. /***/ "./2D/controls/sliders/baseSlider.ts":
  10540. /*!*******************************************!*\
  10541. !*** ./2D/controls/sliders/baseSlider.ts ***!
  10542. \*******************************************/
  10543. /*! exports provided: BaseSlider */
  10544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10545. "use strict";
  10546. __webpack_require__.r(__webpack_exports__);
  10547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  10548. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10549. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  10550. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10551. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10552. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10553. /**
  10554. * Class used to create slider controls
  10555. */
  10556. var BaseSlider = /** @class */ (function (_super) {
  10557. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  10558. /**
  10559. * Creates a new BaseSlider
  10560. * @param name defines the control name
  10561. */
  10562. function BaseSlider(name) {
  10563. var _this = _super.call(this, name) || this;
  10564. _this.name = name;
  10565. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10566. _this._minimum = 0;
  10567. _this._maximum = 100;
  10568. _this._value = 50;
  10569. _this._isVertical = false;
  10570. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10571. _this._isThumbClamped = false;
  10572. _this._displayThumb = true;
  10573. _this._step = 0;
  10574. _this._lastPointerDownID = -1;
  10575. // Shared rendering info
  10576. _this._effectiveBarOffset = 0;
  10577. /** Observable raised when the sldier value changes */
  10578. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10579. // Events
  10580. _this._pointerIsDown = false;
  10581. _this.isPointerBlocker = true;
  10582. return _this;
  10583. }
  10584. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10585. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10586. get: function () {
  10587. return this._displayThumb;
  10588. },
  10589. set: function (value) {
  10590. if (this._displayThumb === value) {
  10591. return;
  10592. }
  10593. this._displayThumb = value;
  10594. this._markAsDirty();
  10595. },
  10596. enumerable: true,
  10597. configurable: true
  10598. });
  10599. Object.defineProperty(BaseSlider.prototype, "step", {
  10600. /** Gets or sets a step to apply to values (0 by default) */
  10601. get: function () {
  10602. return this._step;
  10603. },
  10604. set: function (value) {
  10605. if (this._step === value) {
  10606. return;
  10607. }
  10608. this._step = value;
  10609. this._markAsDirty();
  10610. },
  10611. enumerable: true,
  10612. configurable: true
  10613. });
  10614. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10615. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10616. get: function () {
  10617. return this._barOffset.toString(this._host);
  10618. },
  10619. set: function (value) {
  10620. if (this._barOffset.toString(this._host) === value) {
  10621. return;
  10622. }
  10623. if (this._barOffset.fromString(value)) {
  10624. this._markAsDirty();
  10625. }
  10626. },
  10627. enumerable: true,
  10628. configurable: true
  10629. });
  10630. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10631. /** Gets main bar offset in pixels*/
  10632. get: function () {
  10633. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10634. },
  10635. enumerable: true,
  10636. configurable: true
  10637. });
  10638. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10639. /** Gets or sets thumb width */
  10640. get: function () {
  10641. return this._thumbWidth.toString(this._host);
  10642. },
  10643. set: function (value) {
  10644. if (this._thumbWidth.toString(this._host) === value) {
  10645. return;
  10646. }
  10647. if (this._thumbWidth.fromString(value)) {
  10648. this._markAsDirty();
  10649. }
  10650. },
  10651. enumerable: true,
  10652. configurable: true
  10653. });
  10654. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10655. /** Gets thumb width in pixels */
  10656. get: function () {
  10657. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10658. },
  10659. enumerable: true,
  10660. configurable: true
  10661. });
  10662. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10663. /** Gets or sets minimum value */
  10664. get: function () {
  10665. return this._minimum;
  10666. },
  10667. set: function (value) {
  10668. if (this._minimum === value) {
  10669. return;
  10670. }
  10671. this._minimum = value;
  10672. this._markAsDirty();
  10673. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10674. },
  10675. enumerable: true,
  10676. configurable: true
  10677. });
  10678. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10679. /** Gets or sets maximum value */
  10680. get: function () {
  10681. return this._maximum;
  10682. },
  10683. set: function (value) {
  10684. if (this._maximum === value) {
  10685. return;
  10686. }
  10687. this._maximum = value;
  10688. this._markAsDirty();
  10689. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10690. },
  10691. enumerable: true,
  10692. configurable: true
  10693. });
  10694. Object.defineProperty(BaseSlider.prototype, "value", {
  10695. /** Gets or sets current value */
  10696. get: function () {
  10697. return this._value;
  10698. },
  10699. set: function (value) {
  10700. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10701. if (this._value === value) {
  10702. return;
  10703. }
  10704. this._value = value;
  10705. this._markAsDirty();
  10706. this.onValueChangedObservable.notifyObservers(this._value);
  10707. },
  10708. enumerable: true,
  10709. configurable: true
  10710. });
  10711. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10712. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10713. get: function () {
  10714. return this._isVertical;
  10715. },
  10716. set: function (value) {
  10717. if (this._isVertical === value) {
  10718. return;
  10719. }
  10720. this._isVertical = value;
  10721. this._markAsDirty();
  10722. },
  10723. enumerable: true,
  10724. configurable: true
  10725. });
  10726. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10727. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10728. get: function () {
  10729. return this._isThumbClamped;
  10730. },
  10731. set: function (value) {
  10732. if (this._isThumbClamped === value) {
  10733. return;
  10734. }
  10735. this._isThumbClamped = value;
  10736. this._markAsDirty();
  10737. },
  10738. enumerable: true,
  10739. configurable: true
  10740. });
  10741. BaseSlider.prototype._getTypeName = function () {
  10742. return "BaseSlider";
  10743. };
  10744. BaseSlider.prototype._getThumbPosition = function () {
  10745. if (this.isVertical) {
  10746. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10747. }
  10748. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10749. };
  10750. BaseSlider.prototype._getThumbThickness = function (type) {
  10751. var thumbThickness = 0;
  10752. switch (type) {
  10753. case "circle":
  10754. if (this._thumbWidth.isPixel) {
  10755. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10756. }
  10757. else {
  10758. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10759. }
  10760. break;
  10761. case "rectangle":
  10762. if (this._thumbWidth.isPixel) {
  10763. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10764. }
  10765. else {
  10766. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10767. }
  10768. }
  10769. return thumbThickness;
  10770. };
  10771. BaseSlider.prototype._prepareRenderingData = function (type) {
  10772. // Main bar
  10773. this._effectiveBarOffset = 0;
  10774. this._renderLeft = this._currentMeasure.left;
  10775. this._renderTop = this._currentMeasure.top;
  10776. this._renderWidth = this._currentMeasure.width;
  10777. this._renderHeight = this._currentMeasure.height;
  10778. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10779. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10780. this._effectiveThumbThickness = this._getThumbThickness(type);
  10781. if (this.displayThumb) {
  10782. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10783. }
  10784. //throw error when height is less than width for vertical slider
  10785. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10786. console.error("Height should be greater than width");
  10787. return;
  10788. }
  10789. if (this._barOffset.isPixel) {
  10790. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10791. }
  10792. else {
  10793. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10794. }
  10795. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10796. if (this.isVertical) {
  10797. this._renderLeft += this._effectiveBarOffset;
  10798. if (!this.isThumbClamped && this.displayThumb) {
  10799. this._renderTop += (this._effectiveThumbThickness / 2);
  10800. }
  10801. this._renderHeight = this._backgroundBoxLength;
  10802. this._renderWidth = this._backgroundBoxThickness;
  10803. }
  10804. else {
  10805. this._renderTop += this._effectiveBarOffset;
  10806. if (!this.isThumbClamped && this.displayThumb) {
  10807. this._renderLeft += (this._effectiveThumbThickness / 2);
  10808. }
  10809. this._renderHeight = this._backgroundBoxThickness;
  10810. this._renderWidth = this._backgroundBoxLength;
  10811. }
  10812. };
  10813. /** @hidden */
  10814. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10815. if (this.rotation != 0) {
  10816. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10817. x = this._transformedPosition.x;
  10818. y = this._transformedPosition.y;
  10819. }
  10820. var value;
  10821. if (this._isVertical) {
  10822. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10823. }
  10824. else {
  10825. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10826. }
  10827. var mult = (1 / this._step) | 0;
  10828. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10829. };
  10830. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10831. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10832. return false;
  10833. }
  10834. this._pointerIsDown = true;
  10835. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10836. this._host._capturingControl[pointerId] = this;
  10837. this._lastPointerDownID = pointerId;
  10838. return true;
  10839. };
  10840. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10841. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10842. if (pointerId != this._lastPointerDownID) {
  10843. return;
  10844. }
  10845. if (this._pointerIsDown) {
  10846. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10847. }
  10848. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10849. };
  10850. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10851. this._pointerIsDown = false;
  10852. delete this._host._capturingControl[pointerId];
  10853. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10854. };
  10855. return BaseSlider;
  10856. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10857. /***/ }),
  10858. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10859. /*!*************************************************!*\
  10860. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10861. \*************************************************/
  10862. /*! exports provided: ImageBasedSlider */
  10863. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10864. "use strict";
  10865. __webpack_require__.r(__webpack_exports__);
  10866. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10867. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10868. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10869. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10870. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  10871. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10872. /**
  10873. * Class used to create slider controls based on images
  10874. */
  10875. var ImageBasedSlider = /** @class */ (function (_super) {
  10876. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  10877. /**
  10878. * Creates a new ImageBasedSlider
  10879. * @param name defines the control name
  10880. */
  10881. function ImageBasedSlider(name) {
  10882. var _this = _super.call(this, name) || this;
  10883. _this.name = name;
  10884. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10885. return _this;
  10886. }
  10887. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10888. get: function () {
  10889. return this._displayThumb && this.thumbImage != null;
  10890. },
  10891. set: function (value) {
  10892. if (this._displayThumb === value) {
  10893. return;
  10894. }
  10895. this._displayThumb = value;
  10896. this._markAsDirty();
  10897. },
  10898. enumerable: true,
  10899. configurable: true
  10900. });
  10901. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10902. /**
  10903. * Gets or sets the image used to render the background
  10904. */
  10905. get: function () {
  10906. return this._backgroundImage;
  10907. },
  10908. set: function (value) {
  10909. var _this = this;
  10910. if (this._backgroundImage === value) {
  10911. return;
  10912. }
  10913. this._backgroundImage = value;
  10914. if (value && !value.isLoaded) {
  10915. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10916. }
  10917. this._markAsDirty();
  10918. },
  10919. enumerable: true,
  10920. configurable: true
  10921. });
  10922. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10923. /**
  10924. * Gets or sets the image used to render the value bar
  10925. */
  10926. get: function () {
  10927. return this._valueBarImage;
  10928. },
  10929. set: function (value) {
  10930. var _this = this;
  10931. if (this._valueBarImage === value) {
  10932. return;
  10933. }
  10934. this._valueBarImage = value;
  10935. if (value && !value.isLoaded) {
  10936. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10937. }
  10938. this._markAsDirty();
  10939. },
  10940. enumerable: true,
  10941. configurable: true
  10942. });
  10943. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10944. /**
  10945. * Gets or sets the image used to render the thumb
  10946. */
  10947. get: function () {
  10948. return this._thumbImage;
  10949. },
  10950. set: function (value) {
  10951. var _this = this;
  10952. if (this._thumbImage === value) {
  10953. return;
  10954. }
  10955. this._thumbImage = value;
  10956. if (value && !value.isLoaded) {
  10957. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10958. }
  10959. this._markAsDirty();
  10960. },
  10961. enumerable: true,
  10962. configurable: true
  10963. });
  10964. ImageBasedSlider.prototype._getTypeName = function () {
  10965. return "ImageBasedSlider";
  10966. };
  10967. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  10968. context.save();
  10969. this._applyStates(context);
  10970. this._prepareRenderingData("rectangle");
  10971. var thumbPosition = this._getThumbPosition();
  10972. var left = this._renderLeft;
  10973. var top = this._renderTop;
  10974. var width = this._renderWidth;
  10975. var height = this._renderHeight;
  10976. // Background
  10977. if (this._backgroundImage) {
  10978. this._tempMeasure.copyFromFloats(left, top, width, height);
  10979. if (this.isThumbClamped && this.displayThumb) {
  10980. if (this.isVertical) {
  10981. this._tempMeasure.height += this._effectiveThumbThickness;
  10982. }
  10983. else {
  10984. this._tempMeasure.width += this._effectiveThumbThickness;
  10985. }
  10986. }
  10987. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10988. this._backgroundImage._draw(context);
  10989. }
  10990. // Bar
  10991. if (this._valueBarImage) {
  10992. if (this.isVertical) {
  10993. if (this.isThumbClamped && this.displayThumb) {
  10994. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10995. }
  10996. else {
  10997. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10998. }
  10999. }
  11000. else {
  11001. if (this.isThumbClamped && this.displayThumb) {
  11002. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  11003. }
  11004. else {
  11005. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  11006. }
  11007. }
  11008. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  11009. this._valueBarImage._draw(context);
  11010. }
  11011. // Thumb
  11012. if (this.displayThumb) {
  11013. if (this.isVertical) {
  11014. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11015. }
  11016. else {
  11017. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11018. }
  11019. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11020. this._thumbImage._draw(context);
  11021. }
  11022. context.restore();
  11023. };
  11024. return ImageBasedSlider;
  11025. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11026. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  11027. /***/ }),
  11028. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  11029. /*!***********************************************!*\
  11030. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  11031. \***********************************************/
  11032. /*! exports provided: ImageScrollBar */
  11033. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11034. "use strict";
  11035. __webpack_require__.r(__webpack_exports__);
  11036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  11037. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11038. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11039. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11040. /**
  11041. * Class used to create slider controls
  11042. */
  11043. var ImageScrollBar = /** @class */ (function (_super) {
  11044. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  11045. /**
  11046. * Creates a new ImageScrollBar
  11047. * @param name defines the control name
  11048. */
  11049. function ImageScrollBar(name) {
  11050. var _this = _super.call(this, name) || this;
  11051. _this.name = name;
  11052. _this._thumbLength = 0.5;
  11053. _this._thumbHeight = 1;
  11054. _this._barImageHeight = 1;
  11055. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11056. /** Number of 90° rotation to apply on the images when in vertical mode */
  11057. _this.num90RotationInVerticalMode = 1;
  11058. return _this;
  11059. }
  11060. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  11061. /**
  11062. * Gets or sets the image used to render the background for horizontal bar
  11063. */
  11064. get: function () {
  11065. return this._backgroundBaseImage;
  11066. },
  11067. set: function (value) {
  11068. var _this = this;
  11069. if (this._backgroundBaseImage === value) {
  11070. return;
  11071. }
  11072. this._backgroundBaseImage = value;
  11073. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11074. if (!value.isLoaded) {
  11075. value.onImageLoadedObservable.addOnce(function () {
  11076. var rotatedValue = value._rotate90(_this.num90RotationInVerticalMode, true);
  11077. _this._backgroundImage = rotatedValue;
  11078. if (!rotatedValue.isLoaded) {
  11079. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11080. _this._markAsDirty();
  11081. });
  11082. }
  11083. _this._markAsDirty();
  11084. });
  11085. }
  11086. else {
  11087. this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);
  11088. this._markAsDirty();
  11089. }
  11090. }
  11091. else {
  11092. this._backgroundImage = value;
  11093. if (value && !value.isLoaded) {
  11094. value.onImageLoadedObservable.addOnce(function () {
  11095. _this._markAsDirty();
  11096. });
  11097. }
  11098. this._markAsDirty();
  11099. }
  11100. },
  11101. enumerable: true,
  11102. configurable: true
  11103. });
  11104. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  11105. /**
  11106. * Gets or sets the image used to render the thumb
  11107. */
  11108. get: function () {
  11109. return this._thumbBaseImage;
  11110. },
  11111. set: function (value) {
  11112. var _this = this;
  11113. if (this._thumbBaseImage === value) {
  11114. return;
  11115. }
  11116. this._thumbBaseImage = value;
  11117. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11118. if (!value.isLoaded) {
  11119. value.onImageLoadedObservable.addOnce(function () {
  11120. var rotatedValue = value._rotate90(-_this.num90RotationInVerticalMode, true);
  11121. _this._thumbImage = rotatedValue;
  11122. if (!rotatedValue.isLoaded) {
  11123. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11124. _this._markAsDirty();
  11125. });
  11126. }
  11127. _this._markAsDirty();
  11128. });
  11129. }
  11130. else {
  11131. this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);
  11132. this._markAsDirty();
  11133. }
  11134. }
  11135. else {
  11136. this._thumbImage = value;
  11137. if (value && !value.isLoaded) {
  11138. value.onImageLoadedObservable.addOnce(function () {
  11139. _this._markAsDirty();
  11140. });
  11141. }
  11142. this._markAsDirty();
  11143. }
  11144. },
  11145. enumerable: true,
  11146. configurable: true
  11147. });
  11148. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  11149. /**
  11150. * Gets or sets the length of the thumb
  11151. */
  11152. get: function () {
  11153. return this._thumbLength;
  11154. },
  11155. set: function (value) {
  11156. if (this._thumbLength === value) {
  11157. return;
  11158. }
  11159. this._thumbLength = value;
  11160. this._markAsDirty();
  11161. },
  11162. enumerable: true,
  11163. configurable: true
  11164. });
  11165. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  11166. /**
  11167. * Gets or sets the height of the thumb
  11168. */
  11169. get: function () {
  11170. return this._thumbHeight;
  11171. },
  11172. set: function (value) {
  11173. if (this._thumbLength === value) {
  11174. return;
  11175. }
  11176. this._thumbHeight = value;
  11177. this._markAsDirty();
  11178. },
  11179. enumerable: true,
  11180. configurable: true
  11181. });
  11182. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  11183. /**
  11184. * Gets or sets the height of the bar image
  11185. */
  11186. get: function () {
  11187. return this._barImageHeight;
  11188. },
  11189. set: function (value) {
  11190. if (this._barImageHeight === value) {
  11191. return;
  11192. }
  11193. this._barImageHeight = value;
  11194. this._markAsDirty();
  11195. },
  11196. enumerable: true,
  11197. configurable: true
  11198. });
  11199. ImageScrollBar.prototype._getTypeName = function () {
  11200. return "ImageScrollBar";
  11201. };
  11202. ImageScrollBar.prototype._getThumbThickness = function () {
  11203. var thumbThickness = 0;
  11204. if (this._thumbWidth.isPixel) {
  11205. thumbThickness = this._thumbWidth.getValue(this._host);
  11206. }
  11207. else {
  11208. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11209. }
  11210. return thumbThickness;
  11211. };
  11212. ImageScrollBar.prototype._draw = function (context) {
  11213. context.save();
  11214. this._applyStates(context);
  11215. this._prepareRenderingData("rectangle");
  11216. var thumbPosition = this._getThumbPosition();
  11217. var left = this._renderLeft;
  11218. var top = this._renderTop;
  11219. var width = this._renderWidth;
  11220. var height = this._renderHeight;
  11221. // Background
  11222. if (this._backgroundImage) {
  11223. this._tempMeasure.copyFromFloats(left, top, width, height);
  11224. if (this.isVertical) {
  11225. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  11226. this._tempMeasure.height += this._effectiveThumbThickness;
  11227. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11228. }
  11229. else {
  11230. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  11231. this._tempMeasure.width += this._effectiveThumbThickness;
  11232. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11233. }
  11234. this._backgroundImage._draw(context);
  11235. }
  11236. // Thumb
  11237. if (this.isVertical) {
  11238. 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);
  11239. }
  11240. else {
  11241. 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);
  11242. }
  11243. if (this._thumbImage) {
  11244. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11245. this._thumbImage._draw(context);
  11246. }
  11247. context.restore();
  11248. };
  11249. /** @hidden */
  11250. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11251. if (this.rotation != 0) {
  11252. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11253. x = this._transformedPosition.x;
  11254. y = this._transformedPosition.y;
  11255. }
  11256. if (this._first) {
  11257. this._first = false;
  11258. this._originX = x;
  11259. this._originY = y;
  11260. // Check if move is required
  11261. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11262. if (this.isVertical) {
  11263. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11264. }
  11265. else {
  11266. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11267. }
  11268. }
  11269. }
  11270. // Delta mode
  11271. var delta = 0;
  11272. if (this.isVertical) {
  11273. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11274. }
  11275. else {
  11276. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11277. }
  11278. this.value += delta * (this.maximum - this.minimum);
  11279. this._originX = x;
  11280. this._originY = y;
  11281. };
  11282. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11283. this._first = true;
  11284. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11285. };
  11286. return ImageScrollBar;
  11287. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11288. /***/ }),
  11289. /***/ "./2D/controls/sliders/scrollBar.ts":
  11290. /*!******************************************!*\
  11291. !*** ./2D/controls/sliders/scrollBar.ts ***!
  11292. \******************************************/
  11293. /*! exports provided: ScrollBar */
  11294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11295. "use strict";
  11296. __webpack_require__.r(__webpack_exports__);
  11297. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  11298. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11299. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11300. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11301. /**
  11302. * Class used to create slider controls
  11303. */
  11304. var ScrollBar = /** @class */ (function (_super) {
  11305. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  11306. /**
  11307. * Creates a new Slider
  11308. * @param name defines the control name
  11309. */
  11310. function ScrollBar(name) {
  11311. var _this = _super.call(this, name) || this;
  11312. _this.name = name;
  11313. _this._background = "black";
  11314. _this._borderColor = "white";
  11315. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11316. return _this;
  11317. }
  11318. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  11319. /** Gets or sets border color */
  11320. get: function () {
  11321. return this._borderColor;
  11322. },
  11323. set: function (value) {
  11324. if (this._borderColor === value) {
  11325. return;
  11326. }
  11327. this._borderColor = value;
  11328. this._markAsDirty();
  11329. },
  11330. enumerable: true,
  11331. configurable: true
  11332. });
  11333. Object.defineProperty(ScrollBar.prototype, "background", {
  11334. /** Gets or sets background color */
  11335. get: function () {
  11336. return this._background;
  11337. },
  11338. set: function (value) {
  11339. if (this._background === value) {
  11340. return;
  11341. }
  11342. this._background = value;
  11343. this._markAsDirty();
  11344. },
  11345. enumerable: true,
  11346. configurable: true
  11347. });
  11348. ScrollBar.prototype._getTypeName = function () {
  11349. return "Scrollbar";
  11350. };
  11351. ScrollBar.prototype._getThumbThickness = function () {
  11352. var thumbThickness = 0;
  11353. if (this._thumbWidth.isPixel) {
  11354. thumbThickness = this._thumbWidth.getValue(this._host);
  11355. }
  11356. else {
  11357. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11358. }
  11359. return thumbThickness;
  11360. };
  11361. ScrollBar.prototype._draw = function (context) {
  11362. context.save();
  11363. this._applyStates(context);
  11364. this._prepareRenderingData("rectangle");
  11365. var left = this._renderLeft;
  11366. var thumbPosition = this._getThumbPosition();
  11367. context.fillStyle = this._background;
  11368. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  11369. // Value bar
  11370. context.fillStyle = this.color;
  11371. // Thumb
  11372. if (this.isVertical) {
  11373. this._tempMeasure.left = left - this._effectiveBarOffset;
  11374. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  11375. this._tempMeasure.width = this._currentMeasure.width;
  11376. this._tempMeasure.height = this._effectiveThumbThickness;
  11377. }
  11378. else {
  11379. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  11380. this._tempMeasure.top = this._currentMeasure.top;
  11381. this._tempMeasure.width = this._effectiveThumbThickness;
  11382. this._tempMeasure.height = this._currentMeasure.height;
  11383. }
  11384. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  11385. context.restore();
  11386. };
  11387. /** @hidden */
  11388. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11389. if (this.rotation != 0) {
  11390. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11391. x = this._transformedPosition.x;
  11392. y = this._transformedPosition.y;
  11393. }
  11394. if (this._first) {
  11395. this._first = false;
  11396. this._originX = x;
  11397. this._originY = y;
  11398. // Check if move is required
  11399. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11400. if (this.isVertical) {
  11401. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11402. }
  11403. else {
  11404. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11405. }
  11406. }
  11407. }
  11408. // Delta mode
  11409. var delta = 0;
  11410. if (this.isVertical) {
  11411. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11412. }
  11413. else {
  11414. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11415. }
  11416. this.value += delta * (this.maximum - this.minimum);
  11417. this._originX = x;
  11418. this._originY = y;
  11419. };
  11420. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11421. this._first = true;
  11422. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11423. };
  11424. return ScrollBar;
  11425. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11426. /***/ }),
  11427. /***/ "./2D/controls/sliders/slider.ts":
  11428. /*!***************************************!*\
  11429. !*** ./2D/controls/sliders/slider.ts ***!
  11430. \***************************************/
  11431. /*! exports provided: Slider */
  11432. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11433. "use strict";
  11434. __webpack_require__.r(__webpack_exports__);
  11435. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  11436. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11437. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11438. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  11439. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  11440. /**
  11441. * Class used to create slider controls
  11442. */
  11443. var Slider = /** @class */ (function (_super) {
  11444. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  11445. /**
  11446. * Creates a new Slider
  11447. * @param name defines the control name
  11448. */
  11449. function Slider(name) {
  11450. var _this = _super.call(this, name) || this;
  11451. _this.name = name;
  11452. _this._background = "black";
  11453. _this._borderColor = "white";
  11454. _this._isThumbCircle = false;
  11455. _this._displayValueBar = true;
  11456. return _this;
  11457. }
  11458. Object.defineProperty(Slider.prototype, "displayValueBar", {
  11459. /** Gets or sets a boolean indicating if the value bar must be rendered */
  11460. get: function () {
  11461. return this._displayValueBar;
  11462. },
  11463. set: function (value) {
  11464. if (this._displayValueBar === value) {
  11465. return;
  11466. }
  11467. this._displayValueBar = value;
  11468. this._markAsDirty();
  11469. },
  11470. enumerable: true,
  11471. configurable: true
  11472. });
  11473. Object.defineProperty(Slider.prototype, "borderColor", {
  11474. /** Gets or sets border color */
  11475. get: function () {
  11476. return this._borderColor;
  11477. },
  11478. set: function (value) {
  11479. if (this._borderColor === value) {
  11480. return;
  11481. }
  11482. this._borderColor = value;
  11483. this._markAsDirty();
  11484. },
  11485. enumerable: true,
  11486. configurable: true
  11487. });
  11488. Object.defineProperty(Slider.prototype, "background", {
  11489. /** Gets or sets background color */
  11490. get: function () {
  11491. return this._background;
  11492. },
  11493. set: function (value) {
  11494. if (this._background === value) {
  11495. return;
  11496. }
  11497. this._background = value;
  11498. this._markAsDirty();
  11499. },
  11500. enumerable: true,
  11501. configurable: true
  11502. });
  11503. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  11504. /** Gets or sets a boolean indicating if the thumb should be round or square */
  11505. get: function () {
  11506. return this._isThumbCircle;
  11507. },
  11508. set: function (value) {
  11509. if (this._isThumbCircle === value) {
  11510. return;
  11511. }
  11512. this._isThumbCircle = value;
  11513. this._markAsDirty();
  11514. },
  11515. enumerable: true,
  11516. configurable: true
  11517. });
  11518. Slider.prototype._getTypeName = function () {
  11519. return "Slider";
  11520. };
  11521. Slider.prototype._draw = function (context, invalidatedRectangle) {
  11522. context.save();
  11523. this._applyStates(context);
  11524. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  11525. var left = this._renderLeft;
  11526. var top = this._renderTop;
  11527. var width = this._renderWidth;
  11528. var height = this._renderHeight;
  11529. var radius = 0;
  11530. if (this.isThumbClamped && this.isThumbCircle) {
  11531. if (this.isVertical) {
  11532. top += (this._effectiveThumbThickness / 2);
  11533. }
  11534. else {
  11535. left += (this._effectiveThumbThickness / 2);
  11536. }
  11537. radius = this._backgroundBoxThickness / 2;
  11538. }
  11539. else {
  11540. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  11541. }
  11542. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11543. context.shadowColor = this.shadowColor;
  11544. context.shadowBlur = this.shadowBlur;
  11545. context.shadowOffsetX = this.shadowOffsetX;
  11546. context.shadowOffsetY = this.shadowOffsetY;
  11547. }
  11548. var thumbPosition = this._getThumbPosition();
  11549. context.fillStyle = this._background;
  11550. if (this.isVertical) {
  11551. if (this.isThumbClamped) {
  11552. if (this.isThumbCircle) {
  11553. context.beginPath();
  11554. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  11555. context.fill();
  11556. context.fillRect(left, top, width, height);
  11557. }
  11558. else {
  11559. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  11560. }
  11561. }
  11562. else {
  11563. context.fillRect(left, top, width, height);
  11564. }
  11565. }
  11566. else {
  11567. if (this.isThumbClamped) {
  11568. if (this.isThumbCircle) {
  11569. context.beginPath();
  11570. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11571. context.fill();
  11572. context.fillRect(left, top, width, height);
  11573. }
  11574. else {
  11575. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  11576. }
  11577. }
  11578. else {
  11579. context.fillRect(left, top, width, height);
  11580. }
  11581. }
  11582. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11583. context.shadowBlur = 0;
  11584. context.shadowOffsetX = 0;
  11585. context.shadowOffsetY = 0;
  11586. }
  11587. // Value bar
  11588. context.fillStyle = this.color;
  11589. if (this._displayValueBar) {
  11590. if (this.isVertical) {
  11591. if (this.isThumbClamped) {
  11592. if (this.isThumbCircle) {
  11593. context.beginPath();
  11594. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  11595. context.fill();
  11596. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11597. }
  11598. else {
  11599. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11600. }
  11601. }
  11602. else {
  11603. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11604. }
  11605. }
  11606. else {
  11607. if (this.isThumbClamped) {
  11608. if (this.isThumbCircle) {
  11609. context.beginPath();
  11610. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  11611. context.fill();
  11612. context.fillRect(left, top, thumbPosition, height);
  11613. }
  11614. else {
  11615. context.fillRect(left, top, thumbPosition, height);
  11616. }
  11617. }
  11618. else {
  11619. context.fillRect(left, top, thumbPosition, height);
  11620. }
  11621. }
  11622. }
  11623. // Thumb
  11624. if (this.displayThumb) {
  11625. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11626. context.shadowColor = this.shadowColor;
  11627. context.shadowBlur = this.shadowBlur;
  11628. context.shadowOffsetX = this.shadowOffsetX;
  11629. context.shadowOffsetY = this.shadowOffsetY;
  11630. }
  11631. if (this._isThumbCircle) {
  11632. context.beginPath();
  11633. if (this.isVertical) {
  11634. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11635. }
  11636. else {
  11637. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11638. }
  11639. context.fill();
  11640. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11641. context.shadowBlur = 0;
  11642. context.shadowOffsetX = 0;
  11643. context.shadowOffsetY = 0;
  11644. }
  11645. context.strokeStyle = this._borderColor;
  11646. context.stroke();
  11647. }
  11648. else {
  11649. if (this.isVertical) {
  11650. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11651. }
  11652. else {
  11653. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11654. }
  11655. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11656. context.shadowBlur = 0;
  11657. context.shadowOffsetX = 0;
  11658. context.shadowOffsetY = 0;
  11659. }
  11660. context.strokeStyle = this._borderColor;
  11661. if (this.isVertical) {
  11662. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11663. }
  11664. else {
  11665. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11666. }
  11667. }
  11668. }
  11669. context.restore();
  11670. };
  11671. return Slider;
  11672. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11673. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11674. /***/ }),
  11675. /***/ "./2D/controls/stackPanel.ts":
  11676. /*!***********************************!*\
  11677. !*** ./2D/controls/stackPanel.ts ***!
  11678. \***********************************/
  11679. /*! exports provided: StackPanel */
  11680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11681. "use strict";
  11682. __webpack_require__.r(__webpack_exports__);
  11683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11684. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11685. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  11686. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11687. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11688. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11689. /**
  11690. * Class used to create a 2D stack panel container
  11691. */
  11692. var StackPanel = /** @class */ (function (_super) {
  11693. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11694. /**
  11695. * Creates a new StackPanel
  11696. * @param name defines control name
  11697. */
  11698. function StackPanel(name) {
  11699. var _this = _super.call(this, name) || this;
  11700. _this.name = name;
  11701. _this._isVertical = true;
  11702. _this._manualWidth = false;
  11703. _this._manualHeight = false;
  11704. _this._doNotTrackManualChanges = false;
  11705. /**
  11706. * Gets or sets a boolean indicating that layou warnings should be ignored
  11707. */
  11708. _this.ignoreLayoutWarnings = false;
  11709. return _this;
  11710. }
  11711. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11712. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11713. get: function () {
  11714. return this._isVertical;
  11715. },
  11716. set: function (value) {
  11717. if (this._isVertical === value) {
  11718. return;
  11719. }
  11720. this._isVertical = value;
  11721. this._markAsDirty();
  11722. },
  11723. enumerable: true,
  11724. configurable: true
  11725. });
  11726. Object.defineProperty(StackPanel.prototype, "width", {
  11727. get: function () {
  11728. return this._width.toString(this._host);
  11729. },
  11730. /**
  11731. * Gets or sets panel width.
  11732. * This value should not be set when in horizontal mode as it will be computed automatically
  11733. */
  11734. set: function (value) {
  11735. if (!this._doNotTrackManualChanges) {
  11736. this._manualWidth = true;
  11737. }
  11738. if (this._width.toString(this._host) === value) {
  11739. return;
  11740. }
  11741. if (this._width.fromString(value)) {
  11742. this._markAsDirty();
  11743. }
  11744. },
  11745. enumerable: true,
  11746. configurable: true
  11747. });
  11748. Object.defineProperty(StackPanel.prototype, "height", {
  11749. get: function () {
  11750. return this._height.toString(this._host);
  11751. },
  11752. /**
  11753. * Gets or sets panel height.
  11754. * This value should not be set when in vertical mode as it will be computed automatically
  11755. */
  11756. set: function (value) {
  11757. if (!this._doNotTrackManualChanges) {
  11758. this._manualHeight = true;
  11759. }
  11760. if (this._height.toString(this._host) === value) {
  11761. return;
  11762. }
  11763. if (this._height.fromString(value)) {
  11764. this._markAsDirty();
  11765. }
  11766. },
  11767. enumerable: true,
  11768. configurable: true
  11769. });
  11770. StackPanel.prototype._getTypeName = function () {
  11771. return "StackPanel";
  11772. };
  11773. /** @hidden */
  11774. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11775. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11776. var child = _a[_i];
  11777. if (this._isVertical) {
  11778. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11779. }
  11780. else {
  11781. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11782. }
  11783. }
  11784. _super.prototype._preMeasure.call(this, parentMeasure, context);
  11785. };
  11786. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  11787. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  11788. this._measureForChildren.copyFrom(parentMeasure);
  11789. this._measureForChildren.left = this._currentMeasure.left;
  11790. this._measureForChildren.top = this._currentMeasure.top;
  11791. if (!this.isVertical || this._manualWidth) {
  11792. this._measureForChildren.width = this._currentMeasure.width;
  11793. }
  11794. if (this.isVertical || this._manualHeight) {
  11795. this._measureForChildren.height = this._currentMeasure.height;
  11796. }
  11797. };
  11798. StackPanel.prototype._postMeasure = function () {
  11799. var stackWidth = 0;
  11800. var stackHeight = 0;
  11801. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11802. var child = _a[_i];
  11803. if (!child.isVisible || child.notRenderable) {
  11804. continue;
  11805. }
  11806. if (this._isVertical) {
  11807. if (child.top !== stackHeight + "px") {
  11808. child.top = stackHeight + "px";
  11809. this._rebuildLayout = true;
  11810. child._top.ignoreAdaptiveScaling = true;
  11811. }
  11812. if (child._height.isPercentage && !child._automaticSize) {
  11813. if (!this.ignoreLayoutWarnings) {
  11814. 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");
  11815. }
  11816. }
  11817. else {
  11818. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  11819. }
  11820. }
  11821. else {
  11822. if (child.left !== stackWidth + "px") {
  11823. child.left = stackWidth + "px";
  11824. this._rebuildLayout = true;
  11825. child._left.ignoreAdaptiveScaling = true;
  11826. }
  11827. if (child._width.isPercentage && !child._automaticSize) {
  11828. if (!this.ignoreLayoutWarnings) {
  11829. 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");
  11830. }
  11831. }
  11832. else {
  11833. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  11834. }
  11835. }
  11836. }
  11837. this._doNotTrackManualChanges = true;
  11838. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  11839. // User can now define their own height and width for stack panel.
  11840. var panelWidthChanged = false;
  11841. var panelHeightChanged = false;
  11842. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  11843. var previousHeight = this.height;
  11844. this.height = stackHeight + "px";
  11845. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  11846. }
  11847. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  11848. var previousWidth = this.width;
  11849. this.width = stackWidth + "px";
  11850. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  11851. }
  11852. if (panelHeightChanged) {
  11853. this._height.ignoreAdaptiveScaling = true;
  11854. }
  11855. if (panelWidthChanged) {
  11856. this._width.ignoreAdaptiveScaling = true;
  11857. }
  11858. this._doNotTrackManualChanges = false;
  11859. if (panelWidthChanged || panelHeightChanged) {
  11860. this._rebuildLayout = true;
  11861. }
  11862. _super.prototype._postMeasure.call(this);
  11863. };
  11864. return StackPanel;
  11865. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  11866. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  11867. /***/ }),
  11868. /***/ "./2D/controls/statics.ts":
  11869. /*!********************************!*\
  11870. !*** ./2D/controls/statics.ts ***!
  11871. \********************************/
  11872. /*! exports provided: name */
  11873. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11874. "use strict";
  11875. __webpack_require__.r(__webpack_exports__);
  11876. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  11877. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11878. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11879. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  11880. /**
  11881. * Forcing an export so that this code will execute
  11882. * @hidden
  11883. */
  11884. var name = "Statics";
  11885. /**
  11886. * Creates a stack panel that can be used to render headers
  11887. * @param control defines the control to associate with the header
  11888. * @param text defines the text of the header
  11889. * @param size defines the size of the header
  11890. * @param options defines options used to configure the header
  11891. * @returns a new StackPanel
  11892. */
  11893. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  11894. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  11895. var isHorizontal = options ? options.isHorizontal : true;
  11896. var controlFirst = options ? options.controlFirst : true;
  11897. panel.isVertical = !isHorizontal;
  11898. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  11899. header.text = text;
  11900. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11901. if (isHorizontal) {
  11902. header.width = size;
  11903. }
  11904. else {
  11905. header.height = size;
  11906. }
  11907. if (controlFirst) {
  11908. panel.addControl(control);
  11909. panel.addControl(header);
  11910. header.paddingLeft = "5px";
  11911. }
  11912. else {
  11913. panel.addControl(header);
  11914. panel.addControl(control);
  11915. header.paddingRight = "5px";
  11916. }
  11917. header.shadowBlur = control.shadowBlur;
  11918. header.shadowColor = control.shadowColor;
  11919. header.shadowOffsetX = control.shadowOffsetX;
  11920. header.shadowOffsetY = control.shadowOffsetY;
  11921. return panel;
  11922. };
  11923. /***/ }),
  11924. /***/ "./2D/controls/textBlock.ts":
  11925. /*!**********************************!*\
  11926. !*** ./2D/controls/textBlock.ts ***!
  11927. \**********************************/
  11928. /*! exports provided: TextWrapping, TextBlock */
  11929. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11930. "use strict";
  11931. __webpack_require__.r(__webpack_exports__);
  11932. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  11933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  11934. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11935. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  11936. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11937. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  11938. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11939. /**
  11940. * Enum that determines the text-wrapping mode to use.
  11941. */
  11942. var TextWrapping;
  11943. (function (TextWrapping) {
  11944. /**
  11945. * Clip the text when it's larger than Control.width; this is the default mode.
  11946. */
  11947. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  11948. /**
  11949. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  11950. */
  11951. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  11952. /**
  11953. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  11954. */
  11955. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  11956. })(TextWrapping || (TextWrapping = {}));
  11957. /**
  11958. * Class used to create text block control
  11959. */
  11960. var TextBlock = /** @class */ (function (_super) {
  11961. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  11962. /**
  11963. * Creates a new TextBlock object
  11964. * @param name defines the name of the control
  11965. * @param text defines the text to display (emptry string by default)
  11966. */
  11967. function TextBlock(
  11968. /**
  11969. * Defines the name of the control
  11970. */
  11971. name, text) {
  11972. if (text === void 0) { text = ""; }
  11973. var _this = _super.call(this, name) || this;
  11974. _this.name = name;
  11975. _this._text = "";
  11976. _this._textWrapping = TextWrapping.Clip;
  11977. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  11978. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  11979. _this._resizeToFit = false;
  11980. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  11981. _this._outlineWidth = 0;
  11982. _this._outlineColor = "white";
  11983. /**
  11984. * An event triggered after the text is changed
  11985. */
  11986. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11987. /**
  11988. * An event triggered after the text was broken up into lines
  11989. */
  11990. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11991. _this.text = text;
  11992. return _this;
  11993. }
  11994. Object.defineProperty(TextBlock.prototype, "lines", {
  11995. /**
  11996. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  11997. */
  11998. get: function () {
  11999. return this._lines;
  12000. },
  12001. enumerable: true,
  12002. configurable: true
  12003. });
  12004. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  12005. /**
  12006. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12007. */
  12008. get: function () {
  12009. return this._resizeToFit;
  12010. },
  12011. /**
  12012. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12013. */
  12014. set: function (value) {
  12015. if (this._resizeToFit === value) {
  12016. return;
  12017. }
  12018. this._resizeToFit = value;
  12019. if (this._resizeToFit) {
  12020. this._width.ignoreAdaptiveScaling = true;
  12021. this._height.ignoreAdaptiveScaling = true;
  12022. }
  12023. this._markAsDirty();
  12024. },
  12025. enumerable: true,
  12026. configurable: true
  12027. });
  12028. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  12029. /**
  12030. * Gets or sets a boolean indicating if text must be wrapped
  12031. */
  12032. get: function () {
  12033. return this._textWrapping;
  12034. },
  12035. /**
  12036. * Gets or sets a boolean indicating if text must be wrapped
  12037. */
  12038. set: function (value) {
  12039. if (this._textWrapping === value) {
  12040. return;
  12041. }
  12042. this._textWrapping = +value;
  12043. this._markAsDirty();
  12044. },
  12045. enumerable: true,
  12046. configurable: true
  12047. });
  12048. Object.defineProperty(TextBlock.prototype, "text", {
  12049. /**
  12050. * Gets or sets text to display
  12051. */
  12052. get: function () {
  12053. return this._text;
  12054. },
  12055. /**
  12056. * Gets or sets text to display
  12057. */
  12058. set: function (value) {
  12059. if (this._text === value) {
  12060. return;
  12061. }
  12062. this._text = value;
  12063. this._markAsDirty();
  12064. this.onTextChangedObservable.notifyObservers(this);
  12065. },
  12066. enumerable: true,
  12067. configurable: true
  12068. });
  12069. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  12070. /**
  12071. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12072. */
  12073. get: function () {
  12074. return this._textHorizontalAlignment;
  12075. },
  12076. /**
  12077. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12078. */
  12079. set: function (value) {
  12080. if (this._textHorizontalAlignment === value) {
  12081. return;
  12082. }
  12083. this._textHorizontalAlignment = value;
  12084. this._markAsDirty();
  12085. },
  12086. enumerable: true,
  12087. configurable: true
  12088. });
  12089. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  12090. /**
  12091. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12092. */
  12093. get: function () {
  12094. return this._textVerticalAlignment;
  12095. },
  12096. /**
  12097. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12098. */
  12099. set: function (value) {
  12100. if (this._textVerticalAlignment === value) {
  12101. return;
  12102. }
  12103. this._textVerticalAlignment = value;
  12104. this._markAsDirty();
  12105. },
  12106. enumerable: true,
  12107. configurable: true
  12108. });
  12109. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  12110. /**
  12111. * Gets or sets line spacing value
  12112. */
  12113. get: function () {
  12114. return this._lineSpacing.toString(this._host);
  12115. },
  12116. /**
  12117. * Gets or sets line spacing value
  12118. */
  12119. set: function (value) {
  12120. if (this._lineSpacing.fromString(value)) {
  12121. this._markAsDirty();
  12122. }
  12123. },
  12124. enumerable: true,
  12125. configurable: true
  12126. });
  12127. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  12128. /**
  12129. * Gets or sets outlineWidth of the text to display
  12130. */
  12131. get: function () {
  12132. return this._outlineWidth;
  12133. },
  12134. /**
  12135. * Gets or sets outlineWidth of the text to display
  12136. */
  12137. set: function (value) {
  12138. if (this._outlineWidth === value) {
  12139. return;
  12140. }
  12141. this._outlineWidth = value;
  12142. this._markAsDirty();
  12143. },
  12144. enumerable: true,
  12145. configurable: true
  12146. });
  12147. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  12148. /**
  12149. * Gets or sets outlineColor of the text to display
  12150. */
  12151. get: function () {
  12152. return this._outlineColor;
  12153. },
  12154. /**
  12155. * Gets or sets outlineColor of the text to display
  12156. */
  12157. set: function (value) {
  12158. if (this._outlineColor === value) {
  12159. return;
  12160. }
  12161. this._outlineColor = value;
  12162. this._markAsDirty();
  12163. },
  12164. enumerable: true,
  12165. configurable: true
  12166. });
  12167. TextBlock.prototype._getTypeName = function () {
  12168. return "TextBlock";
  12169. };
  12170. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  12171. if (!this._fontOffset) {
  12172. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  12173. }
  12174. _super.prototype._processMeasures.call(this, parentMeasure, context);
  12175. // Prepare lines
  12176. this._lines = this._breakLines(this._currentMeasure.width, context);
  12177. this.onLinesReadyObservable.notifyObservers(this);
  12178. var maxLineWidth = 0;
  12179. for (var i = 0; i < this._lines.length; i++) {
  12180. var line = this._lines[i];
  12181. if (line.width > maxLineWidth) {
  12182. maxLineWidth = line.width;
  12183. }
  12184. }
  12185. if (this._resizeToFit) {
  12186. if (this._textWrapping === TextWrapping.Clip) {
  12187. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  12188. if (newWidth !== this._width.internalValue) {
  12189. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12190. this._rebuildLayout = true;
  12191. }
  12192. }
  12193. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  12194. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12195. var lineSpacing = 0;
  12196. if (this._lineSpacing.isPixel) {
  12197. lineSpacing = this._lineSpacing.getValue(this._host);
  12198. }
  12199. else {
  12200. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12201. }
  12202. newHeight += (this._lines.length - 1) * lineSpacing;
  12203. }
  12204. if (newHeight !== this._height.internalValue) {
  12205. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12206. this._rebuildLayout = true;
  12207. }
  12208. }
  12209. };
  12210. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  12211. var width = this._currentMeasure.width;
  12212. var x = 0;
  12213. switch (this._textHorizontalAlignment) {
  12214. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  12215. x = 0;
  12216. break;
  12217. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  12218. x = width - textWidth;
  12219. break;
  12220. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  12221. x = (width - textWidth) / 2;
  12222. break;
  12223. }
  12224. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12225. context.shadowColor = this.shadowColor;
  12226. context.shadowBlur = this.shadowBlur;
  12227. context.shadowOffsetX = this.shadowOffsetX;
  12228. context.shadowOffsetY = this.shadowOffsetY;
  12229. }
  12230. if (this.outlineWidth) {
  12231. context.strokeText(text, this._currentMeasure.left + x, y);
  12232. }
  12233. context.fillText(text, this._currentMeasure.left + x, y);
  12234. };
  12235. /** @hidden */
  12236. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  12237. context.save();
  12238. this._applyStates(context);
  12239. // Render lines
  12240. this._renderLines(context);
  12241. context.restore();
  12242. };
  12243. TextBlock.prototype._applyStates = function (context) {
  12244. _super.prototype._applyStates.call(this, context);
  12245. if (this.outlineWidth) {
  12246. context.lineWidth = this.outlineWidth;
  12247. context.strokeStyle = this.outlineColor;
  12248. }
  12249. };
  12250. TextBlock.prototype._breakLines = function (refWidth, context) {
  12251. var lines = [];
  12252. var _lines = this.text.split("\n");
  12253. if (this._textWrapping === TextWrapping.Ellipsis) {
  12254. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  12255. var _line = _lines_1[_i];
  12256. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  12257. }
  12258. }
  12259. else if (this._textWrapping === TextWrapping.WordWrap) {
  12260. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  12261. var _line = _lines_2[_a];
  12262. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  12263. }
  12264. }
  12265. else {
  12266. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  12267. var _line = _lines_3[_b];
  12268. lines.push(this._parseLine(_line, context));
  12269. }
  12270. }
  12271. return lines;
  12272. };
  12273. TextBlock.prototype._parseLine = function (line, context) {
  12274. if (line === void 0) { line = ''; }
  12275. return { text: line, width: context.measureText(line).width };
  12276. };
  12277. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  12278. if (line === void 0) { line = ''; }
  12279. var lineWidth = context.measureText(line).width;
  12280. if (lineWidth > width) {
  12281. line += '…';
  12282. }
  12283. while (line.length > 2 && lineWidth > width) {
  12284. line = line.slice(0, -2) + '…';
  12285. lineWidth = context.measureText(line).width;
  12286. }
  12287. return { text: line, width: lineWidth };
  12288. };
  12289. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  12290. if (line === void 0) { line = ''; }
  12291. var lines = [];
  12292. var words = line.split(' ');
  12293. var lineWidth = 0;
  12294. for (var n = 0; n < words.length; n++) {
  12295. var testLine = n > 0 ? line + " " + words[n] : words[0];
  12296. var metrics = context.measureText(testLine);
  12297. var testWidth = metrics.width;
  12298. if (testWidth > width && n > 0) {
  12299. lines.push({ text: line, width: lineWidth });
  12300. line = words[n];
  12301. lineWidth = context.measureText(line).width;
  12302. }
  12303. else {
  12304. lineWidth = testWidth;
  12305. line = testLine;
  12306. }
  12307. }
  12308. lines.push({ text: line, width: lineWidth });
  12309. return lines;
  12310. };
  12311. TextBlock.prototype._renderLines = function (context) {
  12312. var height = this._currentMeasure.height;
  12313. var rootY = 0;
  12314. switch (this._textVerticalAlignment) {
  12315. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  12316. rootY = this._fontOffset.ascent;
  12317. break;
  12318. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  12319. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  12320. break;
  12321. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  12322. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  12323. break;
  12324. }
  12325. rootY += this._currentMeasure.top;
  12326. for (var i = 0; i < this._lines.length; i++) {
  12327. var line = this._lines[i];
  12328. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  12329. if (this._lineSpacing.isPixel) {
  12330. rootY += this._lineSpacing.getValue(this._host);
  12331. }
  12332. else {
  12333. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12334. }
  12335. }
  12336. this._drawText(line.text, line.width, rootY, context);
  12337. rootY += this._fontOffset.height;
  12338. }
  12339. };
  12340. /**
  12341. * Given a width constraint applied on the text block, find the expected height
  12342. * @returns expected height
  12343. */
  12344. TextBlock.prototype.computeExpectedHeight = function () {
  12345. if (this.text && this.widthInPixels) {
  12346. var context_1 = document.createElement('canvas').getContext('2d');
  12347. if (context_1) {
  12348. this._applyStates(context_1);
  12349. if (!this._fontOffset) {
  12350. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  12351. }
  12352. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  12353. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  12354. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12355. var lineSpacing = 0;
  12356. if (this._lineSpacing.isPixel) {
  12357. lineSpacing = this._lineSpacing.getValue(this._host);
  12358. }
  12359. else {
  12360. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12361. }
  12362. newHeight += (lines.length - 1) * lineSpacing;
  12363. }
  12364. return newHeight;
  12365. }
  12366. }
  12367. return 0;
  12368. };
  12369. TextBlock.prototype.dispose = function () {
  12370. _super.prototype.dispose.call(this);
  12371. this.onTextChangedObservable.clear();
  12372. };
  12373. return TextBlock;
  12374. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  12375. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  12376. /***/ }),
  12377. /***/ "./2D/controls/virtualKeyboard.ts":
  12378. /*!****************************************!*\
  12379. !*** ./2D/controls/virtualKeyboard.ts ***!
  12380. \****************************************/
  12381. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  12382. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12383. "use strict";
  12384. __webpack_require__.r(__webpack_exports__);
  12385. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  12386. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  12387. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12388. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12389. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12390. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12391. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  12392. /**
  12393. * Class used to store key control properties
  12394. */
  12395. var KeyPropertySet = /** @class */ (function () {
  12396. function KeyPropertySet() {
  12397. }
  12398. return KeyPropertySet;
  12399. }());
  12400. /**
  12401. * Class used to create virtual keyboard
  12402. */
  12403. var VirtualKeyboard = /** @class */ (function (_super) {
  12404. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  12405. function VirtualKeyboard() {
  12406. var _this = _super !== null && _super.apply(this, arguments) || this;
  12407. /** Observable raised when a key is pressed */
  12408. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12409. /** Gets or sets default key button width */
  12410. _this.defaultButtonWidth = "40px";
  12411. /** Gets or sets default key button height */
  12412. _this.defaultButtonHeight = "40px";
  12413. /** Gets or sets default key button left padding */
  12414. _this.defaultButtonPaddingLeft = "2px";
  12415. /** Gets or sets default key button right padding */
  12416. _this.defaultButtonPaddingRight = "2px";
  12417. /** Gets or sets default key button top padding */
  12418. _this.defaultButtonPaddingTop = "2px";
  12419. /** Gets or sets default key button bottom padding */
  12420. _this.defaultButtonPaddingBottom = "2px";
  12421. /** Gets or sets default key button foreground color */
  12422. _this.defaultButtonColor = "#DDD";
  12423. /** Gets or sets default key button background color */
  12424. _this.defaultButtonBackground = "#070707";
  12425. /** Gets or sets shift button foreground color */
  12426. _this.shiftButtonColor = "#7799FF";
  12427. /** Gets or sets shift button thickness*/
  12428. _this.selectedShiftThickness = 1;
  12429. /** Gets shift key state */
  12430. _this.shiftState = 0;
  12431. _this._currentlyConnectedInputText = null;
  12432. _this._connectedInputTexts = [];
  12433. _this._onKeyPressObserver = null;
  12434. return _this;
  12435. }
  12436. VirtualKeyboard.prototype._getTypeName = function () {
  12437. return "VirtualKeyboard";
  12438. };
  12439. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  12440. var _this = this;
  12441. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  12442. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  12443. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  12444. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  12445. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  12446. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  12447. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  12448. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  12449. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  12450. button.thickness = 0;
  12451. button.isFocusInvisible = true;
  12452. button.shadowColor = this.shadowColor;
  12453. button.shadowBlur = this.shadowBlur;
  12454. button.shadowOffsetX = this.shadowOffsetX;
  12455. button.shadowOffsetY = this.shadowOffsetY;
  12456. button.onPointerUpObservable.add(function () {
  12457. _this.onKeyPressObservable.notifyObservers(key);
  12458. });
  12459. return button;
  12460. };
  12461. /**
  12462. * Adds a new row of keys
  12463. * @param keys defines the list of keys to add
  12464. * @param propertySets defines the associated property sets
  12465. */
  12466. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  12467. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  12468. panel.isVertical = false;
  12469. panel.isFocusInvisible = true;
  12470. var maxKey = null;
  12471. for (var i = 0; i < keys.length; i++) {
  12472. var properties = null;
  12473. if (propertySets && propertySets.length === keys.length) {
  12474. properties = propertySets[i];
  12475. }
  12476. var key = this._createKey(keys[i], properties);
  12477. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  12478. maxKey = key;
  12479. }
  12480. panel.addControl(key);
  12481. }
  12482. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  12483. this.addControl(panel);
  12484. };
  12485. /**
  12486. * Set the shift key to a specific state
  12487. * @param shiftState defines the new shift state
  12488. */
  12489. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  12490. if (!this.children) {
  12491. return;
  12492. }
  12493. for (var i = 0; i < this.children.length; i++) {
  12494. var row = this.children[i];
  12495. if (!row || !row.children) {
  12496. continue;
  12497. }
  12498. var rowContainer = row;
  12499. for (var j = 0; j < rowContainer.children.length; j++) {
  12500. var button = rowContainer.children[j];
  12501. if (!button || !button.children[0]) {
  12502. continue;
  12503. }
  12504. var button_tblock = button.children[0];
  12505. if (button_tblock.text === "\u21E7") {
  12506. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  12507. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  12508. }
  12509. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  12510. }
  12511. }
  12512. };
  12513. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  12514. /** Gets the input text control currently attached to the keyboard */
  12515. get: function () {
  12516. return this._currentlyConnectedInputText;
  12517. },
  12518. enumerable: true,
  12519. configurable: true
  12520. });
  12521. /**
  12522. * Connects the keyboard with an input text control
  12523. *
  12524. * @param input defines the target control
  12525. */
  12526. VirtualKeyboard.prototype.connect = function (input) {
  12527. var _this = this;
  12528. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  12529. if (inputTextAlreadyConnected) {
  12530. return;
  12531. }
  12532. if (this._onKeyPressObserver === null) {
  12533. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  12534. if (!_this._currentlyConnectedInputText) {
  12535. return;
  12536. }
  12537. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  12538. switch (key) {
  12539. case "\u21E7":
  12540. _this.shiftState++;
  12541. if (_this.shiftState > 2) {
  12542. _this.shiftState = 0;
  12543. }
  12544. _this.applyShiftState(_this.shiftState);
  12545. return;
  12546. case "\u2190":
  12547. _this._currentlyConnectedInputText.processKey(8);
  12548. return;
  12549. case "\u21B5":
  12550. _this._currentlyConnectedInputText.processKey(13);
  12551. return;
  12552. }
  12553. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  12554. if (_this.shiftState === 1) {
  12555. _this.shiftState = 0;
  12556. _this.applyShiftState(_this.shiftState);
  12557. }
  12558. });
  12559. }
  12560. this.isVisible = false;
  12561. this._currentlyConnectedInputText = input;
  12562. input._connectedVirtualKeyboard = this;
  12563. // Events hooking
  12564. var onFocusObserver = input.onFocusObservable.add(function () {
  12565. _this._currentlyConnectedInputText = input;
  12566. input._connectedVirtualKeyboard = _this;
  12567. _this.isVisible = true;
  12568. });
  12569. var onBlurObserver = input.onBlurObservable.add(function () {
  12570. input._connectedVirtualKeyboard = null;
  12571. _this._currentlyConnectedInputText = null;
  12572. _this.isVisible = false;
  12573. });
  12574. this._connectedInputTexts.push({
  12575. input: input,
  12576. onBlurObserver: onBlurObserver,
  12577. onFocusObserver: onFocusObserver
  12578. });
  12579. };
  12580. /**
  12581. * Disconnects the keyboard from connected InputText controls
  12582. *
  12583. * @param input optionally defines a target control, otherwise all are disconnected
  12584. */
  12585. VirtualKeyboard.prototype.disconnect = function (input) {
  12586. var _this = this;
  12587. if (input) {
  12588. // .find not available on IE
  12589. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  12590. if (filtered.length === 1) {
  12591. this._removeConnectedInputObservables(filtered[0]);
  12592. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  12593. if (this._currentlyConnectedInputText === input) {
  12594. this._currentlyConnectedInputText = null;
  12595. }
  12596. }
  12597. }
  12598. else {
  12599. this._connectedInputTexts.forEach(function (connectedInputText) {
  12600. _this._removeConnectedInputObservables(connectedInputText);
  12601. });
  12602. this._connectedInputTexts = [];
  12603. }
  12604. if (this._connectedInputTexts.length === 0) {
  12605. this._currentlyConnectedInputText = null;
  12606. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  12607. this._onKeyPressObserver = null;
  12608. }
  12609. };
  12610. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  12611. connectedInputText.input._connectedVirtualKeyboard = null;
  12612. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  12613. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  12614. };
  12615. /**
  12616. * Release all resources
  12617. */
  12618. VirtualKeyboard.prototype.dispose = function () {
  12619. _super.prototype.dispose.call(this);
  12620. this.disconnect();
  12621. };
  12622. // Statics
  12623. /**
  12624. * Creates a new keyboard using a default layout
  12625. *
  12626. * @param name defines control name
  12627. * @returns a new VirtualKeyboard
  12628. */
  12629. VirtualKeyboard.CreateDefaultLayout = function (name) {
  12630. var returnValue = new VirtualKeyboard(name);
  12631. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  12632. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  12633. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  12634. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  12635. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  12636. return returnValue;
  12637. };
  12638. return VirtualKeyboard;
  12639. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  12640. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  12641. /***/ }),
  12642. /***/ "./2D/index.ts":
  12643. /*!*********************!*\
  12644. !*** ./2D/index.ts ***!
  12645. \*********************/
  12646. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  12647. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12648. "use strict";
  12649. __webpack_require__.r(__webpack_exports__);
  12650. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  12651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  12652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  12653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  12654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  12655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  12656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  12657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  12658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  12659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  12660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  12661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  12662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  12663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  12664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  12665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  12666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  12667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  12668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  12669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  12670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  12671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  12672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  12673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  12674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  12675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  12676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  12677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  12678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  12679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  12680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  12681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  12682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  12683. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  12685. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  12686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  12687. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  12688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  12689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  12690. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  12691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  12692. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  12693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  12694. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  12695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  12696. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  12698. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  12699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  12700. /***/ }),
  12701. /***/ "./2D/math2D.ts":
  12702. /*!**********************!*\
  12703. !*** ./2D/math2D.ts ***!
  12704. \**********************/
  12705. /*! exports provided: Vector2WithInfo, Matrix2D */
  12706. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12707. "use strict";
  12708. __webpack_require__.r(__webpack_exports__);
  12709. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  12710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  12711. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12712. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  12713. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  12714. /**
  12715. * Class used to transport Vector2 information for pointer events
  12716. */
  12717. var Vector2WithInfo = /** @class */ (function (_super) {
  12718. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  12719. /**
  12720. * Creates a new Vector2WithInfo
  12721. * @param source defines the vector2 data to transport
  12722. * @param buttonIndex defines the current mouse button index
  12723. */
  12724. function Vector2WithInfo(source,
  12725. /** defines the current mouse button index */
  12726. buttonIndex) {
  12727. if (buttonIndex === void 0) { buttonIndex = 0; }
  12728. var _this = _super.call(this, source.x, source.y) || this;
  12729. _this.buttonIndex = buttonIndex;
  12730. return _this;
  12731. }
  12732. return Vector2WithInfo;
  12733. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  12734. /** Class used to provide 2D matrix features */
  12735. var Matrix2D = /** @class */ (function () {
  12736. /**
  12737. * Creates a new matrix
  12738. * @param m00 defines value for (0, 0)
  12739. * @param m01 defines value for (0, 1)
  12740. * @param m10 defines value for (1, 0)
  12741. * @param m11 defines value for (1, 1)
  12742. * @param m20 defines value for (2, 0)
  12743. * @param m21 defines value for (2, 1)
  12744. */
  12745. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  12746. /** Gets the internal array of 6 floats used to store matrix data */
  12747. this.m = new Float32Array(6);
  12748. this.fromValues(m00, m01, m10, m11, m20, m21);
  12749. }
  12750. /**
  12751. * Fills the matrix from direct values
  12752. * @param m00 defines value for (0, 0)
  12753. * @param m01 defines value for (0, 1)
  12754. * @param m10 defines value for (1, 0)
  12755. * @param m11 defines value for (1, 1)
  12756. * @param m20 defines value for (2, 0)
  12757. * @param m21 defines value for (2, 1)
  12758. * @returns the current modified matrix
  12759. */
  12760. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  12761. this.m[0] = m00;
  12762. this.m[1] = m01;
  12763. this.m[2] = m10;
  12764. this.m[3] = m11;
  12765. this.m[4] = m20;
  12766. this.m[5] = m21;
  12767. return this;
  12768. };
  12769. /**
  12770. * Gets matrix determinant
  12771. * @returns the determinant
  12772. */
  12773. Matrix2D.prototype.determinant = function () {
  12774. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  12775. };
  12776. /**
  12777. * Inverses the matrix and stores it in a target matrix
  12778. * @param result defines the target matrix
  12779. * @returns the current matrix
  12780. */
  12781. Matrix2D.prototype.invertToRef = function (result) {
  12782. var l0 = this.m[0];
  12783. var l1 = this.m[1];
  12784. var l2 = this.m[2];
  12785. var l3 = this.m[3];
  12786. var l4 = this.m[4];
  12787. var l5 = this.m[5];
  12788. var det = this.determinant();
  12789. if (det < (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  12790. result.m[0] = 0;
  12791. result.m[1] = 0;
  12792. result.m[2] = 0;
  12793. result.m[3] = 0;
  12794. result.m[4] = 0;
  12795. result.m[5] = 0;
  12796. return this;
  12797. }
  12798. var detDiv = 1 / det;
  12799. var det4 = l2 * l5 - l3 * l4;
  12800. var det5 = l1 * l4 - l0 * l5;
  12801. result.m[0] = l3 * detDiv;
  12802. result.m[1] = -l1 * detDiv;
  12803. result.m[2] = -l2 * detDiv;
  12804. result.m[3] = l0 * detDiv;
  12805. result.m[4] = det4 * detDiv;
  12806. result.m[5] = det5 * detDiv;
  12807. return this;
  12808. };
  12809. /**
  12810. * Multiplies the current matrix with another one
  12811. * @param other defines the second operand
  12812. * @param result defines the target matrix
  12813. * @returns the current matrix
  12814. */
  12815. Matrix2D.prototype.multiplyToRef = function (other, result) {
  12816. var l0 = this.m[0];
  12817. var l1 = this.m[1];
  12818. var l2 = this.m[2];
  12819. var l3 = this.m[3];
  12820. var l4 = this.m[4];
  12821. var l5 = this.m[5];
  12822. var r0 = other.m[0];
  12823. var r1 = other.m[1];
  12824. var r2 = other.m[2];
  12825. var r3 = other.m[3];
  12826. var r4 = other.m[4];
  12827. var r5 = other.m[5];
  12828. result.m[0] = l0 * r0 + l1 * r2;
  12829. result.m[1] = l0 * r1 + l1 * r3;
  12830. result.m[2] = l2 * r0 + l3 * r2;
  12831. result.m[3] = l2 * r1 + l3 * r3;
  12832. result.m[4] = l4 * r0 + l5 * r2 + r4;
  12833. result.m[5] = l4 * r1 + l5 * r3 + r5;
  12834. return this;
  12835. };
  12836. /**
  12837. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  12838. * @param x defines the x coordinate to transform
  12839. * @param y defines the x coordinate to transform
  12840. * @param result defines the target vector2
  12841. * @returns the current matrix
  12842. */
  12843. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  12844. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  12845. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  12846. return this;
  12847. };
  12848. // Statics
  12849. /**
  12850. * Creates an identity matrix
  12851. * @returns a new matrix
  12852. */
  12853. Matrix2D.Identity = function () {
  12854. return new Matrix2D(1, 0, 0, 1, 0, 0);
  12855. };
  12856. /**
  12857. * Creates a translation matrix and stores it in a target matrix
  12858. * @param x defines the x coordinate of the translation
  12859. * @param y defines the y coordinate of the translation
  12860. * @param result defines the target matrix
  12861. */
  12862. Matrix2D.TranslationToRef = function (x, y, result) {
  12863. result.fromValues(1, 0, 0, 1, x, y);
  12864. };
  12865. /**
  12866. * Creates a scaling matrix and stores it in a target matrix
  12867. * @param x defines the x coordinate of the scaling
  12868. * @param y defines the y coordinate of the scaling
  12869. * @param result defines the target matrix
  12870. */
  12871. Matrix2D.ScalingToRef = function (x, y, result) {
  12872. result.fromValues(x, 0, 0, y, 0, 0);
  12873. };
  12874. /**
  12875. * Creates a rotation matrix and stores it in a target matrix
  12876. * @param angle defines the rotation angle
  12877. * @param result defines the target matrix
  12878. */
  12879. Matrix2D.RotationToRef = function (angle, result) {
  12880. var s = Math.sin(angle);
  12881. var c = Math.cos(angle);
  12882. result.fromValues(c, s, -s, c, 0, 0);
  12883. };
  12884. /**
  12885. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  12886. * @param tx defines the x coordinate of the translation
  12887. * @param ty defines the y coordinate of the translation
  12888. * @param angle defines the rotation angle
  12889. * @param scaleX defines the x coordinate of the scaling
  12890. * @param scaleY defines the y coordinate of the scaling
  12891. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  12892. * @param result defines the target matrix
  12893. */
  12894. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  12895. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  12896. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  12897. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  12898. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  12899. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  12900. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  12901. if (parentMatrix) {
  12902. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  12903. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  12904. }
  12905. else {
  12906. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  12907. }
  12908. };
  12909. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  12910. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  12911. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  12912. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  12913. Matrix2D._TempCompose0 = Matrix2D.Identity();
  12914. Matrix2D._TempCompose1 = Matrix2D.Identity();
  12915. Matrix2D._TempCompose2 = Matrix2D.Identity();
  12916. return Matrix2D;
  12917. }());
  12918. /***/ }),
  12919. /***/ "./2D/measure.ts":
  12920. /*!***********************!*\
  12921. !*** ./2D/measure.ts ***!
  12922. \***********************/
  12923. /*! exports provided: Measure */
  12924. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12925. "use strict";
  12926. __webpack_require__.r(__webpack_exports__);
  12927. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  12928. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  12929. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  12930. var tmpRect = [
  12931. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12932. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12933. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12934. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12935. ];
  12936. var tmpRect2 = [
  12937. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12938. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12939. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12940. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12941. ];
  12942. var tmpV1 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12943. var tmpV2 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12944. /**
  12945. * Class used to store 2D control sizes
  12946. */
  12947. var Measure = /** @class */ (function () {
  12948. /**
  12949. * Creates a new measure
  12950. * @param left defines left coordinate
  12951. * @param top defines top coordinate
  12952. * @param width defines width dimension
  12953. * @param height defines height dimension
  12954. */
  12955. function Measure(
  12956. /** defines left coordinate */
  12957. left,
  12958. /** defines top coordinate */
  12959. top,
  12960. /** defines width dimension */
  12961. width,
  12962. /** defines height dimension */
  12963. height) {
  12964. this.left = left;
  12965. this.top = top;
  12966. this.width = width;
  12967. this.height = height;
  12968. }
  12969. /**
  12970. * Copy from another measure
  12971. * @param other defines the other measure to copy from
  12972. */
  12973. Measure.prototype.copyFrom = function (other) {
  12974. this.left = other.left;
  12975. this.top = other.top;
  12976. this.width = other.width;
  12977. this.height = other.height;
  12978. };
  12979. /**
  12980. * Copy from a group of 4 floats
  12981. * @param left defines left coordinate
  12982. * @param top defines top coordinate
  12983. * @param width defines width dimension
  12984. * @param height defines height dimension
  12985. */
  12986. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  12987. this.left = left;
  12988. this.top = top;
  12989. this.width = width;
  12990. this.height = height;
  12991. };
  12992. /**
  12993. * Computes the axis aligned bounding box measure for two given measures
  12994. * @param a Input measure
  12995. * @param b Input measure
  12996. * @param result the resulting bounding measure
  12997. */
  12998. Measure.CombineToRef = function (a, b, result) {
  12999. var left = Math.min(a.left, b.left);
  13000. var top = Math.min(a.top, b.top);
  13001. var right = Math.max(a.left + a.width, b.left + b.width);
  13002. var bottom = Math.max(a.top + a.height, b.top + b.height);
  13003. result.left = left;
  13004. result.top = top;
  13005. result.width = right - left;
  13006. result.height = bottom - top;
  13007. };
  13008. /**
  13009. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  13010. * @param transform the matrix to transform the measure before computing the AABB
  13011. * @param result the resulting AABB
  13012. */
  13013. Measure.prototype.transformToRef = function (transform, result) {
  13014. tmpRect[0].copyFromFloats(this.left, this.top);
  13015. tmpRect[1].copyFromFloats(this.left + this.width, this.top);
  13016. tmpRect[2].copyFromFloats(this.left + this.width, this.top + this.height);
  13017. tmpRect[3].copyFromFloats(this.left, this.top + this.height);
  13018. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  13019. tmpV2.copyFromFloats(0, 0);
  13020. for (var i = 0; i < 4; i++) {
  13021. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  13022. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  13023. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  13024. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  13025. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  13026. }
  13027. result.left = tmpV1.x;
  13028. result.top = tmpV1.y;
  13029. result.width = tmpV2.x - tmpV1.x;
  13030. result.height = tmpV2.y - tmpV1.y;
  13031. };
  13032. /**
  13033. * Check equality between this measure and another one
  13034. * @param other defines the other measures
  13035. * @returns true if both measures are equals
  13036. */
  13037. Measure.prototype.isEqualsTo = function (other) {
  13038. if (this.left !== other.left) {
  13039. return false;
  13040. }
  13041. if (this.top !== other.top) {
  13042. return false;
  13043. }
  13044. if (this.width !== other.width) {
  13045. return false;
  13046. }
  13047. if (this.height !== other.height) {
  13048. return false;
  13049. }
  13050. return true;
  13051. };
  13052. /**
  13053. * Creates an empty measure
  13054. * @returns a new measure
  13055. */
  13056. Measure.Empty = function () {
  13057. return new Measure(0, 0, 0, 0);
  13058. };
  13059. return Measure;
  13060. }());
  13061. /***/ }),
  13062. /***/ "./2D/multiLinePoint.ts":
  13063. /*!******************************!*\
  13064. !*** ./2D/multiLinePoint.ts ***!
  13065. \******************************/
  13066. /*! exports provided: MultiLinePoint */
  13067. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13068. "use strict";
  13069. __webpack_require__.r(__webpack_exports__);
  13070. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  13071. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  13072. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13073. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13074. /**
  13075. * Class used to store a point for a MultiLine object.
  13076. * The point can be pure 2D coordinates, a mesh or a control
  13077. */
  13078. var MultiLinePoint = /** @class */ (function () {
  13079. /**
  13080. * Creates a new MultiLinePoint
  13081. * @param multiLine defines the source MultiLine object
  13082. */
  13083. function MultiLinePoint(multiLine) {
  13084. this._multiLine = multiLine;
  13085. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13086. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13087. this._point = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13088. }
  13089. Object.defineProperty(MultiLinePoint.prototype, "x", {
  13090. /** Gets or sets x coordinate */
  13091. get: function () {
  13092. return this._x.toString(this._multiLine._host);
  13093. },
  13094. set: function (value) {
  13095. if (this._x.toString(this._multiLine._host) === value) {
  13096. return;
  13097. }
  13098. if (this._x.fromString(value)) {
  13099. this._multiLine._markAsDirty();
  13100. }
  13101. },
  13102. enumerable: true,
  13103. configurable: true
  13104. });
  13105. Object.defineProperty(MultiLinePoint.prototype, "y", {
  13106. /** Gets or sets y coordinate */
  13107. get: function () {
  13108. return this._y.toString(this._multiLine._host);
  13109. },
  13110. set: function (value) {
  13111. if (this._y.toString(this._multiLine._host) === value) {
  13112. return;
  13113. }
  13114. if (this._y.fromString(value)) {
  13115. this._multiLine._markAsDirty();
  13116. }
  13117. },
  13118. enumerable: true,
  13119. configurable: true
  13120. });
  13121. Object.defineProperty(MultiLinePoint.prototype, "control", {
  13122. /** Gets or sets the control associated with this point */
  13123. get: function () {
  13124. return this._control;
  13125. },
  13126. set: function (value) {
  13127. if (this._control === value) {
  13128. return;
  13129. }
  13130. if (this._control && this._controlObserver) {
  13131. this._control.onDirtyObservable.remove(this._controlObserver);
  13132. this._controlObserver = null;
  13133. }
  13134. this._control = value;
  13135. if (this._control) {
  13136. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  13137. }
  13138. this._multiLine._markAsDirty();
  13139. },
  13140. enumerable: true,
  13141. configurable: true
  13142. });
  13143. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  13144. /** Gets or sets the mesh associated with this point */
  13145. get: function () {
  13146. return this._mesh;
  13147. },
  13148. set: function (value) {
  13149. if (this._mesh === value) {
  13150. return;
  13151. }
  13152. if (this._mesh && this._meshObserver) {
  13153. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  13154. }
  13155. this._mesh = value;
  13156. if (this._mesh) {
  13157. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  13158. }
  13159. this._multiLine._markAsDirty();
  13160. },
  13161. enumerable: true,
  13162. configurable: true
  13163. });
  13164. /** Resets links */
  13165. MultiLinePoint.prototype.resetLinks = function () {
  13166. this.control = null;
  13167. this.mesh = null;
  13168. };
  13169. /**
  13170. * Gets a translation vector
  13171. * @returns the translation vector
  13172. */
  13173. MultiLinePoint.prototype.translate = function () {
  13174. this._point = this._translatePoint();
  13175. return this._point;
  13176. };
  13177. MultiLinePoint.prototype._translatePoint = function () {
  13178. if (this._mesh != null) {
  13179. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  13180. }
  13181. else if (this._control != null) {
  13182. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  13183. }
  13184. else {
  13185. var host = this._multiLine._host;
  13186. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  13187. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  13188. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  13189. }
  13190. };
  13191. /** Release associated resources */
  13192. MultiLinePoint.prototype.dispose = function () {
  13193. this.resetLinks();
  13194. };
  13195. return MultiLinePoint;
  13196. }());
  13197. /***/ }),
  13198. /***/ "./2D/style.ts":
  13199. /*!*********************!*\
  13200. !*** ./2D/style.ts ***!
  13201. \*********************/
  13202. /*! exports provided: Style */
  13203. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13204. "use strict";
  13205. __webpack_require__.r(__webpack_exports__);
  13206. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  13207. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  13208. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13209. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13210. /**
  13211. * Define a style used by control to automatically setup properties based on a template.
  13212. * Only support font related properties so far
  13213. */
  13214. var Style = /** @class */ (function () {
  13215. /**
  13216. * Creates a new style object
  13217. * @param host defines the AdvancedDynamicTexture which hosts this style
  13218. */
  13219. function Style(host) {
  13220. this._fontFamily = "Arial";
  13221. this._fontStyle = "";
  13222. this._fontWeight = "";
  13223. /** @hidden */
  13224. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  13225. /**
  13226. * Observable raised when the style values are changed
  13227. */
  13228. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13229. this._host = host;
  13230. }
  13231. Object.defineProperty(Style.prototype, "fontSize", {
  13232. /**
  13233. * Gets or sets the font size
  13234. */
  13235. get: function () {
  13236. return this._fontSize.toString(this._host);
  13237. },
  13238. set: function (value) {
  13239. if (this._fontSize.toString(this._host) === value) {
  13240. return;
  13241. }
  13242. if (this._fontSize.fromString(value)) {
  13243. this.onChangedObservable.notifyObservers(this);
  13244. }
  13245. },
  13246. enumerable: true,
  13247. configurable: true
  13248. });
  13249. Object.defineProperty(Style.prototype, "fontFamily", {
  13250. /**
  13251. * Gets or sets the font family
  13252. */
  13253. get: function () {
  13254. return this._fontFamily;
  13255. },
  13256. set: function (value) {
  13257. if (this._fontFamily === value) {
  13258. return;
  13259. }
  13260. this._fontFamily = value;
  13261. this.onChangedObservable.notifyObservers(this);
  13262. },
  13263. enumerable: true,
  13264. configurable: true
  13265. });
  13266. Object.defineProperty(Style.prototype, "fontStyle", {
  13267. /**
  13268. * Gets or sets the font style
  13269. */
  13270. get: function () {
  13271. return this._fontStyle;
  13272. },
  13273. set: function (value) {
  13274. if (this._fontStyle === value) {
  13275. return;
  13276. }
  13277. this._fontStyle = value;
  13278. this.onChangedObservable.notifyObservers(this);
  13279. },
  13280. enumerable: true,
  13281. configurable: true
  13282. });
  13283. Object.defineProperty(Style.prototype, "fontWeight", {
  13284. /** Gets or sets font weight */
  13285. get: function () {
  13286. return this._fontWeight;
  13287. },
  13288. set: function (value) {
  13289. if (this._fontWeight === value) {
  13290. return;
  13291. }
  13292. this._fontWeight = value;
  13293. this.onChangedObservable.notifyObservers(this);
  13294. },
  13295. enumerable: true,
  13296. configurable: true
  13297. });
  13298. /** Dispose all associated resources */
  13299. Style.prototype.dispose = function () {
  13300. this.onChangedObservable.clear();
  13301. };
  13302. return Style;
  13303. }());
  13304. /***/ }),
  13305. /***/ "./2D/valueAndUnit.ts":
  13306. /*!****************************!*\
  13307. !*** ./2D/valueAndUnit.ts ***!
  13308. \****************************/
  13309. /*! exports provided: ValueAndUnit */
  13310. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13311. "use strict";
  13312. __webpack_require__.r(__webpack_exports__);
  13313. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  13314. /**
  13315. * Class used to specific a value and its associated unit
  13316. */
  13317. var ValueAndUnit = /** @class */ (function () {
  13318. /**
  13319. * Creates a new ValueAndUnit
  13320. * @param value defines the value to store
  13321. * @param unit defines the unit to store
  13322. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  13323. */
  13324. function ValueAndUnit(value,
  13325. /** defines the unit to store */
  13326. unit,
  13327. /** defines a boolean indicating if the value can be negative */
  13328. negativeValueAllowed) {
  13329. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13330. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  13331. this.unit = unit;
  13332. this.negativeValueAllowed = negativeValueAllowed;
  13333. this._value = 1;
  13334. /**
  13335. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  13336. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  13337. */
  13338. this.ignoreAdaptiveScaling = false;
  13339. this._value = value;
  13340. this._originalUnit = unit;
  13341. }
  13342. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  13343. /** Gets a boolean indicating if the value is a percentage */
  13344. get: function () {
  13345. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  13346. },
  13347. enumerable: true,
  13348. configurable: true
  13349. });
  13350. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  13351. /** Gets a boolean indicating if the value is store as pixel */
  13352. get: function () {
  13353. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  13354. },
  13355. enumerable: true,
  13356. configurable: true
  13357. });
  13358. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  13359. /** Gets direct internal value */
  13360. get: function () {
  13361. return this._value;
  13362. },
  13363. enumerable: true,
  13364. configurable: true
  13365. });
  13366. /**
  13367. * Gets value as pixel
  13368. * @param host defines the root host
  13369. * @param refValue defines the reference value for percentages
  13370. * @returns the value as pixel
  13371. */
  13372. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  13373. if (this.isPixel) {
  13374. return this.getValue(host);
  13375. }
  13376. return this.getValue(host) * refValue;
  13377. };
  13378. /**
  13379. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  13380. * @param value defines the value to store
  13381. * @param unit defines the unit to store
  13382. * @returns the current ValueAndUnit
  13383. */
  13384. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  13385. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13386. this._value = value;
  13387. this.unit = unit;
  13388. return this;
  13389. };
  13390. /**
  13391. * Gets the value accordingly to its unit
  13392. * @param host defines the root host
  13393. * @returns the value
  13394. */
  13395. ValueAndUnit.prototype.getValue = function (host) {
  13396. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  13397. var width = 0;
  13398. var height = 0;
  13399. if (host.idealWidth) {
  13400. width = (this._value * host.getSize().width) / host.idealWidth;
  13401. }
  13402. if (host.idealHeight) {
  13403. height = (this._value * host.getSize().height) / host.idealHeight;
  13404. }
  13405. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  13406. return window.innerWidth < window.innerHeight ? width : height;
  13407. }
  13408. if (host.idealWidth) { // horizontal
  13409. return width;
  13410. }
  13411. if (host.idealHeight) { // vertical
  13412. return height;
  13413. }
  13414. }
  13415. return this._value;
  13416. };
  13417. /**
  13418. * Gets a string representation of the value
  13419. * @param host defines the root host
  13420. * @param decimals defines an optional number of decimals to display
  13421. * @returns a string
  13422. */
  13423. ValueAndUnit.prototype.toString = function (host, decimals) {
  13424. switch (this.unit) {
  13425. case ValueAndUnit.UNITMODE_PERCENTAGE:
  13426. var percentage = this.getValue(host) * 100;
  13427. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  13428. case ValueAndUnit.UNITMODE_PIXEL:
  13429. var pixels = this.getValue(host);
  13430. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  13431. }
  13432. return this.unit.toString();
  13433. };
  13434. /**
  13435. * Store a value parsed from a string
  13436. * @param source defines the source string
  13437. * @returns true if the value was successfully parsed
  13438. */
  13439. ValueAndUnit.prototype.fromString = function (source) {
  13440. var match = ValueAndUnit._Regex.exec(source.toString());
  13441. if (!match || match.length === 0) {
  13442. return false;
  13443. }
  13444. var sourceValue = parseFloat(match[1]);
  13445. var sourceUnit = this._originalUnit;
  13446. if (!this.negativeValueAllowed) {
  13447. if (sourceValue < 0) {
  13448. sourceValue = 0;
  13449. }
  13450. }
  13451. if (match.length === 4) {
  13452. switch (match[3]) {
  13453. case "px":
  13454. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  13455. break;
  13456. case "%":
  13457. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  13458. sourceValue /= 100.0;
  13459. break;
  13460. }
  13461. }
  13462. if (sourceValue === this._value && sourceUnit === this.unit) {
  13463. return false;
  13464. }
  13465. this._value = sourceValue;
  13466. this.unit = sourceUnit;
  13467. return true;
  13468. };
  13469. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  13470. /** UNITMODE_PERCENTAGE */
  13471. get: function () {
  13472. return ValueAndUnit._UNITMODE_PERCENTAGE;
  13473. },
  13474. enumerable: true,
  13475. configurable: true
  13476. });
  13477. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  13478. /** UNITMODE_PIXEL */
  13479. get: function () {
  13480. return ValueAndUnit._UNITMODE_PIXEL;
  13481. },
  13482. enumerable: true,
  13483. configurable: true
  13484. });
  13485. // Static
  13486. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  13487. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  13488. ValueAndUnit._UNITMODE_PIXEL = 1;
  13489. return ValueAndUnit;
  13490. }());
  13491. /***/ }),
  13492. /***/ "./2D/xmlLoader.ts":
  13493. /*!*************************!*\
  13494. !*** ./2D/xmlLoader.ts ***!
  13495. \*************************/
  13496. /*! exports provided: XmlLoader */
  13497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13498. "use strict";
  13499. __webpack_require__.r(__webpack_exports__);
  13500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  13501. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  13502. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  13503. /**
  13504. * Class used to load GUI via XML.
  13505. */
  13506. var XmlLoader = /** @class */ (function () {
  13507. /**
  13508. * Create a new xml loader
  13509. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  13510. */
  13511. function XmlLoader(parentClass) {
  13512. if (parentClass === void 0) { parentClass = null; }
  13513. this._nodes = {};
  13514. this._nodeTypes = {
  13515. element: 1,
  13516. attribute: 2,
  13517. text: 3
  13518. };
  13519. this._isLoaded = false;
  13520. this._objectAttributes = {
  13521. "textHorizontalAlignment": 1,
  13522. "textVerticalAlignment": 2,
  13523. "horizontalAlignment": 3,
  13524. "verticalAlignment": 4,
  13525. "stretch": 5,
  13526. };
  13527. if (parentClass) {
  13528. this._parentClass = parentClass;
  13529. }
  13530. }
  13531. XmlLoader.prototype._getChainElement = function (attributeValue) {
  13532. var element = window;
  13533. if (this._parentClass) {
  13534. element = this._parentClass;
  13535. }
  13536. var value = attributeValue;
  13537. value = value.split(".");
  13538. for (var i = 0; i < value.length; i++) {
  13539. element = element[value[i]];
  13540. }
  13541. return element;
  13542. };
  13543. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  13544. var attribute = attributeName.split(".");
  13545. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  13546. return className[attribute[1]];
  13547. };
  13548. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  13549. if (linkParent === void 0) { linkParent = true; }
  13550. try {
  13551. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  13552. var guiNode = new className();
  13553. if (parent && linkParent) {
  13554. parent.addControl(guiNode);
  13555. }
  13556. for (var i = 0; i < node.attributes.length; i++) {
  13557. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  13558. continue;
  13559. }
  13560. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  13561. var element = this._getChainElement(node.attributes[i].value);
  13562. guiNode[node.attributes[i].name].add(element);
  13563. continue;
  13564. }
  13565. else if (node.attributes[i].name == "linkWithMesh") {
  13566. if (this._parentClass) {
  13567. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  13568. }
  13569. else {
  13570. guiNode.linkWithMesh(window[node.attributes[i].value]);
  13571. }
  13572. }
  13573. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  13574. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  13575. guiNode[node.attributes[i].name] = element;
  13576. }
  13577. else if (!this._objectAttributes[node.attributes[i].name]) {
  13578. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  13579. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  13580. }
  13581. else {
  13582. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  13583. }
  13584. }
  13585. else {
  13586. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  13587. }
  13588. }
  13589. if (!node.attributes.getNamedItem("id")) {
  13590. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  13591. return guiNode;
  13592. }
  13593. var id = node.attributes.getNamedItem("id").value;
  13594. if (id.startsWith("{{") && id.endsWith("}}")) {
  13595. id = this._getChainElement(id.substring(2, id.length - 2));
  13596. }
  13597. if (!this._nodes[id]) {
  13598. this._nodes[id] = guiNode;
  13599. }
  13600. else {
  13601. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  13602. }
  13603. return guiNode;
  13604. }
  13605. catch (e) {
  13606. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  13607. }
  13608. };
  13609. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  13610. var width;
  13611. var height;
  13612. var columns;
  13613. var rows = node.children;
  13614. var cells;
  13615. var isPixel = false;
  13616. var cellNode;
  13617. var rowNumber = -1;
  13618. var columnNumber = -1;
  13619. var totalColumnsNumber = 0;
  13620. for (var i = 0; i < rows.length; i++) {
  13621. if (rows[i].nodeType != this._nodeTypes.element) {
  13622. continue;
  13623. }
  13624. if (rows[i].nodeName != "Row") {
  13625. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  13626. }
  13627. rowNumber += 1;
  13628. columns = rows[i].children;
  13629. if (!rows[i].attributes.getNamedItem("height")) {
  13630. throw "XmlLoader Exception : Height must be defined for grid rows";
  13631. }
  13632. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  13633. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  13634. guiNode.addRowDefinition(height, isPixel);
  13635. for (var j = 0; j < columns.length; j++) {
  13636. if (columns[j].nodeType != this._nodeTypes.element) {
  13637. continue;
  13638. }
  13639. if (columns[j].nodeName != "Column") {
  13640. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  13641. }
  13642. columnNumber += 1;
  13643. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  13644. 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.";
  13645. }
  13646. if (rowNumber == 0) {
  13647. if (!columns[j].attributes.getNamedItem("width")) {
  13648. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  13649. }
  13650. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  13651. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  13652. guiNode.addColumnDefinition(width, isPixel);
  13653. }
  13654. cells = columns[j].children;
  13655. for (var k = 0; k < cells.length; k++) {
  13656. if (cells[k].nodeType != this._nodeTypes.element) {
  13657. continue;
  13658. }
  13659. cellNode = this._createGuiElement(cells[k], guiNode, false);
  13660. guiNode.addControl(cellNode, rowNumber, columnNumber);
  13661. if (cells[k].firstChild) {
  13662. this._parseXml(cells[k].firstChild, cellNode);
  13663. }
  13664. }
  13665. }
  13666. if (rowNumber == 0) {
  13667. totalColumnsNumber = columnNumber;
  13668. }
  13669. columnNumber = -1;
  13670. }
  13671. if (node.nextSibling) {
  13672. this._parseXml(node.nextSibling, parent);
  13673. }
  13674. };
  13675. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  13676. if (node.firstChild) {
  13677. this._parseXml(node.firstChild, guiNode);
  13678. }
  13679. if (node.nextSibling) {
  13680. this._parseXml(node.nextSibling, parent);
  13681. }
  13682. };
  13683. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  13684. if (this._parentClass) {
  13685. this._parentClass[variable] = source[iterator];
  13686. }
  13687. else {
  13688. window[variable] = source[iterator];
  13689. }
  13690. if (node.firstChild) {
  13691. this._parseXml(node.firstChild, guiNode, true);
  13692. }
  13693. };
  13694. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  13695. var dataSource = node.attributes.getNamedItem("dataSource").value;
  13696. if (!dataSource.includes(" in ")) {
  13697. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  13698. }
  13699. else {
  13700. var isArray = true;
  13701. var splittedSource = dataSource.split(" in ");
  13702. if (splittedSource.length < 2) {
  13703. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  13704. }
  13705. var source = splittedSource[1];
  13706. if (source.startsWith("{") && source.endsWith("}")) {
  13707. isArray = false;
  13708. }
  13709. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  13710. source = source.substring(1, source.length - 1);
  13711. }
  13712. if (this._parentClass) {
  13713. source = this._parentClass[source];
  13714. }
  13715. else {
  13716. source = window[source];
  13717. }
  13718. if (isArray) {
  13719. for (var i = 0; i < source.length; i++) {
  13720. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13721. }
  13722. }
  13723. else {
  13724. for (var i in source) {
  13725. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13726. }
  13727. }
  13728. if (node.nextSibling) {
  13729. this._parseXml(node.nextSibling, parent);
  13730. }
  13731. }
  13732. };
  13733. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  13734. if (generated === void 0) { generated = false; }
  13735. if (node.nodeType != this._nodeTypes.element) {
  13736. if (node.nextSibling) {
  13737. this._parseXml(node.nextSibling, parent, generated);
  13738. }
  13739. return;
  13740. }
  13741. if (generated) {
  13742. node.setAttribute("id", parent.id + (parent._children.length + 1));
  13743. }
  13744. var guiNode = this._createGuiElement(node, parent);
  13745. if (node.nodeName == "Grid") {
  13746. this._parseGrid(node, guiNode, parent);
  13747. }
  13748. else if (!node.attributes.getNamedItem("dataSource")) {
  13749. this._parseElement(node, guiNode, parent);
  13750. }
  13751. else {
  13752. this._parseElementsFromSource(node, guiNode, parent);
  13753. }
  13754. };
  13755. /**
  13756. * Gets if the loading has finished.
  13757. * @returns whether the loading has finished or not
  13758. */
  13759. XmlLoader.prototype.isLoaded = function () {
  13760. return this._isLoaded;
  13761. };
  13762. /**
  13763. * Gets a loaded node / control by id.
  13764. * @param id the Controls id set in the xml
  13765. * @returns element of type Control
  13766. */
  13767. XmlLoader.prototype.getNodeById = function (id) {
  13768. return this._nodes[id];
  13769. };
  13770. /**
  13771. * Gets all loaded nodes / controls
  13772. * @returns Array of controls
  13773. */
  13774. XmlLoader.prototype.getNodes = function () {
  13775. return this._nodes;
  13776. };
  13777. /**
  13778. * Initiates the xml layout loading
  13779. * @param xmlFile defines the xml layout to load
  13780. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  13781. * @param callback defines the callback called on layout load.
  13782. */
  13783. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  13784. var xhttp = new XMLHttpRequest();
  13785. xhttp.onreadystatechange = function () {
  13786. if (xhttp.readyState == 4 && xhttp.status == 200) {
  13787. if (!xhttp.responseXML) {
  13788. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  13789. }
  13790. var xmlDoc = xhttp.responseXML.documentElement;
  13791. this._parseXml(xmlDoc.firstChild, rootNode);
  13792. this._isLoaded = true;
  13793. if (callback) {
  13794. callback();
  13795. }
  13796. }
  13797. }.bind(this);
  13798. xhttp.open("GET", xmlFile, true);
  13799. xhttp.send();
  13800. };
  13801. return XmlLoader;
  13802. }());
  13803. /***/ }),
  13804. /***/ "./3D/controls/abstractButton3D.ts":
  13805. /*!*****************************************!*\
  13806. !*** ./3D/controls/abstractButton3D.ts ***!
  13807. \*****************************************/
  13808. /*! exports provided: AbstractButton3D */
  13809. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13810. "use strict";
  13811. __webpack_require__.r(__webpack_exports__);
  13812. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  13813. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13814. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  13815. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13816. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13817. /**
  13818. * Class used as a root to all buttons
  13819. */
  13820. var AbstractButton3D = /** @class */ (function (_super) {
  13821. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  13822. /**
  13823. * Creates a new button
  13824. * @param name defines the control name
  13825. */
  13826. function AbstractButton3D(name) {
  13827. return _super.call(this, name) || this;
  13828. }
  13829. AbstractButton3D.prototype._getTypeName = function () {
  13830. return "AbstractButton3D";
  13831. };
  13832. // Mesh association
  13833. AbstractButton3D.prototype._createNode = function (scene) {
  13834. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  13835. };
  13836. return AbstractButton3D;
  13837. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13838. /***/ }),
  13839. /***/ "./3D/controls/button3D.ts":
  13840. /*!*********************************!*\
  13841. !*** ./3D/controls/button3D.ts ***!
  13842. \*********************************/
  13843. /*! exports provided: Button3D */
  13844. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13845. "use strict";
  13846. __webpack_require__.r(__webpack_exports__);
  13847. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  13848. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13849. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  13850. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  13851. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13852. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13853. /**
  13854. * Class used to create a button in 3D
  13855. */
  13856. var Button3D = /** @class */ (function (_super) {
  13857. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  13858. /**
  13859. * Creates a new button
  13860. * @param name defines the control name
  13861. */
  13862. function Button3D(name) {
  13863. var _this = _super.call(this, name) || this;
  13864. _this._contentResolution = 512;
  13865. _this._contentScaleRatio = 2;
  13866. // Default animations
  13867. _this.pointerEnterAnimation = function () {
  13868. if (!_this.mesh) {
  13869. return;
  13870. }
  13871. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  13872. };
  13873. _this.pointerOutAnimation = function () {
  13874. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13875. };
  13876. _this.pointerDownAnimation = function () {
  13877. if (!_this.mesh) {
  13878. return;
  13879. }
  13880. _this.mesh.scaling.scaleInPlace(0.95);
  13881. };
  13882. _this.pointerUpAnimation = function () {
  13883. if (!_this.mesh) {
  13884. return;
  13885. }
  13886. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13887. };
  13888. return _this;
  13889. }
  13890. Object.defineProperty(Button3D.prototype, "contentResolution", {
  13891. /**
  13892. * Gets or sets the texture resolution used to render content (512 by default)
  13893. */
  13894. get: function () {
  13895. return this._contentResolution;
  13896. },
  13897. set: function (value) {
  13898. if (this._contentResolution === value) {
  13899. return;
  13900. }
  13901. this._contentResolution = value;
  13902. this._resetContent();
  13903. },
  13904. enumerable: true,
  13905. configurable: true
  13906. });
  13907. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  13908. /**
  13909. * Gets or sets the texture scale ratio used to render content (2 by default)
  13910. */
  13911. get: function () {
  13912. return this._contentScaleRatio;
  13913. },
  13914. set: function (value) {
  13915. if (this._contentScaleRatio === value) {
  13916. return;
  13917. }
  13918. this._contentScaleRatio = value;
  13919. this._resetContent();
  13920. },
  13921. enumerable: true,
  13922. configurable: true
  13923. });
  13924. Button3D.prototype._disposeFacadeTexture = function () {
  13925. if (this._facadeTexture) {
  13926. this._facadeTexture.dispose();
  13927. this._facadeTexture = null;
  13928. }
  13929. };
  13930. Button3D.prototype._resetContent = function () {
  13931. this._disposeFacadeTexture();
  13932. this.content = this._content;
  13933. };
  13934. Object.defineProperty(Button3D.prototype, "content", {
  13935. /**
  13936. * Gets or sets the GUI 2D content used to display the button's facade
  13937. */
  13938. get: function () {
  13939. return this._content;
  13940. },
  13941. set: function (value) {
  13942. this._content = value;
  13943. if (!this._host || !this._host.utilityLayer) {
  13944. return;
  13945. }
  13946. if (!this._facadeTexture) {
  13947. 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);
  13948. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  13949. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  13950. this._facadeTexture.premulAlpha = true;
  13951. }
  13952. else {
  13953. this._facadeTexture.rootContainer.clearControls();
  13954. }
  13955. this._facadeTexture.addControl(value);
  13956. this._applyFacade(this._facadeTexture);
  13957. },
  13958. enumerable: true,
  13959. configurable: true
  13960. });
  13961. /**
  13962. * Apply the facade texture (created from the content property).
  13963. * This function can be overloaded by child classes
  13964. * @param facadeTexture defines the AdvancedDynamicTexture to use
  13965. */
  13966. Button3D.prototype._applyFacade = function (facadeTexture) {
  13967. this._currentMaterial.emissiveTexture = facadeTexture;
  13968. };
  13969. Button3D.prototype._getTypeName = function () {
  13970. return "Button3D";
  13971. };
  13972. // Mesh association
  13973. Button3D.prototype._createNode = function (scene) {
  13974. var faceUV = new Array(6);
  13975. for (var i = 0; i < 6; i++) {
  13976. faceUV[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  13977. }
  13978. faceUV[1] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  13979. var mesh = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  13980. width: 1.0,
  13981. height: 1.0,
  13982. depth: 0.08,
  13983. faceUV: faceUV
  13984. }, scene);
  13985. return mesh;
  13986. };
  13987. Button3D.prototype._affectMaterial = function (mesh) {
  13988. var material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  13989. material.specularColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13990. mesh.material = material;
  13991. this._currentMaterial = material;
  13992. this._resetContent();
  13993. };
  13994. /**
  13995. * Releases all associated resources
  13996. */
  13997. Button3D.prototype.dispose = function () {
  13998. _super.prototype.dispose.call(this);
  13999. this._disposeFacadeTexture();
  14000. if (this._currentMaterial) {
  14001. this._currentMaterial.dispose();
  14002. }
  14003. };
  14004. return Button3D;
  14005. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  14006. /***/ }),
  14007. /***/ "./3D/controls/container3D.ts":
  14008. /*!************************************!*\
  14009. !*** ./3D/controls/container3D.ts ***!
  14010. \************************************/
  14011. /*! exports provided: Container3D */
  14012. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14013. "use strict";
  14014. __webpack_require__.r(__webpack_exports__);
  14015. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  14016. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14017. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  14018. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  14019. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14020. /**
  14021. * Class used to create containers for controls
  14022. */
  14023. var Container3D = /** @class */ (function (_super) {
  14024. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  14025. /**
  14026. * Creates a new container
  14027. * @param name defines the container name
  14028. */
  14029. function Container3D(name) {
  14030. var _this = _super.call(this, name) || this;
  14031. _this._blockLayout = false;
  14032. /**
  14033. * Gets the list of child controls
  14034. */
  14035. _this._children = new Array();
  14036. return _this;
  14037. }
  14038. Object.defineProperty(Container3D.prototype, "children", {
  14039. /**
  14040. * Gets the list of child controls
  14041. */
  14042. get: function () {
  14043. return this._children;
  14044. },
  14045. enumerable: true,
  14046. configurable: true
  14047. });
  14048. Object.defineProperty(Container3D.prototype, "blockLayout", {
  14049. /**
  14050. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  14051. * This is helpful to optimize layout operation when adding multiple children in a row
  14052. */
  14053. get: function () {
  14054. return this._blockLayout;
  14055. },
  14056. set: function (value) {
  14057. if (this._blockLayout === value) {
  14058. return;
  14059. }
  14060. this._blockLayout = value;
  14061. if (!this._blockLayout) {
  14062. this._arrangeChildren();
  14063. }
  14064. },
  14065. enumerable: true,
  14066. configurable: true
  14067. });
  14068. /**
  14069. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  14070. * @returns the current container
  14071. */
  14072. Container3D.prototype.updateLayout = function () {
  14073. this._arrangeChildren();
  14074. return this;
  14075. };
  14076. /**
  14077. * Gets a boolean indicating if the given control is in the children of this control
  14078. * @param control defines the control to check
  14079. * @returns true if the control is in the child list
  14080. */
  14081. Container3D.prototype.containsControl = function (control) {
  14082. return this._children.indexOf(control) !== -1;
  14083. };
  14084. /**
  14085. * Adds a control to the children of this control
  14086. * @param control defines the control to add
  14087. * @returns the current container
  14088. */
  14089. Container3D.prototype.addControl = function (control) {
  14090. var index = this._children.indexOf(control);
  14091. if (index !== -1) {
  14092. return this;
  14093. }
  14094. control.parent = this;
  14095. control._host = this._host;
  14096. this._children.push(control);
  14097. if (this._host.utilityLayer) {
  14098. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  14099. if (control.node) {
  14100. control.node.parent = this.node;
  14101. }
  14102. if (!this.blockLayout) {
  14103. this._arrangeChildren();
  14104. }
  14105. }
  14106. return this;
  14107. };
  14108. /**
  14109. * This function will be called everytime a new control is added
  14110. */
  14111. Container3D.prototype._arrangeChildren = function () {
  14112. };
  14113. Container3D.prototype._createNode = function (scene) {
  14114. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  14115. };
  14116. /**
  14117. * Removes a control from the children of this control
  14118. * @param control defines the control to remove
  14119. * @returns the current container
  14120. */
  14121. Container3D.prototype.removeControl = function (control) {
  14122. var index = this._children.indexOf(control);
  14123. if (index !== -1) {
  14124. this._children.splice(index, 1);
  14125. control.parent = null;
  14126. control._disposeNode();
  14127. }
  14128. return this;
  14129. };
  14130. Container3D.prototype._getTypeName = function () {
  14131. return "Container3D";
  14132. };
  14133. /**
  14134. * Releases all associated resources
  14135. */
  14136. Container3D.prototype.dispose = function () {
  14137. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14138. var control = _a[_i];
  14139. control.dispose();
  14140. }
  14141. this._children = [];
  14142. _super.prototype.dispose.call(this);
  14143. };
  14144. /** Control rotation will remain unchanged */
  14145. Container3D.UNSET_ORIENTATION = 0;
  14146. /** Control will rotate to make it look at sphere central axis */
  14147. Container3D.FACEORIGIN_ORIENTATION = 1;
  14148. /** Control will rotate to make it look back at sphere central axis */
  14149. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  14150. /** Control will rotate to look at z axis (0, 0, 1) */
  14151. Container3D.FACEFORWARD_ORIENTATION = 3;
  14152. /** Control will rotate to look at negative z axis (0, 0, -1) */
  14153. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  14154. return Container3D;
  14155. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14156. /***/ }),
  14157. /***/ "./3D/controls/control3D.ts":
  14158. /*!**********************************!*\
  14159. !*** ./3D/controls/control3D.ts ***!
  14160. \**********************************/
  14161. /*! exports provided: Control3D */
  14162. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14163. "use strict";
  14164. __webpack_require__.r(__webpack_exports__);
  14165. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  14166. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  14167. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14168. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14169. /**
  14170. * Class used as base class for controls
  14171. */
  14172. var Control3D = /** @class */ (function () {
  14173. /**
  14174. * Creates a new control
  14175. * @param name defines the control name
  14176. */
  14177. function Control3D(
  14178. /** Defines the control name */
  14179. name) {
  14180. this.name = name;
  14181. this._downCount = 0;
  14182. this._enterCount = -1;
  14183. this._downPointerIds = {};
  14184. this._isVisible = true;
  14185. /**
  14186. * An event triggered when the pointer move over the control
  14187. */
  14188. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14189. /**
  14190. * An event triggered when the pointer move out of the control
  14191. */
  14192. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14193. /**
  14194. * An event triggered when the pointer taps the control
  14195. */
  14196. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14197. /**
  14198. * An event triggered when pointer is up
  14199. */
  14200. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14201. /**
  14202. * An event triggered when a control is clicked on (with a mouse)
  14203. */
  14204. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14205. /**
  14206. * An event triggered when pointer enters the control
  14207. */
  14208. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14209. // Behaviors
  14210. this._behaviors = new Array();
  14211. }
  14212. Object.defineProperty(Control3D.prototype, "position", {
  14213. /** Gets or sets the control position in world space */
  14214. get: function () {
  14215. if (!this._node) {
  14216. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  14217. }
  14218. return this._node.position;
  14219. },
  14220. set: function (value) {
  14221. if (!this._node) {
  14222. return;
  14223. }
  14224. this._node.position = value;
  14225. },
  14226. enumerable: true,
  14227. configurable: true
  14228. });
  14229. Object.defineProperty(Control3D.prototype, "scaling", {
  14230. /** Gets or sets the control scaling in world space */
  14231. get: function () {
  14232. if (!this._node) {
  14233. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  14234. }
  14235. return this._node.scaling;
  14236. },
  14237. set: function (value) {
  14238. if (!this._node) {
  14239. return;
  14240. }
  14241. this._node.scaling = value;
  14242. },
  14243. enumerable: true,
  14244. configurable: true
  14245. });
  14246. Object.defineProperty(Control3D.prototype, "behaviors", {
  14247. /**
  14248. * Gets the list of attached behaviors
  14249. * @see http://doc.babylonjs.com/features/behaviour
  14250. */
  14251. get: function () {
  14252. return this._behaviors;
  14253. },
  14254. enumerable: true,
  14255. configurable: true
  14256. });
  14257. /**
  14258. * Attach a behavior to the control
  14259. * @see http://doc.babylonjs.com/features/behaviour
  14260. * @param behavior defines the behavior to attach
  14261. * @returns the current control
  14262. */
  14263. Control3D.prototype.addBehavior = function (behavior) {
  14264. var _this = this;
  14265. var index = this._behaviors.indexOf(behavior);
  14266. if (index !== -1) {
  14267. return this;
  14268. }
  14269. behavior.init();
  14270. var scene = this._host.scene;
  14271. if (scene.isLoading) {
  14272. // We defer the attach when the scene will be loaded
  14273. scene.onDataLoadedObservable.addOnce(function () {
  14274. behavior.attach(_this);
  14275. });
  14276. }
  14277. else {
  14278. behavior.attach(this);
  14279. }
  14280. this._behaviors.push(behavior);
  14281. return this;
  14282. };
  14283. /**
  14284. * Remove an attached behavior
  14285. * @see http://doc.babylonjs.com/features/behaviour
  14286. * @param behavior defines the behavior to attach
  14287. * @returns the current control
  14288. */
  14289. Control3D.prototype.removeBehavior = function (behavior) {
  14290. var index = this._behaviors.indexOf(behavior);
  14291. if (index === -1) {
  14292. return this;
  14293. }
  14294. this._behaviors[index].detach();
  14295. this._behaviors.splice(index, 1);
  14296. return this;
  14297. };
  14298. /**
  14299. * Gets an attached behavior by name
  14300. * @param name defines the name of the behavior to look for
  14301. * @see http://doc.babylonjs.com/features/behaviour
  14302. * @returns null if behavior was not found else the requested behavior
  14303. */
  14304. Control3D.prototype.getBehaviorByName = function (name) {
  14305. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14306. var behavior = _a[_i];
  14307. if (behavior.name === name) {
  14308. return behavior;
  14309. }
  14310. }
  14311. return null;
  14312. };
  14313. Object.defineProperty(Control3D.prototype, "isVisible", {
  14314. /** Gets or sets a boolean indicating if the control is visible */
  14315. get: function () {
  14316. return this._isVisible;
  14317. },
  14318. set: function (value) {
  14319. if (this._isVisible === value) {
  14320. return;
  14321. }
  14322. this._isVisible = value;
  14323. var mesh = this.mesh;
  14324. if (mesh) {
  14325. mesh.setEnabled(value);
  14326. }
  14327. },
  14328. enumerable: true,
  14329. configurable: true
  14330. });
  14331. Object.defineProperty(Control3D.prototype, "typeName", {
  14332. /**
  14333. * Gets a string representing the class name
  14334. */
  14335. get: function () {
  14336. return this._getTypeName();
  14337. },
  14338. enumerable: true,
  14339. configurable: true
  14340. });
  14341. /**
  14342. * Get the current class name of the control.
  14343. * @returns current class name
  14344. */
  14345. Control3D.prototype.getClassName = function () {
  14346. return this._getTypeName();
  14347. };
  14348. Control3D.prototype._getTypeName = function () {
  14349. return "Control3D";
  14350. };
  14351. Object.defineProperty(Control3D.prototype, "node", {
  14352. /**
  14353. * Gets the transform node used by this control
  14354. */
  14355. get: function () {
  14356. return this._node;
  14357. },
  14358. enumerable: true,
  14359. configurable: true
  14360. });
  14361. Object.defineProperty(Control3D.prototype, "mesh", {
  14362. /**
  14363. * Gets the mesh used to render this control
  14364. */
  14365. get: function () {
  14366. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  14367. return this._node;
  14368. }
  14369. return null;
  14370. },
  14371. enumerable: true,
  14372. configurable: true
  14373. });
  14374. /**
  14375. * Link the control as child of the given node
  14376. * @param node defines the node to link to. Use null to unlink the control
  14377. * @returns the current control
  14378. */
  14379. Control3D.prototype.linkToTransformNode = function (node) {
  14380. if (this._node) {
  14381. this._node.parent = node;
  14382. }
  14383. return this;
  14384. };
  14385. /** @hidden **/
  14386. Control3D.prototype._prepareNode = function (scene) {
  14387. if (!this._node) {
  14388. this._node = this._createNode(scene);
  14389. if (!this.node) {
  14390. return;
  14391. }
  14392. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  14393. this._node.position = this.position;
  14394. this._node.scaling = this.scaling;
  14395. var mesh = this.mesh;
  14396. if (mesh) {
  14397. mesh.isPickable = true;
  14398. this._affectMaterial(mesh);
  14399. }
  14400. }
  14401. };
  14402. /**
  14403. * Node creation.
  14404. * Can be overriden by children
  14405. * @param scene defines the scene where the node must be attached
  14406. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  14407. */
  14408. Control3D.prototype._createNode = function (scene) {
  14409. // Do nothing by default
  14410. return null;
  14411. };
  14412. /**
  14413. * Affect a material to the given mesh
  14414. * @param mesh defines the mesh which will represent the control
  14415. */
  14416. Control3D.prototype._affectMaterial = function (mesh) {
  14417. mesh.material = null;
  14418. };
  14419. // Pointers
  14420. /** @hidden */
  14421. Control3D.prototype._onPointerMove = function (target, coordinates) {
  14422. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  14423. };
  14424. /** @hidden */
  14425. Control3D.prototype._onPointerEnter = function (target) {
  14426. if (this._enterCount > 0) {
  14427. return false;
  14428. }
  14429. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  14430. this._enterCount = 0;
  14431. }
  14432. this._enterCount++;
  14433. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  14434. if (this.pointerEnterAnimation) {
  14435. this.pointerEnterAnimation();
  14436. }
  14437. return true;
  14438. };
  14439. /** @hidden */
  14440. Control3D.prototype._onPointerOut = function (target) {
  14441. this._enterCount = 0;
  14442. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  14443. if (this.pointerOutAnimation) {
  14444. this.pointerOutAnimation();
  14445. }
  14446. };
  14447. /** @hidden */
  14448. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  14449. if (this._downCount !== 0) {
  14450. this._downCount++;
  14451. return false;
  14452. }
  14453. this._downCount++;
  14454. this._downPointerIds[pointerId] = true;
  14455. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14456. if (this.pointerDownAnimation) {
  14457. this.pointerDownAnimation();
  14458. }
  14459. return true;
  14460. };
  14461. /** @hidden */
  14462. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  14463. this._downCount--;
  14464. delete this._downPointerIds[pointerId];
  14465. if (this._downCount < 0) {
  14466. // Handle if forcePointerUp was called prior to this
  14467. this._downCount = 0;
  14468. return;
  14469. }
  14470. if (this._downCount == 0) {
  14471. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  14472. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14473. }
  14474. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14475. if (this.pointerUpAnimation) {
  14476. this.pointerUpAnimation();
  14477. }
  14478. }
  14479. };
  14480. /** @hidden */
  14481. Control3D.prototype.forcePointerUp = function (pointerId) {
  14482. if (pointerId === void 0) { pointerId = null; }
  14483. if (pointerId !== null) {
  14484. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  14485. }
  14486. else {
  14487. for (var key in this._downPointerIds) {
  14488. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  14489. }
  14490. if (this._downCount > 0) {
  14491. this._downCount = 1;
  14492. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  14493. }
  14494. }
  14495. };
  14496. /** @hidden */
  14497. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  14498. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14499. this._onPointerMove(this, pickedPoint);
  14500. var previousControlOver = this._host._lastControlOver[pointerId];
  14501. if (previousControlOver && previousControlOver !== this) {
  14502. previousControlOver._onPointerOut(this);
  14503. }
  14504. if (previousControlOver !== this) {
  14505. this._onPointerEnter(this);
  14506. }
  14507. this._host._lastControlOver[pointerId] = this;
  14508. return true;
  14509. }
  14510. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  14511. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  14512. this._host._lastControlDown[pointerId] = this;
  14513. this._host._lastPickedControl = this;
  14514. return true;
  14515. }
  14516. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14517. if (this._host._lastControlDown[pointerId]) {
  14518. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  14519. }
  14520. delete this._host._lastControlDown[pointerId];
  14521. return true;
  14522. }
  14523. return false;
  14524. };
  14525. /** @hidden */
  14526. Control3D.prototype._disposeNode = function () {
  14527. if (this._node) {
  14528. this._node.dispose();
  14529. this._node = null;
  14530. }
  14531. };
  14532. /**
  14533. * Releases all associated resources
  14534. */
  14535. Control3D.prototype.dispose = function () {
  14536. this.onPointerDownObservable.clear();
  14537. this.onPointerEnterObservable.clear();
  14538. this.onPointerMoveObservable.clear();
  14539. this.onPointerOutObservable.clear();
  14540. this.onPointerUpObservable.clear();
  14541. this.onPointerClickObservable.clear();
  14542. this._disposeNode();
  14543. // Behaviors
  14544. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14545. var behavior = _a[_i];
  14546. behavior.detach();
  14547. }
  14548. };
  14549. return Control3D;
  14550. }());
  14551. /***/ }),
  14552. /***/ "./3D/controls/cylinderPanel.ts":
  14553. /*!**************************************!*\
  14554. !*** ./3D/controls/cylinderPanel.ts ***!
  14555. \**************************************/
  14556. /*! exports provided: CylinderPanel */
  14557. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14558. "use strict";
  14559. __webpack_require__.r(__webpack_exports__);
  14560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  14561. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14562. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  14563. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14564. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14565. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14566. /**
  14567. * Class used to create a container panel deployed on the surface of a cylinder
  14568. */
  14569. var CylinderPanel = /** @class */ (function (_super) {
  14570. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  14571. function CylinderPanel() {
  14572. var _this = _super !== null && _super.apply(this, arguments) || this;
  14573. _this._radius = 5.0;
  14574. return _this;
  14575. }
  14576. Object.defineProperty(CylinderPanel.prototype, "radius", {
  14577. /**
  14578. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  14579. */
  14580. get: function () {
  14581. return this._radius;
  14582. },
  14583. set: function (value) {
  14584. var _this = this;
  14585. if (this._radius === value) {
  14586. return;
  14587. }
  14588. this._radius = value;
  14589. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14590. _this._arrangeChildren();
  14591. });
  14592. },
  14593. enumerable: true,
  14594. configurable: true
  14595. });
  14596. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  14597. var mesh = control.mesh;
  14598. if (!mesh) {
  14599. return;
  14600. }
  14601. var newPos = this._cylindricalMapping(nodePosition);
  14602. control.position = newPos;
  14603. switch (this.orientation) {
  14604. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14605. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  14606. break;
  14607. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14608. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  14609. break;
  14610. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14611. break;
  14612. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14613. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14614. break;
  14615. }
  14616. };
  14617. CylinderPanel.prototype._cylindricalMapping = function (source) {
  14618. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  14619. var yAngle = (source.x / this._radius);
  14620. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14621. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14622. };
  14623. return CylinderPanel;
  14624. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14625. /***/ }),
  14626. /***/ "./3D/controls/holographicButton.ts":
  14627. /*!******************************************!*\
  14628. !*** ./3D/controls/holographicButton.ts ***!
  14629. \******************************************/
  14630. /*! exports provided: HolographicButton */
  14631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14632. "use strict";
  14633. __webpack_require__.r(__webpack_exports__);
  14634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  14635. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14636. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14637. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Materials/standardMaterial */ "babylonjs/Misc/perfCounter");
  14638. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__);
  14639. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14640. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  14641. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  14642. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  14643. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14644. /**
  14645. * Class used to create a holographic button in 3D
  14646. */
  14647. var HolographicButton = /** @class */ (function (_super) {
  14648. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  14649. /**
  14650. * Creates a new button
  14651. * @param name defines the control name
  14652. */
  14653. function HolographicButton(name, shareMaterials) {
  14654. if (shareMaterials === void 0) { shareMaterials = true; }
  14655. var _this = _super.call(this, name) || this;
  14656. _this._shareMaterials = true;
  14657. _this._shareMaterials = shareMaterials;
  14658. // Default animations
  14659. _this.pointerEnterAnimation = function () {
  14660. if (!_this.mesh) {
  14661. return;
  14662. }
  14663. _this._frontPlate.setEnabled(true);
  14664. };
  14665. _this.pointerOutAnimation = function () {
  14666. if (!_this.mesh) {
  14667. return;
  14668. }
  14669. _this._frontPlate.setEnabled(false);
  14670. };
  14671. return _this;
  14672. }
  14673. HolographicButton.prototype._disposeTooltip = function () {
  14674. this._tooltipFade = null;
  14675. if (this._tooltipTextBlock) {
  14676. this._tooltipTextBlock.dispose();
  14677. }
  14678. if (this._tooltipTexture) {
  14679. this._tooltipTexture.dispose();
  14680. }
  14681. if (this._tooltipMesh) {
  14682. this._tooltipMesh.dispose();
  14683. }
  14684. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  14685. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  14686. };
  14687. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  14688. get: function () {
  14689. return this._backPlate.renderingGroupId;
  14690. },
  14691. /**
  14692. * Rendering ground id of all the mesh in the button
  14693. */
  14694. set: function (id) {
  14695. this._backPlate.renderingGroupId = id;
  14696. this._textPlate.renderingGroupId = id;
  14697. this._frontPlate.renderingGroupId = id;
  14698. if (this._tooltipMesh) {
  14699. this._tooltipMesh.renderingGroupId = id;
  14700. }
  14701. },
  14702. enumerable: true,
  14703. configurable: true
  14704. });
  14705. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  14706. get: function () {
  14707. if (this._tooltipTextBlock) {
  14708. return this._tooltipTextBlock.text;
  14709. }
  14710. return null;
  14711. },
  14712. /**
  14713. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  14714. */
  14715. set: function (text) {
  14716. var _this = this;
  14717. if (!text) {
  14718. this._disposeTooltip();
  14719. return;
  14720. }
  14721. if (!this._tooltipFade) {
  14722. // Create tooltip with mesh and text
  14723. this._tooltipMesh = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  14724. 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);
  14725. var mat = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  14726. mat.diffuseColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  14727. tooltipBackground.material = mat;
  14728. tooltipBackground.isPickable = false;
  14729. this._tooltipMesh.addChild(tooltipBackground);
  14730. tooltipBackground.position.z = 0.05;
  14731. this._tooltipMesh.scaling.y = 1 / 3;
  14732. this._tooltipMesh.position.y = 0.7;
  14733. this._tooltipMesh.position.z = -0.15;
  14734. this._tooltipMesh.isPickable = false;
  14735. this._tooltipMesh.parent = this._backPlate;
  14736. // Create text texture for the tooltip
  14737. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  14738. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14739. this._tooltipTextBlock.scaleY = 3;
  14740. this._tooltipTextBlock.color = "white";
  14741. this._tooltipTextBlock.fontSize = 130;
  14742. this._tooltipTexture.addControl(this._tooltipTextBlock);
  14743. // Add hover action to tooltip
  14744. this._tooltipFade = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  14745. this._tooltipFade.delay = 500;
  14746. this._tooltipMesh.addBehavior(this._tooltipFade);
  14747. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  14748. if (_this._tooltipFade) {
  14749. _this._tooltipFade.fadeIn(true);
  14750. }
  14751. });
  14752. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  14753. if (_this._tooltipFade) {
  14754. _this._tooltipFade.fadeIn(false);
  14755. }
  14756. });
  14757. }
  14758. if (this._tooltipTextBlock) {
  14759. this._tooltipTextBlock.text = text;
  14760. }
  14761. },
  14762. enumerable: true,
  14763. configurable: true
  14764. });
  14765. Object.defineProperty(HolographicButton.prototype, "text", {
  14766. /**
  14767. * Gets or sets text for the button
  14768. */
  14769. get: function () {
  14770. return this._text;
  14771. },
  14772. set: function (value) {
  14773. if (this._text === value) {
  14774. return;
  14775. }
  14776. this._text = value;
  14777. this._rebuildContent();
  14778. },
  14779. enumerable: true,
  14780. configurable: true
  14781. });
  14782. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  14783. /**
  14784. * Gets or sets the image url for the button
  14785. */
  14786. get: function () {
  14787. return this._imageUrl;
  14788. },
  14789. set: function (value) {
  14790. if (this._imageUrl === value) {
  14791. return;
  14792. }
  14793. this._imageUrl = value;
  14794. this._rebuildContent();
  14795. },
  14796. enumerable: true,
  14797. configurable: true
  14798. });
  14799. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  14800. /**
  14801. * Gets the back material used by this button
  14802. */
  14803. get: function () {
  14804. return this._backMaterial;
  14805. },
  14806. enumerable: true,
  14807. configurable: true
  14808. });
  14809. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  14810. /**
  14811. * Gets the front material used by this button
  14812. */
  14813. get: function () {
  14814. return this._frontMaterial;
  14815. },
  14816. enumerable: true,
  14817. configurable: true
  14818. });
  14819. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  14820. /**
  14821. * Gets the plate material used by this button
  14822. */
  14823. get: function () {
  14824. return this._plateMaterial;
  14825. },
  14826. enumerable: true,
  14827. configurable: true
  14828. });
  14829. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  14830. /**
  14831. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  14832. */
  14833. get: function () {
  14834. return this._shareMaterials;
  14835. },
  14836. enumerable: true,
  14837. configurable: true
  14838. });
  14839. HolographicButton.prototype._getTypeName = function () {
  14840. return "HolographicButton";
  14841. };
  14842. HolographicButton.prototype._rebuildContent = function () {
  14843. this._disposeFacadeTexture();
  14844. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  14845. panel.isVertical = true;
  14846. if (this._imageUrl) {
  14847. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  14848. image.source = this._imageUrl;
  14849. image.paddingTop = "40px";
  14850. image.height = "180px";
  14851. image.width = "100px";
  14852. image.paddingBottom = "40px";
  14853. panel.addControl(image);
  14854. }
  14855. if (this._text) {
  14856. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14857. text.text = this._text;
  14858. text.color = "white";
  14859. text.height = "30px";
  14860. text.fontSize = 24;
  14861. panel.addControl(text);
  14862. }
  14863. if (this._frontPlate) {
  14864. this.content = panel;
  14865. }
  14866. };
  14867. // Mesh association
  14868. HolographicButton.prototype._createNode = function (scene) {
  14869. this._backPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  14870. width: 1.0,
  14871. height: 1.0,
  14872. depth: 0.08
  14873. }, scene);
  14874. this._frontPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  14875. width: 1.0,
  14876. height: 1.0,
  14877. depth: 0.08
  14878. }, scene);
  14879. this._frontPlate.parent = this._backPlate;
  14880. this._frontPlate.position.z = -0.08;
  14881. this._frontPlate.isPickable = false;
  14882. this._frontPlate.setEnabled(false);
  14883. this._textPlate = _super.prototype._createNode.call(this, scene);
  14884. this._textPlate.parent = this._backPlate;
  14885. this._textPlate.position.z = -0.08;
  14886. this._textPlate.isPickable = false;
  14887. return this._backPlate;
  14888. };
  14889. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  14890. this._plateMaterial.emissiveTexture = facadeTexture;
  14891. this._plateMaterial.opacityTexture = facadeTexture;
  14892. };
  14893. HolographicButton.prototype._createBackMaterial = function (mesh) {
  14894. var _this = this;
  14895. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  14896. this._backMaterial.renderHoverLight = true;
  14897. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  14898. if (pickedPoint) {
  14899. _this._backMaterial.hoverPosition = pickedPoint;
  14900. _this._backMaterial.hoverColor.a = 1.0;
  14901. }
  14902. else {
  14903. _this._backMaterial.hoverColor.a = 0;
  14904. }
  14905. });
  14906. };
  14907. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  14908. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  14909. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  14910. this._frontMaterial.alpha = 0.5; // Additive
  14911. this._frontMaterial.renderBorders = true;
  14912. };
  14913. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  14914. this._plateMaterial = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  14915. this._plateMaterial.specularColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  14916. };
  14917. HolographicButton.prototype._affectMaterial = function (mesh) {
  14918. // Back
  14919. if (this._shareMaterials) {
  14920. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  14921. this._createBackMaterial(mesh);
  14922. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  14923. }
  14924. else {
  14925. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  14926. }
  14927. // Front
  14928. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  14929. this._createFrontMaterial(mesh);
  14930. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  14931. }
  14932. else {
  14933. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  14934. }
  14935. }
  14936. else {
  14937. this._createBackMaterial(mesh);
  14938. this._createFrontMaterial(mesh);
  14939. }
  14940. this._createPlateMaterial(mesh);
  14941. this._backPlate.material = this._backMaterial;
  14942. this._frontPlate.material = this._frontMaterial;
  14943. this._textPlate.material = this._plateMaterial;
  14944. this._rebuildContent();
  14945. };
  14946. /**
  14947. * Releases all associated resources
  14948. */
  14949. HolographicButton.prototype.dispose = function () {
  14950. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  14951. this._disposeTooltip();
  14952. if (!this.shareMaterials) {
  14953. this._backMaterial.dispose();
  14954. this._frontMaterial.dispose();
  14955. this._plateMaterial.dispose();
  14956. if (this._pickedPointObserver) {
  14957. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  14958. this._pickedPointObserver = null;
  14959. }
  14960. }
  14961. };
  14962. return HolographicButton;
  14963. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14964. /***/ }),
  14965. /***/ "./3D/controls/index.ts":
  14966. /*!******************************!*\
  14967. !*** ./3D/controls/index.ts ***!
  14968. \******************************/
  14969. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  14970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14971. "use strict";
  14972. __webpack_require__.r(__webpack_exports__);
  14973. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  14974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14975. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14977. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  14979. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  14981. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  14982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  14983. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  14984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  14985. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  14986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  14987. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  14988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  14989. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  14990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  14991. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  14992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  14993. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  14994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  14995. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  14997. /***/ }),
  14998. /***/ "./3D/controls/meshButton3D.ts":
  14999. /*!*************************************!*\
  15000. !*** ./3D/controls/meshButton3D.ts ***!
  15001. \*************************************/
  15002. /*! exports provided: MeshButton3D */
  15003. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15004. "use strict";
  15005. __webpack_require__.r(__webpack_exports__);
  15006. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  15007. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15008. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15009. /**
  15010. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  15011. */
  15012. var MeshButton3D = /** @class */ (function (_super) {
  15013. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  15014. /**
  15015. * Creates a new 3D button based on a mesh
  15016. * @param mesh mesh to become a 3D button
  15017. * @param name defines the control name
  15018. */
  15019. function MeshButton3D(mesh, name) {
  15020. var _this = _super.call(this, name) || this;
  15021. _this._currentMesh = mesh;
  15022. /**
  15023. * Provides a default behavior on hover/out & up/down
  15024. * Override those function to create your own desired behavior specific to your mesh
  15025. */
  15026. _this.pointerEnterAnimation = function () {
  15027. if (!_this.mesh) {
  15028. return;
  15029. }
  15030. _this.mesh.scaling.scaleInPlace(1.1);
  15031. };
  15032. _this.pointerOutAnimation = function () {
  15033. if (!_this.mesh) {
  15034. return;
  15035. }
  15036. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  15037. };
  15038. _this.pointerDownAnimation = function () {
  15039. if (!_this.mesh) {
  15040. return;
  15041. }
  15042. _this.mesh.scaling.scaleInPlace(0.95);
  15043. };
  15044. _this.pointerUpAnimation = function () {
  15045. if (!_this.mesh) {
  15046. return;
  15047. }
  15048. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  15049. };
  15050. return _this;
  15051. }
  15052. MeshButton3D.prototype._getTypeName = function () {
  15053. return "MeshButton3D";
  15054. };
  15055. // Mesh association
  15056. MeshButton3D.prototype._createNode = function (scene) {
  15057. var _this = this;
  15058. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  15059. mesh.metadata = _this;
  15060. });
  15061. return this._currentMesh;
  15062. };
  15063. MeshButton3D.prototype._affectMaterial = function (mesh) {
  15064. };
  15065. return MeshButton3D;
  15066. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15067. /***/ }),
  15068. /***/ "./3D/controls/planePanel.ts":
  15069. /*!***********************************!*\
  15070. !*** ./3D/controls/planePanel.ts ***!
  15071. \***********************************/
  15072. /*! exports provided: PlanePanel */
  15073. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15074. "use strict";
  15075. __webpack_require__.r(__webpack_exports__);
  15076. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  15077. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15078. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  15079. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  15080. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15081. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15082. /**
  15083. * Class used to create a container panel deployed on the surface of a plane
  15084. */
  15085. var PlanePanel = /** @class */ (function (_super) {
  15086. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  15087. function PlanePanel() {
  15088. return _super !== null && _super.apply(this, arguments) || this;
  15089. }
  15090. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  15091. var mesh = control.mesh;
  15092. if (!mesh) {
  15093. return;
  15094. }
  15095. control.position = nodePosition.clone();
  15096. var target = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15097. target.copyFrom(nodePosition);
  15098. switch (this.orientation) {
  15099. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  15100. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  15101. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15102. mesh.lookAt(target);
  15103. break;
  15104. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15105. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15106. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15107. mesh.lookAt(target);
  15108. break;
  15109. }
  15110. };
  15111. return PlanePanel;
  15112. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  15113. /***/ }),
  15114. /***/ "./3D/controls/scatterPanel.ts":
  15115. /*!*************************************!*\
  15116. !*** ./3D/controls/scatterPanel.ts ***!
  15117. \*************************************/
  15118. /*! exports provided: ScatterPanel */
  15119. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15120. "use strict";
  15121. __webpack_require__.r(__webpack_exports__);
  15122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  15123. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15124. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15125. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15126. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15127. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15128. /**
  15129. * Class used to create a container panel where items get randomized planar mapping
  15130. */
  15131. var ScatterPanel = /** @class */ (function (_super) {
  15132. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  15133. function ScatterPanel() {
  15134. var _this = _super !== null && _super.apply(this, arguments) || this;
  15135. _this._iteration = 100.0;
  15136. return _this;
  15137. }
  15138. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  15139. /**
  15140. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  15141. */
  15142. get: function () {
  15143. return this._iteration;
  15144. },
  15145. set: function (value) {
  15146. var _this = this;
  15147. if (this._iteration === value) {
  15148. return;
  15149. }
  15150. this._iteration = value;
  15151. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15152. _this._arrangeChildren();
  15153. });
  15154. },
  15155. enumerable: true,
  15156. configurable: true
  15157. });
  15158. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  15159. var mesh = control.mesh;
  15160. var newPos = this._scatterMapping(nodePosition);
  15161. if (!mesh) {
  15162. return;
  15163. }
  15164. switch (this.orientation) {
  15165. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15166. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15167. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15168. break;
  15169. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15170. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15171. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15172. break;
  15173. }
  15174. control.position = newPos;
  15175. };
  15176. ScatterPanel.prototype._scatterMapping = function (source) {
  15177. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  15178. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  15179. return source;
  15180. };
  15181. ScatterPanel.prototype._finalProcessing = function () {
  15182. var meshes = [];
  15183. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15184. var child = _a[_i];
  15185. if (!child.mesh) {
  15186. continue;
  15187. }
  15188. meshes.push(child.mesh);
  15189. }
  15190. for (var count = 0; count < this._iteration; count++) {
  15191. meshes.sort(function (a, b) {
  15192. var distance1 = a.position.lengthSquared();
  15193. var distance2 = b.position.lengthSquared();
  15194. if (distance1 < distance2) {
  15195. return 1;
  15196. }
  15197. else if (distance1 > distance2) {
  15198. return -1;
  15199. }
  15200. return 0;
  15201. });
  15202. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  15203. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  15204. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  15205. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15206. for (var i = 0; i < meshes.length - 1; i++) {
  15207. for (var j = i + 1; j < meshes.length; j++) {
  15208. if (i != j) {
  15209. meshes[j].position.subtractToRef(meshes[i].position, difference);
  15210. // Ignore Z axis
  15211. difference2D.x = difference.x;
  15212. difference2D.y = difference.y;
  15213. var combinedRadius = cellSize;
  15214. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  15215. var minSeparation = Math.min(distance, radiusPaddingSquared);
  15216. distance -= minSeparation;
  15217. if (distance < (Math.pow(combinedRadius, 2.0))) {
  15218. difference2D.normalize();
  15219. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  15220. meshes[j].position.addInPlace(difference);
  15221. meshes[i].position.subtractInPlace(difference);
  15222. }
  15223. }
  15224. }
  15225. }
  15226. }
  15227. };
  15228. return ScatterPanel;
  15229. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15230. /***/ }),
  15231. /***/ "./3D/controls/spherePanel.ts":
  15232. /*!************************************!*\
  15233. !*** ./3D/controls/spherePanel.ts ***!
  15234. \************************************/
  15235. /*! exports provided: SpherePanel */
  15236. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15237. "use strict";
  15238. __webpack_require__.r(__webpack_exports__);
  15239. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  15240. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15241. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15242. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15243. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15244. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15245. /**
  15246. * Class used to create a container panel deployed on the surface of a sphere
  15247. */
  15248. var SpherePanel = /** @class */ (function (_super) {
  15249. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  15250. function SpherePanel() {
  15251. var _this = _super !== null && _super.apply(this, arguments) || this;
  15252. _this._radius = 5.0;
  15253. return _this;
  15254. }
  15255. Object.defineProperty(SpherePanel.prototype, "radius", {
  15256. /**
  15257. * Gets or sets the radius of the sphere where to project controls (5 by default)
  15258. */
  15259. get: function () {
  15260. return this._radius;
  15261. },
  15262. set: function (value) {
  15263. var _this = this;
  15264. if (this._radius === value) {
  15265. return;
  15266. }
  15267. this._radius = value;
  15268. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15269. _this._arrangeChildren();
  15270. });
  15271. },
  15272. enumerable: true,
  15273. configurable: true
  15274. });
  15275. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  15276. var mesh = control.mesh;
  15277. if (!mesh) {
  15278. return;
  15279. }
  15280. var newPos = this._sphericalMapping(nodePosition);
  15281. control.position = newPos;
  15282. switch (this.orientation) {
  15283. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15284. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  15285. break;
  15286. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15287. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  15288. break;
  15289. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15290. break;
  15291. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15292. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  15293. break;
  15294. }
  15295. };
  15296. SpherePanel.prototype._sphericalMapping = function (source) {
  15297. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  15298. var xAngle = (source.y / this._radius);
  15299. var yAngle = -(source.x / this._radius);
  15300. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15301. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15302. };
  15303. return SpherePanel;
  15304. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15305. /***/ }),
  15306. /***/ "./3D/controls/stackPanel3D.ts":
  15307. /*!*************************************!*\
  15308. !*** ./3D/controls/stackPanel3D.ts ***!
  15309. \*************************************/
  15310. /*! exports provided: StackPanel3D */
  15311. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15312. "use strict";
  15313. __webpack_require__.r(__webpack_exports__);
  15314. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  15315. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15316. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15317. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15318. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15319. /**
  15320. * Class used to create a stack panel in 3D on XY plane
  15321. */
  15322. var StackPanel3D = /** @class */ (function (_super) {
  15323. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  15324. /**
  15325. * Creates new StackPanel
  15326. * @param isVertical
  15327. */
  15328. function StackPanel3D(isVertical) {
  15329. if (isVertical === void 0) { isVertical = false; }
  15330. var _this = _super.call(this) || this;
  15331. _this._isVertical = false;
  15332. /**
  15333. * Gets or sets the distance between elements
  15334. */
  15335. _this.margin = 0.1;
  15336. _this._isVertical = isVertical;
  15337. return _this;
  15338. }
  15339. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  15340. /**
  15341. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  15342. */
  15343. get: function () {
  15344. return this._isVertical;
  15345. },
  15346. set: function (value) {
  15347. var _this = this;
  15348. if (this._isVertical === value) {
  15349. return;
  15350. }
  15351. this._isVertical = value;
  15352. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15353. _this._arrangeChildren();
  15354. });
  15355. },
  15356. enumerable: true,
  15357. configurable: true
  15358. });
  15359. StackPanel3D.prototype._arrangeChildren = function () {
  15360. var width = 0;
  15361. var height = 0;
  15362. var controlCount = 0;
  15363. var extendSizes = [];
  15364. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15365. // Measure
  15366. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15367. var child = _a[_i];
  15368. if (!child.mesh) {
  15369. continue;
  15370. }
  15371. controlCount++;
  15372. child.mesh.computeWorldMatrix(true);
  15373. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15374. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  15375. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15376. extendSizes.push(extendSize);
  15377. if (this._isVertical) {
  15378. height += extendSize.y;
  15379. }
  15380. else {
  15381. width += extendSize.x;
  15382. }
  15383. }
  15384. if (this._isVertical) {
  15385. height += (controlCount - 1) * this.margin / 2;
  15386. }
  15387. else {
  15388. width += (controlCount - 1) * this.margin / 2;
  15389. }
  15390. // Arrange
  15391. var offset;
  15392. if (this._isVertical) {
  15393. offset = -height;
  15394. }
  15395. else {
  15396. offset = -width;
  15397. }
  15398. var index = 0;
  15399. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15400. var child = _c[_b];
  15401. if (!child.mesh) {
  15402. continue;
  15403. }
  15404. controlCount--;
  15405. var extendSize = extendSizes[index++];
  15406. if (this._isVertical) {
  15407. child.position.y = offset + extendSize.y;
  15408. child.position.x = 0;
  15409. offset += extendSize.y * 2;
  15410. }
  15411. else {
  15412. child.position.x = offset + extendSize.x;
  15413. child.position.y = 0;
  15414. offset += extendSize.x * 2;
  15415. }
  15416. offset += (controlCount > 0 ? this.margin : 0);
  15417. }
  15418. };
  15419. return StackPanel3D;
  15420. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15421. /***/ }),
  15422. /***/ "./3D/controls/volumeBasedPanel.ts":
  15423. /*!*****************************************!*\
  15424. !*** ./3D/controls/volumeBasedPanel.ts ***!
  15425. \*****************************************/
  15426. /*! exports provided: VolumeBasedPanel */
  15427. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15428. "use strict";
  15429. __webpack_require__.r(__webpack_exports__);
  15430. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  15431. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15432. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15433. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15434. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15435. /**
  15436. * Abstract class used to create a container panel deployed on the surface of a volume
  15437. */
  15438. var VolumeBasedPanel = /** @class */ (function (_super) {
  15439. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  15440. /**
  15441. * Creates new VolumeBasedPanel
  15442. */
  15443. function VolumeBasedPanel() {
  15444. var _this = _super.call(this) || this;
  15445. _this._columns = 10;
  15446. _this._rows = 0;
  15447. _this._rowThenColum = true;
  15448. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  15449. /**
  15450. * Gets or sets the distance between elements
  15451. */
  15452. _this.margin = 0;
  15453. return _this;
  15454. }
  15455. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  15456. /**
  15457. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  15458. * | Value | Type | Description |
  15459. * | ----- | ----------------------------------- | ----------- |
  15460. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  15461. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  15462. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  15463. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  15464. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  15465. */
  15466. get: function () {
  15467. return this._orientation;
  15468. },
  15469. set: function (value) {
  15470. var _this = this;
  15471. if (this._orientation === value) {
  15472. return;
  15473. }
  15474. this._orientation = value;
  15475. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15476. _this._arrangeChildren();
  15477. });
  15478. },
  15479. enumerable: true,
  15480. configurable: true
  15481. });
  15482. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  15483. /**
  15484. * Gets or sets the number of columns requested (10 by default).
  15485. * The panel will automatically compute the number of rows based on number of child controls.
  15486. */
  15487. get: function () {
  15488. return this._columns;
  15489. },
  15490. set: function (value) {
  15491. var _this = this;
  15492. if (this._columns === value) {
  15493. return;
  15494. }
  15495. this._columns = value;
  15496. this._rowThenColum = true;
  15497. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15498. _this._arrangeChildren();
  15499. });
  15500. },
  15501. enumerable: true,
  15502. configurable: true
  15503. });
  15504. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  15505. /**
  15506. * Gets or sets a the number of rows requested.
  15507. * The panel will automatically compute the number of columns based on number of child controls.
  15508. */
  15509. get: function () {
  15510. return this._rows;
  15511. },
  15512. set: function (value) {
  15513. var _this = this;
  15514. if (this._rows === value) {
  15515. return;
  15516. }
  15517. this._rows = value;
  15518. this._rowThenColum = false;
  15519. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15520. _this._arrangeChildren();
  15521. });
  15522. },
  15523. enumerable: true,
  15524. configurable: true
  15525. });
  15526. VolumeBasedPanel.prototype._arrangeChildren = function () {
  15527. this._cellWidth = 0;
  15528. this._cellHeight = 0;
  15529. var rows = 0;
  15530. var columns = 0;
  15531. var controlCount = 0;
  15532. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15533. // Measure
  15534. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15535. var child = _a[_i];
  15536. if (!child.mesh) {
  15537. continue;
  15538. }
  15539. controlCount++;
  15540. child.mesh.computeWorldMatrix(true);
  15541. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  15542. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  15543. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15544. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  15545. boundingBox.max.subtractToRef(boundingBox.min, diff);
  15546. diff.scaleInPlace(0.5);
  15547. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  15548. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  15549. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  15550. }
  15551. this._cellWidth += this.margin * 2;
  15552. this._cellHeight += this.margin * 2;
  15553. // Arrange
  15554. if (this._rowThenColum) {
  15555. columns = this._columns;
  15556. rows = Math.ceil(controlCount / this._columns);
  15557. }
  15558. else {
  15559. rows = this._rows;
  15560. columns = Math.ceil(controlCount / this._rows);
  15561. }
  15562. var startOffsetX = (columns * 0.5) * this._cellWidth;
  15563. var startOffsetY = (rows * 0.5) * this._cellHeight;
  15564. var nodeGrid = [];
  15565. var cellCounter = 0;
  15566. if (this._rowThenColum) {
  15567. for (var r = 0; r < rows; r++) {
  15568. for (var c = 0; c < columns; c++) {
  15569. 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));
  15570. cellCounter++;
  15571. if (cellCounter > controlCount) {
  15572. break;
  15573. }
  15574. }
  15575. }
  15576. }
  15577. else {
  15578. for (var c = 0; c < columns; c++) {
  15579. for (var r = 0; r < rows; r++) {
  15580. 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));
  15581. cellCounter++;
  15582. if (cellCounter > controlCount) {
  15583. break;
  15584. }
  15585. }
  15586. }
  15587. }
  15588. cellCounter = 0;
  15589. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15590. var child = _c[_b];
  15591. if (!child.mesh) {
  15592. continue;
  15593. }
  15594. this._mapGridNode(child, nodeGrid[cellCounter]);
  15595. cellCounter++;
  15596. }
  15597. this._finalProcessing();
  15598. };
  15599. /** Child classes can implement this function to provide additional processing */
  15600. VolumeBasedPanel.prototype._finalProcessing = function () {
  15601. };
  15602. return VolumeBasedPanel;
  15603. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15604. /***/ }),
  15605. /***/ "./3D/gui3DManager.ts":
  15606. /*!****************************!*\
  15607. !*** ./3D/gui3DManager.ts ***!
  15608. \****************************/
  15609. /*! exports provided: GUI3DManager */
  15610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15611. "use strict";
  15612. __webpack_require__.r(__webpack_exports__);
  15613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  15614. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  15615. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15616. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  15617. /**
  15618. * Class used to manage 3D user interface
  15619. * @see http://doc.babylonjs.com/how_to/gui3d
  15620. */
  15621. var GUI3DManager = /** @class */ (function () {
  15622. /**
  15623. * Creates a new GUI3DManager
  15624. * @param scene
  15625. */
  15626. function GUI3DManager(scene) {
  15627. var _this = this;
  15628. /** @hidden */
  15629. this._lastControlOver = {};
  15630. /** @hidden */
  15631. this._lastControlDown = {};
  15632. /**
  15633. * Observable raised when the point picked by the pointer events changed
  15634. */
  15635. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15636. // Shared resources
  15637. /** @hidden */
  15638. this._sharedMaterials = {};
  15639. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  15640. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  15641. _this._sceneDisposeObserver = null;
  15642. _this._utilityLayer = null;
  15643. _this.dispose();
  15644. });
  15645. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  15646. this._utilityLayer.onlyCheckPointerDownEvents = false;
  15647. this._utilityLayer.pickUtilitySceneFirst = false;
  15648. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  15649. return mesh && mesh.metadata && mesh.metadata._node;
  15650. };
  15651. // Root
  15652. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  15653. this._rootContainer._host = this;
  15654. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  15655. // Events
  15656. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  15657. _this._handlePointerOut(pointerId, true);
  15658. });
  15659. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  15660. _this._doPicking(pi);
  15661. });
  15662. // Scene
  15663. this._utilityLayer.utilityLayerScene.autoClear = false;
  15664. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  15665. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  15666. }
  15667. Object.defineProperty(GUI3DManager.prototype, "scene", {
  15668. /** Gets the hosting scene */
  15669. get: function () {
  15670. return this._scene;
  15671. },
  15672. enumerable: true,
  15673. configurable: true
  15674. });
  15675. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  15676. /** Gets associated utility layer */
  15677. get: function () {
  15678. return this._utilityLayer;
  15679. },
  15680. enumerable: true,
  15681. configurable: true
  15682. });
  15683. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  15684. var previousControlOver = this._lastControlOver[pointerId];
  15685. if (previousControlOver) {
  15686. previousControlOver._onPointerOut(previousControlOver);
  15687. delete this._lastControlOver[pointerId];
  15688. }
  15689. if (isPointerUp) {
  15690. if (this._lastControlDown[pointerId]) {
  15691. this._lastControlDown[pointerId].forcePointerUp();
  15692. delete this._lastControlDown[pointerId];
  15693. }
  15694. }
  15695. this.onPickedPointChangedObservable.notifyObservers(null);
  15696. };
  15697. GUI3DManager.prototype._doPicking = function (pi) {
  15698. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  15699. return false;
  15700. }
  15701. var pointerEvent = (pi.event);
  15702. var pointerId = pointerEvent.pointerId || 0;
  15703. var buttonIndex = pointerEvent.button;
  15704. var pickingInfo = pi.pickInfo;
  15705. if (!pickingInfo || !pickingInfo.hit) {
  15706. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  15707. return false;
  15708. }
  15709. var control = (pickingInfo.pickedMesh.metadata);
  15710. if (pickingInfo.pickedPoint) {
  15711. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  15712. }
  15713. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  15714. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15715. if (this._lastControlOver[pointerId]) {
  15716. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  15717. }
  15718. delete this._lastControlOver[pointerId];
  15719. }
  15720. }
  15721. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  15722. if (this._lastControlDown[pointerEvent.pointerId]) {
  15723. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  15724. delete this._lastControlDown[pointerEvent.pointerId];
  15725. }
  15726. if (pointerEvent.pointerType === "touch") {
  15727. this._handlePointerOut(pointerId, false);
  15728. }
  15729. }
  15730. return true;
  15731. };
  15732. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  15733. /**
  15734. * Gets the root container
  15735. */
  15736. get: function () {
  15737. return this._rootContainer;
  15738. },
  15739. enumerable: true,
  15740. configurable: true
  15741. });
  15742. /**
  15743. * Gets a boolean indicating if the given control is in the root child list
  15744. * @param control defines the control to check
  15745. * @returns true if the control is in the root child list
  15746. */
  15747. GUI3DManager.prototype.containsControl = function (control) {
  15748. return this._rootContainer.containsControl(control);
  15749. };
  15750. /**
  15751. * Adds a control to the root child list
  15752. * @param control defines the control to add
  15753. * @returns the current manager
  15754. */
  15755. GUI3DManager.prototype.addControl = function (control) {
  15756. this._rootContainer.addControl(control);
  15757. return this;
  15758. };
  15759. /**
  15760. * Removes a control from the root child list
  15761. * @param control defines the control to remove
  15762. * @returns the current container
  15763. */
  15764. GUI3DManager.prototype.removeControl = function (control) {
  15765. this._rootContainer.removeControl(control);
  15766. return this;
  15767. };
  15768. /**
  15769. * Releases all associated resources
  15770. */
  15771. GUI3DManager.prototype.dispose = function () {
  15772. this._rootContainer.dispose();
  15773. for (var materialName in this._sharedMaterials) {
  15774. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  15775. continue;
  15776. }
  15777. this._sharedMaterials[materialName].dispose();
  15778. }
  15779. this._sharedMaterials = {};
  15780. if (this._pointerOutObserver && this._utilityLayer) {
  15781. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  15782. this._pointerOutObserver = null;
  15783. }
  15784. this.onPickedPointChangedObservable.clear();
  15785. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  15786. if (utilityLayerScene) {
  15787. if (this._pointerObserver) {
  15788. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  15789. this._pointerObserver = null;
  15790. }
  15791. }
  15792. if (this._scene) {
  15793. if (this._sceneDisposeObserver) {
  15794. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  15795. this._sceneDisposeObserver = null;
  15796. }
  15797. }
  15798. if (this._utilityLayer) {
  15799. this._utilityLayer.dispose();
  15800. }
  15801. };
  15802. return GUI3DManager;
  15803. }());
  15804. /***/ }),
  15805. /***/ "./3D/index.ts":
  15806. /*!*********************!*\
  15807. !*** ./3D/index.ts ***!
  15808. \*********************/
  15809. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15810. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15811. "use strict";
  15812. __webpack_require__.r(__webpack_exports__);
  15813. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  15814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15826. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  15827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15829. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  15830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  15831. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  15832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  15833. /***/ }),
  15834. /***/ "./3D/materials/fluentMaterial.ts":
  15835. /*!****************************************!*\
  15836. !*** ./3D/materials/fluentMaterial.ts ***!
  15837. \****************************************/
  15838. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15839. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15840. "use strict";
  15841. __webpack_require__.r(__webpack_exports__);
  15842. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  15843. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  15844. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15845. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  15846. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  15847. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  15848. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  15849. /** @hidden */
  15850. var FluentMaterialDefines = /** @class */ (function (_super) {
  15851. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  15852. function FluentMaterialDefines() {
  15853. var _this = _super.call(this) || this;
  15854. _this.INNERGLOW = false;
  15855. _this.BORDER = false;
  15856. _this.HOVERLIGHT = false;
  15857. _this.TEXTURE = false;
  15858. _this.rebuild();
  15859. return _this;
  15860. }
  15861. return FluentMaterialDefines;
  15862. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  15863. /**
  15864. * Class used to render controls with fluent desgin
  15865. */
  15866. var FluentMaterial = /** @class */ (function (_super) {
  15867. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  15868. /**
  15869. * Creates a new Fluent material
  15870. * @param name defines the name of the material
  15871. * @param scene defines the hosting scene
  15872. */
  15873. function FluentMaterial(name, scene) {
  15874. var _this = _super.call(this, name, scene) || this;
  15875. /**
  15876. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  15877. */
  15878. _this.innerGlowColorIntensity = 0.5;
  15879. /**
  15880. * Gets or sets the inner glow color (white by default)
  15881. */
  15882. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  15883. /**
  15884. * Gets or sets alpha value (default is 1.0)
  15885. */
  15886. _this.alpha = 1.0;
  15887. /**
  15888. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  15889. */
  15890. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  15891. /**
  15892. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  15893. */
  15894. _this.renderBorders = false;
  15895. /**
  15896. * Gets or sets border width (default is 0.5)
  15897. */
  15898. _this.borderWidth = 0.5;
  15899. /**
  15900. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  15901. */
  15902. _this.edgeSmoothingValue = 0.02;
  15903. /**
  15904. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  15905. */
  15906. _this.borderMinValue = 0.1;
  15907. /**
  15908. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  15909. */
  15910. _this.renderHoverLight = false;
  15911. /**
  15912. * Gets or sets the radius used to render the hover light (default is 1.0)
  15913. */
  15914. _this.hoverRadius = 1.0;
  15915. /**
  15916. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  15917. */
  15918. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  15919. /**
  15920. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  15921. */
  15922. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  15923. return _this;
  15924. }
  15925. FluentMaterial.prototype.needAlphaBlending = function () {
  15926. return this.alpha !== 1.0;
  15927. };
  15928. FluentMaterial.prototype.needAlphaTesting = function () {
  15929. return false;
  15930. };
  15931. FluentMaterial.prototype.getAlphaTestTexture = function () {
  15932. return null;
  15933. };
  15934. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  15935. if (this.isFrozen) {
  15936. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  15937. return true;
  15938. }
  15939. }
  15940. if (!subMesh._materialDefines) {
  15941. subMesh._materialDefines = new FluentMaterialDefines();
  15942. }
  15943. var scene = this.getScene();
  15944. var defines = subMesh._materialDefines;
  15945. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  15946. if (defines._renderId === scene.getRenderId()) {
  15947. return true;
  15948. }
  15949. }
  15950. if (defines._areTexturesDirty) {
  15951. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  15952. defines.BORDER = this.renderBorders;
  15953. defines.HOVERLIGHT = this.renderHoverLight;
  15954. if (this._albedoTexture) {
  15955. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  15956. return false;
  15957. }
  15958. else {
  15959. defines.TEXTURE = true;
  15960. }
  15961. }
  15962. else {
  15963. defines.TEXTURE = false;
  15964. }
  15965. }
  15966. var engine = scene.getEngine();
  15967. // Get correct effect
  15968. if (defines.isDirty) {
  15969. defines.markAsProcessed();
  15970. scene.resetCachedMaterial();
  15971. //Attributes
  15972. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  15973. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  15974. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  15975. var shaderName = "fluent";
  15976. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  15977. "hoverColor", "hoverPosition", "hoverRadius"
  15978. ];
  15979. var samplers = ["albedoSampler"];
  15980. var uniformBuffers = new Array();
  15981. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  15982. uniformsNames: uniforms,
  15983. uniformBuffersNames: uniformBuffers,
  15984. samplers: samplers,
  15985. defines: defines,
  15986. maxSimultaneousLights: 4
  15987. });
  15988. var join = defines.toString();
  15989. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  15990. attributes: attribs,
  15991. uniformsNames: uniforms,
  15992. uniformBuffersNames: uniformBuffers,
  15993. samplers: samplers,
  15994. defines: join,
  15995. fallbacks: null,
  15996. onCompiled: this.onCompiled,
  15997. onError: this.onError,
  15998. indexParameters: { maxSimultaneousLights: 4 }
  15999. }, engine));
  16000. }
  16001. if (!subMesh.effect || !subMesh.effect.isReady()) {
  16002. return false;
  16003. }
  16004. defines._renderId = scene.getRenderId();
  16005. subMesh.effect._wasPreviouslyReady = true;
  16006. return true;
  16007. };
  16008. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  16009. var scene = this.getScene();
  16010. var defines = subMesh._materialDefines;
  16011. if (!defines) {
  16012. return;
  16013. }
  16014. var effect = subMesh.effect;
  16015. if (!effect) {
  16016. return;
  16017. }
  16018. this._activeEffect = effect;
  16019. // Matrices
  16020. this.bindOnlyWorldMatrix(world);
  16021. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  16022. if (this._mustRebind(scene, effect)) {
  16023. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  16024. if (defines.INNERGLOW) {
  16025. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  16026. }
  16027. if (defines.BORDER) {
  16028. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  16029. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  16030. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  16031. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16032. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16033. }
  16034. if (defines.HOVERLIGHT) {
  16035. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  16036. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  16037. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  16038. }
  16039. if (defines.TEXTURE) {
  16040. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  16041. }
  16042. }
  16043. this._afterBind(mesh, this._activeEffect);
  16044. };
  16045. FluentMaterial.prototype.getActiveTextures = function () {
  16046. var activeTextures = _super.prototype.getActiveTextures.call(this);
  16047. return activeTextures;
  16048. };
  16049. FluentMaterial.prototype.hasTexture = function (texture) {
  16050. if (_super.prototype.hasTexture.call(this, texture)) {
  16051. return true;
  16052. }
  16053. return false;
  16054. };
  16055. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  16056. _super.prototype.dispose.call(this, forceDisposeEffect);
  16057. };
  16058. FluentMaterial.prototype.clone = function (name) {
  16059. var _this = this;
  16060. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  16061. };
  16062. FluentMaterial.prototype.serialize = function () {
  16063. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  16064. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  16065. return serializationObject;
  16066. };
  16067. FluentMaterial.prototype.getClassName = function () {
  16068. return "FluentMaterial";
  16069. };
  16070. // Statics
  16071. FluentMaterial.Parse = function (source, scene, rootUrl) {
  16072. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  16073. };
  16074. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16075. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16076. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16077. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  16078. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16079. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16080. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  16081. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16082. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16083. ], FluentMaterial.prototype, "alpha", void 0);
  16084. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16085. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16086. ], FluentMaterial.prototype, "albedoColor", void 0);
  16087. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16088. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16089. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16090. ], FluentMaterial.prototype, "renderBorders", void 0);
  16091. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16092. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16093. ], FluentMaterial.prototype, "borderWidth", void 0);
  16094. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16095. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16096. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  16097. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16098. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16099. ], FluentMaterial.prototype, "borderMinValue", void 0);
  16100. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16101. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16102. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16103. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  16104. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16105. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16106. ], FluentMaterial.prototype, "hoverRadius", void 0);
  16107. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16108. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  16109. ], FluentMaterial.prototype, "hoverColor", void 0);
  16110. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16111. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  16112. ], FluentMaterial.prototype, "hoverPosition", void 0);
  16113. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16114. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  16115. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  16116. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16117. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  16118. ], FluentMaterial.prototype, "albedoTexture", void 0);
  16119. return FluentMaterial;
  16120. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  16121. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  16122. /***/ }),
  16123. /***/ "./3D/materials/index.ts":
  16124. /*!*******************************!*\
  16125. !*** ./3D/materials/index.ts ***!
  16126. \*******************************/
  16127. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16129. "use strict";
  16130. __webpack_require__.r(__webpack_exports__);
  16131. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  16132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16134. /***/ }),
  16135. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  16136. /*!*************************************************!*\
  16137. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  16138. \*************************************************/
  16139. /*! exports provided: fluentPixelShader */
  16140. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16141. "use strict";
  16142. __webpack_require__.r(__webpack_exports__);
  16143. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  16144. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  16145. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16146. var name = 'fluentPixelShader';
  16147. 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}";
  16148. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16149. /** @hidden */
  16150. var fluentPixelShader = { name: name, shader: shader };
  16151. /***/ }),
  16152. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  16153. /*!***********************************************!*\
  16154. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  16155. \***********************************************/
  16156. /*! exports provided: fluentVertexShader */
  16157. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16158. "use strict";
  16159. __webpack_require__.r(__webpack_exports__);
  16160. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  16161. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  16162. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16163. var name = 'fluentVertexShader';
  16164. 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";
  16165. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16166. /** @hidden */
  16167. var fluentVertexShader = { name: name, shader: shader };
  16168. /***/ }),
  16169. /***/ "./3D/vector3WithInfo.ts":
  16170. /*!*******************************!*\
  16171. !*** ./3D/vector3WithInfo.ts ***!
  16172. \*******************************/
  16173. /*! exports provided: Vector3WithInfo */
  16174. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16175. "use strict";
  16176. __webpack_require__.r(__webpack_exports__);
  16177. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  16178. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16179. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  16180. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  16181. /**
  16182. * Class used to transport Vector3 information for pointer events
  16183. */
  16184. var Vector3WithInfo = /** @class */ (function (_super) {
  16185. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  16186. /**
  16187. * Creates a new Vector3WithInfo
  16188. * @param source defines the vector3 data to transport
  16189. * @param buttonIndex defines the current mouse button index
  16190. */
  16191. function Vector3WithInfo(source,
  16192. /** defines the current mouse button index */
  16193. buttonIndex) {
  16194. if (buttonIndex === void 0) { buttonIndex = 0; }
  16195. var _this = _super.call(this, source.x, source.y, source.z) || this;
  16196. _this.buttonIndex = buttonIndex;
  16197. return _this;
  16198. }
  16199. return Vector3WithInfo;
  16200. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  16201. /***/ }),
  16202. /***/ "./index.ts":
  16203. /*!******************!*\
  16204. !*** ./index.ts ***!
  16205. \******************/
  16206. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  16207. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16208. "use strict";
  16209. __webpack_require__.r(__webpack_exports__);
  16210. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  16211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16252. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  16253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  16254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  16255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  16256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  16257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  16258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  16259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  16260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  16261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  16262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  16263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  16264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  16265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  16266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  16267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16269. /***/ }),
  16270. /***/ "./legacy/legacy.ts":
  16271. /*!**************************!*\
  16272. !*** ./legacy/legacy.ts ***!
  16273. \**************************/
  16274. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  16275. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16276. "use strict";
  16277. __webpack_require__.r(__webpack_exports__);
  16278. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  16279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  16289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  16290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16336. /**
  16337. * Legacy support, defining window.BABYLON.GUI (global variable).
  16338. *
  16339. * This is the entry point for the UMD module.
  16340. * The entry point for a future ESM package should be index.ts
  16341. */
  16342. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  16343. if (typeof globalObject !== "undefined") {
  16344. globalObject.BABYLON = globalObject.BABYLON || {};
  16345. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  16346. }
  16347. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  16348. /***/ }),
  16349. /***/ "babylonjs/Misc/perfCounter":
  16350. /*!****************************************************************************************************!*\
  16351. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  16352. \****************************************************************************************************/
  16353. /*! no static exports found */
  16354. /***/ (function(module, exports) {
  16355. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__;
  16356. /***/ })
  16357. /******/ });
  16358. });
  16359. //# sourceMappingURL=babylon.gui.js.map