babylon.gui.js 746 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170
  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. /** @hidden */
  516. _this._numLayoutCalls = 0;
  517. /** @hidden */
  518. _this._numRenderCalls = 0;
  519. /**
  520. * Define type to string to ensure compatibility across browsers
  521. * Safari doesn't support DataTransfer constructor
  522. */
  523. _this._clipboardData = "";
  524. /**
  525. * Observable event triggered each time an clipboard event is received from the rendering canvas
  526. */
  527. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  528. /**
  529. * Observable event triggered each time a pointer down is intercepted by a control
  530. */
  531. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  532. /**
  533. * Observable event triggered before layout is evaluated
  534. */
  535. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  536. /**
  537. * Observable event triggered after the layout was evaluated
  538. */
  539. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  540. /**
  541. * Observable event triggered before the texture is rendered
  542. */
  543. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  544. /**
  545. * Observable event triggered after the texture was rendered
  546. */
  547. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  548. /**
  549. * Gets or sets a boolean defining if alpha is stored as premultiplied
  550. */
  551. _this.premulAlpha = false;
  552. _this._useInvalidateRectOptimization = true;
  553. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  554. _this._invalidatedRectangle = null;
  555. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  556. /** @hidden */
  557. _this.onClipboardCopy = function (rawEvt) {
  558. var evt = rawEvt;
  559. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  560. _this.onClipboardObservable.notifyObservers(ev);
  561. evt.preventDefault();
  562. };
  563. /** @hidden */
  564. _this.onClipboardCut = function (rawEvt) {
  565. var evt = rawEvt;
  566. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  567. _this.onClipboardObservable.notifyObservers(ev);
  568. evt.preventDefault();
  569. };
  570. /** @hidden */
  571. _this.onClipboardPaste = function (rawEvt) {
  572. var evt = rawEvt;
  573. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  574. _this.onClipboardObservable.notifyObservers(ev);
  575. evt.preventDefault();
  576. };
  577. scene = _this.getScene();
  578. if (!scene || !_this._texture) {
  579. return _this;
  580. }
  581. _this._rootElement = scene.getEngine().getInputElement();
  582. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  583. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  584. if (!_this._focusedControl) {
  585. return;
  586. }
  587. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  588. _this._focusedControl.processKeyboard(info.event);
  589. }
  590. info.skipOnPointerObservable = true;
  591. });
  592. _this._rootContainer._link(_this);
  593. _this.hasAlpha = true;
  594. if (!width || !height) {
  595. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  596. _this._onResize();
  597. }
  598. _this._texture.isReady = true;
  599. return _this;
  600. }
  601. Object.defineProperty(AdvancedDynamicTexture.prototype, "numLayoutCalls", {
  602. /** Gets the number of layout calls made the last time the ADT has been rendered */
  603. get: function () {
  604. return this._numLayoutCalls;
  605. },
  606. enumerable: true,
  607. configurable: true
  608. });
  609. Object.defineProperty(AdvancedDynamicTexture.prototype, "numRenderCalls", {
  610. /** Gets the number of render calls made the last time the ADT has been rendered */
  611. get: function () {
  612. return this._numRenderCalls;
  613. },
  614. enumerable: true,
  615. configurable: true
  616. });
  617. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  618. /**
  619. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  620. * Useful when you want more antialiasing
  621. */
  622. get: function () {
  623. return this._renderScale;
  624. },
  625. set: function (value) {
  626. if (value === this._renderScale) {
  627. return;
  628. }
  629. this._renderScale = value;
  630. this._onResize();
  631. },
  632. enumerable: true,
  633. configurable: true
  634. });
  635. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  636. /** Gets or sets the background color */
  637. get: function () {
  638. return this._background;
  639. },
  640. set: function (value) {
  641. if (this._background === value) {
  642. return;
  643. }
  644. this._background = value;
  645. this.markAsDirty();
  646. },
  647. enumerable: true,
  648. configurable: true
  649. });
  650. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  651. /**
  652. * Gets or sets the ideal width used to design controls.
  653. * The GUI will then rescale everything accordingly
  654. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  655. */
  656. get: function () {
  657. return this._idealWidth;
  658. },
  659. set: function (value) {
  660. if (this._idealWidth === value) {
  661. return;
  662. }
  663. this._idealWidth = value;
  664. this.markAsDirty();
  665. this._rootContainer._markAllAsDirty();
  666. },
  667. enumerable: true,
  668. configurable: true
  669. });
  670. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  671. /**
  672. * Gets or sets the ideal height used to design controls.
  673. * The GUI will then rescale everything accordingly
  674. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  675. */
  676. get: function () {
  677. return this._idealHeight;
  678. },
  679. set: function (value) {
  680. if (this._idealHeight === value) {
  681. return;
  682. }
  683. this._idealHeight = value;
  684. this.markAsDirty();
  685. this._rootContainer._markAllAsDirty();
  686. },
  687. enumerable: true,
  688. configurable: true
  689. });
  690. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  691. /**
  692. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  693. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  694. */
  695. get: function () {
  696. return this._useSmallestIdeal;
  697. },
  698. set: function (value) {
  699. if (this._useSmallestIdeal === value) {
  700. return;
  701. }
  702. this._useSmallestIdeal = value;
  703. this.markAsDirty();
  704. this._rootContainer._markAllAsDirty();
  705. },
  706. enumerable: true,
  707. configurable: true
  708. });
  709. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  710. /**
  711. * Gets or sets a boolean indicating if adaptive scaling must be used
  712. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  713. */
  714. get: function () {
  715. return this._renderAtIdealSize;
  716. },
  717. set: function (value) {
  718. if (this._renderAtIdealSize === value) {
  719. return;
  720. }
  721. this._renderAtIdealSize = value;
  722. this._onResize();
  723. },
  724. enumerable: true,
  725. configurable: true
  726. });
  727. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealRatio", {
  728. /**
  729. * Gets the ratio used when in "ideal mode"
  730. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  731. * */
  732. get: function () {
  733. var rwidth = 0;
  734. var rheight = 0;
  735. if (this._idealWidth) {
  736. rwidth = (this.getSize().width) / this._idealWidth;
  737. }
  738. if (this._idealHeight) {
  739. rheight = (this.getSize().height) / this._idealHeight;
  740. }
  741. if (this._useSmallestIdeal && this._idealWidth && this._idealHeight) {
  742. return window.innerWidth < window.innerHeight ? rwidth : rheight;
  743. }
  744. if (this._idealWidth) { // horizontal
  745. return rwidth;
  746. }
  747. if (this._idealHeight) { // vertical
  748. return rheight;
  749. }
  750. return 1;
  751. },
  752. enumerable: true,
  753. configurable: true
  754. });
  755. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  756. /**
  757. * Gets the underlying layer used to render the texture when in fullscreen mode
  758. */
  759. get: function () {
  760. return this._layerToDispose;
  761. },
  762. enumerable: true,
  763. configurable: true
  764. });
  765. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  766. /**
  767. * Gets the root container control
  768. */
  769. get: function () {
  770. return this._rootContainer;
  771. },
  772. enumerable: true,
  773. configurable: true
  774. });
  775. /**
  776. * Returns an array containing the root container.
  777. * This is mostly used to let the Inspector introspects the ADT
  778. * @returns an array containing the rootContainer
  779. */
  780. AdvancedDynamicTexture.prototype.getChildren = function () {
  781. return [this._rootContainer];
  782. };
  783. /**
  784. * Will return all controls that are inside this texture
  785. * @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
  786. * @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
  787. * @return all child controls
  788. */
  789. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  790. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  791. };
  792. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  793. /**
  794. * Gets or sets the current focused control
  795. */
  796. get: function () {
  797. return this._focusedControl;
  798. },
  799. set: function (control) {
  800. if (this._focusedControl == control) {
  801. return;
  802. }
  803. if (this._focusedControl) {
  804. this._focusedControl.onBlur();
  805. }
  806. if (control) {
  807. control.onFocus();
  808. }
  809. this._focusedControl = control;
  810. },
  811. enumerable: true,
  812. configurable: true
  813. });
  814. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  815. /**
  816. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  817. */
  818. get: function () {
  819. if (!this.layer) {
  820. return true;
  821. }
  822. return (!this.layer.isBackground);
  823. },
  824. set: function (value) {
  825. if (!this.layer) {
  826. return;
  827. }
  828. if (this.layer.isBackground === !value) {
  829. return;
  830. }
  831. this.layer.isBackground = !value;
  832. },
  833. enumerable: true,
  834. configurable: true
  835. });
  836. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  837. /**
  838. * Gets or set information about clipboardData
  839. */
  840. get: function () {
  841. return this._clipboardData;
  842. },
  843. set: function (value) {
  844. this._clipboardData = value;
  845. },
  846. enumerable: true,
  847. configurable: true
  848. });
  849. /**
  850. * Get the current class name of the texture useful for serialization or dynamic coding.
  851. * @returns "AdvancedDynamicTexture"
  852. */
  853. AdvancedDynamicTexture.prototype.getClassName = function () {
  854. return "AdvancedDynamicTexture";
  855. };
  856. /**
  857. * Function used to execute a function on all controls
  858. * @param func defines the function to execute
  859. * @param container defines the container where controls belong. If null the root container will be used
  860. */
  861. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  862. if (!container) {
  863. container = this._rootContainer;
  864. }
  865. func(container);
  866. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  867. var child = _a[_i];
  868. if (child.children) {
  869. this.executeOnAllControls(func, child);
  870. continue;
  871. }
  872. func(child);
  873. }
  874. };
  875. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  876. /**
  877. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  878. */
  879. get: function () {
  880. return this._useInvalidateRectOptimization;
  881. },
  882. set: function (value) {
  883. this._useInvalidateRectOptimization = value;
  884. },
  885. enumerable: true,
  886. configurable: true
  887. });
  888. /**
  889. * Invalidates a rectangle area on the gui texture
  890. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  891. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  892. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  893. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  894. */
  895. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  896. if (!this._useInvalidateRectOptimization) {
  897. return;
  898. }
  899. if (!this._invalidatedRectangle) {
  900. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  901. }
  902. else {
  903. // Compute intersection
  904. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  905. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  906. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  907. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  908. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  909. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  910. }
  911. };
  912. /**
  913. * Marks the texture as dirty forcing a complete update
  914. */
  915. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  916. this._isDirty = true;
  917. };
  918. /**
  919. * Helper function used to create a new style
  920. * @returns a new style
  921. * @see http://doc.babylonjs.com/how_to/gui#styles
  922. */
  923. AdvancedDynamicTexture.prototype.createStyle = function () {
  924. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  925. };
  926. /**
  927. * Adds a new control to the root container
  928. * @param control defines the control to add
  929. * @returns the current texture
  930. */
  931. AdvancedDynamicTexture.prototype.addControl = function (control) {
  932. this._rootContainer.addControl(control);
  933. return this;
  934. };
  935. /**
  936. * Removes a control from the root container
  937. * @param control defines the control to remove
  938. * @returns the current texture
  939. */
  940. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  941. this._rootContainer.removeControl(control);
  942. return this;
  943. };
  944. /**
  945. * Release all resources
  946. */
  947. AdvancedDynamicTexture.prototype.dispose = function () {
  948. var scene = this.getScene();
  949. if (!scene) {
  950. return;
  951. }
  952. this._rootElement = null;
  953. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  954. if (this._resizeObserver) {
  955. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  956. }
  957. if (this._pointerMoveObserver) {
  958. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  959. }
  960. if (this._pointerObserver) {
  961. scene.onPointerObservable.remove(this._pointerObserver);
  962. }
  963. if (this._preKeyboardObserver) {
  964. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  965. }
  966. if (this._canvasPointerOutObserver) {
  967. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  968. }
  969. if (this._layerToDispose) {
  970. this._layerToDispose.texture = null;
  971. this._layerToDispose.dispose();
  972. this._layerToDispose = null;
  973. }
  974. this._rootContainer.dispose();
  975. this.onClipboardObservable.clear();
  976. this.onControlPickedObservable.clear();
  977. this.onBeginRenderObservable.clear();
  978. this.onEndRenderObservable.clear();
  979. this.onBeginLayoutObservable.clear();
  980. this.onEndLayoutObservable.clear();
  981. _super.prototype.dispose.call(this);
  982. };
  983. AdvancedDynamicTexture.prototype._onResize = function () {
  984. var scene = this.getScene();
  985. if (!scene) {
  986. return;
  987. }
  988. // Check size
  989. var engine = scene.getEngine();
  990. var textureSize = this.getSize();
  991. var renderWidth = engine.getRenderWidth() * this._renderScale;
  992. var renderHeight = engine.getRenderHeight() * this._renderScale;
  993. if (this._renderAtIdealSize) {
  994. if (this._idealWidth) {
  995. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  996. renderWidth = this._idealWidth;
  997. }
  998. else if (this._idealHeight) {
  999. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  1000. renderHeight = this._idealHeight;
  1001. }
  1002. }
  1003. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  1004. this.scaleTo(renderWidth, renderHeight);
  1005. this.markAsDirty();
  1006. if (this._idealWidth || this._idealHeight) {
  1007. this._rootContainer._markAllAsDirty();
  1008. }
  1009. }
  1010. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  1011. };
  1012. /** @hidden */
  1013. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  1014. var engine = scene.getEngine();
  1015. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  1016. };
  1017. /**
  1018. * Get screen coordinates for a vector3
  1019. * @param position defines the position to project
  1020. * @param worldMatrix defines the world matrix to use
  1021. * @returns the projected position
  1022. */
  1023. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  1024. var scene = this.getScene();
  1025. if (!scene) {
  1026. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  1027. }
  1028. var globalViewport = this._getGlobalViewport(scene);
  1029. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1030. projectedPosition.scaleInPlace(this.renderScale);
  1031. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  1032. };
  1033. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  1034. if (this._layerToDispose) {
  1035. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  1036. return;
  1037. }
  1038. }
  1039. if (this._isFullscreen && this._linkedControls.length) {
  1040. var scene = this.getScene();
  1041. if (!scene) {
  1042. return;
  1043. }
  1044. var globalViewport = this._getGlobalViewport(scene);
  1045. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  1046. var control = _a[_i];
  1047. if (!control.isVisible) {
  1048. continue;
  1049. }
  1050. var mesh = control._linkedMesh;
  1051. if (!mesh || mesh.isDisposed()) {
  1052. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1053. control.linkWithMesh(null);
  1054. });
  1055. continue;
  1056. }
  1057. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1058. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1059. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1060. control.notRenderable = true;
  1061. continue;
  1062. }
  1063. control.notRenderable = false;
  1064. // Account for RenderScale.
  1065. projectedPosition.scaleInPlace(this.renderScale);
  1066. control._moveToProjectedPosition(projectedPosition);
  1067. }
  1068. }
  1069. if (!this._isDirty && !this._rootContainer.isDirty) {
  1070. return;
  1071. }
  1072. this._isDirty = false;
  1073. this._render();
  1074. this.update(true, this.premulAlpha);
  1075. };
  1076. AdvancedDynamicTexture.prototype._render = function () {
  1077. var textureSize = this.getSize();
  1078. var renderWidth = textureSize.width;
  1079. var renderHeight = textureSize.height;
  1080. var context = this.getContext();
  1081. context.font = "18px Arial";
  1082. context.strokeStyle = "white";
  1083. // Layout
  1084. this.onBeginLayoutObservable.notifyObservers(this);
  1085. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1086. this._numLayoutCalls = 0;
  1087. this._rootContainer._layout(measure, context);
  1088. this.onEndLayoutObservable.notifyObservers(this);
  1089. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1090. // Clear
  1091. if (this._invalidatedRectangle) {
  1092. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1093. }
  1094. else {
  1095. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1096. }
  1097. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1098. if (this._background) {
  1099. context.save();
  1100. context.fillStyle = this._background;
  1101. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1102. context.restore();
  1103. }
  1104. // Render
  1105. this.onBeginRenderObservable.notifyObservers(this);
  1106. this._numRenderCalls = 0;
  1107. this._rootContainer._render(context, this._invalidatedRectangle);
  1108. this.onEndRenderObservable.notifyObservers(this);
  1109. this._invalidatedRectangle = null;
  1110. };
  1111. /** @hidden */
  1112. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1113. if (this._rootElement) {
  1114. this._rootElement.style.cursor = cursor;
  1115. this._cursorChanged = true;
  1116. }
  1117. };
  1118. /** @hidden */
  1119. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1120. this._lastControlDown[pointerId] = control;
  1121. this.onControlPickedObservable.notifyObservers(control);
  1122. };
  1123. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1124. var scene = this.getScene();
  1125. if (!scene) {
  1126. return;
  1127. }
  1128. var engine = scene.getEngine();
  1129. var textureSize = this.getSize();
  1130. if (this._isFullscreen) {
  1131. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1132. var viewport = camera.viewport;
  1133. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1134. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1135. }
  1136. if (this._capturingControl[pointerId]) {
  1137. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1138. return;
  1139. }
  1140. this._cursorChanged = false;
  1141. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1142. this._changeCursor("");
  1143. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1144. if (this._lastControlOver[pointerId]) {
  1145. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1146. delete this._lastControlOver[pointerId];
  1147. }
  1148. }
  1149. }
  1150. if (!this._cursorChanged) {
  1151. this._changeCursor("");
  1152. }
  1153. this._manageFocus();
  1154. };
  1155. /** @hidden */
  1156. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1157. for (var pointerId in list) {
  1158. if (!list.hasOwnProperty(pointerId)) {
  1159. continue;
  1160. }
  1161. var lastControlOver = list[pointerId];
  1162. if (lastControlOver === control) {
  1163. delete list[pointerId];
  1164. }
  1165. }
  1166. };
  1167. /** @hidden */
  1168. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1169. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1170. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1171. };
  1172. /** Attach to all scene events required to support pointer events */
  1173. AdvancedDynamicTexture.prototype.attach = function () {
  1174. var _this = this;
  1175. var scene = this.getScene();
  1176. if (!scene) {
  1177. return;
  1178. }
  1179. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1180. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1181. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1182. return;
  1183. }
  1184. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1185. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1186. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1187. return;
  1188. }
  1189. if (!scene) {
  1190. return;
  1191. }
  1192. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1193. var engine = scene.getEngine();
  1194. if (!camera) {
  1195. tempViewport.x = 0;
  1196. tempViewport.y = 0;
  1197. tempViewport.width = engine.getRenderWidth();
  1198. tempViewport.height = engine.getRenderHeight();
  1199. }
  1200. else {
  1201. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1202. }
  1203. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1204. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1205. _this._shouldBlockPointer = false;
  1206. // Do picking modifies _shouldBlockPointer
  1207. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1208. // Avoid overwriting a true skipOnPointerObservable to false
  1209. if (_this._shouldBlockPointer) {
  1210. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1211. }
  1212. });
  1213. this._attachToOnPointerOut(scene);
  1214. };
  1215. /**
  1216. * Register the clipboard Events onto the canvas
  1217. */
  1218. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1219. self.addEventListener("copy", this.onClipboardCopy, false);
  1220. self.addEventListener("cut", this.onClipboardCut, false);
  1221. self.addEventListener("paste", this.onClipboardPaste, false);
  1222. };
  1223. /**
  1224. * Unregister the clipboard Events from the canvas
  1225. */
  1226. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1227. self.removeEventListener("copy", this.onClipboardCopy);
  1228. self.removeEventListener("cut", this.onClipboardCut);
  1229. self.removeEventListener("paste", this.onClipboardPaste);
  1230. };
  1231. /**
  1232. * Connect the texture to a hosting mesh to enable interactions
  1233. * @param mesh defines the mesh to attach to
  1234. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1235. */
  1236. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1237. var _this = this;
  1238. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1239. var scene = this.getScene();
  1240. if (!scene) {
  1241. return;
  1242. }
  1243. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1244. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1245. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1246. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1247. return;
  1248. }
  1249. var pointerId = pi.event.pointerId || 0;
  1250. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1251. var uv = pi.pickInfo.getTextureCoordinates();
  1252. if (uv) {
  1253. var size = _this.getSize();
  1254. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1255. }
  1256. }
  1257. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1258. if (_this._lastControlDown[pointerId]) {
  1259. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1260. }
  1261. delete _this._lastControlDown[pointerId];
  1262. if (_this.focusedControl) {
  1263. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1264. var canMoveFocus = true;
  1265. if (friendlyControls) {
  1266. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1267. var control = friendlyControls_1[_i];
  1268. // Same host, no need to keep the focus
  1269. if (_this === control._host) {
  1270. continue;
  1271. }
  1272. // Different hosts
  1273. var otherHost = control._host;
  1274. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1275. canMoveFocus = false;
  1276. break;
  1277. }
  1278. }
  1279. }
  1280. if (canMoveFocus) {
  1281. _this.focusedControl = null;
  1282. }
  1283. }
  1284. }
  1285. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1286. if (_this._lastControlOver[pointerId]) {
  1287. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1288. }
  1289. delete _this._lastControlOver[pointerId];
  1290. }
  1291. });
  1292. mesh.enablePointerMoveEvents = supportPointerMove;
  1293. this._attachToOnPointerOut(scene);
  1294. };
  1295. /**
  1296. * Move the focus to a specific control
  1297. * @param control defines the control which will receive the focus
  1298. */
  1299. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1300. this.focusedControl = control;
  1301. this._lastPickedControl = control;
  1302. this._blockNextFocusCheck = true;
  1303. };
  1304. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1305. if (this._blockNextFocusCheck) {
  1306. this._blockNextFocusCheck = false;
  1307. this._lastPickedControl = this._focusedControl;
  1308. return;
  1309. }
  1310. // Focus management
  1311. if (this._focusedControl) {
  1312. if (this._focusedControl !== this._lastPickedControl) {
  1313. if (this._lastPickedControl.isFocusInvisible) {
  1314. return;
  1315. }
  1316. this.focusedControl = null;
  1317. }
  1318. }
  1319. };
  1320. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1321. var _this = this;
  1322. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1323. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1324. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1325. }
  1326. delete _this._lastControlOver[pointerEvent.pointerId];
  1327. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1328. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1329. delete _this._lastControlDown[pointerEvent.pointerId];
  1330. }
  1331. });
  1332. };
  1333. // Statics
  1334. /**
  1335. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1336. * @param mesh defines the mesh which will receive the texture
  1337. * @param width defines the texture width (1024 by default)
  1338. * @param height defines the texture height (1024 by default)
  1339. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1340. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1341. * @returns a new AdvancedDynamicTexture
  1342. */
  1343. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1344. if (width === void 0) { width = 1024; }
  1345. if (height === void 0) { height = 1024; }
  1346. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1347. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1348. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1349. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1350. material.backFaceCulling = false;
  1351. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1352. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1353. if (onlyAlphaTesting) {
  1354. material.diffuseTexture = result;
  1355. material.emissiveTexture = result;
  1356. result.hasAlpha = true;
  1357. }
  1358. else {
  1359. material.emissiveTexture = result;
  1360. material.opacityTexture = result;
  1361. }
  1362. mesh.material = material;
  1363. result.attachToMesh(mesh, supportPointerMove);
  1364. return result;
  1365. };
  1366. /**
  1367. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1368. * In this mode the texture will rely on a layer for its rendering.
  1369. * This allows it to be treated like any other layer.
  1370. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1371. * LayerMask is set through advancedTexture.layer.layerMask
  1372. * @param name defines name for the texture
  1373. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1374. * @param scene defines the hsoting scene
  1375. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1376. * @returns a new AdvancedDynamicTexture
  1377. */
  1378. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1379. if (foreground === void 0) { foreground = true; }
  1380. if (scene === void 0) { scene = null; }
  1381. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1382. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1383. // Display
  1384. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1385. layer.texture = result;
  1386. result._layerToDispose = layer;
  1387. result._isFullscreen = true;
  1388. // Attach
  1389. result.attach();
  1390. return result;
  1391. };
  1392. return AdvancedDynamicTexture;
  1393. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1394. /***/ }),
  1395. /***/ "./2D/controls/button.ts":
  1396. /*!*******************************!*\
  1397. !*** ./2D/controls/button.ts ***!
  1398. \*******************************/
  1399. /*! exports provided: Button */
  1400. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1401. "use strict";
  1402. __webpack_require__.r(__webpack_exports__);
  1403. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1404. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1405. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1406. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1407. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1408. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1409. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  1410. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1411. /**
  1412. * Class used to create 2D buttons
  1413. */
  1414. var Button = /** @class */ (function (_super) {
  1415. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1416. /**
  1417. * Creates a new Button
  1418. * @param name defines the name of the button
  1419. */
  1420. function Button(name) {
  1421. var _this = _super.call(this, name) || this;
  1422. _this.name = name;
  1423. /**
  1424. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1425. */
  1426. _this.delegatePickingToChildren = false;
  1427. _this.thickness = 1;
  1428. _this.isPointerBlocker = true;
  1429. var alphaStore = null;
  1430. _this.pointerEnterAnimation = function () {
  1431. alphaStore = _this.alpha;
  1432. _this.alpha -= 0.1;
  1433. };
  1434. _this.pointerOutAnimation = function () {
  1435. if (alphaStore !== null) {
  1436. _this.alpha = alphaStore;
  1437. }
  1438. };
  1439. _this.pointerDownAnimation = function () {
  1440. _this.scaleX -= 0.05;
  1441. _this.scaleY -= 0.05;
  1442. };
  1443. _this.pointerUpAnimation = function () {
  1444. _this.scaleX += 0.05;
  1445. _this.scaleY += 0.05;
  1446. };
  1447. return _this;
  1448. }
  1449. Object.defineProperty(Button.prototype, "image", {
  1450. /**
  1451. * Returns the image part of the button (if any)
  1452. */
  1453. get: function () {
  1454. return this._image;
  1455. },
  1456. enumerable: true,
  1457. configurable: true
  1458. });
  1459. Object.defineProperty(Button.prototype, "textBlock", {
  1460. /**
  1461. * Returns the image part of the button (if any)
  1462. */
  1463. get: function () {
  1464. return this._textBlock;
  1465. },
  1466. enumerable: true,
  1467. configurable: true
  1468. });
  1469. Button.prototype._getTypeName = function () {
  1470. return "Button";
  1471. };
  1472. // While being a container, the button behaves like a control.
  1473. /** @hidden */
  1474. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1475. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1476. return false;
  1477. }
  1478. if (!_super.prototype.contains.call(this, x, y)) {
  1479. return false;
  1480. }
  1481. if (this.delegatePickingToChildren) {
  1482. var contains = false;
  1483. for (var index = this._children.length - 1; index >= 0; index--) {
  1484. var child = this._children[index];
  1485. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1486. contains = true;
  1487. break;
  1488. }
  1489. }
  1490. if (!contains) {
  1491. return false;
  1492. }
  1493. }
  1494. this._processObservables(type, x, y, pointerId, buttonIndex);
  1495. return true;
  1496. };
  1497. /** @hidden */
  1498. Button.prototype._onPointerEnter = function (target) {
  1499. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1500. return false;
  1501. }
  1502. if (this.pointerEnterAnimation) {
  1503. this.pointerEnterAnimation();
  1504. }
  1505. return true;
  1506. };
  1507. /** @hidden */
  1508. Button.prototype._onPointerOut = function (target, force) {
  1509. if (force === void 0) { force = false; }
  1510. if (this.pointerOutAnimation) {
  1511. this.pointerOutAnimation();
  1512. }
  1513. _super.prototype._onPointerOut.call(this, target, force);
  1514. };
  1515. /** @hidden */
  1516. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1517. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1518. return false;
  1519. }
  1520. if (this.pointerDownAnimation) {
  1521. this.pointerDownAnimation();
  1522. }
  1523. return true;
  1524. };
  1525. /** @hidden */
  1526. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1527. if (this.pointerUpAnimation) {
  1528. this.pointerUpAnimation();
  1529. }
  1530. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1531. };
  1532. // Statics
  1533. /**
  1534. * Creates a new button made with an image and a text
  1535. * @param name defines the name of the button
  1536. * @param text defines the text of the button
  1537. * @param imageUrl defines the url of the image
  1538. * @returns a new Button
  1539. */
  1540. Button.CreateImageButton = function (name, text, imageUrl) {
  1541. var result = new Button(name);
  1542. // Adding text
  1543. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1544. textBlock.textWrapping = true;
  1545. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1546. textBlock.paddingLeft = "20%";
  1547. result.addControl(textBlock);
  1548. // Adding image
  1549. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1550. iconImage.width = "20%";
  1551. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1552. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1553. result.addControl(iconImage);
  1554. // Store
  1555. result._image = iconImage;
  1556. result._textBlock = textBlock;
  1557. return result;
  1558. };
  1559. /**
  1560. * Creates a new button made with an image
  1561. * @param name defines the name of the button
  1562. * @param imageUrl defines the url of the image
  1563. * @returns a new Button
  1564. */
  1565. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1566. var result = new Button(name);
  1567. // Adding image
  1568. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1569. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1570. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1571. result.addControl(iconImage);
  1572. // Store
  1573. result._image = iconImage;
  1574. return result;
  1575. };
  1576. /**
  1577. * Creates a new button made with a text
  1578. * @param name defines the name of the button
  1579. * @param text defines the text of the button
  1580. * @returns a new Button
  1581. */
  1582. Button.CreateSimpleButton = function (name, text) {
  1583. var result = new Button(name);
  1584. // Adding text
  1585. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1586. textBlock.textWrapping = true;
  1587. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1588. result.addControl(textBlock);
  1589. // Store
  1590. result._textBlock = textBlock;
  1591. return result;
  1592. };
  1593. /**
  1594. * Creates a new button made with an image and a centered text
  1595. * @param name defines the name of the button
  1596. * @param text defines the text of the button
  1597. * @param imageUrl defines the url of the image
  1598. * @returns a new Button
  1599. */
  1600. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1601. var result = new Button(name);
  1602. // Adding image
  1603. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1604. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1605. result.addControl(iconImage);
  1606. // Adding text
  1607. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1608. textBlock.textWrapping = true;
  1609. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1610. result.addControl(textBlock);
  1611. // Store
  1612. result._image = iconImage;
  1613. result._textBlock = textBlock;
  1614. return result;
  1615. };
  1616. return Button;
  1617. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1618. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1619. /***/ }),
  1620. /***/ "./2D/controls/checkbox.ts":
  1621. /*!*********************************!*\
  1622. !*** ./2D/controls/checkbox.ts ***!
  1623. \*********************************/
  1624. /*! exports provided: Checkbox */
  1625. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1626. "use strict";
  1627. __webpack_require__.r(__webpack_exports__);
  1628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1629. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1630. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1631. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1632. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1633. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1634. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1635. /**
  1636. * Class used to represent a 2D checkbox
  1637. */
  1638. var Checkbox = /** @class */ (function (_super) {
  1639. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1640. /**
  1641. * Creates a new CheckBox
  1642. * @param name defines the control name
  1643. */
  1644. function Checkbox(name) {
  1645. var _this = _super.call(this, name) || this;
  1646. _this.name = name;
  1647. _this._isChecked = false;
  1648. _this._background = "black";
  1649. _this._checkSizeRatio = 0.8;
  1650. _this._thickness = 1;
  1651. /**
  1652. * Observable raised when isChecked property changes
  1653. */
  1654. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1655. _this.isPointerBlocker = true;
  1656. return _this;
  1657. }
  1658. Object.defineProperty(Checkbox.prototype, "thickness", {
  1659. /** Gets or sets border thickness */
  1660. get: function () {
  1661. return this._thickness;
  1662. },
  1663. set: function (value) {
  1664. if (this._thickness === value) {
  1665. return;
  1666. }
  1667. this._thickness = value;
  1668. this._markAsDirty();
  1669. },
  1670. enumerable: true,
  1671. configurable: true
  1672. });
  1673. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1674. /** Gets or sets a value indicating the ratio between overall size and check size */
  1675. get: function () {
  1676. return this._checkSizeRatio;
  1677. },
  1678. set: function (value) {
  1679. value = Math.max(Math.min(1, value), 0);
  1680. if (this._checkSizeRatio === value) {
  1681. return;
  1682. }
  1683. this._checkSizeRatio = value;
  1684. this._markAsDirty();
  1685. },
  1686. enumerable: true,
  1687. configurable: true
  1688. });
  1689. Object.defineProperty(Checkbox.prototype, "background", {
  1690. /** Gets or sets background color */
  1691. get: function () {
  1692. return this._background;
  1693. },
  1694. set: function (value) {
  1695. if (this._background === value) {
  1696. return;
  1697. }
  1698. this._background = value;
  1699. this._markAsDirty();
  1700. },
  1701. enumerable: true,
  1702. configurable: true
  1703. });
  1704. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1705. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1706. get: function () {
  1707. return this._isChecked;
  1708. },
  1709. set: function (value) {
  1710. if (this._isChecked === value) {
  1711. return;
  1712. }
  1713. this._isChecked = value;
  1714. this._markAsDirty();
  1715. this.onIsCheckedChangedObservable.notifyObservers(value);
  1716. },
  1717. enumerable: true,
  1718. configurable: true
  1719. });
  1720. Checkbox.prototype._getTypeName = function () {
  1721. return "Checkbox";
  1722. };
  1723. /** @hidden */
  1724. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1725. context.save();
  1726. this._applyStates(context);
  1727. var actualWidth = this._currentMeasure.width - this._thickness;
  1728. var actualHeight = this._currentMeasure.height - this._thickness;
  1729. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1730. context.shadowColor = this.shadowColor;
  1731. context.shadowBlur = this.shadowBlur;
  1732. context.shadowOffsetX = this.shadowOffsetX;
  1733. context.shadowOffsetY = this.shadowOffsetY;
  1734. }
  1735. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1736. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1737. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1738. context.shadowBlur = 0;
  1739. context.shadowOffsetX = 0;
  1740. context.shadowOffsetY = 0;
  1741. }
  1742. if (this._isChecked) {
  1743. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1744. var offsetWidth = actualWidth * this._checkSizeRatio;
  1745. var offseHeight = actualHeight * this._checkSizeRatio;
  1746. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1747. }
  1748. context.strokeStyle = this.color;
  1749. context.lineWidth = this._thickness;
  1750. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1751. context.restore();
  1752. };
  1753. // Events
  1754. /** @hidden */
  1755. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1756. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1757. return false;
  1758. }
  1759. this.isChecked = !this.isChecked;
  1760. return true;
  1761. };
  1762. /**
  1763. * Utility function to easily create a checkbox with a header
  1764. * @param title defines the label to use for the header
  1765. * @param onValueChanged defines the callback to call when value changes
  1766. * @returns a StackPanel containing the checkbox and a textBlock
  1767. */
  1768. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1769. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1770. panel.isVertical = false;
  1771. panel.height = "30px";
  1772. var checkbox = new Checkbox();
  1773. checkbox.width = "20px";
  1774. checkbox.height = "20px";
  1775. checkbox.isChecked = true;
  1776. checkbox.color = "green";
  1777. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1778. panel.addControl(checkbox);
  1779. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1780. header.text = title;
  1781. header.width = "180px";
  1782. header.paddingLeft = "5px";
  1783. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1784. header.color = "white";
  1785. panel.addControl(header);
  1786. return panel;
  1787. };
  1788. return Checkbox;
  1789. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1790. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1791. /***/ }),
  1792. /***/ "./2D/controls/colorpicker.ts":
  1793. /*!************************************!*\
  1794. !*** ./2D/controls/colorpicker.ts ***!
  1795. \************************************/
  1796. /*! exports provided: ColorPicker */
  1797. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1798. "use strict";
  1799. __webpack_require__.r(__webpack_exports__);
  1800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1801. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1802. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1803. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1804. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1805. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1806. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1807. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1808. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1809. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1810. /** Class used to create color pickers */
  1811. var ColorPicker = /** @class */ (function (_super) {
  1812. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1813. /**
  1814. * Creates a new ColorPicker
  1815. * @param name defines the control name
  1816. */
  1817. function ColorPicker(name) {
  1818. var _this = _super.call(this, name) || this;
  1819. _this.name = name;
  1820. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1821. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1822. _this._pointerStartedOnSquare = false;
  1823. _this._pointerStartedOnWheel = false;
  1824. _this._squareLeft = 0;
  1825. _this._squareTop = 0;
  1826. _this._squareSize = 0;
  1827. _this._h = 360;
  1828. _this._s = 1;
  1829. _this._v = 1;
  1830. _this._lastPointerDownID = -1;
  1831. /**
  1832. * Observable raised when the value changes
  1833. */
  1834. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1835. // Events
  1836. _this._pointerIsDown = false;
  1837. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1838. _this.size = "200px";
  1839. _this.isPointerBlocker = true;
  1840. return _this;
  1841. }
  1842. Object.defineProperty(ColorPicker.prototype, "value", {
  1843. /** Gets or sets the color of the color picker */
  1844. get: function () {
  1845. return this._value;
  1846. },
  1847. set: function (value) {
  1848. if (this._value.equals(value)) {
  1849. return;
  1850. }
  1851. this._value.copyFrom(value);
  1852. this._value.toHSVToRef(this._tmpColor);
  1853. this._h = this._tmpColor.r;
  1854. this._s = Math.max(this._tmpColor.g, 0.00001);
  1855. this._v = Math.max(this._tmpColor.b, 0.00001);
  1856. this._markAsDirty();
  1857. if (this._value.r <= ColorPicker._Epsilon) {
  1858. this._value.r = 0;
  1859. }
  1860. if (this._value.g <= ColorPicker._Epsilon) {
  1861. this._value.g = 0;
  1862. }
  1863. if (this._value.b <= ColorPicker._Epsilon) {
  1864. this._value.b = 0;
  1865. }
  1866. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1867. this._value.r = 1.0;
  1868. }
  1869. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1870. this._value.g = 1.0;
  1871. }
  1872. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1873. this._value.b = 1.0;
  1874. }
  1875. this.onValueChangedObservable.notifyObservers(this._value);
  1876. },
  1877. enumerable: true,
  1878. configurable: true
  1879. });
  1880. Object.defineProperty(ColorPicker.prototype, "width", {
  1881. /**
  1882. * Gets or sets control width
  1883. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1884. */
  1885. get: function () {
  1886. return this._width.toString(this._host);
  1887. },
  1888. set: function (value) {
  1889. if (this._width.toString(this._host) === value) {
  1890. return;
  1891. }
  1892. if (this._width.fromString(value)) {
  1893. this._height.fromString(value);
  1894. this._markAsDirty();
  1895. }
  1896. },
  1897. enumerable: true,
  1898. configurable: true
  1899. });
  1900. Object.defineProperty(ColorPicker.prototype, "height", {
  1901. /**
  1902. * Gets or sets control height
  1903. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1904. */
  1905. get: function () {
  1906. return this._height.toString(this._host);
  1907. },
  1908. /** Gets or sets control height */
  1909. set: function (value) {
  1910. if (this._height.toString(this._host) === value) {
  1911. return;
  1912. }
  1913. if (this._height.fromString(value)) {
  1914. this._width.fromString(value);
  1915. this._markAsDirty();
  1916. }
  1917. },
  1918. enumerable: true,
  1919. configurable: true
  1920. });
  1921. Object.defineProperty(ColorPicker.prototype, "size", {
  1922. /** Gets or sets control size */
  1923. get: function () {
  1924. return this.width;
  1925. },
  1926. set: function (value) {
  1927. this.width = value;
  1928. },
  1929. enumerable: true,
  1930. configurable: true
  1931. });
  1932. ColorPicker.prototype._getTypeName = function () {
  1933. return "ColorPicker";
  1934. };
  1935. /** @hidden */
  1936. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1937. if (parentMeasure.width < parentMeasure.height) {
  1938. this._currentMeasure.height = parentMeasure.width;
  1939. }
  1940. else {
  1941. this._currentMeasure.width = parentMeasure.height;
  1942. }
  1943. };
  1944. ColorPicker.prototype._updateSquareProps = function () {
  1945. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1946. var wheelThickness = radius * .2;
  1947. var innerDiameter = (radius - wheelThickness) * 2;
  1948. var squareSize = innerDiameter / (Math.sqrt(2));
  1949. var offset = radius - squareSize * .5;
  1950. this._squareLeft = this._currentMeasure.left + offset;
  1951. this._squareTop = this._currentMeasure.top + offset;
  1952. this._squareSize = squareSize;
  1953. };
  1954. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1955. var lgh = context.createLinearGradient(left, top, width + left, top);
  1956. lgh.addColorStop(0, '#fff');
  1957. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1958. context.fillStyle = lgh;
  1959. context.fillRect(left, top, width, height);
  1960. var lgv = context.createLinearGradient(left, top, left, height + top);
  1961. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1962. lgv.addColorStop(1, '#000');
  1963. context.fillStyle = lgv;
  1964. context.fillRect(left, top, width, height);
  1965. };
  1966. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1967. context.beginPath();
  1968. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1969. context.lineWidth = 3;
  1970. context.strokeStyle = '#333333';
  1971. context.stroke();
  1972. context.beginPath();
  1973. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1974. context.lineWidth = 3;
  1975. context.strokeStyle = '#ffffff';
  1976. context.stroke();
  1977. };
  1978. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1979. var canvas = document.createElement("canvas");
  1980. canvas.width = radius * 2;
  1981. canvas.height = radius * 2;
  1982. var context = canvas.getContext("2d");
  1983. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1984. var data = image.data;
  1985. var color = this._tmpColor;
  1986. var maxDistSq = radius * radius;
  1987. var innerRadius = radius - thickness;
  1988. var minDistSq = innerRadius * innerRadius;
  1989. for (var x = -radius; x < radius; x++) {
  1990. for (var y = -radius; y < radius; y++) {
  1991. var distSq = x * x + y * y;
  1992. if (distSq > maxDistSq || distSq < minDistSq) {
  1993. continue;
  1994. }
  1995. var dist = Math.sqrt(distSq);
  1996. var ang = Math.atan2(y, x);
  1997. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1998. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1999. data[index] = color.r * 255;
  2000. data[index + 1] = color.g * 255;
  2001. data[index + 2] = color.b * 255;
  2002. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2003. //apply less alpha to bigger color pickers
  2004. var alphaAmount = .2;
  2005. var maxAlpha = .2;
  2006. var minAlpha = .04;
  2007. var lowerRadius = 50;
  2008. var upperRadius = 150;
  2009. if (radius < lowerRadius) {
  2010. alphaAmount = maxAlpha;
  2011. }
  2012. else if (radius > upperRadius) {
  2013. alphaAmount = minAlpha;
  2014. }
  2015. else {
  2016. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  2017. }
  2018. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2019. if (alphaRatio < alphaAmount) {
  2020. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  2021. }
  2022. else if (alphaRatio > 1 - alphaAmount) {
  2023. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  2024. }
  2025. else {
  2026. data[index + 3] = 255;
  2027. }
  2028. }
  2029. }
  2030. context.putImageData(image, 0, 0);
  2031. return canvas;
  2032. };
  2033. /** @hidden */
  2034. ColorPicker.prototype._draw = function (context) {
  2035. context.save();
  2036. this._applyStates(context);
  2037. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2038. var wheelThickness = radius * .2;
  2039. var left = this._currentMeasure.left;
  2040. var top = this._currentMeasure.top;
  2041. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2042. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2043. }
  2044. this._updateSquareProps();
  2045. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2046. context.shadowColor = this.shadowColor;
  2047. context.shadowBlur = this.shadowBlur;
  2048. context.shadowOffsetX = this.shadowOffsetX;
  2049. context.shadowOffsetY = this.shadowOffsetY;
  2050. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2051. }
  2052. context.drawImage(this._colorWheelCanvas, left, top);
  2053. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2054. context.shadowBlur = 0;
  2055. context.shadowOffsetX = 0;
  2056. context.shadowOffsetY = 0;
  2057. }
  2058. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2059. var cx = this._squareLeft + this._squareSize * this._s;
  2060. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2061. this._drawCircle(cx, cy, radius * .04, context);
  2062. var dist = radius - wheelThickness * .5;
  2063. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2064. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2065. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2066. context.restore();
  2067. };
  2068. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2069. if (this._pointerStartedOnWheel) {
  2070. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2071. var centerX = radius + this._currentMeasure.left;
  2072. var centerY = radius + this._currentMeasure.top;
  2073. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2074. }
  2075. else if (this._pointerStartedOnSquare) {
  2076. this._updateSquareProps();
  2077. this._s = (x - this._squareLeft) / this._squareSize;
  2078. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2079. this._s = Math.min(this._s, 1);
  2080. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2081. this._v = Math.min(this._v, 1);
  2082. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2083. }
  2084. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2085. this.value = this._tmpColor;
  2086. };
  2087. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2088. this._updateSquareProps();
  2089. var left = this._squareLeft;
  2090. var top = this._squareTop;
  2091. var size = this._squareSize;
  2092. if (x >= left && x <= left + size &&
  2093. y >= top && y <= top + size) {
  2094. return true;
  2095. }
  2096. return false;
  2097. };
  2098. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2099. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2100. var centerX = radius + this._currentMeasure.left;
  2101. var centerY = radius + this._currentMeasure.top;
  2102. var wheelThickness = radius * .2;
  2103. var innerRadius = radius - wheelThickness;
  2104. var radiusSq = radius * radius;
  2105. var innerRadiusSq = innerRadius * innerRadius;
  2106. var dx = x - centerX;
  2107. var dy = y - centerY;
  2108. var distSq = dx * dx + dy * dy;
  2109. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2110. return true;
  2111. }
  2112. return false;
  2113. };
  2114. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2115. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2116. return false;
  2117. }
  2118. this._pointerIsDown = true;
  2119. this._pointerStartedOnSquare = false;
  2120. this._pointerStartedOnWheel = false;
  2121. // Invert transform
  2122. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2123. var x = this._transformedPosition.x;
  2124. var y = this._transformedPosition.y;
  2125. if (this._isPointOnSquare(x, y)) {
  2126. this._pointerStartedOnSquare = true;
  2127. }
  2128. else if (this._isPointOnWheel(x, y)) {
  2129. this._pointerStartedOnWheel = true;
  2130. }
  2131. this._updateValueFromPointer(x, y);
  2132. this._host._capturingControl[pointerId] = this;
  2133. this._lastPointerDownID = pointerId;
  2134. return true;
  2135. };
  2136. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2137. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2138. if (pointerId != this._lastPointerDownID) {
  2139. return;
  2140. }
  2141. // Invert transform
  2142. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2143. var x = this._transformedPosition.x;
  2144. var y = this._transformedPosition.y;
  2145. if (this._pointerIsDown) {
  2146. this._updateValueFromPointer(x, y);
  2147. }
  2148. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2149. };
  2150. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2151. this._pointerIsDown = false;
  2152. delete this._host._capturingControl[pointerId];
  2153. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2154. };
  2155. /**
  2156. * This function expands the color picker by creating a color picker dialog with manual
  2157. * color value input and the ability to save colors into an array to be used later in
  2158. * subsequent launches of the dialogue.
  2159. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2160. * @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.
  2161. * @returns picked color as a hex string and the saved colors array as hex strings.
  2162. */
  2163. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2164. return new Promise(function (resolve, reject) {
  2165. // Default options
  2166. options.pickerWidth = options.pickerWidth || "640px";
  2167. options.pickerHeight = options.pickerHeight || "400px";
  2168. options.headerHeight = options.headerHeight || "35px";
  2169. options.lastColor = options.lastColor || "#000000";
  2170. options.swatchLimit = options.swatchLimit || 20;
  2171. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2172. // Window size settings
  2173. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2174. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2175. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2176. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2177. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2178. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2179. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2180. // Button Colors
  2181. var buttonColor = "#c0c0c0";
  2182. var buttonBackgroundColor = "#535353";
  2183. var buttonBackgroundHoverColor = "#414141";
  2184. var buttonBackgroundClickColor = "515151";
  2185. var buttonDisabledColor = "#555555";
  2186. var buttonDisabledBackgroundColor = "#454545";
  2187. var currentSwatchesOutlineColor = "#404040";
  2188. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2189. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2190. var iconColorDark = "#aaaaaa";
  2191. var iconColorLight = "#ffffff";
  2192. var closeIconColor;
  2193. // Button settings
  2194. var buttonFontSize;
  2195. var butEdit;
  2196. var buttonWidth;
  2197. var buttonHeight;
  2198. // Input Text Colors
  2199. var inputFieldLabels = ["R", "G", "B"];
  2200. var inputTextBackgroundColor = "#454545";
  2201. var inputTextColor = "#f0f0f0";
  2202. // This is the current color as set by either the picker or by entering a value
  2203. var currentColor;
  2204. // This int is used for naming swatches and serves as the index for calling them from the list
  2205. var swatchNumber;
  2206. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2207. var swatchDrawer;
  2208. var editSwatchMode = false;
  2209. // Color InputText fields that will be updated upon value change
  2210. var picker;
  2211. var rValInt;
  2212. var gValInt;
  2213. var bValInt;
  2214. var rValDec;
  2215. var gValDec;
  2216. var bValDec;
  2217. var hexVal;
  2218. var newSwatch;
  2219. var lastVal;
  2220. var activeField;
  2221. /**
  2222. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2223. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2224. * are will receive no update. This is to prevent the input from the user being overwritten.
  2225. */
  2226. function updateValues(value, inputField) {
  2227. activeField = inputField;
  2228. var pickedColor = value.toHexString();
  2229. newSwatch.background = pickedColor;
  2230. if (rValInt.name != activeField) {
  2231. rValInt.text = Math.floor(value.r * 255).toString();
  2232. }
  2233. if (gValInt.name != activeField) {
  2234. gValInt.text = Math.floor(value.g * 255).toString();
  2235. }
  2236. if (bValInt.name != activeField) {
  2237. bValInt.text = Math.floor(value.b * 255).toString();
  2238. }
  2239. if (rValDec.name != activeField) {
  2240. rValDec.text = value.r.toString();
  2241. }
  2242. if (gValDec.name != activeField) {
  2243. gValDec.text = value.g.toString();
  2244. }
  2245. if (bValDec.name != activeField) {
  2246. bValDec.text = value.b.toString();
  2247. }
  2248. if (hexVal.name != activeField) {
  2249. var minusPound = pickedColor.split("#");
  2250. hexVal.text = minusPound[1];
  2251. }
  2252. if (picker.name != activeField) {
  2253. picker.value = value;
  2254. }
  2255. }
  2256. // 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.
  2257. function updateInt(field, channel) {
  2258. var newValue = field.text;
  2259. var checkVal = /[^0-9]/g.test(newValue);
  2260. if (checkVal) {
  2261. field.text = lastVal;
  2262. return;
  2263. }
  2264. else {
  2265. if (newValue != "") {
  2266. if (Math.floor(parseInt(newValue)) < 0) {
  2267. newValue = "0";
  2268. }
  2269. else if (Math.floor(parseInt(newValue)) > 255) {
  2270. newValue = "255";
  2271. }
  2272. else if (isNaN(parseInt(newValue))) {
  2273. newValue = "0";
  2274. }
  2275. }
  2276. if (activeField == field.name) {
  2277. lastVal = newValue;
  2278. }
  2279. }
  2280. if (newValue != "") {
  2281. newValue = parseInt(newValue).toString();
  2282. field.text = newValue;
  2283. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2284. if (activeField == field.name) {
  2285. if (channel == "r") {
  2286. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2287. }
  2288. else if (channel == "g") {
  2289. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2290. }
  2291. else {
  2292. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2293. }
  2294. }
  2295. }
  2296. }
  2297. // 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.
  2298. function updateFloat(field, channel) {
  2299. var newValue = field.text;
  2300. var checkVal = /[^0-9\.]/g.test(newValue);
  2301. if (checkVal) {
  2302. field.text = lastVal;
  2303. return;
  2304. }
  2305. else {
  2306. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2307. if (parseFloat(newValue) < 0.0) {
  2308. newValue = "0.0";
  2309. }
  2310. else if (parseFloat(newValue) > 1.0) {
  2311. newValue = "1.0";
  2312. }
  2313. else if (isNaN(parseFloat(newValue))) {
  2314. newValue = "0.0";
  2315. }
  2316. }
  2317. if (activeField == field.name) {
  2318. lastVal = newValue;
  2319. }
  2320. }
  2321. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2322. newValue = parseFloat(newValue).toString();
  2323. field.text = newValue;
  2324. }
  2325. else {
  2326. newValue = "0.0";
  2327. }
  2328. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2329. if (activeField == field.name) {
  2330. if (channel == "r") {
  2331. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2332. }
  2333. else if (channel == "g") {
  2334. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2335. }
  2336. else {
  2337. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2338. }
  2339. }
  2340. }
  2341. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2342. function deleteSwatch(index) {
  2343. if (options.savedColors) {
  2344. options.savedColors.splice(index, 1);
  2345. }
  2346. if (options.savedColors && options.savedColors.length == 0) {
  2347. setEditButtonVisibility(false);
  2348. editSwatchMode = false;
  2349. }
  2350. }
  2351. // Creates and styles an individual swatch when updateSwatches is called.
  2352. function createSwatch() {
  2353. if (options.savedColors && options.savedColors[swatchNumber]) {
  2354. if (editSwatchMode) {
  2355. var icon = "b";
  2356. }
  2357. else {
  2358. var icon = "";
  2359. }
  2360. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2361. swatch.fontFamily = "BabylonJSglyphs";
  2362. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2363. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2364. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2365. if (swatchLuminence > luminanceLimit) {
  2366. swatch.color = iconColorDark;
  2367. }
  2368. else {
  2369. swatch.color = iconColorLight;
  2370. }
  2371. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2372. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2373. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2374. swatch.background = options.savedColors[swatchNumber];
  2375. swatch.thickness = 2;
  2376. var metadata_1 = swatchNumber;
  2377. swatch.pointerDownAnimation = function () {
  2378. swatch.thickness = 4;
  2379. };
  2380. swatch.pointerUpAnimation = function () {
  2381. swatch.thickness = 3;
  2382. };
  2383. swatch.pointerEnterAnimation = function () {
  2384. swatch.thickness = 3;
  2385. };
  2386. swatch.pointerOutAnimation = function () {
  2387. swatch.thickness = 2;
  2388. };
  2389. swatch.onPointerClickObservable.add(function () {
  2390. if (!editSwatchMode) {
  2391. if (options.savedColors) {
  2392. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2393. }
  2394. }
  2395. else {
  2396. deleteSwatch(metadata_1);
  2397. updateSwatches("", butSave);
  2398. }
  2399. });
  2400. return swatch;
  2401. }
  2402. else {
  2403. return null;
  2404. }
  2405. }
  2406. // Mode switch to render button text and close symbols on swatch controls
  2407. function editSwatches(mode) {
  2408. if (mode !== undefined) {
  2409. editSwatchMode = mode;
  2410. }
  2411. if (editSwatchMode) {
  2412. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2413. var thisButton = swatchDrawer.children[i];
  2414. thisButton.textBlock.text = "b";
  2415. }
  2416. if (butEdit !== undefined) {
  2417. butEdit.textBlock.text = "Done";
  2418. }
  2419. }
  2420. else {
  2421. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2422. var thisButton = swatchDrawer.children[i];
  2423. thisButton.textBlock.text = "";
  2424. }
  2425. if (butEdit !== undefined) {
  2426. butEdit.textBlock.text = "Edit";
  2427. }
  2428. }
  2429. }
  2430. /**
  2431. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2432. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2433. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2434. * saved colors there are and how many can be stored per row.
  2435. */
  2436. function updateSwatches(color, button) {
  2437. if (options.savedColors) {
  2438. if (color != "") {
  2439. options.savedColors.push(color);
  2440. }
  2441. swatchNumber = 0;
  2442. swatchDrawer.clearControls();
  2443. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2444. if (rowCount == 0) {
  2445. var gutterCount = 0;
  2446. }
  2447. else {
  2448. var gutterCount = rowCount + 1;
  2449. }
  2450. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2451. var currentRows = swatchDrawer.rowCount;
  2452. for (var i = 0; i < currentRows; i++) {
  2453. swatchDrawer.removeRowDefinition(0);
  2454. }
  2455. for (var i = 0; i < rowCount + gutterCount; i++) {
  2456. if (i % 2) {
  2457. swatchDrawer.addRowDefinition(swatchSize, true);
  2458. }
  2459. else {
  2460. swatchDrawer.addRowDefinition(gutterSize, true);
  2461. }
  2462. }
  2463. }
  2464. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2465. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2466. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2467. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2468. var totalButtonsThisRow = options.numSwatchesPerLine;
  2469. }
  2470. else {
  2471. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2472. }
  2473. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2474. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2475. if (x > options.numSwatchesPerLine) {
  2476. continue;
  2477. }
  2478. var swatch = createSwatch();
  2479. if (swatch != null) {
  2480. swatchDrawer.addControl(swatch, y, w);
  2481. w += 2;
  2482. swatchNumber++;
  2483. }
  2484. else {
  2485. continue;
  2486. }
  2487. }
  2488. }
  2489. if (options.savedColors.length >= options.swatchLimit) {
  2490. disableButton(button, true);
  2491. }
  2492. else {
  2493. disableButton(button, false);
  2494. }
  2495. }
  2496. }
  2497. // Shows or hides edit swatches button depending on if there are saved swatches
  2498. function setEditButtonVisibility(enableButton) {
  2499. if (enableButton) {
  2500. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2501. butEdit.width = buttonWidth;
  2502. butEdit.height = buttonHeight;
  2503. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2504. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2505. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2506. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2507. butEdit.thickness = 2;
  2508. butEdit.color = buttonColor;
  2509. butEdit.fontSize = buttonFontSize;
  2510. butEdit.background = buttonBackgroundColor;
  2511. butEdit.onPointerEnterObservable.add(function () {
  2512. butEdit.background = buttonBackgroundHoverColor;
  2513. });
  2514. butEdit.onPointerOutObservable.add(function () {
  2515. butEdit.background = buttonBackgroundColor;
  2516. });
  2517. butEdit.pointerDownAnimation = function () {
  2518. butEdit.background = buttonBackgroundClickColor;
  2519. };
  2520. butEdit.pointerUpAnimation = function () {
  2521. butEdit.background = buttonBackgroundHoverColor;
  2522. };
  2523. butEdit.onPointerClickObservable.add(function () {
  2524. if (editSwatchMode) {
  2525. editSwatchMode = false;
  2526. }
  2527. else {
  2528. editSwatchMode = true;
  2529. }
  2530. editSwatches();
  2531. });
  2532. pickerGrid.addControl(butEdit, 1, 0);
  2533. }
  2534. else {
  2535. pickerGrid.removeControl(butEdit);
  2536. }
  2537. }
  2538. // Called when the user hits the limit of saved colors in the drawer.
  2539. function disableButton(button, disabled) {
  2540. if (disabled) {
  2541. button.color = buttonDisabledColor;
  2542. button.background = buttonDisabledBackgroundColor;
  2543. }
  2544. else {
  2545. button.color = buttonColor;
  2546. button.background = buttonBackgroundColor;
  2547. }
  2548. }
  2549. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2550. function closePicker(color) {
  2551. if (options.savedColors && options.savedColors.length > 0) {
  2552. resolve({
  2553. savedColors: options.savedColors,
  2554. pickedColor: color
  2555. });
  2556. }
  2557. else {
  2558. resolve({
  2559. pickedColor: color
  2560. });
  2561. }
  2562. advancedTexture.removeControl(dialogContainer);
  2563. }
  2564. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2565. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2566. dialogContainer.name = "Dialog Container";
  2567. dialogContainer.width = options.pickerWidth;
  2568. if (options.savedColors) {
  2569. dialogContainer.height = containerSize;
  2570. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2571. dialogContainer.addRowDefinition(topRow, false);
  2572. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2573. }
  2574. else {
  2575. dialogContainer.height = options.pickerHeight;
  2576. dialogContainer.addRowDefinition(1.0, false);
  2577. }
  2578. advancedTexture.addControl(dialogContainer);
  2579. // Swatch drawer which contains all saved color buttons
  2580. if (options.savedColors) {
  2581. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2582. swatchDrawer.name = "Swatch Drawer";
  2583. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2584. swatchDrawer.background = buttonBackgroundColor;
  2585. swatchDrawer.width = options.pickerWidth;
  2586. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2587. if (initialRows == 0) {
  2588. var gutterCount = 0;
  2589. }
  2590. else {
  2591. var gutterCount = initialRows + 1;
  2592. }
  2593. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2594. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2595. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2596. if (i % 2 != 0) {
  2597. swatchDrawer.addRowDefinition(swatchSize, true);
  2598. }
  2599. else {
  2600. swatchDrawer.addRowDefinition(gutterSize, true);
  2601. }
  2602. }
  2603. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2604. if (i % 2 != 0) {
  2605. swatchDrawer.addColumnDefinition(swatchSize, true);
  2606. }
  2607. else {
  2608. swatchDrawer.addColumnDefinition(gutterSize, true);
  2609. }
  2610. }
  2611. dialogContainer.addControl(swatchDrawer, 1, 0);
  2612. }
  2613. // Picker container
  2614. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2615. pickerPanel.name = "Picker Panel";
  2616. pickerPanel.height = options.pickerHeight;
  2617. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2618. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2619. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2620. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2621. dialogContainer.addControl(pickerPanel, 0, 0);
  2622. // Picker container header
  2623. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2624. header.name = "Dialogue Header Bar";
  2625. header.background = "#cccccc";
  2626. header.thickness = 0;
  2627. pickerPanel.addControl(header, 0, 0);
  2628. // Header close button
  2629. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2630. closeButton.fontFamily = "BabylonJSglyphs";
  2631. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2632. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2633. closeButton.color = closeIconColor.toHexString();
  2634. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2635. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2636. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2637. closeButton.height = closeButton.width = options.headerHeight;
  2638. closeButton.background = header.background;
  2639. closeButton.thickness = 0;
  2640. closeButton.pointerDownAnimation = function () {
  2641. };
  2642. closeButton.pointerUpAnimation = function () {
  2643. closeButton.background = header.background;
  2644. };
  2645. closeButton.pointerEnterAnimation = function () {
  2646. closeButton.color = header.background;
  2647. closeButton.background = "red";
  2648. };
  2649. closeButton.pointerOutAnimation = function () {
  2650. closeButton.color = closeIconColor.toHexString();
  2651. closeButton.background = header.background;
  2652. };
  2653. closeButton.onPointerClickObservable.add(function () {
  2654. closePicker(currentSwatch.background);
  2655. });
  2656. pickerPanel.addControl(closeButton, 0, 0);
  2657. // Dialog container body
  2658. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2659. dialogBody.name = "Dialogue Body";
  2660. dialogBody.background = buttonBackgroundColor;
  2661. var dialogBodyCols = [0.4375, 0.5625];
  2662. dialogBody.addRowDefinition(1.0, false);
  2663. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2664. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2665. pickerPanel.addControl(dialogBody, 1, 0);
  2666. // Picker grid
  2667. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2668. pickerGrid.name = "Picker Grid";
  2669. pickerGrid.addRowDefinition(0.85, false);
  2670. pickerGrid.addRowDefinition(0.15, false);
  2671. dialogBody.addControl(pickerGrid, 0, 0);
  2672. // Picker control
  2673. picker = new ColorPicker();
  2674. picker.name = "GUI Color Picker";
  2675. if (options.pickerHeight < options.pickerWidth) {
  2676. picker.width = 0.89;
  2677. }
  2678. else {
  2679. picker.height = 0.89;
  2680. }
  2681. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2682. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2683. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2684. picker.onPointerDownObservable.add(function () {
  2685. activeField = picker.name;
  2686. lastVal = "";
  2687. editSwatches(false);
  2688. });
  2689. picker.onValueChangedObservable.add(function (value) {
  2690. if (activeField == picker.name) {
  2691. updateValues(value, picker.name);
  2692. }
  2693. });
  2694. pickerGrid.addControl(picker, 0, 0);
  2695. // Picker body right quarant
  2696. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2697. pickerBodyRight.name = "Dialogue Right Half";
  2698. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2699. var pickerBodyRightRows = [0.514, 0.486];
  2700. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2701. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2702. dialogBody.addControl(pickerBodyRight, 1, 1);
  2703. // Picker container swatches and buttons
  2704. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2705. pickerSwatchesButtons.name = "Swatches and Buttons";
  2706. var pickerButtonsCol = [0.417, 0.583];
  2707. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2708. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2709. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2710. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2711. // Picker Swatches quadrant
  2712. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2713. pickerSwatches.name = "New and Current Swatches";
  2714. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2715. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2716. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2717. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2718. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2719. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2720. // Active swatches
  2721. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2722. activeSwatches.name = "Active Swatches";
  2723. activeSwatches.width = 0.67;
  2724. activeSwatches.addRowDefinition(0.5, false);
  2725. activeSwatches.addRowDefinition(0.5, false);
  2726. pickerSwatches.addControl(activeSwatches, 2, 0);
  2727. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2728. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2729. if (options.pickerWidth > options.pickerHeight) {
  2730. var labelTextSize = labelHeight;
  2731. }
  2732. else {
  2733. var labelTextSize = labelWidth;
  2734. }
  2735. // New color swatch and previous color button
  2736. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2737. newText.text = "new";
  2738. newText.name = "New Color Label";
  2739. newText.color = buttonColor;
  2740. newText.fontSize = labelTextSize;
  2741. pickerSwatches.addControl(newText, 1, 0);
  2742. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2743. newSwatch.name = "New Color Swatch";
  2744. newSwatch.background = options.lastColor;
  2745. newSwatch.thickness = 0;
  2746. activeSwatches.addControl(newSwatch, 0, 0);
  2747. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2748. currentSwatch.background = options.lastColor;
  2749. currentSwatch.thickness = 0;
  2750. currentSwatch.onPointerClickObservable.add(function () {
  2751. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2752. updateValues(revertColor, currentSwatch.name);
  2753. editSwatches(false);
  2754. });
  2755. currentSwatch.pointerDownAnimation = function () { };
  2756. currentSwatch.pointerUpAnimation = function () { };
  2757. currentSwatch.pointerEnterAnimation = function () { };
  2758. currentSwatch.pointerOutAnimation = function () { };
  2759. activeSwatches.addControl(currentSwatch, 1, 0);
  2760. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2761. swatchOutline.name = "Swatch Outline";
  2762. swatchOutline.width = 0.67;
  2763. swatchOutline.thickness = 2;
  2764. swatchOutline.color = currentSwatchesOutlineColor;
  2765. swatchOutline.isHitTestVisible = false;
  2766. pickerSwatches.addControl(swatchOutline, 2, 0);
  2767. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2768. currentText.name = "Current Color Label";
  2769. currentText.text = "current";
  2770. currentText.color = buttonColor;
  2771. currentText.fontSize = labelTextSize;
  2772. pickerSwatches.addControl(currentText, 3, 0);
  2773. // Buttons grid
  2774. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2775. buttonGrid.name = "Button Grid";
  2776. buttonGrid.height = 0.8;
  2777. var buttonGridRows = 1 / 3;
  2778. buttonGrid.addRowDefinition(buttonGridRows, false);
  2779. buttonGrid.addRowDefinition(buttonGridRows, false);
  2780. buttonGrid.addRowDefinition(buttonGridRows, false);
  2781. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2782. // Determine pixel width and height for all buttons from overall panel dimensions
  2783. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2784. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2785. // Determine button type size
  2786. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2787. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2788. }
  2789. else {
  2790. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2791. }
  2792. // Panel Buttons
  2793. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2794. butOK.width = buttonWidth;
  2795. butOK.height = buttonHeight;
  2796. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2797. butOK.thickness = 2;
  2798. butOK.color = buttonColor;
  2799. butOK.fontSize = buttonFontSize;
  2800. butOK.background = buttonBackgroundColor;
  2801. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2802. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2803. butOK.pointerDownAnimation = function () {
  2804. butOK.background = buttonBackgroundClickColor;
  2805. };
  2806. butOK.pointerUpAnimation = function () {
  2807. butOK.background = buttonBackgroundHoverColor;
  2808. };
  2809. butOK.onPointerClickObservable.add(function () {
  2810. editSwatches(false);
  2811. closePicker(newSwatch.background);
  2812. });
  2813. buttonGrid.addControl(butOK, 0, 0);
  2814. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2815. butCancel.width = buttonWidth;
  2816. butCancel.height = buttonHeight;
  2817. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2818. butCancel.thickness = 2;
  2819. butCancel.color = buttonColor;
  2820. butCancel.fontSize = buttonFontSize;
  2821. butCancel.background = buttonBackgroundColor;
  2822. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2823. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2824. butCancel.pointerDownAnimation = function () {
  2825. butCancel.background = buttonBackgroundClickColor;
  2826. };
  2827. butCancel.pointerUpAnimation = function () {
  2828. butCancel.background = buttonBackgroundHoverColor;
  2829. };
  2830. butCancel.onPointerClickObservable.add(function () {
  2831. editSwatches(false);
  2832. closePicker(currentSwatch.background);
  2833. });
  2834. buttonGrid.addControl(butCancel, 1, 0);
  2835. if (options.savedColors) {
  2836. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2837. butSave.width = buttonWidth;
  2838. butSave.height = buttonHeight;
  2839. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2840. butSave.thickness = 2;
  2841. butSave.fontSize = buttonFontSize;
  2842. if (options.savedColors.length < options.swatchLimit) {
  2843. butSave.color = buttonColor;
  2844. butSave.background = buttonBackgroundColor;
  2845. }
  2846. else {
  2847. disableButton(butSave, true);
  2848. }
  2849. butSave.onPointerEnterObservable.add(function () {
  2850. if (options.savedColors) {
  2851. if (options.savedColors.length < options.swatchLimit) {
  2852. butSave.background = buttonBackgroundHoverColor;
  2853. }
  2854. }
  2855. });
  2856. butSave.onPointerOutObservable.add(function () {
  2857. if (options.savedColors) {
  2858. if (options.savedColors.length < options.swatchLimit) {
  2859. butSave.background = buttonBackgroundColor;
  2860. }
  2861. }
  2862. });
  2863. butSave.pointerDownAnimation = function () {
  2864. if (options.savedColors) {
  2865. if (options.savedColors.length < options.swatchLimit) {
  2866. butSave.background = buttonBackgroundClickColor;
  2867. }
  2868. }
  2869. };
  2870. butSave.pointerUpAnimation = function () {
  2871. if (options.savedColors) {
  2872. if (options.savedColors.length < options.swatchLimit) {
  2873. butSave.background = buttonBackgroundHoverColor;
  2874. }
  2875. }
  2876. };
  2877. butSave.onPointerClickObservable.add(function () {
  2878. if (options.savedColors) {
  2879. if (options.savedColors.length == 0) {
  2880. setEditButtonVisibility(true);
  2881. }
  2882. if (options.savedColors.length < options.swatchLimit) {
  2883. updateSwatches(newSwatch.background, butSave);
  2884. }
  2885. editSwatches(false);
  2886. }
  2887. });
  2888. if (options.savedColors.length > 0) {
  2889. setEditButtonVisibility(true);
  2890. }
  2891. buttonGrid.addControl(butSave, 2, 0);
  2892. }
  2893. // Picker color values input
  2894. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2895. pickerColorValues.name = "Dialog Lower Right";
  2896. pickerColorValues.addRowDefinition(0.02, false);
  2897. pickerColorValues.addRowDefinition(0.63, false);
  2898. pickerColorValues.addRowDefinition(0.21, false);
  2899. pickerColorValues.addRowDefinition(0.14, false);
  2900. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2901. // RGB values text boxes
  2902. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2903. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2904. rgbValuesQuadrant.name = "RGB Values";
  2905. rgbValuesQuadrant.width = 0.82;
  2906. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2907. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2908. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2909. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2910. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2911. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2912. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2913. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2914. for (var i = 0; i < inputFieldLabels.length; i++) {
  2915. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2916. labelText.text = inputFieldLabels[i];
  2917. labelText.color = buttonColor;
  2918. labelText.fontSize = buttonFontSize;
  2919. rgbValuesQuadrant.addControl(labelText, i, 0);
  2920. }
  2921. // Input fields for RGB values
  2922. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2923. rValInt.width = 0.83;
  2924. rValInt.height = 0.72;
  2925. rValInt.name = "rIntField";
  2926. rValInt.fontSize = buttonFontSize;
  2927. rValInt.text = (currentColor.r * 255).toString();
  2928. rValInt.color = inputTextColor;
  2929. rValInt.background = inputTextBackgroundColor;
  2930. rValInt.onFocusObservable.add(function () {
  2931. activeField = rValInt.name;
  2932. lastVal = rValInt.text;
  2933. editSwatches(false);
  2934. });
  2935. rValInt.onBlurObservable.add(function () {
  2936. if (rValInt.text == "") {
  2937. rValInt.text = "0";
  2938. }
  2939. updateInt(rValInt, "r");
  2940. if (activeField == rValInt.name) {
  2941. activeField = "";
  2942. }
  2943. });
  2944. rValInt.onTextChangedObservable.add(function () {
  2945. if (activeField == rValInt.name) {
  2946. updateInt(rValInt, "r");
  2947. }
  2948. });
  2949. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2950. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2951. gValInt.width = 0.83;
  2952. gValInt.height = 0.72;
  2953. gValInt.name = "gIntField";
  2954. gValInt.fontSize = buttonFontSize;
  2955. gValInt.text = (currentColor.g * 255).toString();
  2956. gValInt.color = inputTextColor;
  2957. gValInt.background = inputTextBackgroundColor;
  2958. gValInt.onFocusObservable.add(function () {
  2959. activeField = gValInt.name;
  2960. lastVal = gValInt.text;
  2961. editSwatches(false);
  2962. });
  2963. gValInt.onBlurObservable.add(function () {
  2964. if (gValInt.text == "") {
  2965. gValInt.text = "0";
  2966. }
  2967. updateInt(gValInt, "g");
  2968. if (activeField == gValInt.name) {
  2969. activeField = "";
  2970. }
  2971. });
  2972. gValInt.onTextChangedObservable.add(function () {
  2973. if (activeField == gValInt.name) {
  2974. updateInt(gValInt, "g");
  2975. }
  2976. });
  2977. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2978. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2979. bValInt.width = 0.83;
  2980. bValInt.height = 0.72;
  2981. bValInt.name = "bIntField";
  2982. bValInt.fontSize = buttonFontSize;
  2983. bValInt.text = (currentColor.b * 255).toString();
  2984. bValInt.color = inputTextColor;
  2985. bValInt.background = inputTextBackgroundColor;
  2986. bValInt.onFocusObservable.add(function () {
  2987. activeField = bValInt.name;
  2988. lastVal = bValInt.text;
  2989. editSwatches(false);
  2990. });
  2991. bValInt.onBlurObservable.add(function () {
  2992. if (bValInt.text == "") {
  2993. bValInt.text = "0";
  2994. }
  2995. updateInt(bValInt, "b");
  2996. if (activeField == bValInt.name) {
  2997. activeField = "";
  2998. }
  2999. });
  3000. bValInt.onTextChangedObservable.add(function () {
  3001. if (activeField == bValInt.name) {
  3002. updateInt(bValInt, "b");
  3003. }
  3004. });
  3005. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  3006. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3007. rValDec.width = 0.95;
  3008. rValDec.height = 0.72;
  3009. rValDec.name = "rDecField";
  3010. rValDec.fontSize = buttonFontSize;
  3011. rValDec.text = currentColor.r.toString();
  3012. rValDec.color = inputTextColor;
  3013. rValDec.background = inputTextBackgroundColor;
  3014. rValDec.onFocusObservable.add(function () {
  3015. activeField = rValDec.name;
  3016. lastVal = rValDec.text;
  3017. editSwatches(false);
  3018. });
  3019. rValDec.onBlurObservable.add(function () {
  3020. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3021. rValDec.text = "0";
  3022. updateFloat(rValDec, "r");
  3023. }
  3024. if (activeField == rValDec.name) {
  3025. activeField = "";
  3026. }
  3027. });
  3028. rValDec.onTextChangedObservable.add(function () {
  3029. if (activeField == rValDec.name) {
  3030. updateFloat(rValDec, "r");
  3031. }
  3032. });
  3033. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3034. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3035. gValDec.width = 0.95;
  3036. gValDec.height = 0.72;
  3037. gValDec.name = "gDecField";
  3038. gValDec.fontSize = buttonFontSize;
  3039. gValDec.text = currentColor.g.toString();
  3040. gValDec.color = inputTextColor;
  3041. gValDec.background = inputTextBackgroundColor;
  3042. gValDec.onFocusObservable.add(function () {
  3043. activeField = gValDec.name;
  3044. lastVal = gValDec.text;
  3045. editSwatches(false);
  3046. });
  3047. gValDec.onBlurObservable.add(function () {
  3048. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3049. gValDec.text = "0";
  3050. updateFloat(gValDec, "g");
  3051. }
  3052. if (activeField == gValDec.name) {
  3053. activeField = "";
  3054. }
  3055. });
  3056. gValDec.onTextChangedObservable.add(function () {
  3057. if (activeField == gValDec.name) {
  3058. updateFloat(gValDec, "g");
  3059. }
  3060. });
  3061. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3062. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3063. bValDec.width = 0.95;
  3064. bValDec.height = 0.72;
  3065. bValDec.name = "bDecField";
  3066. bValDec.fontSize = buttonFontSize;
  3067. bValDec.text = currentColor.b.toString();
  3068. bValDec.color = inputTextColor;
  3069. bValDec.background = inputTextBackgroundColor;
  3070. bValDec.onFocusObservable.add(function () {
  3071. activeField = bValDec.name;
  3072. lastVal = bValDec.text;
  3073. editSwatches(false);
  3074. });
  3075. bValDec.onBlurObservable.add(function () {
  3076. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3077. bValDec.text = "0";
  3078. updateFloat(bValDec, "b");
  3079. }
  3080. if (activeField == bValDec.name) {
  3081. activeField = "";
  3082. }
  3083. });
  3084. bValDec.onTextChangedObservable.add(function () {
  3085. if (activeField == bValDec.name) {
  3086. updateFloat(bValDec, "b");
  3087. }
  3088. });
  3089. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3090. // Hex value input
  3091. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3092. hexValueQuadrant.name = "Hex Value";
  3093. hexValueQuadrant.width = 0.82;
  3094. hexValueQuadrant.addRowDefinition(1.0, false);
  3095. hexValueQuadrant.addColumnDefinition(0.1, false);
  3096. hexValueQuadrant.addColumnDefinition(0.9, false);
  3097. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3098. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3099. labelText.text = "#";
  3100. labelText.color = buttonColor;
  3101. labelText.fontSize = buttonFontSize;
  3102. hexValueQuadrant.addControl(labelText, 0, 0);
  3103. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3104. hexVal.width = 0.96;
  3105. hexVal.height = 0.72;
  3106. hexVal.name = "hexField";
  3107. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3108. hexVal.fontSize = buttonFontSize;
  3109. var minusPound = options.lastColor.split("#");
  3110. hexVal.text = minusPound[1];
  3111. hexVal.color = inputTextColor;
  3112. hexVal.background = inputTextBackgroundColor;
  3113. hexVal.onFocusObservable.add(function () {
  3114. activeField = hexVal.name;
  3115. lastVal = hexVal.text;
  3116. editSwatches(false);
  3117. });
  3118. hexVal.onBlurObservable.add(function () {
  3119. if (hexVal.text.length == 3) {
  3120. var val = hexVal.text.split("");
  3121. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3122. }
  3123. if (hexVal.text == "") {
  3124. hexVal.text = "000000";
  3125. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3126. }
  3127. if (activeField == hexVal.name) {
  3128. activeField = "";
  3129. }
  3130. });
  3131. hexVal.onTextChangedObservable.add(function () {
  3132. var newHexValue = hexVal.text;
  3133. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3134. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3135. hexVal.text = lastVal;
  3136. }
  3137. else {
  3138. if (hexVal.text.length < 6) {
  3139. var leadingZero = 6 - hexVal.text.length;
  3140. for (var i = 0; i < leadingZero; i++) {
  3141. newHexValue = "0" + newHexValue;
  3142. }
  3143. }
  3144. if (hexVal.text.length == 3) {
  3145. var val = hexVal.text.split("");
  3146. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3147. }
  3148. newHexValue = "#" + newHexValue;
  3149. if (activeField == hexVal.name) {
  3150. lastVal = hexVal.text;
  3151. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3152. }
  3153. }
  3154. });
  3155. hexValueQuadrant.addControl(hexVal, 0, 1);
  3156. if (options.savedColors && options.savedColors.length > 0) {
  3157. updateSwatches("", butSave);
  3158. }
  3159. });
  3160. };
  3161. ColorPicker._Epsilon = 0.000001;
  3162. return ColorPicker;
  3163. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3164. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3165. /***/ }),
  3166. /***/ "./2D/controls/container.ts":
  3167. /*!**********************************!*\
  3168. !*** ./2D/controls/container.ts ***!
  3169. \**********************************/
  3170. /*! exports provided: Container */
  3171. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3172. "use strict";
  3173. __webpack_require__.r(__webpack_exports__);
  3174. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3175. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3176. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/perfCounter");
  3177. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3178. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3179. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3180. /**
  3181. * Root class for 2D containers
  3182. * @see http://doc.babylonjs.com/how_to/gui#containers
  3183. */
  3184. var Container = /** @class */ (function (_super) {
  3185. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3186. /**
  3187. * Creates a new Container
  3188. * @param name defines the name of the container
  3189. */
  3190. function Container(name) {
  3191. var _this = _super.call(this, name) || this;
  3192. _this.name = name;
  3193. /** @hidden */
  3194. _this._children = new Array();
  3195. /** @hidden */
  3196. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3197. /** @hidden */
  3198. _this._background = "";
  3199. /** @hidden */
  3200. _this._adaptWidthToChildren = false;
  3201. /** @hidden */
  3202. _this._adaptHeightToChildren = false;
  3203. /**
  3204. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3205. */
  3206. _this.logLayoutCycleErrors = false;
  3207. /**
  3208. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3209. */
  3210. _this.maxLayoutCycle = 3;
  3211. return _this;
  3212. }
  3213. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3214. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3215. get: function () {
  3216. return this._adaptHeightToChildren;
  3217. },
  3218. set: function (value) {
  3219. if (this._adaptHeightToChildren === value) {
  3220. return;
  3221. }
  3222. this._adaptHeightToChildren = value;
  3223. if (value) {
  3224. this.height = "100%";
  3225. }
  3226. this._markAsDirty();
  3227. },
  3228. enumerable: true,
  3229. configurable: true
  3230. });
  3231. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3232. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3233. get: function () {
  3234. return this._adaptWidthToChildren;
  3235. },
  3236. set: function (value) {
  3237. if (this._adaptWidthToChildren === value) {
  3238. return;
  3239. }
  3240. this._adaptWidthToChildren = value;
  3241. if (value) {
  3242. this.width = "100%";
  3243. }
  3244. this._markAsDirty();
  3245. },
  3246. enumerable: true,
  3247. configurable: true
  3248. });
  3249. Object.defineProperty(Container.prototype, "background", {
  3250. /** Gets or sets background color */
  3251. get: function () {
  3252. return this._background;
  3253. },
  3254. set: function (value) {
  3255. if (this._background === value) {
  3256. return;
  3257. }
  3258. this._background = value;
  3259. this._markAsDirty();
  3260. },
  3261. enumerable: true,
  3262. configurable: true
  3263. });
  3264. Object.defineProperty(Container.prototype, "children", {
  3265. /** Gets the list of children */
  3266. get: function () {
  3267. return this._children;
  3268. },
  3269. enumerable: true,
  3270. configurable: true
  3271. });
  3272. Container.prototype._getTypeName = function () {
  3273. return "Container";
  3274. };
  3275. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3276. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3277. var child = _a[_i];
  3278. child._markMatrixAsDirty();
  3279. }
  3280. };
  3281. /**
  3282. * Gets a child using its name
  3283. * @param name defines the child name to look for
  3284. * @returns the child control if found
  3285. */
  3286. Container.prototype.getChildByName = function (name) {
  3287. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3288. var child = _a[_i];
  3289. if (child.name === name) {
  3290. return child;
  3291. }
  3292. }
  3293. return null;
  3294. };
  3295. /**
  3296. * Gets a child using its type and its name
  3297. * @param name defines the child name to look for
  3298. * @param type defines the child type to look for
  3299. * @returns the child control if found
  3300. */
  3301. Container.prototype.getChildByType = function (name, type) {
  3302. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3303. var child = _a[_i];
  3304. if (child.typeName === type) {
  3305. return child;
  3306. }
  3307. }
  3308. return null;
  3309. };
  3310. /**
  3311. * Search for a specific control in children
  3312. * @param control defines the control to look for
  3313. * @returns true if the control is in child list
  3314. */
  3315. Container.prototype.containsControl = function (control) {
  3316. return this.children.indexOf(control) !== -1;
  3317. };
  3318. /**
  3319. * Adds a new control to the current container
  3320. * @param control defines the control to add
  3321. * @returns the current container
  3322. */
  3323. Container.prototype.addControl = function (control) {
  3324. if (!control) {
  3325. return this;
  3326. }
  3327. var index = this._children.indexOf(control);
  3328. if (index !== -1) {
  3329. return this;
  3330. }
  3331. control._link(this._host);
  3332. control._markAllAsDirty();
  3333. this._reOrderControl(control);
  3334. this._markAsDirty();
  3335. return this;
  3336. };
  3337. /**
  3338. * Removes all controls from the current container
  3339. * @returns the current container
  3340. */
  3341. Container.prototype.clearControls = function () {
  3342. var children = this.children.slice();
  3343. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3344. var child = children_1[_i];
  3345. this.removeControl(child);
  3346. }
  3347. return this;
  3348. };
  3349. /**
  3350. * Removes a control from the current container
  3351. * @param control defines the control to remove
  3352. * @returns the current container
  3353. */
  3354. Container.prototype.removeControl = function (control) {
  3355. var index = this._children.indexOf(control);
  3356. if (index !== -1) {
  3357. this._children.splice(index, 1);
  3358. control.parent = null;
  3359. }
  3360. control.linkWithMesh(null);
  3361. if (this._host) {
  3362. this._host._cleanControlAfterRemoval(control);
  3363. }
  3364. this._markAsDirty();
  3365. return this;
  3366. };
  3367. /** @hidden */
  3368. Container.prototype._reOrderControl = function (control) {
  3369. this.removeControl(control);
  3370. var wasAdded = false;
  3371. for (var index = 0; index < this._children.length; index++) {
  3372. if (this._children[index].zIndex > control.zIndex) {
  3373. this._children.splice(index, 0, control);
  3374. wasAdded = true;
  3375. break;
  3376. }
  3377. }
  3378. if (!wasAdded) {
  3379. this._children.push(control);
  3380. }
  3381. control.parent = this;
  3382. this._markAsDirty();
  3383. };
  3384. /** @hidden */
  3385. Container.prototype._offsetLeft = function (offset) {
  3386. _super.prototype._offsetLeft.call(this, offset);
  3387. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3388. var child = _a[_i];
  3389. child._offsetLeft(offset);
  3390. }
  3391. };
  3392. /** @hidden */
  3393. Container.prototype._offsetTop = function (offset) {
  3394. _super.prototype._offsetTop.call(this, offset);
  3395. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3396. var child = _a[_i];
  3397. child._offsetTop(offset);
  3398. }
  3399. };
  3400. /** @hidden */
  3401. Container.prototype._markAllAsDirty = function () {
  3402. _super.prototype._markAllAsDirty.call(this);
  3403. for (var index = 0; index < this._children.length; index++) {
  3404. this._children[index]._markAllAsDirty();
  3405. }
  3406. };
  3407. /** @hidden */
  3408. Container.prototype._localDraw = function (context) {
  3409. if (this._background) {
  3410. context.save();
  3411. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3412. context.shadowColor = this.shadowColor;
  3413. context.shadowBlur = this.shadowBlur;
  3414. context.shadowOffsetX = this.shadowOffsetX;
  3415. context.shadowOffsetY = this.shadowOffsetY;
  3416. }
  3417. context.fillStyle = this._background;
  3418. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3419. context.restore();
  3420. }
  3421. };
  3422. /** @hidden */
  3423. Container.prototype._link = function (host) {
  3424. _super.prototype._link.call(this, host);
  3425. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3426. var child = _a[_i];
  3427. child._link(host);
  3428. }
  3429. };
  3430. /** @hidden */
  3431. Container.prototype._beforeLayout = function () {
  3432. // Do nothing
  3433. };
  3434. /** @hidden */
  3435. Container.prototype._processMeasures = function (parentMeasure, context) {
  3436. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3437. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3438. this._evaluateClippingState(parentMeasure);
  3439. }
  3440. };
  3441. /** @hidden */
  3442. Container.prototype._layout = function (parentMeasure, context) {
  3443. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3444. return false;
  3445. }
  3446. this.host._numLayoutCalls++;
  3447. if (this._isDirty) {
  3448. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3449. }
  3450. var rebuildCount = 0;
  3451. context.save();
  3452. this._applyStates(context);
  3453. this._beforeLayout();
  3454. do {
  3455. var computedWidth = -1;
  3456. var computedHeight = -1;
  3457. this._rebuildLayout = false;
  3458. this._processMeasures(parentMeasure, context);
  3459. if (!this._isClipped) {
  3460. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3461. var child = _a[_i];
  3462. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3463. if (child._layout(this._measureForChildren, context)) {
  3464. if (this.adaptWidthToChildren && child._width.isPixel) {
  3465. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3466. }
  3467. if (this.adaptHeightToChildren && child._height.isPixel) {
  3468. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3469. }
  3470. }
  3471. }
  3472. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3473. if (this.width !== computedWidth + "px") {
  3474. this.width = computedWidth + "px";
  3475. this._rebuildLayout = true;
  3476. }
  3477. }
  3478. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3479. if (this.height !== computedHeight + "px") {
  3480. this.height = computedHeight + "px";
  3481. this._rebuildLayout = true;
  3482. }
  3483. }
  3484. this._postMeasure();
  3485. }
  3486. rebuildCount++;
  3487. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3488. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3489. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3490. }
  3491. context.restore();
  3492. if (this._isDirty) {
  3493. this.invalidateRect();
  3494. this._isDirty = false;
  3495. }
  3496. return true;
  3497. };
  3498. Container.prototype._postMeasure = function () {
  3499. // Do nothing by default
  3500. };
  3501. /** @hidden */
  3502. Container.prototype._draw = function (context, invalidatedRectangle) {
  3503. this._localDraw(context);
  3504. if (this.clipChildren) {
  3505. this._clipForChildren(context);
  3506. }
  3507. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3508. var child = _a[_i];
  3509. // Only redraw parts of the screen that are invalidated
  3510. if (invalidatedRectangle) {
  3511. if (!child._intersectsRect(invalidatedRectangle)) {
  3512. continue;
  3513. }
  3514. }
  3515. child._render(context, invalidatedRectangle);
  3516. }
  3517. };
  3518. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3519. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3520. if (!this.children) {
  3521. return;
  3522. }
  3523. for (var index = 0; index < this.children.length; index++) {
  3524. var item = this.children[index];
  3525. if (!predicate || predicate(item)) {
  3526. results.push(item);
  3527. }
  3528. if (!directDescendantsOnly) {
  3529. item.getDescendantsToRef(results, false, predicate);
  3530. }
  3531. }
  3532. };
  3533. /** @hidden */
  3534. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3535. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3536. return false;
  3537. }
  3538. if (!_super.prototype.contains.call(this, x, y)) {
  3539. return false;
  3540. }
  3541. // Checking backwards to pick closest first
  3542. for (var index = this._children.length - 1; index >= 0; index--) {
  3543. var child = this._children[index];
  3544. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3545. if (child.hoverCursor) {
  3546. this._host._changeCursor(child.hoverCursor);
  3547. }
  3548. return true;
  3549. }
  3550. }
  3551. if (!this.isHitTestVisible) {
  3552. return false;
  3553. }
  3554. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3555. };
  3556. /** @hidden */
  3557. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3558. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3559. this._measureForChildren.copyFrom(this._currentMeasure);
  3560. };
  3561. /** Releases associated resources */
  3562. Container.prototype.dispose = function () {
  3563. _super.prototype.dispose.call(this);
  3564. for (var index = this.children.length - 1; index >= 0; index--) {
  3565. this.children[index].dispose();
  3566. }
  3567. };
  3568. return Container;
  3569. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3570. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3571. /***/ }),
  3572. /***/ "./2D/controls/control.ts":
  3573. /*!********************************!*\
  3574. !*** ./2D/controls/control.ts ***!
  3575. \********************************/
  3576. /*! exports provided: Control */
  3577. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3578. "use strict";
  3579. __webpack_require__.r(__webpack_exports__);
  3580. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3581. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  3582. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3583. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3584. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3585. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3586. /**
  3587. * Root class used for all 2D controls
  3588. * @see http://doc.babylonjs.com/how_to/gui#controls
  3589. */
  3590. var Control = /** @class */ (function () {
  3591. // Functions
  3592. /**
  3593. * Creates a new control
  3594. * @param name defines the name of the control
  3595. */
  3596. function Control(
  3597. /** defines the name of the control */
  3598. name) {
  3599. this.name = name;
  3600. this._alpha = 1;
  3601. this._alphaSet = false;
  3602. this._zIndex = 0;
  3603. /** @hidden */
  3604. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3605. this._fontFamily = "Arial";
  3606. this._fontStyle = "";
  3607. this._fontWeight = "";
  3608. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3609. /** @hidden */
  3610. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3611. /** @hidden */
  3612. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3613. this._color = "";
  3614. this._style = null;
  3615. /** @hidden */
  3616. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3617. /** @hidden */
  3618. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3619. /** @hidden */
  3620. this._isDirty = true;
  3621. /** @hidden */
  3622. this._wasDirty = false;
  3623. /** @hidden */
  3624. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3625. /** @hidden */
  3626. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3627. /** @hidden */
  3628. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3629. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3630. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3631. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3632. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3633. /** @hidden */
  3634. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3635. /** @hidden */
  3636. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3637. this._scaleX = 1.0;
  3638. this._scaleY = 1.0;
  3639. this._rotation = 0;
  3640. this._transformCenterX = 0.5;
  3641. this._transformCenterY = 0.5;
  3642. /** @hidden */
  3643. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3644. /** @hidden */
  3645. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3646. /** @hidden */
  3647. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3648. this._isMatrixDirty = true;
  3649. this._isVisible = true;
  3650. this._isHighlighted = false;
  3651. this._fontSet = false;
  3652. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3653. this._downCount = 0;
  3654. this._enterCount = -1;
  3655. this._doNotRender = false;
  3656. this._downPointerIds = {};
  3657. this._isEnabled = true;
  3658. this._disabledColor = "#9a9a9a";
  3659. /** @hidden */
  3660. this._rebuildLayout = false;
  3661. /** @hidden */
  3662. this._customData = {};
  3663. /** @hidden */
  3664. this._isClipped = false;
  3665. /** @hidden */
  3666. this._automaticSize = false;
  3667. /**
  3668. * Gets or sets an object used to store user defined information for the node
  3669. */
  3670. this.metadata = null;
  3671. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3672. this.isHitTestVisible = true;
  3673. /** Gets or sets a boolean indicating if the control can block pointer events */
  3674. this.isPointerBlocker = false;
  3675. /** Gets or sets a boolean indicating if the control can be focusable */
  3676. this.isFocusInvisible = false;
  3677. /**
  3678. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3679. * 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
  3680. */
  3681. this.clipChildren = true;
  3682. /**
  3683. * Gets or sets a boolean indicating that control content must be clipped
  3684. * 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
  3685. */
  3686. this.clipContent = true;
  3687. /**
  3688. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3689. */
  3690. this.useBitmapCache = false;
  3691. this._shadowOffsetX = 0;
  3692. this._shadowOffsetY = 0;
  3693. this._shadowBlur = 0;
  3694. this._shadowColor = 'black';
  3695. /** Gets or sets the cursor to use when the control is hovered */
  3696. this.hoverCursor = "";
  3697. /** @hidden */
  3698. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3699. /** @hidden */
  3700. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3701. /**
  3702. * An event triggered when the pointer move over the control.
  3703. */
  3704. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3705. /**
  3706. * An event triggered when the pointer move out of the control.
  3707. */
  3708. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3709. /**
  3710. * An event triggered when the pointer taps the control
  3711. */
  3712. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3713. /**
  3714. * An event triggered when pointer up
  3715. */
  3716. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3717. /**
  3718. * An event triggered when a control is clicked on
  3719. */
  3720. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3721. /**
  3722. * An event triggered when pointer enters the control
  3723. */
  3724. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3725. /**
  3726. * An event triggered when the control is marked as dirty
  3727. */
  3728. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3729. /**
  3730. * An event triggered before drawing the control
  3731. */
  3732. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3733. /**
  3734. * An event triggered after the control was drawn
  3735. */
  3736. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3737. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3738. }
  3739. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3740. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3741. get: function () {
  3742. return this._shadowOffsetX;
  3743. },
  3744. set: function (value) {
  3745. if (this._shadowOffsetX === value) {
  3746. return;
  3747. }
  3748. this._shadowOffsetX = value;
  3749. this._markAsDirty();
  3750. },
  3751. enumerable: true,
  3752. configurable: true
  3753. });
  3754. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3755. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3756. get: function () {
  3757. return this._shadowOffsetY;
  3758. },
  3759. set: function (value) {
  3760. if (this._shadowOffsetY === value) {
  3761. return;
  3762. }
  3763. this._shadowOffsetY = value;
  3764. this._markAsDirty();
  3765. },
  3766. enumerable: true,
  3767. configurable: true
  3768. });
  3769. Object.defineProperty(Control.prototype, "shadowBlur", {
  3770. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3771. get: function () {
  3772. return this._shadowBlur;
  3773. },
  3774. set: function (value) {
  3775. if (this._shadowBlur === value) {
  3776. return;
  3777. }
  3778. this._shadowBlur = value;
  3779. this._markAsDirty();
  3780. },
  3781. enumerable: true,
  3782. configurable: true
  3783. });
  3784. Object.defineProperty(Control.prototype, "shadowColor", {
  3785. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3786. get: function () {
  3787. return this._shadowColor;
  3788. },
  3789. set: function (value) {
  3790. if (this._shadowColor === value) {
  3791. return;
  3792. }
  3793. this._shadowColor = value;
  3794. this._markAsDirty();
  3795. },
  3796. enumerable: true,
  3797. configurable: true
  3798. });
  3799. Object.defineProperty(Control.prototype, "typeName", {
  3800. // Properties
  3801. /** Gets the control type name */
  3802. get: function () {
  3803. return this._getTypeName();
  3804. },
  3805. enumerable: true,
  3806. configurable: true
  3807. });
  3808. /**
  3809. * Get the current class name of the control.
  3810. * @returns current class name
  3811. */
  3812. Control.prototype.getClassName = function () {
  3813. return this._getTypeName();
  3814. };
  3815. Object.defineProperty(Control.prototype, "host", {
  3816. /**
  3817. * Get the hosting AdvancedDynamicTexture
  3818. */
  3819. get: function () {
  3820. return this._host;
  3821. },
  3822. enumerable: true,
  3823. configurable: true
  3824. });
  3825. Object.defineProperty(Control.prototype, "fontOffset", {
  3826. /** Gets or set information about font offsets (used to render and align text) */
  3827. get: function () {
  3828. return this._fontOffset;
  3829. },
  3830. set: function (offset) {
  3831. this._fontOffset = offset;
  3832. },
  3833. enumerable: true,
  3834. configurable: true
  3835. });
  3836. Object.defineProperty(Control.prototype, "alpha", {
  3837. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3838. get: function () {
  3839. return this._alpha;
  3840. },
  3841. set: function (value) {
  3842. if (this._alpha === value) {
  3843. return;
  3844. }
  3845. this._alphaSet = true;
  3846. this._alpha = value;
  3847. this._markAsDirty();
  3848. },
  3849. enumerable: true,
  3850. configurable: true
  3851. });
  3852. Object.defineProperty(Control.prototype, "isHighlighted", {
  3853. /**
  3854. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3855. */
  3856. get: function () {
  3857. return this._isHighlighted;
  3858. },
  3859. set: function (value) {
  3860. if (this._isHighlighted === value) {
  3861. return;
  3862. }
  3863. this._isHighlighted = value;
  3864. this._markAsDirty();
  3865. },
  3866. enumerable: true,
  3867. configurable: true
  3868. });
  3869. Object.defineProperty(Control.prototype, "scaleX", {
  3870. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3871. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3872. */
  3873. get: function () {
  3874. return this._scaleX;
  3875. },
  3876. set: function (value) {
  3877. if (this._scaleX === value) {
  3878. return;
  3879. }
  3880. this._scaleX = value;
  3881. this._markAsDirty();
  3882. this._markMatrixAsDirty();
  3883. },
  3884. enumerable: true,
  3885. configurable: true
  3886. });
  3887. Object.defineProperty(Control.prototype, "scaleY", {
  3888. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3889. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3890. */
  3891. get: function () {
  3892. return this._scaleY;
  3893. },
  3894. set: function (value) {
  3895. if (this._scaleY === value) {
  3896. return;
  3897. }
  3898. this._scaleY = value;
  3899. this._markAsDirty();
  3900. this._markMatrixAsDirty();
  3901. },
  3902. enumerable: true,
  3903. configurable: true
  3904. });
  3905. Object.defineProperty(Control.prototype, "rotation", {
  3906. /** Gets or sets the rotation angle (0 by default)
  3907. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3908. */
  3909. get: function () {
  3910. return this._rotation;
  3911. },
  3912. set: function (value) {
  3913. if (this._rotation === value) {
  3914. return;
  3915. }
  3916. this._rotation = value;
  3917. this._markAsDirty();
  3918. this._markMatrixAsDirty();
  3919. },
  3920. enumerable: true,
  3921. configurable: true
  3922. });
  3923. Object.defineProperty(Control.prototype, "transformCenterY", {
  3924. /** Gets or sets the transformation center on Y axis (0 by default)
  3925. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3926. */
  3927. get: function () {
  3928. return this._transformCenterY;
  3929. },
  3930. set: function (value) {
  3931. if (this._transformCenterY === value) {
  3932. return;
  3933. }
  3934. this._transformCenterY = value;
  3935. this._markAsDirty();
  3936. this._markMatrixAsDirty();
  3937. },
  3938. enumerable: true,
  3939. configurable: true
  3940. });
  3941. Object.defineProperty(Control.prototype, "transformCenterX", {
  3942. /** Gets or sets the transformation center on X axis (0 by default)
  3943. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3944. */
  3945. get: function () {
  3946. return this._transformCenterX;
  3947. },
  3948. set: function (value) {
  3949. if (this._transformCenterX === value) {
  3950. return;
  3951. }
  3952. this._transformCenterX = value;
  3953. this._markAsDirty();
  3954. this._markMatrixAsDirty();
  3955. },
  3956. enumerable: true,
  3957. configurable: true
  3958. });
  3959. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3960. /**
  3961. * Gets or sets the horizontal alignment
  3962. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3963. */
  3964. get: function () {
  3965. return this._horizontalAlignment;
  3966. },
  3967. set: function (value) {
  3968. if (this._horizontalAlignment === value) {
  3969. return;
  3970. }
  3971. this._horizontalAlignment = value;
  3972. this._markAsDirty();
  3973. },
  3974. enumerable: true,
  3975. configurable: true
  3976. });
  3977. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3978. /**
  3979. * Gets or sets the vertical alignment
  3980. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3981. */
  3982. get: function () {
  3983. return this._verticalAlignment;
  3984. },
  3985. set: function (value) {
  3986. if (this._verticalAlignment === value) {
  3987. return;
  3988. }
  3989. this._verticalAlignment = value;
  3990. this._markAsDirty();
  3991. },
  3992. enumerable: true,
  3993. configurable: true
  3994. });
  3995. Object.defineProperty(Control.prototype, "width", {
  3996. /**
  3997. * Gets or sets control width
  3998. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3999. */
  4000. get: function () {
  4001. return this._width.toString(this._host);
  4002. },
  4003. set: function (value) {
  4004. if (this._width.toString(this._host) === value) {
  4005. return;
  4006. }
  4007. if (this._width.fromString(value)) {
  4008. this._markAsDirty();
  4009. }
  4010. },
  4011. enumerable: true,
  4012. configurable: true
  4013. });
  4014. Object.defineProperty(Control.prototype, "widthInPixels", {
  4015. /**
  4016. * Gets or sets the control width in pixel
  4017. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4018. */
  4019. get: function () {
  4020. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4021. },
  4022. set: function (value) {
  4023. if (isNaN(value)) {
  4024. return;
  4025. }
  4026. this.width = value + "px";
  4027. },
  4028. enumerable: true,
  4029. configurable: true
  4030. });
  4031. Object.defineProperty(Control.prototype, "height", {
  4032. /**
  4033. * Gets or sets control height
  4034. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4035. */
  4036. get: function () {
  4037. return this._height.toString(this._host);
  4038. },
  4039. set: function (value) {
  4040. if (this._height.toString(this._host) === value) {
  4041. return;
  4042. }
  4043. if (this._height.fromString(value)) {
  4044. this._markAsDirty();
  4045. }
  4046. },
  4047. enumerable: true,
  4048. configurable: true
  4049. });
  4050. Object.defineProperty(Control.prototype, "heightInPixels", {
  4051. /**
  4052. * Gets or sets control height in pixel
  4053. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4054. */
  4055. get: function () {
  4056. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4057. },
  4058. set: function (value) {
  4059. if (isNaN(value)) {
  4060. return;
  4061. }
  4062. this.height = value + "px";
  4063. },
  4064. enumerable: true,
  4065. configurable: true
  4066. });
  4067. Object.defineProperty(Control.prototype, "fontFamily", {
  4068. /** Gets or set font family */
  4069. get: function () {
  4070. if (!this._fontSet) {
  4071. return "";
  4072. }
  4073. return this._fontFamily;
  4074. },
  4075. set: function (value) {
  4076. if (this._fontFamily === value) {
  4077. return;
  4078. }
  4079. this._fontFamily = value;
  4080. this._resetFontCache();
  4081. },
  4082. enumerable: true,
  4083. configurable: true
  4084. });
  4085. Object.defineProperty(Control.prototype, "fontStyle", {
  4086. /** Gets or sets font style */
  4087. get: function () {
  4088. return this._fontStyle;
  4089. },
  4090. set: function (value) {
  4091. if (this._fontStyle === value) {
  4092. return;
  4093. }
  4094. this._fontStyle = value;
  4095. this._resetFontCache();
  4096. },
  4097. enumerable: true,
  4098. configurable: true
  4099. });
  4100. Object.defineProperty(Control.prototype, "fontWeight", {
  4101. /** Gets or sets font weight */
  4102. get: function () {
  4103. return this._fontWeight;
  4104. },
  4105. set: function (value) {
  4106. if (this._fontWeight === value) {
  4107. return;
  4108. }
  4109. this._fontWeight = value;
  4110. this._resetFontCache();
  4111. },
  4112. enumerable: true,
  4113. configurable: true
  4114. });
  4115. Object.defineProperty(Control.prototype, "style", {
  4116. /**
  4117. * Gets or sets style
  4118. * @see http://doc.babylonjs.com/how_to/gui#styles
  4119. */
  4120. get: function () {
  4121. return this._style;
  4122. },
  4123. set: function (value) {
  4124. var _this = this;
  4125. if (this._style) {
  4126. this._style.onChangedObservable.remove(this._styleObserver);
  4127. this._styleObserver = null;
  4128. }
  4129. this._style = value;
  4130. if (this._style) {
  4131. this._styleObserver = this._style.onChangedObservable.add(function () {
  4132. _this._markAsDirty();
  4133. _this._resetFontCache();
  4134. });
  4135. }
  4136. this._markAsDirty();
  4137. this._resetFontCache();
  4138. },
  4139. enumerable: true,
  4140. configurable: true
  4141. });
  4142. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4143. /** @hidden */
  4144. get: function () {
  4145. return this._fontSize.isPercentage;
  4146. },
  4147. enumerable: true,
  4148. configurable: true
  4149. });
  4150. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4151. /** Gets or sets font size in pixels */
  4152. get: function () {
  4153. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4154. if (fontSizeToUse.isPixel) {
  4155. return fontSizeToUse.getValue(this._host);
  4156. }
  4157. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4158. },
  4159. set: function (value) {
  4160. if (isNaN(value)) {
  4161. return;
  4162. }
  4163. this.fontSize = value + "px";
  4164. },
  4165. enumerable: true,
  4166. configurable: true
  4167. });
  4168. Object.defineProperty(Control.prototype, "fontSize", {
  4169. /** Gets or sets font size */
  4170. get: function () {
  4171. return this._fontSize.toString(this._host);
  4172. },
  4173. set: function (value) {
  4174. if (this._fontSize.toString(this._host) === value) {
  4175. return;
  4176. }
  4177. if (this._fontSize.fromString(value)) {
  4178. this._markAsDirty();
  4179. this._resetFontCache();
  4180. }
  4181. },
  4182. enumerable: true,
  4183. configurable: true
  4184. });
  4185. Object.defineProperty(Control.prototype, "color", {
  4186. /** Gets or sets foreground color */
  4187. get: function () {
  4188. return this._color;
  4189. },
  4190. set: function (value) {
  4191. if (this._color === value) {
  4192. return;
  4193. }
  4194. this._color = value;
  4195. this._markAsDirty();
  4196. },
  4197. enumerable: true,
  4198. configurable: true
  4199. });
  4200. Object.defineProperty(Control.prototype, "zIndex", {
  4201. /** Gets or sets z index which is used to reorder controls on the z axis */
  4202. get: function () {
  4203. return this._zIndex;
  4204. },
  4205. set: function (value) {
  4206. if (this.zIndex === value) {
  4207. return;
  4208. }
  4209. this._zIndex = value;
  4210. if (this.parent) {
  4211. this.parent._reOrderControl(this);
  4212. }
  4213. },
  4214. enumerable: true,
  4215. configurable: true
  4216. });
  4217. Object.defineProperty(Control.prototype, "notRenderable", {
  4218. /** Gets or sets a boolean indicating if the control can be rendered */
  4219. get: function () {
  4220. return this._doNotRender;
  4221. },
  4222. set: function (value) {
  4223. if (this._doNotRender === value) {
  4224. return;
  4225. }
  4226. this._doNotRender = value;
  4227. this._markAsDirty();
  4228. },
  4229. enumerable: true,
  4230. configurable: true
  4231. });
  4232. Object.defineProperty(Control.prototype, "isVisible", {
  4233. /** Gets or sets a boolean indicating if the control is visible */
  4234. get: function () {
  4235. return this._isVisible;
  4236. },
  4237. set: function (value) {
  4238. if (this._isVisible === value) {
  4239. return;
  4240. }
  4241. this._isVisible = value;
  4242. this._markAsDirty(true);
  4243. },
  4244. enumerable: true,
  4245. configurable: true
  4246. });
  4247. Object.defineProperty(Control.prototype, "isDirty", {
  4248. /** Gets a boolean indicating that the control needs to update its rendering */
  4249. get: function () {
  4250. return this._isDirty;
  4251. },
  4252. enumerable: true,
  4253. configurable: true
  4254. });
  4255. Object.defineProperty(Control.prototype, "linkedMesh", {
  4256. /**
  4257. * Gets the current linked mesh (or null if none)
  4258. */
  4259. get: function () {
  4260. return this._linkedMesh;
  4261. },
  4262. enumerable: true,
  4263. configurable: true
  4264. });
  4265. Object.defineProperty(Control.prototype, "paddingLeft", {
  4266. /**
  4267. * Gets or sets a value indicating the padding to use on the left of the control
  4268. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4269. */
  4270. get: function () {
  4271. return this._paddingLeft.toString(this._host);
  4272. },
  4273. set: function (value) {
  4274. if (this._paddingLeft.fromString(value)) {
  4275. this._markAsDirty();
  4276. }
  4277. },
  4278. enumerable: true,
  4279. configurable: true
  4280. });
  4281. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4282. /**
  4283. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4284. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4285. */
  4286. get: function () {
  4287. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4288. },
  4289. set: function (value) {
  4290. if (isNaN(value)) {
  4291. return;
  4292. }
  4293. this.paddingLeft = value + "px";
  4294. },
  4295. enumerable: true,
  4296. configurable: true
  4297. });
  4298. Object.defineProperty(Control.prototype, "paddingRight", {
  4299. /**
  4300. * Gets or sets a value indicating the padding to use on the right of the control
  4301. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4302. */
  4303. get: function () {
  4304. return this._paddingRight.toString(this._host);
  4305. },
  4306. set: function (value) {
  4307. if (this._paddingRight.fromString(value)) {
  4308. this._markAsDirty();
  4309. }
  4310. },
  4311. enumerable: true,
  4312. configurable: true
  4313. });
  4314. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4315. /**
  4316. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4317. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4318. */
  4319. get: function () {
  4320. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4321. },
  4322. set: function (value) {
  4323. if (isNaN(value)) {
  4324. return;
  4325. }
  4326. this.paddingRight = value + "px";
  4327. },
  4328. enumerable: true,
  4329. configurable: true
  4330. });
  4331. Object.defineProperty(Control.prototype, "paddingTop", {
  4332. /**
  4333. * Gets or sets a value indicating the padding to use on the top of the control
  4334. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4335. */
  4336. get: function () {
  4337. return this._paddingTop.toString(this._host);
  4338. },
  4339. set: function (value) {
  4340. if (this._paddingTop.fromString(value)) {
  4341. this._markAsDirty();
  4342. }
  4343. },
  4344. enumerable: true,
  4345. configurable: true
  4346. });
  4347. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4348. /**
  4349. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4350. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4351. */
  4352. get: function () {
  4353. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4354. },
  4355. set: function (value) {
  4356. if (isNaN(value)) {
  4357. return;
  4358. }
  4359. this.paddingTop = value + "px";
  4360. },
  4361. enumerable: true,
  4362. configurable: true
  4363. });
  4364. Object.defineProperty(Control.prototype, "paddingBottom", {
  4365. /**
  4366. * Gets or sets a value indicating the padding to use on the bottom of the control
  4367. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4368. */
  4369. get: function () {
  4370. return this._paddingBottom.toString(this._host);
  4371. },
  4372. set: function (value) {
  4373. if (this._paddingBottom.fromString(value)) {
  4374. this._markAsDirty();
  4375. }
  4376. },
  4377. enumerable: true,
  4378. configurable: true
  4379. });
  4380. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4381. /**
  4382. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4383. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4384. */
  4385. get: function () {
  4386. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4387. },
  4388. set: function (value) {
  4389. if (isNaN(value)) {
  4390. return;
  4391. }
  4392. this.paddingBottom = value + "px";
  4393. },
  4394. enumerable: true,
  4395. configurable: true
  4396. });
  4397. Object.defineProperty(Control.prototype, "left", {
  4398. /**
  4399. * Gets or sets a value indicating the left coordinate of the control
  4400. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4401. */
  4402. get: function () {
  4403. return this._left.toString(this._host);
  4404. },
  4405. set: function (value) {
  4406. if (this._left.fromString(value)) {
  4407. this._markAsDirty();
  4408. }
  4409. },
  4410. enumerable: true,
  4411. configurable: true
  4412. });
  4413. Object.defineProperty(Control.prototype, "leftInPixels", {
  4414. /**
  4415. * Gets or sets a value indicating the left coordinate in pixels of the control
  4416. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4417. */
  4418. get: function () {
  4419. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4420. },
  4421. set: function (value) {
  4422. if (isNaN(value)) {
  4423. return;
  4424. }
  4425. this.left = value + "px";
  4426. },
  4427. enumerable: true,
  4428. configurable: true
  4429. });
  4430. Object.defineProperty(Control.prototype, "top", {
  4431. /**
  4432. * Gets or sets a value indicating the top coordinate of the control
  4433. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4434. */
  4435. get: function () {
  4436. return this._top.toString(this._host);
  4437. },
  4438. set: function (value) {
  4439. if (this._top.fromString(value)) {
  4440. this._markAsDirty();
  4441. }
  4442. },
  4443. enumerable: true,
  4444. configurable: true
  4445. });
  4446. Object.defineProperty(Control.prototype, "topInPixels", {
  4447. /**
  4448. * Gets or sets a value indicating the top coordinate in pixels of the control
  4449. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4450. */
  4451. get: function () {
  4452. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4453. },
  4454. set: function (value) {
  4455. if (isNaN(value)) {
  4456. return;
  4457. }
  4458. this.top = value + "px";
  4459. },
  4460. enumerable: true,
  4461. configurable: true
  4462. });
  4463. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4464. /**
  4465. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4466. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4467. */
  4468. get: function () {
  4469. return this._linkOffsetX.toString(this._host);
  4470. },
  4471. set: function (value) {
  4472. if (this._linkOffsetX.fromString(value)) {
  4473. this._markAsDirty();
  4474. }
  4475. },
  4476. enumerable: true,
  4477. configurable: true
  4478. });
  4479. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4480. /**
  4481. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4482. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4483. */
  4484. get: function () {
  4485. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4486. },
  4487. set: function (value) {
  4488. if (isNaN(value)) {
  4489. return;
  4490. }
  4491. this.linkOffsetX = value + "px";
  4492. },
  4493. enumerable: true,
  4494. configurable: true
  4495. });
  4496. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4497. /**
  4498. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4499. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4500. */
  4501. get: function () {
  4502. return this._linkOffsetY.toString(this._host);
  4503. },
  4504. set: function (value) {
  4505. if (this._linkOffsetY.fromString(value)) {
  4506. this._markAsDirty();
  4507. }
  4508. },
  4509. enumerable: true,
  4510. configurable: true
  4511. });
  4512. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4513. /**
  4514. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4515. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4516. */
  4517. get: function () {
  4518. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4519. },
  4520. set: function (value) {
  4521. if (isNaN(value)) {
  4522. return;
  4523. }
  4524. this.linkOffsetY = value + "px";
  4525. },
  4526. enumerable: true,
  4527. configurable: true
  4528. });
  4529. Object.defineProperty(Control.prototype, "centerX", {
  4530. /** Gets the center coordinate on X axis */
  4531. get: function () {
  4532. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4533. },
  4534. enumerable: true,
  4535. configurable: true
  4536. });
  4537. Object.defineProperty(Control.prototype, "centerY", {
  4538. /** Gets the center coordinate on Y axis */
  4539. get: function () {
  4540. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4541. },
  4542. enumerable: true,
  4543. configurable: true
  4544. });
  4545. Object.defineProperty(Control.prototype, "isEnabled", {
  4546. /** Gets or sets if control is Enabled*/
  4547. get: function () {
  4548. return this._isEnabled;
  4549. },
  4550. set: function (value) {
  4551. if (this._isEnabled === value) {
  4552. return;
  4553. }
  4554. this._isEnabled = value;
  4555. this._markAsDirty();
  4556. },
  4557. enumerable: true,
  4558. configurable: true
  4559. });
  4560. Object.defineProperty(Control.prototype, "disabledColor", {
  4561. /** Gets or sets background color of control if it's disabled*/
  4562. get: function () {
  4563. return this._disabledColor;
  4564. },
  4565. set: function (value) {
  4566. if (this._disabledColor === value) {
  4567. return;
  4568. }
  4569. this._disabledColor = value;
  4570. this._markAsDirty();
  4571. },
  4572. enumerable: true,
  4573. configurable: true
  4574. });
  4575. /** @hidden */
  4576. Control.prototype._getTypeName = function () {
  4577. return "Control";
  4578. };
  4579. /**
  4580. * Gets the first ascendant in the hierarchy of the given type
  4581. * @param className defines the required type
  4582. * @returns the ascendant or null if not found
  4583. */
  4584. Control.prototype.getAscendantOfClass = function (className) {
  4585. if (!this.parent) {
  4586. return null;
  4587. }
  4588. if (this.parent.getClassName() === className) {
  4589. return this.parent;
  4590. }
  4591. return this.parent.getAscendantOfClass(className);
  4592. };
  4593. /** @hidden */
  4594. Control.prototype._resetFontCache = function () {
  4595. this._fontSet = true;
  4596. this._markAsDirty();
  4597. };
  4598. /**
  4599. * Determines if a container is an ascendant of the current control
  4600. * @param container defines the container to look for
  4601. * @returns true if the container is one of the ascendant of the control
  4602. */
  4603. Control.prototype.isAscendant = function (container) {
  4604. if (!this.parent) {
  4605. return false;
  4606. }
  4607. if (this.parent === container) {
  4608. return true;
  4609. }
  4610. return this.parent.isAscendant(container);
  4611. };
  4612. /**
  4613. * Gets coordinates in local control space
  4614. * @param globalCoordinates defines the coordinates to transform
  4615. * @returns the new coordinates in local space
  4616. */
  4617. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4618. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4619. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4620. return result;
  4621. };
  4622. /**
  4623. * Gets coordinates in local control space
  4624. * @param globalCoordinates defines the coordinates to transform
  4625. * @param result defines the target vector2 where to store the result
  4626. * @returns the current control
  4627. */
  4628. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4629. result.x = globalCoordinates.x - this._currentMeasure.left;
  4630. result.y = globalCoordinates.y - this._currentMeasure.top;
  4631. return this;
  4632. };
  4633. /**
  4634. * Gets coordinates in parent local control space
  4635. * @param globalCoordinates defines the coordinates to transform
  4636. * @returns the new coordinates in parent local space
  4637. */
  4638. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4639. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4640. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4641. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4642. return result;
  4643. };
  4644. /**
  4645. * Move the current control to a vector3 position projected onto the screen.
  4646. * @param position defines the target position
  4647. * @param scene defines the hosting scene
  4648. */
  4649. Control.prototype.moveToVector3 = function (position, scene) {
  4650. if (!this._host || this.parent !== this._host._rootContainer) {
  4651. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4652. return;
  4653. }
  4654. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4655. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4656. var globalViewport = this._host._getGlobalViewport(scene);
  4657. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4658. this._moveToProjectedPosition(projectedPosition);
  4659. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4660. this.notRenderable = true;
  4661. return;
  4662. }
  4663. this.notRenderable = false;
  4664. };
  4665. /**
  4666. * Will store all controls that have this control as ascendant in a given array
  4667. * @param results defines the array where to store the descendants
  4668. * @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
  4669. * @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
  4670. */
  4671. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4672. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4673. // Do nothing by default
  4674. };
  4675. /**
  4676. * Will return all controls that have this control as ascendant
  4677. * @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
  4678. * @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
  4679. * @return all child controls
  4680. */
  4681. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4682. var results = new Array();
  4683. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4684. return results;
  4685. };
  4686. /**
  4687. * Link current control with a target mesh
  4688. * @param mesh defines the mesh to link with
  4689. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4690. */
  4691. Control.prototype.linkWithMesh = function (mesh) {
  4692. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4693. if (mesh) {
  4694. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4695. }
  4696. return;
  4697. }
  4698. var index = this._host._linkedControls.indexOf(this);
  4699. if (index !== -1) {
  4700. this._linkedMesh = mesh;
  4701. if (!mesh) {
  4702. this._host._linkedControls.splice(index, 1);
  4703. }
  4704. return;
  4705. }
  4706. else if (!mesh) {
  4707. return;
  4708. }
  4709. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4710. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4711. this._linkedMesh = mesh;
  4712. this._host._linkedControls.push(this);
  4713. };
  4714. /** @hidden */
  4715. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4716. var oldLeft = this._left.getValue(this._host);
  4717. var oldTop = this._top.getValue(this._host);
  4718. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4719. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4720. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4721. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4722. newLeft = oldLeft;
  4723. }
  4724. if (Math.abs(newTop - oldTop) < 0.5) {
  4725. newTop = oldTop;
  4726. }
  4727. }
  4728. this.left = newLeft + "px";
  4729. this.top = newTop + "px";
  4730. this._left.ignoreAdaptiveScaling = true;
  4731. this._top.ignoreAdaptiveScaling = true;
  4732. this._markAsDirty();
  4733. };
  4734. /** @hidden */
  4735. Control.prototype._offsetLeft = function (offset) {
  4736. this._isDirty = true;
  4737. this._currentMeasure.left += offset;
  4738. };
  4739. /** @hidden */
  4740. Control.prototype._offsetTop = function (offset) {
  4741. this._isDirty = true;
  4742. this._currentMeasure.top += offset;
  4743. };
  4744. /** @hidden */
  4745. Control.prototype._markMatrixAsDirty = function () {
  4746. this._isMatrixDirty = true;
  4747. this._flagDescendantsAsMatrixDirty();
  4748. };
  4749. /** @hidden */
  4750. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4751. // No child
  4752. };
  4753. /** @hidden */
  4754. Control.prototype._intersectsRect = function (rect) {
  4755. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4756. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4757. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4758. return false;
  4759. }
  4760. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4761. return false;
  4762. }
  4763. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4764. return false;
  4765. }
  4766. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4767. return false;
  4768. }
  4769. return true;
  4770. };
  4771. /** @hidden */
  4772. Control.prototype.invalidateRect = function () {
  4773. this._transform();
  4774. if (this.host && this.host.useInvalidateRectOptimization) {
  4775. // Rotate by transform to get the measure transformed to global space
  4776. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4777. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4778. // the previous measure is used to properly clear a control that is scaled down
  4779. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4780. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4781. // Expand rect based on shadows
  4782. var shadowOffsetX = this.shadowOffsetX;
  4783. var shadowOffsetY = this.shadowOffsetY;
  4784. var shadowBlur = this.shadowBlur;
  4785. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4786. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4787. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4788. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4789. 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));
  4790. }
  4791. else {
  4792. 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));
  4793. }
  4794. }
  4795. };
  4796. /** @hidden */
  4797. Control.prototype._markAsDirty = function (force) {
  4798. if (force === void 0) { force = false; }
  4799. if (!this._isVisible && !force) {
  4800. return;
  4801. }
  4802. this._isDirty = true;
  4803. // Redraw only this rectangle
  4804. if (this._host) {
  4805. this._host.markAsDirty();
  4806. }
  4807. };
  4808. /** @hidden */
  4809. Control.prototype._markAllAsDirty = function () {
  4810. this._markAsDirty();
  4811. if (this._font) {
  4812. this._prepareFont();
  4813. }
  4814. };
  4815. /** @hidden */
  4816. Control.prototype._link = function (host) {
  4817. this._host = host;
  4818. if (this._host) {
  4819. this.uniqueId = this._host.getScene().getUniqueId();
  4820. }
  4821. };
  4822. /** @hidden */
  4823. Control.prototype._transform = function (context) {
  4824. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4825. return;
  4826. }
  4827. // postTranslate
  4828. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4829. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4830. if (context) {
  4831. context.translate(offsetX, offsetY);
  4832. // rotate
  4833. context.rotate(this._rotation);
  4834. // scale
  4835. context.scale(this._scaleX, this._scaleY);
  4836. // preTranslate
  4837. context.translate(-offsetX, -offsetY);
  4838. }
  4839. // Need to update matrices?
  4840. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4841. this._cachedOffsetX = offsetX;
  4842. this._cachedOffsetY = offsetY;
  4843. this._isMatrixDirty = false;
  4844. this._flagDescendantsAsMatrixDirty();
  4845. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4846. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4847. }
  4848. };
  4849. /** @hidden */
  4850. Control.prototype._renderHighlight = function (context) {
  4851. if (!this.isHighlighted) {
  4852. return;
  4853. }
  4854. context.save();
  4855. context.strokeStyle = "#4affff";
  4856. context.lineWidth = 2;
  4857. this._renderHighlightSpecific(context);
  4858. context.restore();
  4859. };
  4860. /** @hidden */
  4861. Control.prototype._renderHighlightSpecific = function (context) {
  4862. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4863. };
  4864. /** @hidden */
  4865. Control.prototype._applyStates = function (context) {
  4866. if (this._isFontSizeInPercentage) {
  4867. this._fontSet = true;
  4868. }
  4869. if (this._fontSet) {
  4870. this._prepareFont();
  4871. this._fontSet = false;
  4872. }
  4873. if (this._font) {
  4874. context.font = this._font;
  4875. }
  4876. if (this._color) {
  4877. context.fillStyle = this._color;
  4878. }
  4879. if (Control.AllowAlphaInheritance) {
  4880. context.globalAlpha *= this._alpha;
  4881. }
  4882. else if (this._alphaSet) {
  4883. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4884. }
  4885. };
  4886. /** @hidden */
  4887. Control.prototype._layout = function (parentMeasure, context) {
  4888. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4889. return false;
  4890. }
  4891. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4892. this.host._numLayoutCalls++;
  4893. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4894. context.save();
  4895. this._applyStates(context);
  4896. var rebuildCount = 0;
  4897. do {
  4898. this._rebuildLayout = false;
  4899. this._processMeasures(parentMeasure, context);
  4900. rebuildCount++;
  4901. } while (this._rebuildLayout && rebuildCount < 3);
  4902. if (rebuildCount >= 3) {
  4903. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4904. }
  4905. context.restore();
  4906. this.invalidateRect();
  4907. this._evaluateClippingState(parentMeasure);
  4908. }
  4909. this._wasDirty = this._isDirty;
  4910. this._isDirty = false;
  4911. return true;
  4912. };
  4913. /** @hidden */
  4914. Control.prototype._processMeasures = function (parentMeasure, context) {
  4915. this._currentMeasure.copyFrom(parentMeasure);
  4916. // Let children take some pre-measurement actions
  4917. this._preMeasure(parentMeasure, context);
  4918. this._measure();
  4919. this._computeAlignment(parentMeasure, context);
  4920. // Convert to int values
  4921. this._currentMeasure.left = this._currentMeasure.left | 0;
  4922. this._currentMeasure.top = this._currentMeasure.top | 0;
  4923. this._currentMeasure.width = this._currentMeasure.width | 0;
  4924. this._currentMeasure.height = this._currentMeasure.height | 0;
  4925. // Let children add more features
  4926. this._additionalProcessing(parentMeasure, context);
  4927. this._cachedParentMeasure.copyFrom(parentMeasure);
  4928. if (this.onDirtyObservable.hasObservers()) {
  4929. this.onDirtyObservable.notifyObservers(this);
  4930. }
  4931. };
  4932. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4933. if (this.parent && this.parent.clipChildren) {
  4934. // Early clip
  4935. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4936. this._isClipped = true;
  4937. return;
  4938. }
  4939. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4940. this._isClipped = true;
  4941. return;
  4942. }
  4943. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4944. this._isClipped = true;
  4945. return;
  4946. }
  4947. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4948. this._isClipped = true;
  4949. return;
  4950. }
  4951. }
  4952. this._isClipped = false;
  4953. };
  4954. /** @hidden */
  4955. Control.prototype._measure = function () {
  4956. // Width / Height
  4957. if (this._width.isPixel) {
  4958. this._currentMeasure.width = this._width.getValue(this._host);
  4959. }
  4960. else {
  4961. this._currentMeasure.width *= this._width.getValue(this._host);
  4962. }
  4963. if (this._height.isPixel) {
  4964. this._currentMeasure.height = this._height.getValue(this._host);
  4965. }
  4966. else {
  4967. this._currentMeasure.height *= this._height.getValue(this._host);
  4968. }
  4969. };
  4970. /** @hidden */
  4971. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4972. var width = this._currentMeasure.width;
  4973. var height = this._currentMeasure.height;
  4974. var parentWidth = parentMeasure.width;
  4975. var parentHeight = parentMeasure.height;
  4976. // Left / top
  4977. var x = 0;
  4978. var y = 0;
  4979. switch (this.horizontalAlignment) {
  4980. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4981. x = 0;
  4982. break;
  4983. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4984. x = parentWidth - width;
  4985. break;
  4986. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4987. x = (parentWidth - width) / 2;
  4988. break;
  4989. }
  4990. switch (this.verticalAlignment) {
  4991. case Control.VERTICAL_ALIGNMENT_TOP:
  4992. y = 0;
  4993. break;
  4994. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4995. y = parentHeight - height;
  4996. break;
  4997. case Control.VERTICAL_ALIGNMENT_CENTER:
  4998. y = (parentHeight - height) / 2;
  4999. break;
  5000. }
  5001. if (this._paddingLeft.isPixel) {
  5002. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  5003. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  5004. }
  5005. else {
  5006. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  5007. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  5008. }
  5009. if (this._paddingRight.isPixel) {
  5010. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  5011. }
  5012. else {
  5013. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  5014. }
  5015. if (this._paddingTop.isPixel) {
  5016. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  5017. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  5018. }
  5019. else {
  5020. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  5021. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  5022. }
  5023. if (this._paddingBottom.isPixel) {
  5024. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  5025. }
  5026. else {
  5027. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  5028. }
  5029. if (this._left.isPixel) {
  5030. this._currentMeasure.left += this._left.getValue(this._host);
  5031. }
  5032. else {
  5033. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  5034. }
  5035. if (this._top.isPixel) {
  5036. this._currentMeasure.top += this._top.getValue(this._host);
  5037. }
  5038. else {
  5039. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5040. }
  5041. this._currentMeasure.left += x;
  5042. this._currentMeasure.top += y;
  5043. };
  5044. /** @hidden */
  5045. Control.prototype._preMeasure = function (parentMeasure, context) {
  5046. // Do nothing
  5047. };
  5048. /** @hidden */
  5049. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5050. // Do nothing
  5051. };
  5052. /** @hidden */
  5053. Control.prototype._clipForChildren = function (context) {
  5054. // DO nothing
  5055. };
  5056. Control.prototype._clip = function (context, invalidatedRectangle) {
  5057. context.beginPath();
  5058. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5059. if (invalidatedRectangle) {
  5060. // Rotate the invalidated rect into the control's space
  5061. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5062. // Get the intersection of the rect in context space and the current context
  5063. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5064. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5065. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5066. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5067. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5068. Control._ClipMeasure.copyFrom(intersection);
  5069. }
  5070. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5071. var shadowOffsetX = this.shadowOffsetX;
  5072. var shadowOffsetY = this.shadowOffsetY;
  5073. var shadowBlur = this.shadowBlur;
  5074. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5075. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5076. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5077. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5078. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5079. }
  5080. else {
  5081. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5082. }
  5083. context.clip();
  5084. };
  5085. /** @hidden */
  5086. Control.prototype._render = function (context, invalidatedRectangle) {
  5087. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5088. this._isDirty = false;
  5089. return false;
  5090. }
  5091. this.host._numRenderCalls++;
  5092. context.save();
  5093. this._applyStates(context);
  5094. // Transform
  5095. this._transform(context);
  5096. // Clip
  5097. if (this.clipContent) {
  5098. this._clip(context, invalidatedRectangle);
  5099. }
  5100. if (this.onBeforeDrawObservable.hasObservers()) {
  5101. this.onBeforeDrawObservable.notifyObservers(this);
  5102. }
  5103. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5104. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5105. }
  5106. else {
  5107. this._draw(context, invalidatedRectangle);
  5108. }
  5109. if (this.useBitmapCache && this._wasDirty) {
  5110. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5111. }
  5112. this._renderHighlight(context);
  5113. if (this.onAfterDrawObservable.hasObservers()) {
  5114. this.onAfterDrawObservable.notifyObservers(this);
  5115. }
  5116. context.restore();
  5117. return true;
  5118. };
  5119. /** @hidden */
  5120. Control.prototype._draw = function (context, invalidatedRectangle) {
  5121. // Do nothing
  5122. };
  5123. /**
  5124. * Tests if a given coordinates belong to the current control
  5125. * @param x defines x coordinate to test
  5126. * @param y defines y coordinate to test
  5127. * @returns true if the coordinates are inside the control
  5128. */
  5129. Control.prototype.contains = function (x, y) {
  5130. // Invert transform
  5131. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5132. x = this._transformedPosition.x;
  5133. y = this._transformedPosition.y;
  5134. // Check
  5135. if (x < this._currentMeasure.left) {
  5136. return false;
  5137. }
  5138. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5139. return false;
  5140. }
  5141. if (y < this._currentMeasure.top) {
  5142. return false;
  5143. }
  5144. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5145. return false;
  5146. }
  5147. if (this.isPointerBlocker) {
  5148. this._host._shouldBlockPointer = true;
  5149. }
  5150. return true;
  5151. };
  5152. /** @hidden */
  5153. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5154. if (!this._isEnabled) {
  5155. return false;
  5156. }
  5157. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5158. return false;
  5159. }
  5160. if (!this.contains(x, y)) {
  5161. return false;
  5162. }
  5163. this._processObservables(type, x, y, pointerId, buttonIndex);
  5164. return true;
  5165. };
  5166. /** @hidden */
  5167. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5168. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5169. if (canNotify && this.parent != null) {
  5170. this.parent._onPointerMove(target, coordinates, pointerId);
  5171. }
  5172. };
  5173. /** @hidden */
  5174. Control.prototype._onPointerEnter = function (target) {
  5175. if (!this._isEnabled) {
  5176. return false;
  5177. }
  5178. if (this._enterCount > 0) {
  5179. return false;
  5180. }
  5181. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5182. this._enterCount = 0;
  5183. }
  5184. this._enterCount++;
  5185. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5186. if (canNotify && this.parent != null) {
  5187. this.parent._onPointerEnter(target);
  5188. }
  5189. return true;
  5190. };
  5191. /** @hidden */
  5192. Control.prototype._onPointerOut = function (target, force) {
  5193. if (force === void 0) { force = false; }
  5194. if (!force && (!this._isEnabled || target === this)) {
  5195. return;
  5196. }
  5197. this._enterCount = 0;
  5198. var canNotify = true;
  5199. if (!target.isAscendant(this)) {
  5200. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5201. }
  5202. if (canNotify && this.parent != null) {
  5203. this.parent._onPointerOut(target, force);
  5204. }
  5205. };
  5206. /** @hidden */
  5207. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5208. // Prevent pointerout to lose control context.
  5209. // Event redundancy is checked inside the function.
  5210. this._onPointerEnter(this);
  5211. if (this._downCount !== 0) {
  5212. return false;
  5213. }
  5214. this._downCount++;
  5215. this._downPointerIds[pointerId] = true;
  5216. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5217. if (canNotify && this.parent != null) {
  5218. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5219. }
  5220. return true;
  5221. };
  5222. /** @hidden */
  5223. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5224. if (!this._isEnabled) {
  5225. return;
  5226. }
  5227. this._downCount = 0;
  5228. delete this._downPointerIds[pointerId];
  5229. var canNotifyClick = notifyClick;
  5230. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5231. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5232. }
  5233. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5234. if (canNotify && this.parent != null) {
  5235. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5236. }
  5237. };
  5238. /** @hidden */
  5239. Control.prototype._forcePointerUp = function (pointerId) {
  5240. if (pointerId === void 0) { pointerId = null; }
  5241. if (pointerId !== null) {
  5242. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5243. }
  5244. else {
  5245. for (var key in this._downPointerIds) {
  5246. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5247. }
  5248. }
  5249. };
  5250. /** @hidden */
  5251. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5252. if (!this._isEnabled) {
  5253. return false;
  5254. }
  5255. this._dummyVector2.copyFromFloats(x, y);
  5256. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5257. this._onPointerMove(this, this._dummyVector2, pointerId);
  5258. var previousControlOver = this._host._lastControlOver[pointerId];
  5259. if (previousControlOver && previousControlOver !== this) {
  5260. previousControlOver._onPointerOut(this);
  5261. }
  5262. if (previousControlOver !== this) {
  5263. this._onPointerEnter(this);
  5264. }
  5265. this._host._lastControlOver[pointerId] = this;
  5266. return true;
  5267. }
  5268. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5269. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5270. this._host._registerLastControlDown(this, pointerId);
  5271. this._host._lastPickedControl = this;
  5272. return true;
  5273. }
  5274. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5275. if (this._host._lastControlDown[pointerId]) {
  5276. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5277. }
  5278. delete this._host._lastControlDown[pointerId];
  5279. return true;
  5280. }
  5281. return false;
  5282. };
  5283. Control.prototype._prepareFont = function () {
  5284. if (!this._font && !this._fontSet) {
  5285. return;
  5286. }
  5287. if (this._style) {
  5288. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5289. }
  5290. else {
  5291. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5292. }
  5293. this._fontOffset = Control._GetFontOffset(this._font);
  5294. };
  5295. /** Releases associated resources */
  5296. Control.prototype.dispose = function () {
  5297. this.onDirtyObservable.clear();
  5298. this.onBeforeDrawObservable.clear();
  5299. this.onAfterDrawObservable.clear();
  5300. this.onPointerDownObservable.clear();
  5301. this.onPointerEnterObservable.clear();
  5302. this.onPointerMoveObservable.clear();
  5303. this.onPointerOutObservable.clear();
  5304. this.onPointerUpObservable.clear();
  5305. this.onPointerClickObservable.clear();
  5306. if (this._styleObserver && this._style) {
  5307. this._style.onChangedObservable.remove(this._styleObserver);
  5308. this._styleObserver = null;
  5309. }
  5310. if (this.parent) {
  5311. this.parent.removeControl(this);
  5312. this.parent = null;
  5313. }
  5314. if (this._host) {
  5315. var index = this._host._linkedControls.indexOf(this);
  5316. if (index > -1) {
  5317. this.linkWithMesh(null);
  5318. }
  5319. }
  5320. };
  5321. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5322. /** HORIZONTAL_ALIGNMENT_LEFT */
  5323. get: function () {
  5324. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5325. },
  5326. enumerable: true,
  5327. configurable: true
  5328. });
  5329. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5330. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5331. get: function () {
  5332. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5333. },
  5334. enumerable: true,
  5335. configurable: true
  5336. });
  5337. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5338. /** HORIZONTAL_ALIGNMENT_CENTER */
  5339. get: function () {
  5340. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5341. },
  5342. enumerable: true,
  5343. configurable: true
  5344. });
  5345. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5346. /** VERTICAL_ALIGNMENT_TOP */
  5347. get: function () {
  5348. return Control._VERTICAL_ALIGNMENT_TOP;
  5349. },
  5350. enumerable: true,
  5351. configurable: true
  5352. });
  5353. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5354. /** VERTICAL_ALIGNMENT_BOTTOM */
  5355. get: function () {
  5356. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5357. },
  5358. enumerable: true,
  5359. configurable: true
  5360. });
  5361. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5362. /** VERTICAL_ALIGNMENT_CENTER */
  5363. get: function () {
  5364. return Control._VERTICAL_ALIGNMENT_CENTER;
  5365. },
  5366. enumerable: true,
  5367. configurable: true
  5368. });
  5369. /** @hidden */
  5370. Control._GetFontOffset = function (font) {
  5371. if (Control._FontHeightSizes[font]) {
  5372. return Control._FontHeightSizes[font];
  5373. }
  5374. var text = document.createElement("span");
  5375. text.innerHTML = "Hg";
  5376. text.style.font = font;
  5377. var block = document.createElement("div");
  5378. block.style.display = "inline-block";
  5379. block.style.width = "1px";
  5380. block.style.height = "0px";
  5381. block.style.verticalAlign = "bottom";
  5382. var div = document.createElement("div");
  5383. div.appendChild(text);
  5384. div.appendChild(block);
  5385. document.body.appendChild(div);
  5386. var fontAscent = 0;
  5387. var fontHeight = 0;
  5388. try {
  5389. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5390. block.style.verticalAlign = "baseline";
  5391. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5392. }
  5393. finally {
  5394. document.body.removeChild(div);
  5395. }
  5396. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5397. Control._FontHeightSizes[font] = result;
  5398. return result;
  5399. };
  5400. /** @hidden */
  5401. Control.drawEllipse = function (x, y, width, height, context) {
  5402. context.translate(x, y);
  5403. context.scale(width, height);
  5404. context.beginPath();
  5405. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5406. context.closePath();
  5407. context.scale(1 / width, 1 / height);
  5408. context.translate(-x, -y);
  5409. };
  5410. /**
  5411. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5412. */
  5413. Control.AllowAlphaInheritance = false;
  5414. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5415. // Statics
  5416. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5417. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5418. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5419. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5420. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5421. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5422. Control._FontHeightSizes = {};
  5423. /**
  5424. * Creates a stack panel that can be used to render headers
  5425. * @param control defines the control to associate with the header
  5426. * @param text defines the text of the header
  5427. * @param size defines the size of the header
  5428. * @param options defines options used to configure the header
  5429. * @returns a new StackPanel
  5430. * @ignore
  5431. * @hidden
  5432. */
  5433. Control.AddHeader = function () { };
  5434. return Control;
  5435. }());
  5436. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5437. /***/ }),
  5438. /***/ "./2D/controls/displayGrid.ts":
  5439. /*!************************************!*\
  5440. !*** ./2D/controls/displayGrid.ts ***!
  5441. \************************************/
  5442. /*! exports provided: DisplayGrid */
  5443. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5444. "use strict";
  5445. __webpack_require__.r(__webpack_exports__);
  5446. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5447. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5448. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5449. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5450. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5451. /** Class used to render a grid */
  5452. var DisplayGrid = /** @class */ (function (_super) {
  5453. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5454. /**
  5455. * Creates a new GridDisplayRectangle
  5456. * @param name defines the control name
  5457. */
  5458. function DisplayGrid(name) {
  5459. var _this = _super.call(this, name) || this;
  5460. _this.name = name;
  5461. _this._cellWidth = 20;
  5462. _this._cellHeight = 20;
  5463. _this._minorLineTickness = 1;
  5464. _this._minorLineColor = "DarkGray";
  5465. _this._majorLineTickness = 2;
  5466. _this._majorLineColor = "White";
  5467. _this._majorLineFrequency = 5;
  5468. _this._background = "Black";
  5469. _this._displayMajorLines = true;
  5470. _this._displayMinorLines = true;
  5471. return _this;
  5472. }
  5473. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5474. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5475. get: function () {
  5476. return this._displayMinorLines;
  5477. },
  5478. set: function (value) {
  5479. if (this._displayMinorLines === value) {
  5480. return;
  5481. }
  5482. this._displayMinorLines = value;
  5483. this._markAsDirty();
  5484. },
  5485. enumerable: true,
  5486. configurable: true
  5487. });
  5488. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5489. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5490. get: function () {
  5491. return this._displayMajorLines;
  5492. },
  5493. set: function (value) {
  5494. if (this._displayMajorLines === value) {
  5495. return;
  5496. }
  5497. this._displayMajorLines = value;
  5498. this._markAsDirty();
  5499. },
  5500. enumerable: true,
  5501. configurable: true
  5502. });
  5503. Object.defineProperty(DisplayGrid.prototype, "background", {
  5504. /** Gets or sets background color (Black by default) */
  5505. get: function () {
  5506. return this._background;
  5507. },
  5508. set: function (value) {
  5509. if (this._background === value) {
  5510. return;
  5511. }
  5512. this._background = value;
  5513. this._markAsDirty();
  5514. },
  5515. enumerable: true,
  5516. configurable: true
  5517. });
  5518. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5519. /** Gets or sets the width of each cell (20 by default) */
  5520. get: function () {
  5521. return this._cellWidth;
  5522. },
  5523. set: function (value) {
  5524. this._cellWidth = value;
  5525. this._markAsDirty();
  5526. },
  5527. enumerable: true,
  5528. configurable: true
  5529. });
  5530. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5531. /** Gets or sets the height of each cell (20 by default) */
  5532. get: function () {
  5533. return this._cellHeight;
  5534. },
  5535. set: function (value) {
  5536. this._cellHeight = value;
  5537. this._markAsDirty();
  5538. },
  5539. enumerable: true,
  5540. configurable: true
  5541. });
  5542. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5543. /** Gets or sets the tickness of minor lines (1 by default) */
  5544. get: function () {
  5545. return this._minorLineTickness;
  5546. },
  5547. set: function (value) {
  5548. this._minorLineTickness = value;
  5549. this._markAsDirty();
  5550. },
  5551. enumerable: true,
  5552. configurable: true
  5553. });
  5554. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5555. /** Gets or sets the color of minor lines (DarkGray by default) */
  5556. get: function () {
  5557. return this._minorLineColor;
  5558. },
  5559. set: function (value) {
  5560. this._minorLineColor = value;
  5561. this._markAsDirty();
  5562. },
  5563. enumerable: true,
  5564. configurable: true
  5565. });
  5566. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5567. /** Gets or sets the tickness of major lines (2 by default) */
  5568. get: function () {
  5569. return this._majorLineTickness;
  5570. },
  5571. set: function (value) {
  5572. this._majorLineTickness = value;
  5573. this._markAsDirty();
  5574. },
  5575. enumerable: true,
  5576. configurable: true
  5577. });
  5578. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5579. /** Gets or sets the color of major lines (White by default) */
  5580. get: function () {
  5581. return this._majorLineColor;
  5582. },
  5583. set: function (value) {
  5584. this._majorLineColor = value;
  5585. this._markAsDirty();
  5586. },
  5587. enumerable: true,
  5588. configurable: true
  5589. });
  5590. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5591. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5592. get: function () {
  5593. return this._majorLineFrequency;
  5594. },
  5595. set: function (value) {
  5596. this._majorLineFrequency = value;
  5597. this._markAsDirty();
  5598. },
  5599. enumerable: true,
  5600. configurable: true
  5601. });
  5602. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5603. context.save();
  5604. this._applyStates(context);
  5605. if (this._isEnabled) {
  5606. if (this._background) {
  5607. context.fillStyle = this._background;
  5608. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5609. }
  5610. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5611. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5612. // Minor lines
  5613. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5614. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5615. if (this._displayMinorLines) {
  5616. context.strokeStyle = this._minorLineColor;
  5617. context.lineWidth = this._minorLineTickness;
  5618. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5619. var cellX = left + x * this.cellWidth;
  5620. context.beginPath();
  5621. context.moveTo(cellX, this._currentMeasure.top);
  5622. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5623. context.stroke();
  5624. }
  5625. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5626. var cellY = top_1 + y * this.cellHeight;
  5627. context.beginPath();
  5628. context.moveTo(this._currentMeasure.left, cellY);
  5629. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5630. context.stroke();
  5631. }
  5632. }
  5633. // Major lines
  5634. if (this._displayMajorLines) {
  5635. context.strokeStyle = this._majorLineColor;
  5636. context.lineWidth = this._majorLineTickness;
  5637. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5638. var cellX = left + x * this.cellWidth;
  5639. context.beginPath();
  5640. context.moveTo(cellX, this._currentMeasure.top);
  5641. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5642. context.stroke();
  5643. }
  5644. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5645. var cellY = top_1 + y * this.cellHeight;
  5646. context.moveTo(this._currentMeasure.left, cellY);
  5647. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5648. context.closePath();
  5649. context.stroke();
  5650. }
  5651. }
  5652. }
  5653. context.restore();
  5654. };
  5655. DisplayGrid.prototype._getTypeName = function () {
  5656. return "DisplayGrid";
  5657. };
  5658. return DisplayGrid;
  5659. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5660. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5661. /***/ }),
  5662. /***/ "./2D/controls/ellipse.ts":
  5663. /*!********************************!*\
  5664. !*** ./2D/controls/ellipse.ts ***!
  5665. \********************************/
  5666. /*! exports provided: Ellipse */
  5667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5668. "use strict";
  5669. __webpack_require__.r(__webpack_exports__);
  5670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5671. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5672. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5673. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5674. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5675. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5676. /** Class used to create 2D ellipse containers */
  5677. var Ellipse = /** @class */ (function (_super) {
  5678. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5679. /**
  5680. * Creates a new Ellipse
  5681. * @param name defines the control name
  5682. */
  5683. function Ellipse(name) {
  5684. var _this = _super.call(this, name) || this;
  5685. _this.name = name;
  5686. _this._thickness = 1;
  5687. return _this;
  5688. }
  5689. Object.defineProperty(Ellipse.prototype, "thickness", {
  5690. /** Gets or sets border thickness */
  5691. get: function () {
  5692. return this._thickness;
  5693. },
  5694. set: function (value) {
  5695. if (this._thickness === value) {
  5696. return;
  5697. }
  5698. this._thickness = value;
  5699. this._markAsDirty();
  5700. },
  5701. enumerable: true,
  5702. configurable: true
  5703. });
  5704. Ellipse.prototype._getTypeName = function () {
  5705. return "Ellipse";
  5706. };
  5707. Ellipse.prototype._localDraw = function (context) {
  5708. context.save();
  5709. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5710. context.shadowColor = this.shadowColor;
  5711. context.shadowBlur = this.shadowBlur;
  5712. context.shadowOffsetX = this.shadowOffsetX;
  5713. context.shadowOffsetY = this.shadowOffsetY;
  5714. }
  5715. _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);
  5716. if (this._background) {
  5717. context.fillStyle = this._background;
  5718. context.fill();
  5719. }
  5720. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5721. context.shadowBlur = 0;
  5722. context.shadowOffsetX = 0;
  5723. context.shadowOffsetY = 0;
  5724. }
  5725. if (this._thickness) {
  5726. if (this.color) {
  5727. context.strokeStyle = this.color;
  5728. }
  5729. context.lineWidth = this._thickness;
  5730. context.stroke();
  5731. }
  5732. context.restore();
  5733. };
  5734. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5735. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5736. this._measureForChildren.width -= 2 * this._thickness;
  5737. this._measureForChildren.height -= 2 * this._thickness;
  5738. this._measureForChildren.left += this._thickness;
  5739. this._measureForChildren.top += this._thickness;
  5740. };
  5741. Ellipse.prototype._clipForChildren = function (context) {
  5742. _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);
  5743. context.clip();
  5744. };
  5745. return Ellipse;
  5746. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5747. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5748. /***/ }),
  5749. /***/ "./2D/controls/grid.ts":
  5750. /*!*****************************!*\
  5751. !*** ./2D/controls/grid.ts ***!
  5752. \*****************************/
  5753. /*! exports provided: Grid */
  5754. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5755. "use strict";
  5756. __webpack_require__.r(__webpack_exports__);
  5757. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5758. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5759. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5760. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5761. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5762. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  5763. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5764. /**
  5765. * Class used to create a 2D grid container
  5766. */
  5767. var Grid = /** @class */ (function (_super) {
  5768. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5769. /**
  5770. * Creates a new Grid
  5771. * @param name defines control name
  5772. */
  5773. function Grid(name) {
  5774. var _this = _super.call(this, name) || this;
  5775. _this.name = name;
  5776. _this._rowDefinitions = new Array();
  5777. _this._columnDefinitions = new Array();
  5778. _this._cells = {};
  5779. _this._childControls = new Array();
  5780. return _this;
  5781. }
  5782. Object.defineProperty(Grid.prototype, "columnCount", {
  5783. /**
  5784. * Gets the number of columns
  5785. */
  5786. get: function () {
  5787. return this._columnDefinitions.length;
  5788. },
  5789. enumerable: true,
  5790. configurable: true
  5791. });
  5792. Object.defineProperty(Grid.prototype, "rowCount", {
  5793. /**
  5794. * Gets the number of rows
  5795. */
  5796. get: function () {
  5797. return this._rowDefinitions.length;
  5798. },
  5799. enumerable: true,
  5800. configurable: true
  5801. });
  5802. Object.defineProperty(Grid.prototype, "children", {
  5803. /** Gets the list of children */
  5804. get: function () {
  5805. return this._childControls;
  5806. },
  5807. enumerable: true,
  5808. configurable: true
  5809. });
  5810. Object.defineProperty(Grid.prototype, "cells", {
  5811. /** Gets the list of cells (e.g. the containers) */
  5812. get: function () {
  5813. return this._cells;
  5814. },
  5815. enumerable: true,
  5816. configurable: true
  5817. });
  5818. /**
  5819. * Gets the definition of a specific row
  5820. * @param index defines the index of the row
  5821. * @returns the row definition
  5822. */
  5823. Grid.prototype.getRowDefinition = function (index) {
  5824. if (index < 0 || index >= this._rowDefinitions.length) {
  5825. return null;
  5826. }
  5827. return this._rowDefinitions[index];
  5828. };
  5829. /**
  5830. * Gets the definition of a specific column
  5831. * @param index defines the index of the column
  5832. * @returns the column definition
  5833. */
  5834. Grid.prototype.getColumnDefinition = function (index) {
  5835. if (index < 0 || index >= this._columnDefinitions.length) {
  5836. return null;
  5837. }
  5838. return this._columnDefinitions[index];
  5839. };
  5840. /**
  5841. * Adds a new row to the grid
  5842. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5843. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5844. * @returns the current grid
  5845. */
  5846. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5847. if (isPixel === void 0) { isPixel = false; }
  5848. 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));
  5849. this._markAsDirty();
  5850. return this;
  5851. };
  5852. /**
  5853. * Adds a new column to the grid
  5854. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5855. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5856. * @returns the current grid
  5857. */
  5858. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5859. if (isPixel === void 0) { isPixel = false; }
  5860. 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));
  5861. this._markAsDirty();
  5862. return this;
  5863. };
  5864. /**
  5865. * Update a row definition
  5866. * @param index defines the index of the row to update
  5867. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5868. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5869. * @returns the current grid
  5870. */
  5871. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5872. if (isPixel === void 0) { isPixel = false; }
  5873. if (index < 0 || index >= this._rowDefinitions.length) {
  5874. return this;
  5875. }
  5876. var current = this._rowDefinitions[index];
  5877. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5878. return this;
  5879. }
  5880. 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);
  5881. this._markAsDirty();
  5882. return this;
  5883. };
  5884. /**
  5885. * Update a column definition
  5886. * @param index defines the index of the column to update
  5887. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5888. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5889. * @returns the current grid
  5890. */
  5891. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5892. if (isPixel === void 0) { isPixel = false; }
  5893. if (index < 0 || index >= this._columnDefinitions.length) {
  5894. return this;
  5895. }
  5896. var current = this._columnDefinitions[index];
  5897. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5898. return this;
  5899. }
  5900. 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);
  5901. this._markAsDirty();
  5902. return this;
  5903. };
  5904. /**
  5905. * Gets the list of children stored in a specific cell
  5906. * @param row defines the row to check
  5907. * @param column defines the column to check
  5908. * @returns the list of controls
  5909. */
  5910. Grid.prototype.getChildrenAt = function (row, column) {
  5911. var cell = this._cells[row + ":" + column];
  5912. if (!cell) {
  5913. return null;
  5914. }
  5915. return cell.children;
  5916. };
  5917. /**
  5918. * Gets a string representing the child cell info (row x column)
  5919. * @param child defines the control to get info from
  5920. * @returns a string containing the child cell info (row x column)
  5921. */
  5922. Grid.prototype.getChildCellInfo = function (child) {
  5923. return child._tag;
  5924. };
  5925. Grid.prototype._removeCell = function (cell, key) {
  5926. if (!cell) {
  5927. return;
  5928. }
  5929. _super.prototype.removeControl.call(this, cell);
  5930. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5931. var control = _a[_i];
  5932. var childIndex = this._childControls.indexOf(control);
  5933. if (childIndex !== -1) {
  5934. this._childControls.splice(childIndex, 1);
  5935. }
  5936. }
  5937. delete this._cells[key];
  5938. };
  5939. Grid.prototype._offsetCell = function (previousKey, key) {
  5940. if (!this._cells[key]) {
  5941. return;
  5942. }
  5943. this._cells[previousKey] = this._cells[key];
  5944. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5945. var control = _a[_i];
  5946. control._tag = previousKey;
  5947. }
  5948. delete this._cells[key];
  5949. };
  5950. /**
  5951. * Remove a column definition at specified index
  5952. * @param index defines the index of the column to remove
  5953. * @returns the current grid
  5954. */
  5955. Grid.prototype.removeColumnDefinition = function (index) {
  5956. if (index < 0 || index >= this._columnDefinitions.length) {
  5957. return this;
  5958. }
  5959. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5960. var key = x + ":" + index;
  5961. var cell = this._cells[key];
  5962. this._removeCell(cell, key);
  5963. }
  5964. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5965. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5966. var previousKey = x + ":" + (y - 1);
  5967. var key = x + ":" + y;
  5968. this._offsetCell(previousKey, key);
  5969. }
  5970. }
  5971. this._columnDefinitions.splice(index, 1);
  5972. this._markAsDirty();
  5973. return this;
  5974. };
  5975. /**
  5976. * Remove a row definition at specified index
  5977. * @param index defines the index of the row to remove
  5978. * @returns the current grid
  5979. */
  5980. Grid.prototype.removeRowDefinition = function (index) {
  5981. if (index < 0 || index >= this._rowDefinitions.length) {
  5982. return this;
  5983. }
  5984. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5985. var key = index + ":" + y;
  5986. var cell = this._cells[key];
  5987. this._removeCell(cell, key);
  5988. }
  5989. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5990. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5991. var previousKey = x - 1 + ":" + y;
  5992. var key = x + ":" + y;
  5993. this._offsetCell(previousKey, key);
  5994. }
  5995. }
  5996. this._rowDefinitions.splice(index, 1);
  5997. this._markAsDirty();
  5998. return this;
  5999. };
  6000. /**
  6001. * Adds a new control to the current grid
  6002. * @param control defines the control to add
  6003. * @param row defines the row where to add the control (0 by default)
  6004. * @param column defines the column where to add the control (0 by default)
  6005. * @returns the current grid
  6006. */
  6007. Grid.prototype.addControl = function (control, row, column) {
  6008. if (row === void 0) { row = 0; }
  6009. if (column === void 0) { column = 0; }
  6010. if (this._rowDefinitions.length === 0) {
  6011. // Add default row definition
  6012. this.addRowDefinition(1, false);
  6013. }
  6014. if (this._columnDefinitions.length === 0) {
  6015. // Add default column definition
  6016. this.addColumnDefinition(1, false);
  6017. }
  6018. if (this._childControls.indexOf(control) !== -1) {
  6019. 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");
  6020. return this;
  6021. }
  6022. var x = Math.min(row, this._rowDefinitions.length - 1);
  6023. var y = Math.min(column, this._columnDefinitions.length - 1);
  6024. var key = x + ":" + y;
  6025. var goodContainer = this._cells[key];
  6026. if (!goodContainer) {
  6027. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6028. this._cells[key] = goodContainer;
  6029. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6030. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6031. _super.prototype.addControl.call(this, goodContainer);
  6032. }
  6033. goodContainer.addControl(control);
  6034. this._childControls.push(control);
  6035. control._tag = key;
  6036. control.parent = this;
  6037. this._markAsDirty();
  6038. return this;
  6039. };
  6040. /**
  6041. * Removes a control from the current container
  6042. * @param control defines the control to remove
  6043. * @returns the current container
  6044. */
  6045. Grid.prototype.removeControl = function (control) {
  6046. var index = this._childControls.indexOf(control);
  6047. if (index !== -1) {
  6048. this._childControls.splice(index, 1);
  6049. }
  6050. var cell = this._cells[control._tag];
  6051. if (cell) {
  6052. cell.removeControl(control);
  6053. control._tag = null;
  6054. }
  6055. this._markAsDirty();
  6056. return this;
  6057. };
  6058. Grid.prototype._getTypeName = function () {
  6059. return "Grid";
  6060. };
  6061. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6062. var widths = [];
  6063. var heights = [];
  6064. var lefts = [];
  6065. var tops = [];
  6066. var availableWidth = this._currentMeasure.width;
  6067. var globalWidthPercentage = 0;
  6068. var availableHeight = this._currentMeasure.height;
  6069. var globalHeightPercentage = 0;
  6070. // Heights
  6071. var index = 0;
  6072. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6073. var value = _a[_i];
  6074. if (value.isPixel) {
  6075. var height = value.getValue(this._host);
  6076. availableHeight -= height;
  6077. heights[index] = height;
  6078. }
  6079. else {
  6080. globalHeightPercentage += value.internalValue;
  6081. }
  6082. index++;
  6083. }
  6084. var top = 0;
  6085. index = 0;
  6086. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6087. var value = _c[_b];
  6088. tops.push(top);
  6089. if (!value.isPixel) {
  6090. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6091. top += height;
  6092. heights[index] = height;
  6093. }
  6094. else {
  6095. top += value.getValue(this._host);
  6096. }
  6097. index++;
  6098. }
  6099. // Widths
  6100. index = 0;
  6101. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6102. var value = _e[_d];
  6103. if (value.isPixel) {
  6104. var width = value.getValue(this._host);
  6105. availableWidth -= width;
  6106. widths[index] = width;
  6107. }
  6108. else {
  6109. globalWidthPercentage += value.internalValue;
  6110. }
  6111. index++;
  6112. }
  6113. var left = 0;
  6114. index = 0;
  6115. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6116. var value = _g[_f];
  6117. lefts.push(left);
  6118. if (!value.isPixel) {
  6119. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6120. left += width;
  6121. widths[index] = width;
  6122. }
  6123. else {
  6124. left += value.getValue(this._host);
  6125. }
  6126. index++;
  6127. }
  6128. definitionCallback(lefts, tops, widths, heights);
  6129. };
  6130. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6131. var _this = this;
  6132. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6133. // Setting child sizes
  6134. for (var key in _this._cells) {
  6135. if (!_this._cells.hasOwnProperty(key)) {
  6136. continue;
  6137. }
  6138. var split = key.split(":");
  6139. var x = parseInt(split[0]);
  6140. var y = parseInt(split[1]);
  6141. var cell = _this._cells[key];
  6142. cell.left = lefts[y] + "px";
  6143. cell.top = tops[x] + "px";
  6144. cell.width = widths[y] + "px";
  6145. cell.height = heights[x] + "px";
  6146. cell._left.ignoreAdaptiveScaling = true;
  6147. cell._top.ignoreAdaptiveScaling = true;
  6148. cell._width.ignoreAdaptiveScaling = true;
  6149. cell._height.ignoreAdaptiveScaling = true;
  6150. }
  6151. });
  6152. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6153. };
  6154. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6155. for (var key in this._cells) {
  6156. if (!this._cells.hasOwnProperty(key)) {
  6157. continue;
  6158. }
  6159. var child = this._cells[key];
  6160. child._markMatrixAsDirty();
  6161. }
  6162. };
  6163. Grid.prototype._renderHighlightSpecific = function (context) {
  6164. var _this = this;
  6165. _super.prototype._renderHighlightSpecific.call(this, context);
  6166. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6167. // Columns
  6168. for (var index = 0; index < lefts.length; index++) {
  6169. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6170. context.beginPath();
  6171. context.moveTo(left, _this._currentMeasure.top);
  6172. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6173. context.stroke();
  6174. }
  6175. // Rows
  6176. for (var index = 0; index < tops.length; index++) {
  6177. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6178. context.beginPath();
  6179. context.moveTo(_this._currentMeasure.left, top_1);
  6180. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6181. context.stroke();
  6182. }
  6183. });
  6184. context.restore();
  6185. };
  6186. /** Releases associated resources */
  6187. Grid.prototype.dispose = function () {
  6188. _super.prototype.dispose.call(this);
  6189. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6190. var control = _a[_i];
  6191. control.dispose();
  6192. }
  6193. this._childControls = [];
  6194. };
  6195. return Grid;
  6196. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6197. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6198. /***/ }),
  6199. /***/ "./2D/controls/image.ts":
  6200. /*!******************************!*\
  6201. !*** ./2D/controls/image.ts ***!
  6202. \******************************/
  6203. /*! exports provided: Image */
  6204. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6205. "use strict";
  6206. __webpack_require__.r(__webpack_exports__);
  6207. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6208. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6209. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6210. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6211. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6212. /**
  6213. * Class used to create 2D images
  6214. */
  6215. var Image = /** @class */ (function (_super) {
  6216. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6217. /**
  6218. * Creates a new Image
  6219. * @param name defines the control name
  6220. * @param url defines the image url
  6221. */
  6222. function Image(name, url) {
  6223. if (url === void 0) { url = null; }
  6224. var _this = _super.call(this, name) || this;
  6225. _this.name = name;
  6226. _this._workingCanvas = null;
  6227. _this._loaded = false;
  6228. _this._stretch = Image.STRETCH_FILL;
  6229. _this._autoScale = false;
  6230. _this._sourceLeft = 0;
  6231. _this._sourceTop = 0;
  6232. _this._sourceWidth = 0;
  6233. _this._sourceHeight = 0;
  6234. _this._svgAttributesComputationCompleted = false;
  6235. _this._isSVG = false;
  6236. _this._cellWidth = 0;
  6237. _this._cellHeight = 0;
  6238. _this._cellId = -1;
  6239. _this._populateNinePatchSlicesFromImage = false;
  6240. /**
  6241. * Observable notified when the content is loaded
  6242. */
  6243. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6244. /**
  6245. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6246. */
  6247. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6248. _this.source = url;
  6249. return _this;
  6250. }
  6251. Object.defineProperty(Image.prototype, "isLoaded", {
  6252. /**
  6253. * Gets a boolean indicating that the content is loaded
  6254. */
  6255. get: function () {
  6256. return this._loaded;
  6257. },
  6258. enumerable: true,
  6259. configurable: true
  6260. });
  6261. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6262. /**
  6263. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6264. */
  6265. get: function () {
  6266. return this._populateNinePatchSlicesFromImage;
  6267. },
  6268. set: function (value) {
  6269. if (this._populateNinePatchSlicesFromImage === value) {
  6270. return;
  6271. }
  6272. this._populateNinePatchSlicesFromImage = value;
  6273. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6274. this._extractNinePatchSliceDataFromImage();
  6275. }
  6276. },
  6277. enumerable: true,
  6278. configurable: true
  6279. });
  6280. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6281. /**
  6282. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6283. * Beware using this as this will comsume more memory as the image has to be stored twice
  6284. */
  6285. get: function () {
  6286. return this._detectPointerOnOpaqueOnly;
  6287. },
  6288. set: function (value) {
  6289. if (this._detectPointerOnOpaqueOnly === value) {
  6290. return;
  6291. }
  6292. this._detectPointerOnOpaqueOnly = value;
  6293. },
  6294. enumerable: true,
  6295. configurable: true
  6296. });
  6297. Object.defineProperty(Image.prototype, "sliceLeft", {
  6298. /**
  6299. * Gets or sets the left value for slicing (9-patch)
  6300. */
  6301. get: function () {
  6302. return this._sliceLeft;
  6303. },
  6304. set: function (value) {
  6305. if (this._sliceLeft === value) {
  6306. return;
  6307. }
  6308. this._sliceLeft = value;
  6309. this._markAsDirty();
  6310. },
  6311. enumerable: true,
  6312. configurable: true
  6313. });
  6314. Object.defineProperty(Image.prototype, "sliceRight", {
  6315. /**
  6316. * Gets or sets the right value for slicing (9-patch)
  6317. */
  6318. get: function () {
  6319. return this._sliceRight;
  6320. },
  6321. set: function (value) {
  6322. if (this._sliceRight === value) {
  6323. return;
  6324. }
  6325. this._sliceRight = value;
  6326. this._markAsDirty();
  6327. },
  6328. enumerable: true,
  6329. configurable: true
  6330. });
  6331. Object.defineProperty(Image.prototype, "sliceTop", {
  6332. /**
  6333. * Gets or sets the top value for slicing (9-patch)
  6334. */
  6335. get: function () {
  6336. return this._sliceTop;
  6337. },
  6338. set: function (value) {
  6339. if (this._sliceTop === value) {
  6340. return;
  6341. }
  6342. this._sliceTop = value;
  6343. this._markAsDirty();
  6344. },
  6345. enumerable: true,
  6346. configurable: true
  6347. });
  6348. Object.defineProperty(Image.prototype, "sliceBottom", {
  6349. /**
  6350. * Gets or sets the bottom value for slicing (9-patch)
  6351. */
  6352. get: function () {
  6353. return this._sliceBottom;
  6354. },
  6355. set: function (value) {
  6356. if (this._sliceBottom === value) {
  6357. return;
  6358. }
  6359. this._sliceBottom = value;
  6360. this._markAsDirty();
  6361. },
  6362. enumerable: true,
  6363. configurable: true
  6364. });
  6365. Object.defineProperty(Image.prototype, "sourceLeft", {
  6366. /**
  6367. * Gets or sets the left coordinate in the source image
  6368. */
  6369. get: function () {
  6370. return this._sourceLeft;
  6371. },
  6372. set: function (value) {
  6373. if (this._sourceLeft === value) {
  6374. return;
  6375. }
  6376. this._sourceLeft = value;
  6377. this._markAsDirty();
  6378. },
  6379. enumerable: true,
  6380. configurable: true
  6381. });
  6382. Object.defineProperty(Image.prototype, "sourceTop", {
  6383. /**
  6384. * Gets or sets the top coordinate in the source image
  6385. */
  6386. get: function () {
  6387. return this._sourceTop;
  6388. },
  6389. set: function (value) {
  6390. if (this._sourceTop === value) {
  6391. return;
  6392. }
  6393. this._sourceTop = value;
  6394. this._markAsDirty();
  6395. },
  6396. enumerable: true,
  6397. configurable: true
  6398. });
  6399. Object.defineProperty(Image.prototype, "sourceWidth", {
  6400. /**
  6401. * Gets or sets the width to capture in the source image
  6402. */
  6403. get: function () {
  6404. return this._sourceWidth;
  6405. },
  6406. set: function (value) {
  6407. if (this._sourceWidth === value) {
  6408. return;
  6409. }
  6410. this._sourceWidth = value;
  6411. this._markAsDirty();
  6412. },
  6413. enumerable: true,
  6414. configurable: true
  6415. });
  6416. Object.defineProperty(Image.prototype, "sourceHeight", {
  6417. /**
  6418. * Gets or sets the height to capture in the source image
  6419. */
  6420. get: function () {
  6421. return this._sourceHeight;
  6422. },
  6423. set: function (value) {
  6424. if (this._sourceHeight === value) {
  6425. return;
  6426. }
  6427. this._sourceHeight = value;
  6428. this._markAsDirty();
  6429. },
  6430. enumerable: true,
  6431. configurable: true
  6432. });
  6433. Object.defineProperty(Image.prototype, "isSVG", {
  6434. /** Indicates if the format of the image is SVG */
  6435. get: function () {
  6436. return this._isSVG;
  6437. },
  6438. enumerable: true,
  6439. configurable: true
  6440. });
  6441. Object.defineProperty(Image.prototype, "svgAttributesComputationCompleted", {
  6442. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  6443. get: function () {
  6444. return this._svgAttributesComputationCompleted;
  6445. },
  6446. enumerable: true,
  6447. configurable: true
  6448. });
  6449. Object.defineProperty(Image.prototype, "autoScale", {
  6450. /**
  6451. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6452. * @see http://doc.babylonjs.com/how_to/gui#image
  6453. */
  6454. get: function () {
  6455. return this._autoScale;
  6456. },
  6457. set: function (value) {
  6458. if (this._autoScale === value) {
  6459. return;
  6460. }
  6461. this._autoScale = value;
  6462. if (value && this._loaded) {
  6463. this.synchronizeSizeWithContent();
  6464. }
  6465. },
  6466. enumerable: true,
  6467. configurable: true
  6468. });
  6469. Object.defineProperty(Image.prototype, "stretch", {
  6470. /** Gets or sets the streching mode used by the image */
  6471. get: function () {
  6472. return this._stretch;
  6473. },
  6474. set: function (value) {
  6475. if (this._stretch === value) {
  6476. return;
  6477. }
  6478. this._stretch = value;
  6479. this._markAsDirty();
  6480. },
  6481. enumerable: true,
  6482. configurable: true
  6483. });
  6484. /** @hidden */
  6485. Image.prototype._rotate90 = function (n, preserveProperties) {
  6486. if (preserveProperties === void 0) { preserveProperties = false; }
  6487. var canvas = document.createElement('canvas');
  6488. var context = canvas.getContext('2d');
  6489. var width = this._domImage.width;
  6490. var height = this._domImage.height;
  6491. canvas.width = height;
  6492. canvas.height = width;
  6493. context.translate(canvas.width / 2, canvas.height / 2);
  6494. context.rotate(n * Math.PI / 2);
  6495. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  6496. var dataUrl = canvas.toDataURL("image/jpg");
  6497. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  6498. if (preserveProperties) {
  6499. rotatedImage._stretch = this._stretch;
  6500. rotatedImage._autoScale = this._autoScale;
  6501. rotatedImage._cellId = this._cellId;
  6502. rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;
  6503. rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;
  6504. }
  6505. this._handleRotationForSVGImage(this, rotatedImage, n);
  6506. return rotatedImage;
  6507. };
  6508. Image.prototype._handleRotationForSVGImage = function (srcImage, dstImage, n) {
  6509. var _this = this;
  6510. if (!srcImage._isSVG) {
  6511. return;
  6512. }
  6513. if (srcImage._svgAttributesComputationCompleted) {
  6514. this._rotate90SourceProperties(srcImage, dstImage, n);
  6515. this._markAsDirty();
  6516. }
  6517. else {
  6518. srcImage.onSVGAttributesComputedObservable.addOnce(function () {
  6519. _this._rotate90SourceProperties(srcImage, dstImage, n);
  6520. _this._markAsDirty();
  6521. });
  6522. }
  6523. };
  6524. Image.prototype._rotate90SourceProperties = function (srcImage, dstImage, n) {
  6525. var _a, _b;
  6526. var srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
  6527. var dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
  6528. if (n != 0) {
  6529. var mult = n < 0 ? -1 : 1;
  6530. n = n % 4;
  6531. for (var i = 0; i < Math.abs(n); ++i) {
  6532. dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;
  6533. dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;
  6534. _a = [dstHeight, dstWidth], dstWidth = _a[0], dstHeight = _a[1];
  6535. if (n < 0) {
  6536. dstTop -= dstHeight;
  6537. }
  6538. else {
  6539. dstLeft -= dstWidth;
  6540. }
  6541. srcLeft = dstLeft;
  6542. srcTop = dstTop;
  6543. _b = [srcHeight, srcWidth], srcWidth = _b[0], srcHeight = _b[1];
  6544. }
  6545. }
  6546. dstImage.sourceLeft = dstLeft;
  6547. dstImage.sourceTop = dstTop;
  6548. dstImage.sourceWidth = dstWidth;
  6549. dstImage.sourceHeight = dstHeight;
  6550. };
  6551. Object.defineProperty(Image.prototype, "domImage", {
  6552. get: function () {
  6553. return this._domImage;
  6554. },
  6555. /**
  6556. * Gets or sets the internal DOM image used to render the control
  6557. */
  6558. set: function (value) {
  6559. var _this = this;
  6560. this._domImage = value;
  6561. this._loaded = false;
  6562. if (this._domImage.width) {
  6563. this._onImageLoaded();
  6564. }
  6565. else {
  6566. this._domImage.onload = function () {
  6567. _this._onImageLoaded();
  6568. };
  6569. }
  6570. },
  6571. enumerable: true,
  6572. configurable: true
  6573. });
  6574. Image.prototype._onImageLoaded = function () {
  6575. this._imageWidth = this._domImage.width;
  6576. this._imageHeight = this._domImage.height;
  6577. this._loaded = true;
  6578. if (this._populateNinePatchSlicesFromImage) {
  6579. this._extractNinePatchSliceDataFromImage();
  6580. }
  6581. if (this._autoScale) {
  6582. this.synchronizeSizeWithContent();
  6583. }
  6584. this.onImageLoadedObservable.notifyObservers(this);
  6585. this._markAsDirty();
  6586. };
  6587. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6588. if (!this._workingCanvas) {
  6589. this._workingCanvas = document.createElement('canvas');
  6590. }
  6591. var canvas = this._workingCanvas;
  6592. var context = canvas.getContext('2d');
  6593. var width = this._domImage.width;
  6594. var height = this._domImage.height;
  6595. canvas.width = width;
  6596. canvas.height = height;
  6597. context.drawImage(this._domImage, 0, 0, width, height);
  6598. var imageData = context.getImageData(0, 0, width, height);
  6599. // Left and right
  6600. this._sliceLeft = -1;
  6601. this._sliceRight = -1;
  6602. for (var x = 0; x < width; x++) {
  6603. var alpha = imageData.data[x * 4 + 3];
  6604. if (alpha > 127 && this._sliceLeft === -1) {
  6605. this._sliceLeft = x;
  6606. continue;
  6607. }
  6608. if (alpha < 127 && this._sliceLeft > -1) {
  6609. this._sliceRight = x;
  6610. break;
  6611. }
  6612. }
  6613. // top and bottom
  6614. this._sliceTop = -1;
  6615. this._sliceBottom = -1;
  6616. for (var y = 0; y < height; y++) {
  6617. var alpha = imageData.data[y * width * 4 + 3];
  6618. if (alpha > 127 && this._sliceTop === -1) {
  6619. this._sliceTop = y;
  6620. continue;
  6621. }
  6622. if (alpha < 127 && this._sliceTop > -1) {
  6623. this._sliceBottom = y;
  6624. break;
  6625. }
  6626. }
  6627. };
  6628. Object.defineProperty(Image.prototype, "source", {
  6629. /**
  6630. * Gets or sets image source url
  6631. */
  6632. set: function (value) {
  6633. var _this = this;
  6634. if (this._source === value) {
  6635. return;
  6636. }
  6637. this._loaded = false;
  6638. this._source = value;
  6639. if (value) {
  6640. value = this._svgCheck(value);
  6641. }
  6642. this._domImage = document.createElement("img");
  6643. this._domImage.onload = function () {
  6644. _this._onImageLoaded();
  6645. };
  6646. if (value) {
  6647. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6648. this._domImage.src = value;
  6649. }
  6650. },
  6651. enumerable: true,
  6652. configurable: true
  6653. });
  6654. /**
  6655. * Checks for svg document with icon id present
  6656. */
  6657. Image.prototype._svgCheck = function (value) {
  6658. var _this = this;
  6659. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6660. this._isSVG = true;
  6661. var svgsrc = value.split('#')[0];
  6662. var elemid = value.split('#')[1];
  6663. // check if object alr exist in document
  6664. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6665. if (svgExist) {
  6666. var svgDoc = svgExist.contentDocument;
  6667. // get viewbox width and height, get svg document width and height in px
  6668. if (svgDoc && svgDoc.documentElement) {
  6669. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6670. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6671. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6672. if (vb && docwidth && docheight) {
  6673. this._getSVGAttribs(svgExist, elemid);
  6674. return value;
  6675. }
  6676. }
  6677. // wait for object to load
  6678. svgExist.addEventListener("load", function () {
  6679. _this._getSVGAttribs(svgExist, elemid);
  6680. });
  6681. }
  6682. else {
  6683. // create document object
  6684. var svgImage = document.createElement("object");
  6685. svgImage.data = svgsrc;
  6686. svgImage.type = "image/svg+xml";
  6687. svgImage.width = "0%";
  6688. svgImage.height = "0%";
  6689. document.body.appendChild(svgImage);
  6690. // when the object has loaded, get the element attribs
  6691. svgImage.onload = function () {
  6692. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6693. if (svgobj) {
  6694. _this._getSVGAttribs(svgobj, elemid);
  6695. }
  6696. };
  6697. }
  6698. return svgsrc;
  6699. }
  6700. else {
  6701. return value;
  6702. }
  6703. };
  6704. /**
  6705. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6706. * given external svg file and icon id
  6707. */
  6708. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6709. var svgDoc = svgsrc.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. // get element bbox and matrix transform
  6716. var elem = svgDoc.getElementById(elemid);
  6717. if (vb && docwidth && docheight) {
  6718. var vb_width = Number(vb.split(" ")[2]);
  6719. var vb_height = Number(vb.split(" ")[3]);
  6720. var elem_bbox = elem.getBBox();
  6721. var elem_matrix_a = 1;
  6722. var elem_matrix_d = 1;
  6723. var elem_matrix_e = 0;
  6724. var elem_matrix_f = 0;
  6725. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6726. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6727. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6728. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6729. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6730. }
  6731. // compute source coordinates and dimensions
  6732. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6733. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6734. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6735. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6736. this._svgAttributesComputationCompleted = true;
  6737. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6738. }
  6739. }
  6740. };
  6741. Object.defineProperty(Image.prototype, "cellWidth", {
  6742. /**
  6743. * Gets or sets the cell width to use when animation sheet is enabled
  6744. * @see http://doc.babylonjs.com/how_to/gui#image
  6745. */
  6746. get: function () {
  6747. return this._cellWidth;
  6748. },
  6749. set: function (value) {
  6750. if (this._cellWidth === value) {
  6751. return;
  6752. }
  6753. this._cellWidth = value;
  6754. this._markAsDirty();
  6755. },
  6756. enumerable: true,
  6757. configurable: true
  6758. });
  6759. Object.defineProperty(Image.prototype, "cellHeight", {
  6760. /**
  6761. * Gets or sets the cell height to use when animation sheet is enabled
  6762. * @see http://doc.babylonjs.com/how_to/gui#image
  6763. */
  6764. get: function () {
  6765. return this._cellHeight;
  6766. },
  6767. set: function (value) {
  6768. if (this._cellHeight === value) {
  6769. return;
  6770. }
  6771. this._cellHeight = value;
  6772. this._markAsDirty();
  6773. },
  6774. enumerable: true,
  6775. configurable: true
  6776. });
  6777. Object.defineProperty(Image.prototype, "cellId", {
  6778. /**
  6779. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6780. * @see http://doc.babylonjs.com/how_to/gui#image
  6781. */
  6782. get: function () {
  6783. return this._cellId;
  6784. },
  6785. set: function (value) {
  6786. if (this._cellId === value) {
  6787. return;
  6788. }
  6789. this._cellId = value;
  6790. this._markAsDirty();
  6791. },
  6792. enumerable: true,
  6793. configurable: true
  6794. });
  6795. /**
  6796. * Tests if a given coordinates belong to the current control
  6797. * @param x defines x coordinate to test
  6798. * @param y defines y coordinate to test
  6799. * @returns true if the coordinates are inside the control
  6800. */
  6801. Image.prototype.contains = function (x, y) {
  6802. if (!_super.prototype.contains.call(this, x, y)) {
  6803. return false;
  6804. }
  6805. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6806. return true;
  6807. }
  6808. var canvas = this._workingCanvas;
  6809. var context = canvas.getContext("2d");
  6810. var width = this._currentMeasure.width | 0;
  6811. var height = this._currentMeasure.height | 0;
  6812. var imageData = context.getImageData(0, 0, width, height).data;
  6813. x = (x - this._currentMeasure.left) | 0;
  6814. y = (y - this._currentMeasure.top) | 0;
  6815. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6816. return pickedPixel > 0;
  6817. };
  6818. Image.prototype._getTypeName = function () {
  6819. return "Image";
  6820. };
  6821. /** Force the control to synchronize with its content */
  6822. Image.prototype.synchronizeSizeWithContent = function () {
  6823. if (!this._loaded) {
  6824. return;
  6825. }
  6826. this.width = this._domImage.width + "px";
  6827. this.height = this._domImage.height + "px";
  6828. };
  6829. Image.prototype._processMeasures = function (parentMeasure, context) {
  6830. if (this._loaded) {
  6831. switch (this._stretch) {
  6832. case Image.STRETCH_NONE:
  6833. break;
  6834. case Image.STRETCH_FILL:
  6835. break;
  6836. case Image.STRETCH_UNIFORM:
  6837. break;
  6838. case Image.STRETCH_NINE_PATCH:
  6839. break;
  6840. case Image.STRETCH_EXTEND:
  6841. if (this._autoScale) {
  6842. this.synchronizeSizeWithContent();
  6843. }
  6844. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6845. this.parent.adaptWidthToChildren = true;
  6846. this.parent.adaptHeightToChildren = true;
  6847. }
  6848. break;
  6849. }
  6850. }
  6851. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6852. };
  6853. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6854. if (!this._detectPointerOnOpaqueOnly) {
  6855. return;
  6856. }
  6857. if (!this._workingCanvas) {
  6858. this._workingCanvas = document.createElement('canvas');
  6859. }
  6860. var canvas = this._workingCanvas;
  6861. var width = this._currentMeasure.width;
  6862. var height = this._currentMeasure.height;
  6863. var context = canvas.getContext("2d");
  6864. canvas.width = width;
  6865. canvas.height = height;
  6866. context.clearRect(0, 0, width, height);
  6867. };
  6868. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6869. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6870. if (!this._detectPointerOnOpaqueOnly) {
  6871. return;
  6872. }
  6873. var canvas = this._workingCanvas;
  6874. context = canvas.getContext("2d");
  6875. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6876. };
  6877. Image.prototype._draw = function (context) {
  6878. context.save();
  6879. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6880. context.shadowColor = this.shadowColor;
  6881. context.shadowBlur = this.shadowBlur;
  6882. context.shadowOffsetX = this.shadowOffsetX;
  6883. context.shadowOffsetY = this.shadowOffsetY;
  6884. }
  6885. var x, y, width, height;
  6886. if (this.cellId == -1) {
  6887. x = this._sourceLeft;
  6888. y = this._sourceTop;
  6889. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6890. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6891. }
  6892. else {
  6893. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6894. var column = (this.cellId / rowCount) >> 0;
  6895. var row = this.cellId % rowCount;
  6896. x = this.cellWidth * row;
  6897. y = this.cellHeight * column;
  6898. width = this.cellWidth;
  6899. height = this.cellHeight;
  6900. }
  6901. this._prepareWorkingCanvasForOpaqueDetection();
  6902. this._applyStates(context);
  6903. if (this._loaded) {
  6904. switch (this._stretch) {
  6905. case Image.STRETCH_NONE:
  6906. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6907. break;
  6908. case Image.STRETCH_FILL:
  6909. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6910. break;
  6911. case Image.STRETCH_UNIFORM:
  6912. var hRatio = this._currentMeasure.width / width;
  6913. var vRatio = this._currentMeasure.height / height;
  6914. var ratio = Math.min(hRatio, vRatio);
  6915. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6916. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6917. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6918. break;
  6919. case Image.STRETCH_EXTEND:
  6920. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6921. break;
  6922. case Image.STRETCH_NINE_PATCH:
  6923. this._renderNinePatch(context);
  6924. break;
  6925. }
  6926. }
  6927. context.restore();
  6928. };
  6929. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6930. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6931. };
  6932. Image.prototype._renderNinePatch = function (context) {
  6933. var height = this._imageHeight;
  6934. var leftWidth = this._sliceLeft;
  6935. var topHeight = this._sliceTop;
  6936. var bottomHeight = this._imageHeight - this._sliceBottom;
  6937. var rightWidth = this._imageWidth - this._sliceRight;
  6938. var left = 0;
  6939. var top = 0;
  6940. if (this._populateNinePatchSlicesFromImage) {
  6941. left = 1;
  6942. top = 1;
  6943. height -= 2;
  6944. leftWidth -= 1;
  6945. topHeight -= 1;
  6946. bottomHeight -= 1;
  6947. rightWidth -= 1;
  6948. }
  6949. var centerWidth = this._sliceRight - this._sliceLeft;
  6950. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft;
  6951. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6952. // Corners
  6953. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6954. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6955. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6956. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6957. // Center
  6958. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight);
  6959. // Borders
  6960. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6961. 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);
  6962. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6963. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6964. };
  6965. Image.prototype.dispose = function () {
  6966. _super.prototype.dispose.call(this);
  6967. this.onImageLoadedObservable.clear();
  6968. this.onSVGAttributesComputedObservable.clear();
  6969. };
  6970. // Static
  6971. /** STRETCH_NONE */
  6972. Image.STRETCH_NONE = 0;
  6973. /** STRETCH_FILL */
  6974. Image.STRETCH_FILL = 1;
  6975. /** STRETCH_UNIFORM */
  6976. Image.STRETCH_UNIFORM = 2;
  6977. /** STRETCH_EXTEND */
  6978. Image.STRETCH_EXTEND = 3;
  6979. /** NINE_PATCH */
  6980. Image.STRETCH_NINE_PATCH = 4;
  6981. return Image;
  6982. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6983. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  6984. /***/ }),
  6985. /***/ "./2D/controls/index.ts":
  6986. /*!******************************!*\
  6987. !*** ./2D/controls/index.ts ***!
  6988. \******************************/
  6989. /*! 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 */
  6990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6991. "use strict";
  6992. __webpack_require__.r(__webpack_exports__);
  6993. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6995. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6997. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6999. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  7000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  7001. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  7003. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  7004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  7005. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  7006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  7007. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  7008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  7009. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  7011. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  7012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  7013. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  7014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  7015. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  7016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  7017. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  7018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  7019. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  7020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  7021. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  7022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  7023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  7024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  7025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  7026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  7027. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  7028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  7029. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  7030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  7031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  7032. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  7033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  7034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  7035. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  7036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  7037. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  7038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  7039. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  7040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  7041. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  7042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  7043. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  7044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  7045. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  7046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  7047. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  7048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__["ImageScrollBar"]; });
  7049. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  7050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_25__["name"]; });
  7051. /***/ }),
  7052. /***/ "./2D/controls/inputPassword.ts":
  7053. /*!**************************************!*\
  7054. !*** ./2D/controls/inputPassword.ts ***!
  7055. \**************************************/
  7056. /*! exports provided: InputPassword */
  7057. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7058. "use strict";
  7059. __webpack_require__.r(__webpack_exports__);
  7060. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  7061. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7062. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7063. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  7064. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  7065. /**
  7066. * Class used to create a password control
  7067. */
  7068. var InputPassword = /** @class */ (function (_super) {
  7069. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  7070. function InputPassword() {
  7071. return _super !== null && _super.apply(this, arguments) || this;
  7072. }
  7073. InputPassword.prototype._beforeRenderText = function (text) {
  7074. var txt = "";
  7075. for (var i = 0; i < text.length; i++) {
  7076. txt += "\u2022";
  7077. }
  7078. return txt;
  7079. };
  7080. return InputPassword;
  7081. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  7082. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  7083. /***/ }),
  7084. /***/ "./2D/controls/inputText.ts":
  7085. /*!**********************************!*\
  7086. !*** ./2D/controls/inputText.ts ***!
  7087. \**********************************/
  7088. /*! exports provided: InputText */
  7089. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7090. "use strict";
  7091. __webpack_require__.r(__webpack_exports__);
  7092. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  7093. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7094. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  7095. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  7096. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7097. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7098. /**
  7099. * Class used to create input text control
  7100. */
  7101. var InputText = /** @class */ (function (_super) {
  7102. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7103. /**
  7104. * Creates a new InputText
  7105. * @param name defines the control name
  7106. * @param text defines the text of the control
  7107. */
  7108. function InputText(name, text) {
  7109. if (text === void 0) { text = ""; }
  7110. var _this = _super.call(this, name) || this;
  7111. _this.name = name;
  7112. _this._text = "";
  7113. _this._placeholderText = "";
  7114. _this._background = "#222222";
  7115. _this._focusedBackground = "#000000";
  7116. _this._focusedColor = "white";
  7117. _this._placeholderColor = "gray";
  7118. _this._thickness = 1;
  7119. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7120. _this._autoStretchWidth = true;
  7121. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7122. _this._isFocused = false;
  7123. _this._blinkIsEven = false;
  7124. _this._cursorOffset = 0;
  7125. _this._deadKey = false;
  7126. _this._addKey = true;
  7127. _this._currentKey = "";
  7128. _this._isTextHighlightOn = false;
  7129. _this._textHighlightColor = "#d5e0ff";
  7130. _this._highligherOpacity = 0.4;
  7131. _this._highlightedText = "";
  7132. _this._startHighlightIndex = 0;
  7133. _this._endHighlightIndex = 0;
  7134. _this._cursorIndex = -1;
  7135. _this._onFocusSelectAll = false;
  7136. _this._isPointerDown = false;
  7137. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7138. _this.promptMessage = "Please enter text:";
  7139. /** Force disable prompt on mobile device */
  7140. _this.disableMobilePrompt = false;
  7141. /** Observable raised when the text changes */
  7142. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7143. /** Observable raised just before an entered character is to be added */
  7144. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7145. /** Observable raised when the control gets the focus */
  7146. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7147. /** Observable raised when the control loses the focus */
  7148. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7149. /**Observable raised when the text is highlighted */
  7150. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7151. /**Observable raised when copy event is triggered */
  7152. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7153. /** Observable raised when cut event is triggered */
  7154. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7155. /** Observable raised when paste event is triggered */
  7156. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7157. /** Observable raised when a key event was processed */
  7158. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7159. _this.text = text;
  7160. _this.isPointerBlocker = true;
  7161. return _this;
  7162. }
  7163. Object.defineProperty(InputText.prototype, "maxWidth", {
  7164. /** Gets or sets the maximum width allowed by the control */
  7165. get: function () {
  7166. return this._maxWidth.toString(this._host);
  7167. },
  7168. set: function (value) {
  7169. if (this._maxWidth.toString(this._host) === value) {
  7170. return;
  7171. }
  7172. if (this._maxWidth.fromString(value)) {
  7173. this._markAsDirty();
  7174. }
  7175. },
  7176. enumerable: true,
  7177. configurable: true
  7178. });
  7179. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7180. /** Gets the maximum width allowed by the control in pixels */
  7181. get: function () {
  7182. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7183. },
  7184. enumerable: true,
  7185. configurable: true
  7186. });
  7187. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7188. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7189. get: function () {
  7190. return this._highligherOpacity;
  7191. },
  7192. set: function (value) {
  7193. if (this._highligherOpacity === value) {
  7194. return;
  7195. }
  7196. this._highligherOpacity = value;
  7197. this._markAsDirty();
  7198. },
  7199. enumerable: true,
  7200. configurable: true
  7201. });
  7202. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7203. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7204. get: function () {
  7205. return this._onFocusSelectAll;
  7206. },
  7207. set: function (value) {
  7208. if (this._onFocusSelectAll === value) {
  7209. return;
  7210. }
  7211. this._onFocusSelectAll = value;
  7212. this._markAsDirty();
  7213. },
  7214. enumerable: true,
  7215. configurable: true
  7216. });
  7217. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7218. /** Gets or sets the text hightlight color */
  7219. get: function () {
  7220. return this._textHighlightColor;
  7221. },
  7222. set: function (value) {
  7223. if (this._textHighlightColor === value) {
  7224. return;
  7225. }
  7226. this._textHighlightColor = value;
  7227. this._markAsDirty();
  7228. },
  7229. enumerable: true,
  7230. configurable: true
  7231. });
  7232. Object.defineProperty(InputText.prototype, "margin", {
  7233. /** Gets or sets control margin */
  7234. get: function () {
  7235. return this._margin.toString(this._host);
  7236. },
  7237. set: function (value) {
  7238. if (this._margin.toString(this._host) === value) {
  7239. return;
  7240. }
  7241. if (this._margin.fromString(value)) {
  7242. this._markAsDirty();
  7243. }
  7244. },
  7245. enumerable: true,
  7246. configurable: true
  7247. });
  7248. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7249. /** Gets control margin in pixels */
  7250. get: function () {
  7251. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7252. },
  7253. enumerable: true,
  7254. configurable: true
  7255. });
  7256. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7257. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7258. get: function () {
  7259. return this._autoStretchWidth;
  7260. },
  7261. set: function (value) {
  7262. if (this._autoStretchWidth === value) {
  7263. return;
  7264. }
  7265. this._autoStretchWidth = value;
  7266. this._markAsDirty();
  7267. },
  7268. enumerable: true,
  7269. configurable: true
  7270. });
  7271. Object.defineProperty(InputText.prototype, "thickness", {
  7272. /** Gets or sets border thickness */
  7273. get: function () {
  7274. return this._thickness;
  7275. },
  7276. set: function (value) {
  7277. if (this._thickness === value) {
  7278. return;
  7279. }
  7280. this._thickness = value;
  7281. this._markAsDirty();
  7282. },
  7283. enumerable: true,
  7284. configurable: true
  7285. });
  7286. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7287. /** Gets or sets the background color when focused */
  7288. get: function () {
  7289. return this._focusedBackground;
  7290. },
  7291. set: function (value) {
  7292. if (this._focusedBackground === value) {
  7293. return;
  7294. }
  7295. this._focusedBackground = value;
  7296. this._markAsDirty();
  7297. },
  7298. enumerable: true,
  7299. configurable: true
  7300. });
  7301. Object.defineProperty(InputText.prototype, "focusedColor", {
  7302. /** Gets or sets the background color when focused */
  7303. get: function () {
  7304. return this._focusedColor;
  7305. },
  7306. set: function (value) {
  7307. if (this._focusedColor === value) {
  7308. return;
  7309. }
  7310. this._focusedColor = value;
  7311. this._markAsDirty();
  7312. },
  7313. enumerable: true,
  7314. configurable: true
  7315. });
  7316. Object.defineProperty(InputText.prototype, "background", {
  7317. /** Gets or sets the background color */
  7318. get: function () {
  7319. return this._background;
  7320. },
  7321. set: function (value) {
  7322. if (this._background === value) {
  7323. return;
  7324. }
  7325. this._background = value;
  7326. this._markAsDirty();
  7327. },
  7328. enumerable: true,
  7329. configurable: true
  7330. });
  7331. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7332. /** Gets or sets the placeholder color */
  7333. get: function () {
  7334. return this._placeholderColor;
  7335. },
  7336. set: function (value) {
  7337. if (this._placeholderColor === value) {
  7338. return;
  7339. }
  7340. this._placeholderColor = value;
  7341. this._markAsDirty();
  7342. },
  7343. enumerable: true,
  7344. configurable: true
  7345. });
  7346. Object.defineProperty(InputText.prototype, "placeholderText", {
  7347. /** Gets or sets the text displayed when the control is empty */
  7348. get: function () {
  7349. return this._placeholderText;
  7350. },
  7351. set: function (value) {
  7352. if (this._placeholderText === value) {
  7353. return;
  7354. }
  7355. this._placeholderText = value;
  7356. this._markAsDirty();
  7357. },
  7358. enumerable: true,
  7359. configurable: true
  7360. });
  7361. Object.defineProperty(InputText.prototype, "deadKey", {
  7362. /** Gets or sets the dead key flag */
  7363. get: function () {
  7364. return this._deadKey;
  7365. },
  7366. set: function (flag) {
  7367. this._deadKey = flag;
  7368. },
  7369. enumerable: true,
  7370. configurable: true
  7371. });
  7372. Object.defineProperty(InputText.prototype, "highlightedText", {
  7373. /** Gets or sets the highlight text */
  7374. get: function () {
  7375. return this._highlightedText;
  7376. },
  7377. set: function (text) {
  7378. if (this._highlightedText === text) {
  7379. return;
  7380. }
  7381. this._highlightedText = text;
  7382. this._markAsDirty();
  7383. },
  7384. enumerable: true,
  7385. configurable: true
  7386. });
  7387. Object.defineProperty(InputText.prototype, "addKey", {
  7388. /** Gets or sets if the current key should be added */
  7389. get: function () {
  7390. return this._addKey;
  7391. },
  7392. set: function (flag) {
  7393. this._addKey = flag;
  7394. },
  7395. enumerable: true,
  7396. configurable: true
  7397. });
  7398. Object.defineProperty(InputText.prototype, "currentKey", {
  7399. /** Gets or sets the value of the current key being entered */
  7400. get: function () {
  7401. return this._currentKey;
  7402. },
  7403. set: function (key) {
  7404. this._currentKey = key;
  7405. },
  7406. enumerable: true,
  7407. configurable: true
  7408. });
  7409. Object.defineProperty(InputText.prototype, "text", {
  7410. /** Gets or sets the text displayed in the control */
  7411. get: function () {
  7412. return this._text;
  7413. },
  7414. set: function (value) {
  7415. var valueAsString = value.toString(); // Forcing convertion
  7416. if (this._text === valueAsString) {
  7417. return;
  7418. }
  7419. this._text = valueAsString;
  7420. this._markAsDirty();
  7421. this.onTextChangedObservable.notifyObservers(this);
  7422. },
  7423. enumerable: true,
  7424. configurable: true
  7425. });
  7426. Object.defineProperty(InputText.prototype, "width", {
  7427. /** Gets or sets control width */
  7428. get: function () {
  7429. return this._width.toString(this._host);
  7430. },
  7431. set: function (value) {
  7432. if (this._width.toString(this._host) === value) {
  7433. return;
  7434. }
  7435. if (this._width.fromString(value)) {
  7436. this._markAsDirty();
  7437. }
  7438. this.autoStretchWidth = false;
  7439. },
  7440. enumerable: true,
  7441. configurable: true
  7442. });
  7443. /** @hidden */
  7444. InputText.prototype.onBlur = function () {
  7445. this._isFocused = false;
  7446. this._scrollLeft = null;
  7447. this._cursorOffset = 0;
  7448. clearTimeout(this._blinkTimeout);
  7449. this._markAsDirty();
  7450. this.onBlurObservable.notifyObservers(this);
  7451. this._host.unRegisterClipboardEvents();
  7452. if (this._onClipboardObserver) {
  7453. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7454. }
  7455. var scene = this._host.getScene();
  7456. if (this._onPointerDblTapObserver && scene) {
  7457. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7458. }
  7459. };
  7460. /** @hidden */
  7461. InputText.prototype.onFocus = function () {
  7462. var _this = this;
  7463. if (!this._isEnabled) {
  7464. return;
  7465. }
  7466. this._scrollLeft = null;
  7467. this._isFocused = true;
  7468. this._blinkIsEven = false;
  7469. this._cursorOffset = 0;
  7470. this._markAsDirty();
  7471. this.onFocusObservable.notifyObservers(this);
  7472. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7473. var value = prompt(this.promptMessage);
  7474. if (value !== null) {
  7475. this.text = value;
  7476. }
  7477. this._host.focusedControl = null;
  7478. return;
  7479. }
  7480. this._host.registerClipboardEvents();
  7481. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7482. // process clipboard event, can be configured.
  7483. switch (clipboardInfo.type) {
  7484. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7485. _this._onCopyText(clipboardInfo.event);
  7486. _this.onTextCopyObservable.notifyObservers(_this);
  7487. break;
  7488. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7489. _this._onCutText(clipboardInfo.event);
  7490. _this.onTextCutObservable.notifyObservers(_this);
  7491. break;
  7492. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7493. _this._onPasteText(clipboardInfo.event);
  7494. _this.onTextPasteObservable.notifyObservers(_this);
  7495. break;
  7496. default: return;
  7497. }
  7498. });
  7499. var scene = this._host.getScene();
  7500. if (scene) {
  7501. //register the pointer double tap event
  7502. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7503. if (!_this._isFocused) {
  7504. return;
  7505. }
  7506. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7507. _this._processDblClick(pointerInfo);
  7508. }
  7509. });
  7510. }
  7511. if (this._onFocusSelectAll) {
  7512. this._selectAllText();
  7513. }
  7514. };
  7515. InputText.prototype._getTypeName = function () {
  7516. return "InputText";
  7517. };
  7518. /**
  7519. * Function called to get the list of controls that should not steal the focus from this control
  7520. * @returns an array of controls
  7521. */
  7522. InputText.prototype.keepsFocusWith = function () {
  7523. if (!this._connectedVirtualKeyboard) {
  7524. return null;
  7525. }
  7526. return [this._connectedVirtualKeyboard];
  7527. };
  7528. /** @hidden */
  7529. InputText.prototype.processKey = function (keyCode, key, evt) {
  7530. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7531. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7532. return;
  7533. }
  7534. //select all
  7535. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7536. this._selectAllText();
  7537. evt.preventDefault();
  7538. return;
  7539. }
  7540. // Specific cases
  7541. switch (keyCode) {
  7542. case 32: //SPACE
  7543. key = " "; //ie11 key for space is "Spacebar"
  7544. break;
  7545. case 191: //SLASH
  7546. if (evt) {
  7547. evt.preventDefault();
  7548. }
  7549. break;
  7550. case 8: // BACKSPACE
  7551. if (this._text && this._text.length > 0) {
  7552. //delete the highlighted text
  7553. if (this._isTextHighlightOn) {
  7554. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7555. this._isTextHighlightOn = false;
  7556. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7557. this._blinkIsEven = false;
  7558. if (evt) {
  7559. evt.preventDefault();
  7560. }
  7561. return;
  7562. }
  7563. //delete single character
  7564. if (this._cursorOffset === 0) {
  7565. this.text = this._text.substr(0, this._text.length - 1);
  7566. }
  7567. else {
  7568. var deletePosition = this._text.length - this._cursorOffset;
  7569. if (deletePosition > 0) {
  7570. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7571. }
  7572. }
  7573. }
  7574. if (evt) {
  7575. evt.preventDefault();
  7576. }
  7577. return;
  7578. case 46: // DELETE
  7579. if (this._isTextHighlightOn) {
  7580. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7581. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7582. while (decrementor > 0 && this._cursorOffset > 0) {
  7583. this._cursorOffset--;
  7584. }
  7585. this._isTextHighlightOn = false;
  7586. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7587. if (evt) {
  7588. evt.preventDefault();
  7589. }
  7590. return;
  7591. }
  7592. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7593. var deletePosition = this._text.length - this._cursorOffset;
  7594. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7595. this._cursorOffset--;
  7596. }
  7597. if (evt) {
  7598. evt.preventDefault();
  7599. }
  7600. return;
  7601. case 13: // RETURN
  7602. this._host.focusedControl = null;
  7603. this._isTextHighlightOn = false;
  7604. return;
  7605. case 35: // END
  7606. this._cursorOffset = 0;
  7607. this._blinkIsEven = false;
  7608. this._isTextHighlightOn = false;
  7609. this._markAsDirty();
  7610. return;
  7611. case 36: // HOME
  7612. this._cursorOffset = this._text.length;
  7613. this._blinkIsEven = false;
  7614. this._isTextHighlightOn = false;
  7615. this._markAsDirty();
  7616. return;
  7617. case 37: // LEFT
  7618. this._cursorOffset++;
  7619. if (this._cursorOffset > this._text.length) {
  7620. this._cursorOffset = this._text.length;
  7621. }
  7622. if (evt && evt.shiftKey) {
  7623. // update the cursor
  7624. this._blinkIsEven = false;
  7625. // shift + ctrl/cmd + <-
  7626. if (evt.ctrlKey || evt.metaKey) {
  7627. if (!this._isTextHighlightOn) {
  7628. if (this._text.length === this._cursorOffset) {
  7629. return;
  7630. }
  7631. else {
  7632. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7633. }
  7634. }
  7635. this._startHighlightIndex = 0;
  7636. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7637. this._cursorOffset = this._text.length;
  7638. this._isTextHighlightOn = true;
  7639. this._markAsDirty();
  7640. return;
  7641. }
  7642. //store the starting point
  7643. if (!this._isTextHighlightOn) {
  7644. this._isTextHighlightOn = true;
  7645. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7646. }
  7647. //if text is already highlighted
  7648. else if (this._cursorIndex === -1) {
  7649. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7650. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7651. }
  7652. //set the highlight indexes
  7653. if (this._cursorIndex < this._cursorOffset) {
  7654. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7655. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7656. }
  7657. else if (this._cursorIndex > this._cursorOffset) {
  7658. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7659. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7660. }
  7661. else {
  7662. this._isTextHighlightOn = false;
  7663. }
  7664. this._markAsDirty();
  7665. return;
  7666. }
  7667. if (this._isTextHighlightOn) {
  7668. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7669. this._isTextHighlightOn = false;
  7670. }
  7671. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7672. this._cursorOffset = this.text.length;
  7673. evt.preventDefault();
  7674. }
  7675. this._blinkIsEven = false;
  7676. this._isTextHighlightOn = false;
  7677. this._cursorIndex = -1;
  7678. this._markAsDirty();
  7679. return;
  7680. case 39: // RIGHT
  7681. this._cursorOffset--;
  7682. if (this._cursorOffset < 0) {
  7683. this._cursorOffset = 0;
  7684. }
  7685. if (evt && evt.shiftKey) {
  7686. //update the cursor
  7687. this._blinkIsEven = false;
  7688. //shift + ctrl/cmd + ->
  7689. if (evt.ctrlKey || evt.metaKey) {
  7690. if (!this._isTextHighlightOn) {
  7691. if (this._cursorOffset === 0) {
  7692. return;
  7693. }
  7694. else {
  7695. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7696. }
  7697. }
  7698. this._endHighlightIndex = this._text.length;
  7699. this._isTextHighlightOn = true;
  7700. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7701. this._cursorOffset = 0;
  7702. this._markAsDirty();
  7703. return;
  7704. }
  7705. if (!this._isTextHighlightOn) {
  7706. this._isTextHighlightOn = true;
  7707. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7708. }
  7709. //if text is already highlighted
  7710. else if (this._cursorIndex === -1) {
  7711. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7712. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7713. }
  7714. //set the highlight indexes
  7715. if (this._cursorIndex < this._cursorOffset) {
  7716. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7717. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7718. }
  7719. else if (this._cursorIndex > this._cursorOffset) {
  7720. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7721. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7722. }
  7723. else {
  7724. this._isTextHighlightOn = false;
  7725. }
  7726. this._markAsDirty();
  7727. return;
  7728. }
  7729. if (this._isTextHighlightOn) {
  7730. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7731. this._isTextHighlightOn = false;
  7732. }
  7733. //ctr + ->
  7734. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7735. this._cursorOffset = 0;
  7736. evt.preventDefault();
  7737. }
  7738. this._blinkIsEven = false;
  7739. this._isTextHighlightOn = false;
  7740. this._cursorIndex = -1;
  7741. this._markAsDirty();
  7742. return;
  7743. case 222: // Dead
  7744. if (evt) {
  7745. evt.preventDefault();
  7746. }
  7747. this._cursorIndex = -1;
  7748. this.deadKey = true;
  7749. break;
  7750. }
  7751. // Printable characters
  7752. if (key &&
  7753. ((keyCode === -1) || // Direct access
  7754. (keyCode === 32) || // Space
  7755. (keyCode > 47 && keyCode < 64) || // Numbers
  7756. (keyCode > 64 && keyCode < 91) || // Letters
  7757. (keyCode > 159 && keyCode < 193) || // Special characters
  7758. (keyCode > 218 && keyCode < 223) || // Special characters
  7759. (keyCode > 95 && keyCode < 112))) { // Numpad
  7760. this._currentKey = key;
  7761. this.onBeforeKeyAddObservable.notifyObservers(this);
  7762. key = this._currentKey;
  7763. if (this._addKey) {
  7764. if (this._isTextHighlightOn) {
  7765. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7766. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7767. this._isTextHighlightOn = false;
  7768. this._blinkIsEven = false;
  7769. this._markAsDirty();
  7770. }
  7771. else if (this._cursorOffset === 0) {
  7772. this.text += key;
  7773. }
  7774. else {
  7775. var insertPosition = this._text.length - this._cursorOffset;
  7776. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7777. }
  7778. }
  7779. }
  7780. };
  7781. /** @hidden */
  7782. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7783. //update the cursor
  7784. this._blinkIsEven = false;
  7785. if (this._cursorIndex === -1) {
  7786. this._cursorIndex = offset;
  7787. }
  7788. else {
  7789. if (this._cursorIndex < this._cursorOffset) {
  7790. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7791. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7792. }
  7793. else if (this._cursorIndex > this._cursorOffset) {
  7794. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7795. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7796. }
  7797. else {
  7798. this._isTextHighlightOn = false;
  7799. this._markAsDirty();
  7800. return;
  7801. }
  7802. }
  7803. this._isTextHighlightOn = true;
  7804. this._markAsDirty();
  7805. };
  7806. /** @hidden */
  7807. InputText.prototype._processDblClick = function (evt) {
  7808. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7809. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7810. this._endHighlightIndex = this._startHighlightIndex;
  7811. var rWord = /\w+/g, moveLeft, moveRight;
  7812. do {
  7813. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7814. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7815. } while (moveLeft || moveRight);
  7816. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7817. this.onTextHighlightObservable.notifyObservers(this);
  7818. this._isTextHighlightOn = true;
  7819. this._clickedCoordinate = null;
  7820. this._blinkIsEven = true;
  7821. this._cursorIndex = -1;
  7822. this._markAsDirty();
  7823. };
  7824. /** @hidden */
  7825. InputText.prototype._selectAllText = function () {
  7826. this._blinkIsEven = true;
  7827. this._isTextHighlightOn = true;
  7828. this._startHighlightIndex = 0;
  7829. this._endHighlightIndex = this._text.length;
  7830. this._cursorOffset = this._text.length;
  7831. this._cursorIndex = -1;
  7832. this._markAsDirty();
  7833. };
  7834. /**
  7835. * Handles the keyboard event
  7836. * @param evt Defines the KeyboardEvent
  7837. */
  7838. InputText.prototype.processKeyboard = function (evt) {
  7839. // process pressed key
  7840. this.processKey(evt.keyCode, evt.key, evt);
  7841. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7842. };
  7843. /** @hidden */
  7844. InputText.prototype._onCopyText = function (ev) {
  7845. this._isTextHighlightOn = false;
  7846. //when write permission to clipbaord data is denied
  7847. try {
  7848. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7849. }
  7850. catch (_a) { } //pass
  7851. this._host.clipboardData = this._highlightedText;
  7852. };
  7853. /** @hidden */
  7854. InputText.prototype._onCutText = function (ev) {
  7855. if (!this._highlightedText) {
  7856. return;
  7857. }
  7858. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7859. this._isTextHighlightOn = false;
  7860. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7861. //when write permission to clipbaord data is denied
  7862. try {
  7863. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7864. }
  7865. catch (_a) { } //pass
  7866. this._host.clipboardData = this._highlightedText;
  7867. this._highlightedText = "";
  7868. };
  7869. /** @hidden */
  7870. InputText.prototype._onPasteText = function (ev) {
  7871. var data = "";
  7872. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7873. data = ev.clipboardData.getData("text/plain");
  7874. }
  7875. else {
  7876. //get the cached data; returns blank string by default
  7877. data = this._host.clipboardData;
  7878. }
  7879. var insertPosition = this._text.length - this._cursorOffset;
  7880. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7881. };
  7882. InputText.prototype._draw = function (context, invalidatedRectangle) {
  7883. var _this = this;
  7884. context.save();
  7885. this._applyStates(context);
  7886. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7887. context.shadowColor = this.shadowColor;
  7888. context.shadowBlur = this.shadowBlur;
  7889. context.shadowOffsetX = this.shadowOffsetX;
  7890. context.shadowOffsetY = this.shadowOffsetY;
  7891. }
  7892. // Background
  7893. if (this._isFocused) {
  7894. if (this._focusedBackground) {
  7895. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7896. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7897. }
  7898. }
  7899. else if (this._background) {
  7900. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7901. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7902. }
  7903. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7904. context.shadowBlur = 0;
  7905. context.shadowOffsetX = 0;
  7906. context.shadowOffsetY = 0;
  7907. }
  7908. if (!this._fontOffset) {
  7909. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7910. }
  7911. // Text
  7912. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7913. if (this.color) {
  7914. context.fillStyle = this.color;
  7915. }
  7916. var text = this._beforeRenderText(this._text);
  7917. if (!this._isFocused && !this._text && this._placeholderText) {
  7918. text = this._placeholderText;
  7919. if (this._placeholderColor) {
  7920. context.fillStyle = this._placeholderColor;
  7921. }
  7922. }
  7923. this._textWidth = context.measureText(text).width;
  7924. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7925. if (this._autoStretchWidth) {
  7926. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7927. }
  7928. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7929. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7930. context.save();
  7931. context.beginPath();
  7932. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7933. context.clip();
  7934. if (this._isFocused && this._textWidth > availableWidth) {
  7935. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7936. if (!this._scrollLeft) {
  7937. this._scrollLeft = textLeft;
  7938. }
  7939. }
  7940. else {
  7941. this._scrollLeft = clipTextLeft;
  7942. }
  7943. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7944. // Cursor
  7945. if (this._isFocused) {
  7946. // Need to move cursor
  7947. if (this._clickedCoordinate) {
  7948. var rightPosition = this._scrollLeft + this._textWidth;
  7949. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7950. var currentSize = 0;
  7951. this._cursorOffset = 0;
  7952. var previousDist = 0;
  7953. do {
  7954. if (this._cursorOffset) {
  7955. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7956. }
  7957. this._cursorOffset++;
  7958. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7959. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7960. // Find closest move
  7961. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7962. this._cursorOffset--;
  7963. }
  7964. this._blinkIsEven = false;
  7965. this._clickedCoordinate = null;
  7966. }
  7967. // Render cursor
  7968. if (!this._blinkIsEven) {
  7969. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7970. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7971. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7972. if (cursorLeft < clipTextLeft) {
  7973. this._scrollLeft += (clipTextLeft - cursorLeft);
  7974. cursorLeft = clipTextLeft;
  7975. this._markAsDirty();
  7976. }
  7977. else if (cursorLeft > clipTextLeft + availableWidth) {
  7978. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7979. cursorLeft = clipTextLeft + availableWidth;
  7980. this._markAsDirty();
  7981. }
  7982. if (!this._isTextHighlightOn) {
  7983. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7984. }
  7985. }
  7986. clearTimeout(this._blinkTimeout);
  7987. this._blinkTimeout = setTimeout(function () {
  7988. _this._blinkIsEven = !_this._blinkIsEven;
  7989. _this._markAsDirty();
  7990. }, 500);
  7991. //show the highlighted text
  7992. if (this._isTextHighlightOn) {
  7993. clearTimeout(this._blinkTimeout);
  7994. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7995. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7996. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7997. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7998. if (highlightCursorLeft < clipTextLeft) {
  7999. width = width - (clipTextLeft - highlightCursorLeft);
  8000. if (!width) {
  8001. // when using left arrow on text.length > availableWidth;
  8002. // assigns the width of the first letter after clipTextLeft
  8003. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  8004. }
  8005. highlightCursorLeft = clipTextLeft;
  8006. }
  8007. //for transparancy
  8008. context.globalAlpha = this._highligherOpacity;
  8009. context.fillStyle = this._textHighlightColor;
  8010. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  8011. context.globalAlpha = 1.0;
  8012. }
  8013. }
  8014. context.restore();
  8015. // Border
  8016. if (this._thickness) {
  8017. if (this._isFocused) {
  8018. if (this.focusedColor) {
  8019. context.strokeStyle = this.focusedColor;
  8020. }
  8021. }
  8022. else {
  8023. if (this.color) {
  8024. context.strokeStyle = this.color;
  8025. }
  8026. }
  8027. context.lineWidth = this._thickness;
  8028. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8029. }
  8030. context.restore();
  8031. };
  8032. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8033. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8034. return false;
  8035. }
  8036. this._clickedCoordinate = coordinates.x;
  8037. this._isTextHighlightOn = false;
  8038. this._highlightedText = "";
  8039. this._cursorIndex = -1;
  8040. this._isPointerDown = true;
  8041. this._host._capturingControl[pointerId] = this;
  8042. if (this._host.focusedControl === this) {
  8043. // Move cursor
  8044. clearTimeout(this._blinkTimeout);
  8045. this._markAsDirty();
  8046. return true;
  8047. }
  8048. if (!this._isEnabled) {
  8049. return false;
  8050. }
  8051. this._host.focusedControl = this;
  8052. return true;
  8053. };
  8054. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  8055. if (this._host.focusedControl === this && this._isPointerDown) {
  8056. this._clickedCoordinate = coordinates.x;
  8057. this._markAsDirty();
  8058. this._updateValueFromCursorIndex(this._cursorOffset);
  8059. }
  8060. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  8061. };
  8062. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  8063. this._isPointerDown = false;
  8064. delete this._host._capturingControl[pointerId];
  8065. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  8066. };
  8067. InputText.prototype._beforeRenderText = function (text) {
  8068. return text;
  8069. };
  8070. InputText.prototype.dispose = function () {
  8071. _super.prototype.dispose.call(this);
  8072. this.onBlurObservable.clear();
  8073. this.onFocusObservable.clear();
  8074. this.onTextChangedObservable.clear();
  8075. this.onTextCopyObservable.clear();
  8076. this.onTextCutObservable.clear();
  8077. this.onTextPasteObservable.clear();
  8078. this.onTextHighlightObservable.clear();
  8079. this.onKeyboardEventProcessedObservable.clear();
  8080. };
  8081. return InputText;
  8082. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8083. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  8084. /***/ }),
  8085. /***/ "./2D/controls/line.ts":
  8086. /*!*****************************!*\
  8087. !*** ./2D/controls/line.ts ***!
  8088. \*****************************/
  8089. /*! exports provided: Line */
  8090. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8091. "use strict";
  8092. __webpack_require__.r(__webpack_exports__);
  8093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  8094. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8095. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  8096. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  8097. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8098. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  8099. /** Class used to render 2D lines */
  8100. var Line = /** @class */ (function (_super) {
  8101. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8102. /**
  8103. * Creates a new Line
  8104. * @param name defines the control name
  8105. */
  8106. function Line(name) {
  8107. var _this = _super.call(this, name) || this;
  8108. _this.name = name;
  8109. _this._lineWidth = 1;
  8110. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8111. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8112. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8113. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8114. _this._dash = new Array();
  8115. _this._automaticSize = true;
  8116. _this.isHitTestVisible = false;
  8117. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8118. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8119. return _this;
  8120. }
  8121. Object.defineProperty(Line.prototype, "dash", {
  8122. /** Gets or sets the dash pattern */
  8123. get: function () {
  8124. return this._dash;
  8125. },
  8126. set: function (value) {
  8127. if (this._dash === value) {
  8128. return;
  8129. }
  8130. this._dash = value;
  8131. this._markAsDirty();
  8132. },
  8133. enumerable: true,
  8134. configurable: true
  8135. });
  8136. Object.defineProperty(Line.prototype, "connectedControl", {
  8137. /** Gets or sets the control connected with the line end */
  8138. get: function () {
  8139. return this._connectedControl;
  8140. },
  8141. set: function (value) {
  8142. var _this = this;
  8143. if (this._connectedControl === value) {
  8144. return;
  8145. }
  8146. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8147. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8148. this._connectedControlDirtyObserver = null;
  8149. }
  8150. if (value) {
  8151. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8152. }
  8153. this._connectedControl = value;
  8154. this._markAsDirty();
  8155. },
  8156. enumerable: true,
  8157. configurable: true
  8158. });
  8159. Object.defineProperty(Line.prototype, "x1", {
  8160. /** Gets or sets start coordinates on X axis */
  8161. get: function () {
  8162. return this._x1.toString(this._host);
  8163. },
  8164. set: function (value) {
  8165. if (this._x1.toString(this._host) === value) {
  8166. return;
  8167. }
  8168. if (this._x1.fromString(value)) {
  8169. this._markAsDirty();
  8170. }
  8171. },
  8172. enumerable: true,
  8173. configurable: true
  8174. });
  8175. Object.defineProperty(Line.prototype, "y1", {
  8176. /** Gets or sets start coordinates on Y axis */
  8177. get: function () {
  8178. return this._y1.toString(this._host);
  8179. },
  8180. set: function (value) {
  8181. if (this._y1.toString(this._host) === value) {
  8182. return;
  8183. }
  8184. if (this._y1.fromString(value)) {
  8185. this._markAsDirty();
  8186. }
  8187. },
  8188. enumerable: true,
  8189. configurable: true
  8190. });
  8191. Object.defineProperty(Line.prototype, "x2", {
  8192. /** Gets or sets end coordinates on X axis */
  8193. get: function () {
  8194. return this._x2.toString(this._host);
  8195. },
  8196. set: function (value) {
  8197. if (this._x2.toString(this._host) === value) {
  8198. return;
  8199. }
  8200. if (this._x2.fromString(value)) {
  8201. this._markAsDirty();
  8202. }
  8203. },
  8204. enumerable: true,
  8205. configurable: true
  8206. });
  8207. Object.defineProperty(Line.prototype, "y2", {
  8208. /** Gets or sets end coordinates on Y axis */
  8209. get: function () {
  8210. return this._y2.toString(this._host);
  8211. },
  8212. set: function (value) {
  8213. if (this._y2.toString(this._host) === value) {
  8214. return;
  8215. }
  8216. if (this._y2.fromString(value)) {
  8217. this._markAsDirty();
  8218. }
  8219. },
  8220. enumerable: true,
  8221. configurable: true
  8222. });
  8223. Object.defineProperty(Line.prototype, "lineWidth", {
  8224. /** Gets or sets line width */
  8225. get: function () {
  8226. return this._lineWidth;
  8227. },
  8228. set: function (value) {
  8229. if (this._lineWidth === value) {
  8230. return;
  8231. }
  8232. this._lineWidth = value;
  8233. this._markAsDirty();
  8234. },
  8235. enumerable: true,
  8236. configurable: true
  8237. });
  8238. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8239. /** Gets or sets horizontal alignment */
  8240. set: function (value) {
  8241. return;
  8242. },
  8243. enumerable: true,
  8244. configurable: true
  8245. });
  8246. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8247. /** Gets or sets vertical alignment */
  8248. set: function (value) {
  8249. return;
  8250. },
  8251. enumerable: true,
  8252. configurable: true
  8253. });
  8254. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8255. get: function () {
  8256. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8257. },
  8258. enumerable: true,
  8259. configurable: true
  8260. });
  8261. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8262. get: function () {
  8263. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8264. },
  8265. enumerable: true,
  8266. configurable: true
  8267. });
  8268. Line.prototype._getTypeName = function () {
  8269. return "Line";
  8270. };
  8271. Line.prototype._draw = function (context) {
  8272. context.save();
  8273. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8274. context.shadowColor = this.shadowColor;
  8275. context.shadowBlur = this.shadowBlur;
  8276. context.shadowOffsetX = this.shadowOffsetX;
  8277. context.shadowOffsetY = this.shadowOffsetY;
  8278. }
  8279. this._applyStates(context);
  8280. context.strokeStyle = this.color;
  8281. context.lineWidth = this._lineWidth;
  8282. context.setLineDash(this._dash);
  8283. context.beginPath();
  8284. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8285. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8286. context.stroke();
  8287. context.restore();
  8288. };
  8289. Line.prototype._measure = function () {
  8290. // Width / Height
  8291. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8292. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8293. };
  8294. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8295. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8296. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8297. };
  8298. /**
  8299. * Move one end of the line given 3D cartesian coordinates.
  8300. * @param position Targeted world position
  8301. * @param scene Scene
  8302. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8303. */
  8304. Line.prototype.moveToVector3 = function (position, scene, end) {
  8305. if (end === void 0) { end = false; }
  8306. if (!this._host || this.parent !== this._host._rootContainer) {
  8307. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8308. return;
  8309. }
  8310. var globalViewport = this._host._getGlobalViewport(scene);
  8311. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8312. this._moveToProjectedPosition(projectedPosition, end);
  8313. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8314. this.notRenderable = true;
  8315. return;
  8316. }
  8317. this.notRenderable = false;
  8318. };
  8319. /**
  8320. * Move one end of the line to a position in screen absolute space.
  8321. * @param projectedPosition Position in screen absolute space (X, Y)
  8322. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8323. */
  8324. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8325. if (end === void 0) { end = false; }
  8326. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8327. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8328. if (end) {
  8329. this.x2 = x;
  8330. this.y2 = y;
  8331. this._x2.ignoreAdaptiveScaling = true;
  8332. this._y2.ignoreAdaptiveScaling = true;
  8333. }
  8334. else {
  8335. this.x1 = x;
  8336. this.y1 = y;
  8337. this._x1.ignoreAdaptiveScaling = true;
  8338. this._y1.ignoreAdaptiveScaling = true;
  8339. }
  8340. };
  8341. return Line;
  8342. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8343. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8344. /***/ }),
  8345. /***/ "./2D/controls/multiLine.ts":
  8346. /*!**********************************!*\
  8347. !*** ./2D/controls/multiLine.ts ***!
  8348. \**********************************/
  8349. /*! exports provided: MultiLine */
  8350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8351. "use strict";
  8352. __webpack_require__.r(__webpack_exports__);
  8353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8354. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8355. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/perfCounter");
  8356. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8357. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8358. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8359. /**
  8360. * Class used to create multi line control
  8361. */
  8362. var MultiLine = /** @class */ (function (_super) {
  8363. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8364. /**
  8365. * Creates a new MultiLine
  8366. * @param name defines the control name
  8367. */
  8368. function MultiLine(name) {
  8369. var _this = _super.call(this, name) || this;
  8370. _this.name = name;
  8371. _this._lineWidth = 1;
  8372. /** Function called when a point is updated */
  8373. _this.onPointUpdate = function () {
  8374. _this._markAsDirty();
  8375. };
  8376. _this._automaticSize = true;
  8377. _this.isHitTestVisible = false;
  8378. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8379. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8380. _this._dash = [];
  8381. _this._points = [];
  8382. return _this;
  8383. }
  8384. Object.defineProperty(MultiLine.prototype, "dash", {
  8385. /** Gets or sets dash pattern */
  8386. get: function () {
  8387. return this._dash;
  8388. },
  8389. set: function (value) {
  8390. if (this._dash === value) {
  8391. return;
  8392. }
  8393. this._dash = value;
  8394. this._markAsDirty();
  8395. },
  8396. enumerable: true,
  8397. configurable: true
  8398. });
  8399. /**
  8400. * Gets point stored at specified index
  8401. * @param index defines the index to look for
  8402. * @returns the requested point if found
  8403. */
  8404. MultiLine.prototype.getAt = function (index) {
  8405. if (!this._points[index]) {
  8406. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8407. }
  8408. return this._points[index];
  8409. };
  8410. /**
  8411. * Adds new points to the point collection
  8412. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8413. * @returns the list of created MultiLinePoint
  8414. */
  8415. MultiLine.prototype.add = function () {
  8416. var _this = this;
  8417. var items = [];
  8418. for (var _i = 0; _i < arguments.length; _i++) {
  8419. items[_i] = arguments[_i];
  8420. }
  8421. return items.map(function (item) { return _this.push(item); });
  8422. };
  8423. /**
  8424. * Adds a new point to the point collection
  8425. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8426. * @returns the created MultiLinePoint
  8427. */
  8428. MultiLine.prototype.push = function (item) {
  8429. var point = this.getAt(this._points.length);
  8430. if (item == null) {
  8431. return point;
  8432. }
  8433. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8434. point.mesh = item;
  8435. }
  8436. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8437. point.control = item;
  8438. }
  8439. else if (item.x != null && item.y != null) {
  8440. point.x = item.x;
  8441. point.y = item.y;
  8442. }
  8443. return point;
  8444. };
  8445. /**
  8446. * Remove a specific value or point from the active point collection
  8447. * @param value defines the value or point to remove
  8448. */
  8449. MultiLine.prototype.remove = function (value) {
  8450. var index;
  8451. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8452. index = this._points.indexOf(value);
  8453. if (index === -1) {
  8454. return;
  8455. }
  8456. }
  8457. else {
  8458. index = value;
  8459. }
  8460. var point = this._points[index];
  8461. if (!point) {
  8462. return;
  8463. }
  8464. point.dispose();
  8465. this._points.splice(index, 1);
  8466. };
  8467. /**
  8468. * Resets this object to initial state (no point)
  8469. */
  8470. MultiLine.prototype.reset = function () {
  8471. while (this._points.length > 0) {
  8472. this.remove(this._points.length - 1);
  8473. }
  8474. };
  8475. /**
  8476. * Resets all links
  8477. */
  8478. MultiLine.prototype.resetLinks = function () {
  8479. this._points.forEach(function (point) {
  8480. if (point != null) {
  8481. point.resetLinks();
  8482. }
  8483. });
  8484. };
  8485. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8486. /** Gets or sets line width */
  8487. get: function () {
  8488. return this._lineWidth;
  8489. },
  8490. set: function (value) {
  8491. if (this._lineWidth === value) {
  8492. return;
  8493. }
  8494. this._lineWidth = value;
  8495. this._markAsDirty();
  8496. },
  8497. enumerable: true,
  8498. configurable: true
  8499. });
  8500. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8501. set: function (value) {
  8502. return;
  8503. },
  8504. enumerable: true,
  8505. configurable: true
  8506. });
  8507. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8508. set: function (value) {
  8509. return;
  8510. },
  8511. enumerable: true,
  8512. configurable: true
  8513. });
  8514. MultiLine.prototype._getTypeName = function () {
  8515. return "MultiLine";
  8516. };
  8517. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8518. context.save();
  8519. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8520. context.shadowColor = this.shadowColor;
  8521. context.shadowBlur = this.shadowBlur;
  8522. context.shadowOffsetX = this.shadowOffsetX;
  8523. context.shadowOffsetY = this.shadowOffsetY;
  8524. }
  8525. this._applyStates(context);
  8526. context.strokeStyle = this.color;
  8527. context.lineWidth = this._lineWidth;
  8528. context.setLineDash(this._dash);
  8529. context.beginPath();
  8530. var first = true; //first index is not necessarily 0
  8531. this._points.forEach(function (point) {
  8532. if (!point) {
  8533. return;
  8534. }
  8535. if (first) {
  8536. context.moveTo(point._point.x, point._point.y);
  8537. first = false;
  8538. }
  8539. else {
  8540. context.lineTo(point._point.x, point._point.y);
  8541. }
  8542. });
  8543. context.stroke();
  8544. context.restore();
  8545. };
  8546. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8547. var _this = this;
  8548. this._minX = null;
  8549. this._minY = null;
  8550. this._maxX = null;
  8551. this._maxY = null;
  8552. this._points.forEach(function (point, index) {
  8553. if (!point) {
  8554. return;
  8555. }
  8556. point.translate();
  8557. if (_this._minX == null || point._point.x < _this._minX) {
  8558. _this._minX = point._point.x;
  8559. }
  8560. if (_this._minY == null || point._point.y < _this._minY) {
  8561. _this._minY = point._point.y;
  8562. }
  8563. if (_this._maxX == null || point._point.x > _this._maxX) {
  8564. _this._maxX = point._point.x;
  8565. }
  8566. if (_this._maxY == null || point._point.y > _this._maxY) {
  8567. _this._maxY = point._point.y;
  8568. }
  8569. });
  8570. if (this._minX == null) {
  8571. this._minX = 0;
  8572. }
  8573. if (this._minY == null) {
  8574. this._minY = 0;
  8575. }
  8576. if (this._maxX == null) {
  8577. this._maxX = 0;
  8578. }
  8579. if (this._maxY == null) {
  8580. this._maxY = 0;
  8581. }
  8582. };
  8583. MultiLine.prototype._measure = function () {
  8584. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8585. return;
  8586. }
  8587. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8588. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8589. };
  8590. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8591. if (this._minX == null || this._minY == null) {
  8592. return;
  8593. }
  8594. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8595. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8596. };
  8597. MultiLine.prototype.dispose = function () {
  8598. this.reset();
  8599. _super.prototype.dispose.call(this);
  8600. };
  8601. return MultiLine;
  8602. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8603. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8604. /***/ }),
  8605. /***/ "./2D/controls/radioButton.ts":
  8606. /*!************************************!*\
  8607. !*** ./2D/controls/radioButton.ts ***!
  8608. \************************************/
  8609. /*! exports provided: RadioButton */
  8610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8611. "use strict";
  8612. __webpack_require__.r(__webpack_exports__);
  8613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8614. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8615. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  8616. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8617. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8618. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8619. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8620. /**
  8621. * Class used to create radio button controls
  8622. */
  8623. var RadioButton = /** @class */ (function (_super) {
  8624. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8625. /**
  8626. * Creates a new RadioButton
  8627. * @param name defines the control name
  8628. */
  8629. function RadioButton(name) {
  8630. var _this = _super.call(this, name) || this;
  8631. _this.name = name;
  8632. _this._isChecked = false;
  8633. _this._background = "black";
  8634. _this._checkSizeRatio = 0.8;
  8635. _this._thickness = 1;
  8636. /** Gets or sets group name */
  8637. _this.group = "";
  8638. /** Observable raised when isChecked is changed */
  8639. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8640. _this.isPointerBlocker = true;
  8641. return _this;
  8642. }
  8643. Object.defineProperty(RadioButton.prototype, "thickness", {
  8644. /** Gets or sets border thickness */
  8645. get: function () {
  8646. return this._thickness;
  8647. },
  8648. set: function (value) {
  8649. if (this._thickness === value) {
  8650. return;
  8651. }
  8652. this._thickness = value;
  8653. this._markAsDirty();
  8654. },
  8655. enumerable: true,
  8656. configurable: true
  8657. });
  8658. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8659. /** Gets or sets a value indicating the ratio between overall size and check size */
  8660. get: function () {
  8661. return this._checkSizeRatio;
  8662. },
  8663. set: function (value) {
  8664. value = Math.max(Math.min(1, value), 0);
  8665. if (this._checkSizeRatio === value) {
  8666. return;
  8667. }
  8668. this._checkSizeRatio = value;
  8669. this._markAsDirty();
  8670. },
  8671. enumerable: true,
  8672. configurable: true
  8673. });
  8674. Object.defineProperty(RadioButton.prototype, "background", {
  8675. /** Gets or sets background color */
  8676. get: function () {
  8677. return this._background;
  8678. },
  8679. set: function (value) {
  8680. if (this._background === value) {
  8681. return;
  8682. }
  8683. this._background = value;
  8684. this._markAsDirty();
  8685. },
  8686. enumerable: true,
  8687. configurable: true
  8688. });
  8689. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8690. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8691. get: function () {
  8692. return this._isChecked;
  8693. },
  8694. set: function (value) {
  8695. var _this = this;
  8696. if (this._isChecked === value) {
  8697. return;
  8698. }
  8699. this._isChecked = value;
  8700. this._markAsDirty();
  8701. this.onIsCheckedChangedObservable.notifyObservers(value);
  8702. if (this._isChecked && this._host) {
  8703. // Update all controls from same group
  8704. this._host.executeOnAllControls(function (control) {
  8705. if (control === _this) {
  8706. return;
  8707. }
  8708. if (control.group === undefined) {
  8709. return;
  8710. }
  8711. var childRadio = control;
  8712. if (childRadio.group === _this.group) {
  8713. childRadio.isChecked = false;
  8714. }
  8715. });
  8716. }
  8717. },
  8718. enumerable: true,
  8719. configurable: true
  8720. });
  8721. RadioButton.prototype._getTypeName = function () {
  8722. return "RadioButton";
  8723. };
  8724. RadioButton.prototype._draw = function (context) {
  8725. context.save();
  8726. this._applyStates(context);
  8727. var actualWidth = this._currentMeasure.width - this._thickness;
  8728. var actualHeight = this._currentMeasure.height - this._thickness;
  8729. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8730. context.shadowColor = this.shadowColor;
  8731. context.shadowBlur = this.shadowBlur;
  8732. context.shadowOffsetX = this.shadowOffsetX;
  8733. context.shadowOffsetY = this.shadowOffsetY;
  8734. }
  8735. // Outer
  8736. _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);
  8737. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8738. context.fill();
  8739. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8740. context.shadowBlur = 0;
  8741. context.shadowOffsetX = 0;
  8742. context.shadowOffsetY = 0;
  8743. }
  8744. context.strokeStyle = this.color;
  8745. context.lineWidth = this._thickness;
  8746. context.stroke();
  8747. // Inner
  8748. if (this._isChecked) {
  8749. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8750. var offsetWidth = actualWidth * this._checkSizeRatio;
  8751. var offseHeight = actualHeight * this._checkSizeRatio;
  8752. _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);
  8753. context.fill();
  8754. }
  8755. context.restore();
  8756. };
  8757. // Events
  8758. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8759. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8760. return false;
  8761. }
  8762. if (!this.isChecked) {
  8763. this.isChecked = true;
  8764. }
  8765. return true;
  8766. };
  8767. /**
  8768. * Utility function to easily create a radio button with a header
  8769. * @param title defines the label to use for the header
  8770. * @param group defines the group to use for the radio button
  8771. * @param isChecked defines the initial state of the radio button
  8772. * @param onValueChanged defines the callback to call when value changes
  8773. * @returns a StackPanel containing the radio button and a textBlock
  8774. */
  8775. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8776. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8777. panel.isVertical = false;
  8778. panel.height = "30px";
  8779. var radio = new RadioButton();
  8780. radio.width = "20px";
  8781. radio.height = "20px";
  8782. radio.isChecked = isChecked;
  8783. radio.color = "green";
  8784. radio.group = group;
  8785. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8786. panel.addControl(radio);
  8787. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8788. header.text = title;
  8789. header.width = "180px";
  8790. header.paddingLeft = "5px";
  8791. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8792. header.color = "white";
  8793. panel.addControl(header);
  8794. return panel;
  8795. };
  8796. return RadioButton;
  8797. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8798. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8799. /***/ }),
  8800. /***/ "./2D/controls/rectangle.ts":
  8801. /*!**********************************!*\
  8802. !*** ./2D/controls/rectangle.ts ***!
  8803. \**********************************/
  8804. /*! exports provided: Rectangle */
  8805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8806. "use strict";
  8807. __webpack_require__.r(__webpack_exports__);
  8808. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8809. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8810. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8811. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  8812. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8813. /** Class used to create rectangle container */
  8814. var Rectangle = /** @class */ (function (_super) {
  8815. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8816. /**
  8817. * Creates a new Rectangle
  8818. * @param name defines the control name
  8819. */
  8820. function Rectangle(name) {
  8821. var _this = _super.call(this, name) || this;
  8822. _this.name = name;
  8823. _this._thickness = 1;
  8824. _this._cornerRadius = 0;
  8825. return _this;
  8826. }
  8827. Object.defineProperty(Rectangle.prototype, "thickness", {
  8828. /** Gets or sets border thickness */
  8829. get: function () {
  8830. return this._thickness;
  8831. },
  8832. set: function (value) {
  8833. if (this._thickness === value) {
  8834. return;
  8835. }
  8836. this._thickness = value;
  8837. this._markAsDirty();
  8838. },
  8839. enumerable: true,
  8840. configurable: true
  8841. });
  8842. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8843. /** Gets or sets the corner radius angle */
  8844. get: function () {
  8845. return this._cornerRadius;
  8846. },
  8847. set: function (value) {
  8848. if (value < 0) {
  8849. value = 0;
  8850. }
  8851. if (this._cornerRadius === value) {
  8852. return;
  8853. }
  8854. this._cornerRadius = value;
  8855. this._markAsDirty();
  8856. },
  8857. enumerable: true,
  8858. configurable: true
  8859. });
  8860. Rectangle.prototype._getTypeName = function () {
  8861. return "Rectangle";
  8862. };
  8863. Rectangle.prototype._localDraw = function (context) {
  8864. context.save();
  8865. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8866. context.shadowColor = this.shadowColor;
  8867. context.shadowBlur = this.shadowBlur;
  8868. context.shadowOffsetX = this.shadowOffsetX;
  8869. context.shadowOffsetY = this.shadowOffsetY;
  8870. }
  8871. if (this._background) {
  8872. context.fillStyle = this._background;
  8873. if (this._cornerRadius) {
  8874. this._drawRoundedRect(context, this._thickness / 2);
  8875. context.fill();
  8876. }
  8877. else {
  8878. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8879. }
  8880. }
  8881. if (this._thickness) {
  8882. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8883. context.shadowBlur = 0;
  8884. context.shadowOffsetX = 0;
  8885. context.shadowOffsetY = 0;
  8886. }
  8887. if (this.color) {
  8888. context.strokeStyle = this.color;
  8889. }
  8890. context.lineWidth = this._thickness;
  8891. if (this._cornerRadius) {
  8892. this._drawRoundedRect(context, this._thickness / 2);
  8893. context.stroke();
  8894. }
  8895. else {
  8896. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8897. }
  8898. }
  8899. context.restore();
  8900. };
  8901. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8902. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8903. this._measureForChildren.width -= 2 * this._thickness;
  8904. this._measureForChildren.height -= 2 * this._thickness;
  8905. this._measureForChildren.left += this._thickness;
  8906. this._measureForChildren.top += this._thickness;
  8907. };
  8908. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8909. if (offset === void 0) { offset = 0; }
  8910. var x = this._currentMeasure.left + offset;
  8911. var y = this._currentMeasure.top + offset;
  8912. var width = this._currentMeasure.width - offset * 2;
  8913. var height = this._currentMeasure.height - offset * 2;
  8914. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8915. context.beginPath();
  8916. context.moveTo(x + radius, y);
  8917. context.lineTo(x + width - radius, y);
  8918. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8919. context.lineTo(x + width, y + height - radius);
  8920. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8921. context.lineTo(x + radius, y + height);
  8922. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8923. context.lineTo(x, y + radius);
  8924. context.quadraticCurveTo(x, y, x + radius, y);
  8925. context.closePath();
  8926. };
  8927. Rectangle.prototype._clipForChildren = function (context) {
  8928. if (this._cornerRadius) {
  8929. this._drawRoundedRect(context, this._thickness);
  8930. context.clip();
  8931. }
  8932. };
  8933. return Rectangle;
  8934. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8935. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  8936. /***/ }),
  8937. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8938. /*!***************************************************!*\
  8939. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8940. \***************************************************/
  8941. /*! exports provided: ScrollViewer */
  8942. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8943. "use strict";
  8944. __webpack_require__.r(__webpack_exports__);
  8945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8946. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8947. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/perfCounter");
  8948. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8949. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8950. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8951. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8952. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8953. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8954. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  8955. /**
  8956. * Class used to hold a viewer window and sliders in a grid
  8957. */
  8958. var ScrollViewer = /** @class */ (function (_super) {
  8959. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  8960. /**
  8961. * Creates a new ScrollViewer
  8962. * @param name of ScrollViewer
  8963. */
  8964. function ScrollViewer(name, isImageBased) {
  8965. var _this = _super.call(this, name) || this;
  8966. _this._barSize = 20;
  8967. _this._pointerIsOver = false;
  8968. _this._wheelPrecision = 0.05;
  8969. _this._thumbLength = 0.5;
  8970. _this._thumbHeight = 1;
  8971. _this._barImageHeight = 1;
  8972. _this._horizontalBarImageHeight = 1;
  8973. _this._verticalBarImageHeight = 1;
  8974. _this._forceHorizontalBar = false;
  8975. _this._forceVerticalBar = false;
  8976. _this._useImageBar = isImageBased ? isImageBased : false;
  8977. _this.onDirtyObservable.add(function () {
  8978. _this._horizontalBarSpace.color = _this.color;
  8979. _this._verticalBarSpace.color = _this.color;
  8980. _this._dragSpace.color = _this.color;
  8981. });
  8982. _this.onPointerEnterObservable.add(function () {
  8983. _this._pointerIsOver = true;
  8984. });
  8985. _this.onPointerOutObservable.add(function () {
  8986. _this._pointerIsOver = false;
  8987. });
  8988. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8989. if (_this._useImageBar) {
  8990. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__["ImageScrollBar"]();
  8991. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__["ImageScrollBar"]();
  8992. }
  8993. else {
  8994. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8995. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8996. }
  8997. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]("scrollViewer_window");
  8998. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8999. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  9000. _this._grid.addColumnDefinition(1);
  9001. _this._grid.addColumnDefinition(0, true);
  9002. _this._grid.addRowDefinition(1);
  9003. _this._grid.addRowDefinition(0, true);
  9004. _super.prototype.addControl.call(_this, _this._grid);
  9005. _this._grid.addControl(_this._window, 0, 0);
  9006. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  9007. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9008. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  9009. _this._verticalBarSpace.thickness = 1;
  9010. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  9011. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  9012. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  9013. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9014. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  9015. _this._horizontalBarSpace.thickness = 1;
  9016. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  9017. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  9018. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  9019. _this._dragSpace.thickness = 1;
  9020. _this._grid.addControl(_this._dragSpace, 1, 1);
  9021. // Colors
  9022. if (!_this._useImageBar) {
  9023. _this.barColor = "grey";
  9024. _this.barBackground = "transparent";
  9025. }
  9026. return _this;
  9027. }
  9028. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  9029. /**
  9030. * Gets the horizontal scrollbar
  9031. */
  9032. get: function () {
  9033. return this._horizontalBar;
  9034. },
  9035. enumerable: true,
  9036. configurable: true
  9037. });
  9038. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  9039. /**
  9040. * Gets the vertical scrollbar
  9041. */
  9042. get: function () {
  9043. return this._verticalBar;
  9044. },
  9045. enumerable: true,
  9046. configurable: true
  9047. });
  9048. /**
  9049. * Adds a new control to the current container
  9050. * @param control defines the control to add
  9051. * @returns the current container
  9052. */
  9053. ScrollViewer.prototype.addControl = function (control) {
  9054. if (!control) {
  9055. return this;
  9056. }
  9057. this._window.addControl(control);
  9058. return this;
  9059. };
  9060. /**
  9061. * Removes a control from the current container
  9062. * @param control defines the control to remove
  9063. * @returns the current container
  9064. */
  9065. ScrollViewer.prototype.removeControl = function (control) {
  9066. this._window.removeControl(control);
  9067. return this;
  9068. };
  9069. Object.defineProperty(ScrollViewer.prototype, "children", {
  9070. /** Gets the list of children */
  9071. get: function () {
  9072. return this._window.children;
  9073. },
  9074. enumerable: true,
  9075. configurable: true
  9076. });
  9077. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  9078. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9079. var child = _a[_i];
  9080. child._markMatrixAsDirty();
  9081. }
  9082. };
  9083. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  9084. /**
  9085. * Freezes or unfreezes the controls in the window.
  9086. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  9087. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  9088. */
  9089. get: function () {
  9090. return this._window.freezeControls;
  9091. },
  9092. set: function (value) {
  9093. this._window.freezeControls = value;
  9094. },
  9095. enumerable: true,
  9096. configurable: true
  9097. });
  9098. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  9099. /** Gets the bucket width */
  9100. get: function () {
  9101. return this._window.bucketWidth;
  9102. },
  9103. enumerable: true,
  9104. configurable: true
  9105. });
  9106. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9107. /** Gets the bucket height */
  9108. get: function () {
  9109. return this._window.bucketHeight;
  9110. },
  9111. enumerable: true,
  9112. configurable: true
  9113. });
  9114. /**
  9115. * Sets the bucket sizes.
  9116. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9117. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9118. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9119. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9120. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9121. * used), that's why it is not enabled by default.
  9122. * @param width width of the bucket
  9123. * @param height height of the bucket
  9124. */
  9125. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9126. this._window.setBucketSizes(width, height);
  9127. };
  9128. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9129. /**
  9130. * Forces the horizontal scroll bar to be displayed
  9131. */
  9132. get: function () {
  9133. return this._forceHorizontalBar;
  9134. },
  9135. set: function (value) {
  9136. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9137. this._horizontalBar.isVisible = value;
  9138. this._forceHorizontalBar = value;
  9139. },
  9140. enumerable: true,
  9141. configurable: true
  9142. });
  9143. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9144. /**
  9145. * Forces the vertical scroll bar to be displayed
  9146. */
  9147. get: function () {
  9148. return this._forceVerticalBar;
  9149. },
  9150. set: function (value) {
  9151. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9152. this._verticalBar.isVisible = value;
  9153. this._forceVerticalBar = value;
  9154. },
  9155. enumerable: true,
  9156. configurable: true
  9157. });
  9158. /** Reset the scroll viewer window to initial size */
  9159. ScrollViewer.prototype.resetWindow = function () {
  9160. this._window.width = "100%";
  9161. this._window.height = "100%";
  9162. };
  9163. ScrollViewer.prototype._getTypeName = function () {
  9164. return "ScrollViewer";
  9165. };
  9166. ScrollViewer.prototype._buildClientSizes = function () {
  9167. var ratio = this.host.idealRatio;
  9168. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9169. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9170. this._clientWidth = this._window.parentClientWidth;
  9171. this._clientHeight = this._window.parentClientHeight;
  9172. };
  9173. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  9174. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9175. this._buildClientSizes();
  9176. };
  9177. ScrollViewer.prototype._postMeasure = function () {
  9178. _super.prototype._postMeasure.call(this);
  9179. this._updateScroller();
  9180. };
  9181. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  9182. /**
  9183. * Gets or sets the mouse wheel precision
  9184. * from 0 to 1 with a default value of 0.05
  9185. * */
  9186. get: function () {
  9187. return this._wheelPrecision;
  9188. },
  9189. set: function (value) {
  9190. if (this._wheelPrecision === value) {
  9191. return;
  9192. }
  9193. if (value < 0) {
  9194. value = 0;
  9195. }
  9196. if (value > 1) {
  9197. value = 1;
  9198. }
  9199. this._wheelPrecision = value;
  9200. },
  9201. enumerable: true,
  9202. configurable: true
  9203. });
  9204. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  9205. /** Gets or sets the scroll bar container background color */
  9206. get: function () {
  9207. return this._horizontalBarSpace.background;
  9208. },
  9209. set: function (color) {
  9210. if (this._horizontalBarSpace.background === color) {
  9211. return;
  9212. }
  9213. this._horizontalBarSpace.background = color;
  9214. this._verticalBarSpace.background = color;
  9215. },
  9216. enumerable: true,
  9217. configurable: true
  9218. });
  9219. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9220. /** Gets or sets the bar color */
  9221. get: function () {
  9222. return this._barColor;
  9223. },
  9224. set: function (color) {
  9225. if (this._barColor === color) {
  9226. return;
  9227. }
  9228. this._barColor = color;
  9229. this._horizontalBar.color = color;
  9230. this._verticalBar.color = color;
  9231. },
  9232. enumerable: true,
  9233. configurable: true
  9234. });
  9235. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9236. /** Gets or sets the bar image */
  9237. get: function () {
  9238. return this._barImage;
  9239. },
  9240. set: function (value) {
  9241. if (this._barImage === value) {
  9242. return;
  9243. }
  9244. this._barImage = value;
  9245. var hb = this._horizontalBar;
  9246. var vb = this._verticalBar;
  9247. hb.thumbImage = value;
  9248. vb.thumbImage = value;
  9249. },
  9250. enumerable: true,
  9251. configurable: true
  9252. });
  9253. Object.defineProperty(ScrollViewer.prototype, "horizontalThumbImage", {
  9254. /** Gets or sets the horizontal bar image */
  9255. get: function () {
  9256. return this._horizontalBarImage;
  9257. },
  9258. set: function (value) {
  9259. if (this._horizontalBarImage === value) {
  9260. return;
  9261. }
  9262. this._horizontalBarImage = value;
  9263. var hb = this._horizontalBar;
  9264. hb.thumbImage = value;
  9265. },
  9266. enumerable: true,
  9267. configurable: true
  9268. });
  9269. Object.defineProperty(ScrollViewer.prototype, "verticalThumbImage", {
  9270. /** Gets or sets the vertical bar image */
  9271. get: function () {
  9272. return this._verticalBarImage;
  9273. },
  9274. set: function (value) {
  9275. if (this._verticalBarImage === value) {
  9276. return;
  9277. }
  9278. this._verticalBarImage = value;
  9279. var vb = this._verticalBar;
  9280. vb.thumbImage = value;
  9281. },
  9282. enumerable: true,
  9283. configurable: true
  9284. });
  9285. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9286. /** Gets or sets the size of the bar */
  9287. get: function () {
  9288. return this._barSize;
  9289. },
  9290. set: function (value) {
  9291. if (this._barSize === value) {
  9292. return;
  9293. }
  9294. this._barSize = value;
  9295. this._markAsDirty();
  9296. if (this._horizontalBar.isVisible) {
  9297. this._grid.setRowDefinition(1, this._barSize, true);
  9298. }
  9299. if (this._verticalBar.isVisible) {
  9300. this._grid.setColumnDefinition(1, this._barSize, true);
  9301. }
  9302. },
  9303. enumerable: true,
  9304. configurable: true
  9305. });
  9306. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9307. /** Gets or sets the length of the thumb */
  9308. get: function () {
  9309. return this._thumbLength;
  9310. },
  9311. set: function (value) {
  9312. if (this._thumbLength === value) {
  9313. return;
  9314. }
  9315. if (value <= 0) {
  9316. value = 0.1;
  9317. }
  9318. if (value > 1) {
  9319. value = 1;
  9320. }
  9321. this._thumbLength = value;
  9322. var hb = this._horizontalBar;
  9323. var vb = this._verticalBar;
  9324. hb.thumbLength = value;
  9325. vb.thumbLength = value;
  9326. this._markAsDirty();
  9327. },
  9328. enumerable: true,
  9329. configurable: true
  9330. });
  9331. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9332. /** Gets or sets the height of the thumb */
  9333. get: function () {
  9334. return this._thumbHeight;
  9335. },
  9336. set: function (value) {
  9337. if (this._thumbHeight === value) {
  9338. return;
  9339. }
  9340. if (value <= 0) {
  9341. value = 0.1;
  9342. }
  9343. if (value > 1) {
  9344. value = 1;
  9345. }
  9346. this._thumbHeight = value;
  9347. var hb = this._horizontalBar;
  9348. var vb = this._verticalBar;
  9349. hb.thumbHeight = value;
  9350. vb.thumbHeight = value;
  9351. this._markAsDirty();
  9352. },
  9353. enumerable: true,
  9354. configurable: true
  9355. });
  9356. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9357. /** Gets or sets the height of the bar image */
  9358. get: function () {
  9359. return this._barImageHeight;
  9360. },
  9361. set: function (value) {
  9362. if (this._barImageHeight === value) {
  9363. return;
  9364. }
  9365. if (value <= 0) {
  9366. value = 0.1;
  9367. }
  9368. if (value > 1) {
  9369. value = 1;
  9370. }
  9371. this._barImageHeight = value;
  9372. var hb = this._horizontalBar;
  9373. var vb = this._verticalBar;
  9374. hb.barImageHeight = value;
  9375. vb.barImageHeight = value;
  9376. this._markAsDirty();
  9377. },
  9378. enumerable: true,
  9379. configurable: true
  9380. });
  9381. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImageHeight", {
  9382. /** Gets or sets the height of the horizontal bar image */
  9383. get: function () {
  9384. return this._horizontalBarImageHeight;
  9385. },
  9386. set: function (value) {
  9387. if (this._horizontalBarImageHeight === value) {
  9388. return;
  9389. }
  9390. if (value <= 0) {
  9391. value = 0.1;
  9392. }
  9393. if (value > 1) {
  9394. value = 1;
  9395. }
  9396. this._horizontalBarImageHeight = value;
  9397. var hb = this._horizontalBar;
  9398. hb.barImageHeight = value;
  9399. this._markAsDirty();
  9400. },
  9401. enumerable: true,
  9402. configurable: true
  9403. });
  9404. Object.defineProperty(ScrollViewer.prototype, "verticalBarImageHeight", {
  9405. /** Gets or sets the height of the vertical bar image */
  9406. get: function () {
  9407. return this._verticalBarImageHeight;
  9408. },
  9409. set: function (value) {
  9410. if (this._verticalBarImageHeight === value) {
  9411. return;
  9412. }
  9413. if (value <= 0) {
  9414. value = 0.1;
  9415. }
  9416. if (value > 1) {
  9417. value = 1;
  9418. }
  9419. this._verticalBarImageHeight = value;
  9420. var vb = this._verticalBar;
  9421. vb.barImageHeight = value;
  9422. this._markAsDirty();
  9423. },
  9424. enumerable: true,
  9425. configurable: true
  9426. });
  9427. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9428. /** Gets or sets the bar background */
  9429. get: function () {
  9430. return this._barBackground;
  9431. },
  9432. set: function (color) {
  9433. if (this._barBackground === color) {
  9434. return;
  9435. }
  9436. this._barBackground = color;
  9437. var hb = this._horizontalBar;
  9438. var vb = this._verticalBar;
  9439. hb.background = color;
  9440. vb.background = color;
  9441. this._dragSpace.background = color;
  9442. },
  9443. enumerable: true,
  9444. configurable: true
  9445. });
  9446. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9447. /** Gets or sets the bar background image */
  9448. get: function () {
  9449. return this._barBackgroundImage;
  9450. },
  9451. set: function (value) {
  9452. if (this._barBackgroundImage === value) {
  9453. }
  9454. this._barBackgroundImage = value;
  9455. var hb = this._horizontalBar;
  9456. var vb = this._verticalBar;
  9457. hb.backgroundImage = value;
  9458. vb.backgroundImage = value;
  9459. },
  9460. enumerable: true,
  9461. configurable: true
  9462. });
  9463. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImage", {
  9464. /** Gets or sets the horizontal bar background image */
  9465. get: function () {
  9466. return this._horizontalBarBackgroundImage;
  9467. },
  9468. set: function (value) {
  9469. if (this._horizontalBarBackgroundImage === value) {
  9470. }
  9471. this._horizontalBarBackgroundImage = value;
  9472. var hb = this._horizontalBar;
  9473. hb.backgroundImage = value;
  9474. },
  9475. enumerable: true,
  9476. configurable: true
  9477. });
  9478. Object.defineProperty(ScrollViewer.prototype, "verticalBarImage", {
  9479. /** Gets or sets the vertical bar background image */
  9480. get: function () {
  9481. return this._verticalBarBackgroundImage;
  9482. },
  9483. set: function (value) {
  9484. if (this._verticalBarBackgroundImage === value) {
  9485. }
  9486. this._verticalBarBackgroundImage = value;
  9487. var vb = this._verticalBar;
  9488. vb.backgroundImage = value;
  9489. },
  9490. enumerable: true,
  9491. configurable: true
  9492. });
  9493. ScrollViewer.prototype._setWindowPosition = function () {
  9494. var ratio = this.host.idealRatio;
  9495. var windowContentsWidth = this._window._currentMeasure.width;
  9496. var windowContentsHeight = this._window._currentMeasure.height;
  9497. var _endLeft = this._clientWidth - windowContentsWidth;
  9498. var _endTop = this._clientHeight - windowContentsHeight;
  9499. var newLeft = (this._horizontalBar.value / ratio) * _endLeft + "px";
  9500. var newTop = (this._verticalBar.value / ratio) * _endTop + "px";
  9501. if (newLeft !== this._window.left) {
  9502. this._window.left = newLeft;
  9503. if (!this.freezeControls) {
  9504. this._rebuildLayout = true;
  9505. }
  9506. }
  9507. if (newTop !== this._window.top) {
  9508. this._window.top = newTop;
  9509. if (!this.freezeControls) {
  9510. this._rebuildLayout = true;
  9511. }
  9512. }
  9513. };
  9514. /** @hidden */
  9515. ScrollViewer.prototype._updateScroller = function () {
  9516. var windowContentsWidth = this._window._currentMeasure.width;
  9517. var windowContentsHeight = this._window._currentMeasure.height;
  9518. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  9519. this._grid.setRowDefinition(1, 0, true);
  9520. this._horizontalBar.isVisible = false;
  9521. this._horizontalBar.value = 0;
  9522. this._rebuildLayout = true;
  9523. }
  9524. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  9525. this._grid.setRowDefinition(1, this._barSize, true);
  9526. this._horizontalBar.isVisible = true;
  9527. this._rebuildLayout = true;
  9528. }
  9529. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  9530. this._grid.setColumnDefinition(1, 0, true);
  9531. this._verticalBar.isVisible = false;
  9532. this._verticalBar.value = 0;
  9533. this._rebuildLayout = true;
  9534. }
  9535. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  9536. this._grid.setColumnDefinition(1, this._barSize, true);
  9537. this._verticalBar.isVisible = true;
  9538. this._rebuildLayout = true;
  9539. }
  9540. this._buildClientSizes();
  9541. var ratio = this.host.idealRatio;
  9542. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientWidth / ratio) + "px";
  9543. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientHeight / ratio) + "px";
  9544. };
  9545. ScrollViewer.prototype._link = function (host) {
  9546. _super.prototype._link.call(this, host);
  9547. this._attachWheel();
  9548. };
  9549. /** @hidden */
  9550. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9551. var _this = this;
  9552. barControl.paddingLeft = 0;
  9553. barControl.width = "100%";
  9554. barControl.height = "100%";
  9555. barControl.barOffset = 0;
  9556. barControl.value = 0;
  9557. barControl.maximum = 1;
  9558. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9559. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9560. barControl.isVertical = isVertical;
  9561. barControl.rotation = rotation;
  9562. barControl.isVisible = false;
  9563. barContainer.addControl(barControl);
  9564. barControl.onValueChangedObservable.add(function (value) {
  9565. _this._setWindowPosition();
  9566. });
  9567. };
  9568. /** @hidden */
  9569. ScrollViewer.prototype._attachWheel = function () {
  9570. var _this = this;
  9571. if (!this._host || this._onPointerObserver) {
  9572. return;
  9573. }
  9574. var scene = this._host.getScene();
  9575. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  9576. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  9577. return;
  9578. }
  9579. if (_this._verticalBar.isVisible == true) {
  9580. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  9581. _this._verticalBar.value -= _this._wheelPrecision;
  9582. }
  9583. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9584. _this._verticalBar.value += _this._wheelPrecision;
  9585. }
  9586. }
  9587. if (_this._horizontalBar.isVisible == true) {
  9588. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9589. _this._horizontalBar.value += _this._wheelPrecision;
  9590. }
  9591. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  9592. _this._horizontalBar.value -= _this._wheelPrecision;
  9593. }
  9594. }
  9595. });
  9596. };
  9597. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9598. if (!this.isHighlighted) {
  9599. return;
  9600. }
  9601. _super.prototype._renderHighlightSpecific.call(this, context);
  9602. this._grid._renderHighlightSpecific(context);
  9603. context.restore();
  9604. };
  9605. /** Releases associated resources */
  9606. ScrollViewer.prototype.dispose = function () {
  9607. var scene = this._host.getScene();
  9608. if (scene && this._onPointerObserver) {
  9609. scene.onPointerObservable.remove(this._onPointerObserver);
  9610. this._onPointerObserver = null;
  9611. }
  9612. _super.prototype.dispose.call(this);
  9613. };
  9614. return ScrollViewer;
  9615. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  9616. babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9617. /***/ }),
  9618. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9619. /*!*********************************************************!*\
  9620. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9621. \*********************************************************/
  9622. /*! exports provided: _ScrollViewerWindow */
  9623. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9624. "use strict";
  9625. __webpack_require__.r(__webpack_exports__);
  9626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9627. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9628. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9629. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9630. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9631. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9632. /**
  9633. * Class used to hold a the container for ScrollViewer
  9634. * @hidden
  9635. */
  9636. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9637. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9638. /**
  9639. * Creates a new ScrollViewerWindow
  9640. * @param name of ScrollViewerWindow
  9641. */
  9642. function _ScrollViewerWindow(name) {
  9643. var _this = _super.call(this, name) || this;
  9644. _this._freezeControls = false;
  9645. _this._bucketWidth = 0;
  9646. _this._bucketHeight = 0;
  9647. _this._buckets = {};
  9648. return _this;
  9649. }
  9650. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  9651. get: function () {
  9652. return this._freezeControls;
  9653. },
  9654. set: function (value) {
  9655. if (this._freezeControls === value) {
  9656. return;
  9657. }
  9658. // trigger a full normal layout calculation to be sure all children have their measures up to date
  9659. this._freezeControls = false;
  9660. var textureSize = this.host.getSize();
  9661. var renderWidth = textureSize.width;
  9662. var renderHeight = textureSize.height;
  9663. var context = this.host.getContext();
  9664. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  9665. this.host._numLayoutCalls = 0;
  9666. this.host._rootContainer._layout(measure, context);
  9667. // in freeze mode, prepare children measures accordingly
  9668. if (value) {
  9669. this._updateMeasures();
  9670. if (this._useBuckets()) {
  9671. this._makeBuckets();
  9672. }
  9673. }
  9674. this._freezeControls = value;
  9675. this.host.markAsDirty(); // redraw with the (new) current settings
  9676. },
  9677. enumerable: true,
  9678. configurable: true
  9679. });
  9680. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  9681. get: function () {
  9682. return this._bucketWidth;
  9683. },
  9684. enumerable: true,
  9685. configurable: true
  9686. });
  9687. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  9688. get: function () {
  9689. return this._bucketHeight;
  9690. },
  9691. enumerable: true,
  9692. configurable: true
  9693. });
  9694. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  9695. this._bucketWidth = width;
  9696. this._bucketHeight = height;
  9697. if (this._useBuckets()) {
  9698. if (this._freezeControls) {
  9699. this._makeBuckets();
  9700. }
  9701. }
  9702. else {
  9703. this._buckets = {};
  9704. }
  9705. };
  9706. _ScrollViewerWindow.prototype._useBuckets = function () {
  9707. return this._bucketWidth > 0 && this._bucketHeight > 0;
  9708. };
  9709. _ScrollViewerWindow.prototype._makeBuckets = function () {
  9710. this._buckets = {};
  9711. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  9712. this._dispatchInBuckets(this._children);
  9713. };
  9714. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  9715. for (var i = 0; i < children.length; ++i) {
  9716. var child = children[i];
  9717. 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);
  9718. while (bStartY <= bEndY) {
  9719. for (var x = bStartX; x <= bEndX; ++x) {
  9720. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9721. if (!lstc) {
  9722. lstc = [];
  9723. this._buckets[bucket] = lstc;
  9724. }
  9725. lstc.push(child);
  9726. }
  9727. bStartY++;
  9728. }
  9729. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9730. this._dispatchInBuckets(child._children);
  9731. }
  9732. }
  9733. };
  9734. // reset left and top measures for the window and all its children
  9735. _ScrollViewerWindow.prototype._updateMeasures = function () {
  9736. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9737. this._measureForChildren.left -= left;
  9738. this._measureForChildren.top -= top;
  9739. this._currentMeasure.left -= left;
  9740. this._currentMeasure.top -= top;
  9741. this._updateChildrenMeasures(this._children, left, top);
  9742. };
  9743. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  9744. for (var i = 0; i < children.length; ++i) {
  9745. var child = children[i];
  9746. child._currentMeasure.left -= left;
  9747. child._currentMeasure.top -= top;
  9748. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  9749. child._customData._origTop = child._currentMeasure.top;
  9750. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9751. this._updateChildrenMeasures(child._children, left, top);
  9752. }
  9753. }
  9754. };
  9755. _ScrollViewerWindow.prototype._getTypeName = function () {
  9756. return "ScrollViewerWindow";
  9757. };
  9758. /** @hidden */
  9759. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9760. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9761. this._parentMeasure = parentMeasure;
  9762. this._measureForChildren.left = this._currentMeasure.left;
  9763. this._measureForChildren.top = this._currentMeasure.top;
  9764. this._measureForChildren.width = parentMeasure.width;
  9765. this._measureForChildren.height = parentMeasure.height;
  9766. };
  9767. /** @hidden */
  9768. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  9769. if (this._freezeControls) {
  9770. this.invalidateRect(); // will trigger a redraw of the window
  9771. return false;
  9772. }
  9773. return _super.prototype._layout.call(this, parentMeasure, context);
  9774. };
  9775. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  9776. for (var i = 0; i < children.length; ++i) {
  9777. var child = children[i];
  9778. child._currentMeasure.left = child._customData._origLeft + left;
  9779. child._currentMeasure.top = child._customData._origTop + top;
  9780. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9781. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9782. this._scrollChildren(child._children, left, top);
  9783. }
  9784. }
  9785. };
  9786. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  9787. 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);
  9788. while (bStartY <= bEndY) {
  9789. for (var x = bStartX; x <= bEndX; ++x) {
  9790. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9791. if (lstc) {
  9792. for (var i = 0; i < lstc.length; ++i) {
  9793. var child = lstc[i];
  9794. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  9795. child._currentMeasure.top = child._customData._origTop + scrollTop;
  9796. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9797. }
  9798. }
  9799. }
  9800. bStartY++;
  9801. }
  9802. };
  9803. /** @hidden */
  9804. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  9805. if (!this._freezeControls) {
  9806. _super.prototype._draw.call(this, context, invalidatedRectangle);
  9807. return;
  9808. }
  9809. this._localDraw(context);
  9810. if (this.clipChildren) {
  9811. this._clipForChildren(context);
  9812. }
  9813. var left = this.leftInPixels, top = this.topInPixels;
  9814. if (this._useBuckets()) {
  9815. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  9816. this._scrollChildrenWithBuckets(left, top, left, top);
  9817. }
  9818. else {
  9819. this._scrollChildren(this._children, left, top);
  9820. }
  9821. this._oldLeft = left;
  9822. this._oldTop = top;
  9823. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9824. var child = _a[_i];
  9825. if (!child._intersectsRect(this._parentMeasure)) {
  9826. continue;
  9827. }
  9828. child._render(context, this._parentMeasure);
  9829. }
  9830. };
  9831. _ScrollViewerWindow.prototype._postMeasure = function () {
  9832. if (this._freezeControls) {
  9833. _super.prototype._postMeasure.call(this);
  9834. return;
  9835. }
  9836. var maxWidth = this.parentClientWidth;
  9837. var maxHeight = this.parentClientHeight;
  9838. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9839. var child = _a[_i];
  9840. if (!child.isVisible || child.notRenderable) {
  9841. continue;
  9842. }
  9843. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9844. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9845. }
  9846. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9847. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9848. }
  9849. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9850. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9851. }
  9852. if (this._currentMeasure.width !== maxWidth) {
  9853. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9854. this._currentMeasure.width = maxWidth;
  9855. this._rebuildLayout = true;
  9856. this._isDirty = true;
  9857. }
  9858. if (this._currentMeasure.height !== maxHeight) {
  9859. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9860. this._currentMeasure.height = maxHeight;
  9861. this._rebuildLayout = true;
  9862. this._isDirty = true;
  9863. }
  9864. _super.prototype._postMeasure.call(this);
  9865. };
  9866. return _ScrollViewerWindow;
  9867. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  9868. /***/ }),
  9869. /***/ "./2D/controls/selector.ts":
  9870. /*!*********************************!*\
  9871. !*** ./2D/controls/selector.ts ***!
  9872. \*********************************/
  9873. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9875. "use strict";
  9876. __webpack_require__.r(__webpack_exports__);
  9877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9878. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9879. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9880. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9881. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9882. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9883. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9884. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9885. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9886. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9887. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9888. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9889. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9890. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9891. /** Class used to create a RadioGroup
  9892. * which contains groups of radio buttons
  9893. */
  9894. var SelectorGroup = /** @class */ (function () {
  9895. /**
  9896. * Creates a new SelectorGroup
  9897. * @param name of group, used as a group heading
  9898. */
  9899. function SelectorGroup(
  9900. /** name of SelectorGroup */
  9901. name) {
  9902. this.name = name;
  9903. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9904. this._selectors = new Array();
  9905. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9906. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9907. this._groupHeader = this._addGroupHeader(name);
  9908. }
  9909. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9910. /** Gets the groupPanel of the SelectorGroup */
  9911. get: function () {
  9912. return this._groupPanel;
  9913. },
  9914. enumerable: true,
  9915. configurable: true
  9916. });
  9917. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9918. /** Gets the selectors array */
  9919. get: function () {
  9920. return this._selectors;
  9921. },
  9922. enumerable: true,
  9923. configurable: true
  9924. });
  9925. Object.defineProperty(SelectorGroup.prototype, "header", {
  9926. /** Gets and sets the group header */
  9927. get: function () {
  9928. return this._groupHeader.text;
  9929. },
  9930. set: function (label) {
  9931. if (this._groupHeader.text === "label") {
  9932. return;
  9933. }
  9934. this._groupHeader.text = label;
  9935. },
  9936. enumerable: true,
  9937. configurable: true
  9938. });
  9939. /** @hidden */
  9940. SelectorGroup.prototype._addGroupHeader = function (text) {
  9941. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9942. groupHeading.width = 0.9;
  9943. groupHeading.height = "30px";
  9944. groupHeading.textWrapping = true;
  9945. groupHeading.color = "black";
  9946. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9947. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9948. groupHeading.left = "2px";
  9949. this._groupPanel.addControl(groupHeading);
  9950. return groupHeading;
  9951. };
  9952. /** @hidden*/
  9953. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9954. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9955. return;
  9956. }
  9957. return this._selectors[selectorNb];
  9958. };
  9959. /** Removes the selector at the given position
  9960. * @param selectorNb the position of the selector within the group
  9961. */
  9962. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9963. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9964. return;
  9965. }
  9966. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9967. this._selectors.splice(selectorNb, 1);
  9968. };
  9969. return SelectorGroup;
  9970. }());
  9971. /** Class used to create a CheckboxGroup
  9972. * which contains groups of checkbox buttons
  9973. */
  9974. var CheckboxGroup = /** @class */ (function (_super) {
  9975. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  9976. function CheckboxGroup() {
  9977. return _super !== null && _super.apply(this, arguments) || this;
  9978. }
  9979. /** Adds a checkbox as a control
  9980. * @param text is the label for the selector
  9981. * @param func is the function called when the Selector is checked
  9982. * @param checked is true when Selector is checked
  9983. */
  9984. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9985. if (func === void 0) { func = function (s) { }; }
  9986. if (checked === void 0) { checked = false; }
  9987. var checked = checked || false;
  9988. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9989. button.width = "20px";
  9990. button.height = "20px";
  9991. button.color = "#364249";
  9992. button.background = "#CCCCCC";
  9993. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9994. button.onIsCheckedChangedObservable.add(function (state) {
  9995. func(state);
  9996. });
  9997. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9998. _selector.height = "30px";
  9999. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10000. _selector.left = "4px";
  10001. this.groupPanel.addControl(_selector);
  10002. this.selectors.push(_selector);
  10003. button.isChecked = checked;
  10004. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10005. button.color = this.groupPanel.parent.parent.buttonColor;
  10006. button.background = this.groupPanel.parent.parent.buttonBackground;
  10007. }
  10008. };
  10009. /** @hidden */
  10010. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10011. this.selectors[selectorNb].children[1].text = label;
  10012. };
  10013. /** @hidden */
  10014. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10015. this.selectors[selectorNb].children[1].color = color;
  10016. };
  10017. /** @hidden */
  10018. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10019. this.selectors[selectorNb].children[0].color = color;
  10020. };
  10021. /** @hidden */
  10022. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10023. this.selectors[selectorNb].children[0].background = color;
  10024. };
  10025. return CheckboxGroup;
  10026. }(SelectorGroup));
  10027. /** Class used to create a RadioGroup
  10028. * which contains groups of radio buttons
  10029. */
  10030. var RadioGroup = /** @class */ (function (_super) {
  10031. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  10032. function RadioGroup() {
  10033. var _this = _super !== null && _super.apply(this, arguments) || this;
  10034. _this._selectNb = 0;
  10035. return _this;
  10036. }
  10037. /** Adds a radio button as a control
  10038. * @param label is the label for the selector
  10039. * @param func is the function called when the Selector is checked
  10040. * @param checked is true when Selector is checked
  10041. */
  10042. RadioGroup.prototype.addRadio = function (label, func, checked) {
  10043. if (func === void 0) { func = function (n) { }; }
  10044. if (checked === void 0) { checked = false; }
  10045. var nb = this._selectNb++;
  10046. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  10047. button.name = label;
  10048. button.width = "20px";
  10049. button.height = "20px";
  10050. button.color = "#364249";
  10051. button.background = "#CCCCCC";
  10052. button.group = this.name;
  10053. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10054. button.onIsCheckedChangedObservable.add(function (state) {
  10055. if (state) {
  10056. func(nb);
  10057. }
  10058. });
  10059. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  10060. _selector.height = "30px";
  10061. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10062. _selector.left = "4px";
  10063. this.groupPanel.addControl(_selector);
  10064. this.selectors.push(_selector);
  10065. button.isChecked = checked;
  10066. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10067. button.color = this.groupPanel.parent.parent.buttonColor;
  10068. button.background = this.groupPanel.parent.parent.buttonBackground;
  10069. }
  10070. };
  10071. /** @hidden */
  10072. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10073. this.selectors[selectorNb].children[1].text = label;
  10074. };
  10075. /** @hidden */
  10076. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10077. this.selectors[selectorNb].children[1].color = color;
  10078. };
  10079. /** @hidden */
  10080. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10081. this.selectors[selectorNb].children[0].color = color;
  10082. };
  10083. /** @hidden */
  10084. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10085. this.selectors[selectorNb].children[0].background = color;
  10086. };
  10087. return RadioGroup;
  10088. }(SelectorGroup));
  10089. /** Class used to create a SliderGroup
  10090. * which contains groups of slider buttons
  10091. */
  10092. var SliderGroup = /** @class */ (function (_super) {
  10093. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  10094. function SliderGroup() {
  10095. return _super !== null && _super.apply(this, arguments) || this;
  10096. }
  10097. /**
  10098. * Adds a slider to the SelectorGroup
  10099. * @param label is the label for the SliderBar
  10100. * @param func is the function called when the Slider moves
  10101. * @param unit is a string describing the units used, eg degrees or metres
  10102. * @param min is the minimum value for the Slider
  10103. * @param max is the maximum value for the Slider
  10104. * @param value is the start value for the Slider between min and max
  10105. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  10106. */
  10107. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  10108. if (func === void 0) { func = function (v) { }; }
  10109. if (unit === void 0) { unit = "Units"; }
  10110. if (min === void 0) { min = 0; }
  10111. if (max === void 0) { max = 0; }
  10112. if (value === void 0) { value = 0; }
  10113. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  10114. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  10115. button.name = unit;
  10116. button.value = value;
  10117. button.minimum = min;
  10118. button.maximum = max;
  10119. button.width = 0.9;
  10120. button.height = "20px";
  10121. button.color = "#364249";
  10122. button.background = "#CCCCCC";
  10123. button.borderColor = "black";
  10124. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10125. button.left = "4px";
  10126. button.paddingBottom = "4px";
  10127. button.onValueChangedObservable.add(function (value) {
  10128. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  10129. func(value);
  10130. });
  10131. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  10132. _selector.height = "60px";
  10133. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10134. _selector.left = "4px";
  10135. _selector.children[0].name = label;
  10136. this.groupPanel.addControl(_selector);
  10137. this.selectors.push(_selector);
  10138. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10139. button.color = this.groupPanel.parent.parent.buttonColor;
  10140. button.background = this.groupPanel.parent.parent.buttonBackground;
  10141. }
  10142. };
  10143. /** @hidden */
  10144. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10145. this.selectors[selectorNb].children[0].name = label;
  10146. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  10147. };
  10148. /** @hidden */
  10149. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10150. this.selectors[selectorNb].children[0].color = color;
  10151. };
  10152. /** @hidden */
  10153. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10154. this.selectors[selectorNb].children[1].color = color;
  10155. };
  10156. /** @hidden */
  10157. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10158. this.selectors[selectorNb].children[1].background = color;
  10159. };
  10160. return SliderGroup;
  10161. }(SelectorGroup));
  10162. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  10163. * @see http://doc.babylonjs.com/how_to/selector
  10164. */
  10165. var SelectionPanel = /** @class */ (function (_super) {
  10166. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  10167. /**
  10168. * Creates a new SelectionPanel
  10169. * @param name of SelectionPanel
  10170. * @param groups is an array of SelectionGroups
  10171. */
  10172. function SelectionPanel(
  10173. /** name of SelectionPanel */
  10174. name,
  10175. /** an array of SelectionGroups */
  10176. groups) {
  10177. if (groups === void 0) { groups = []; }
  10178. var _this = _super.call(this, name) || this;
  10179. _this.name = name;
  10180. _this.groups = groups;
  10181. _this._buttonColor = "#364249";
  10182. _this._buttonBackground = "#CCCCCC";
  10183. _this._headerColor = "black";
  10184. _this._barColor = "white";
  10185. _this._barHeight = "2px";
  10186. _this._spacerHeight = "20px";
  10187. _this._bars = new Array();
  10188. _this._groups = groups;
  10189. _this.thickness = 2;
  10190. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10191. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10192. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10193. _this._panel.top = 5;
  10194. _this._panel.left = 5;
  10195. _this._panel.width = 0.95;
  10196. if (groups.length > 0) {
  10197. for (var i = 0; i < groups.length - 1; i++) {
  10198. _this._panel.addControl(groups[i].groupPanel);
  10199. _this._addSpacer();
  10200. }
  10201. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  10202. }
  10203. _this.addControl(_this._panel);
  10204. return _this;
  10205. }
  10206. SelectionPanel.prototype._getTypeName = function () {
  10207. return "SelectionPanel";
  10208. };
  10209. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  10210. /** Gets or sets the headerColor */
  10211. get: function () {
  10212. return this._headerColor;
  10213. },
  10214. set: function (color) {
  10215. if (this._headerColor === color) {
  10216. return;
  10217. }
  10218. this._headerColor = color;
  10219. this._setHeaderColor();
  10220. },
  10221. enumerable: true,
  10222. configurable: true
  10223. });
  10224. SelectionPanel.prototype._setHeaderColor = function () {
  10225. for (var i = 0; i < this._groups.length; i++) {
  10226. this._groups[i].groupPanel.children[0].color = this._headerColor;
  10227. }
  10228. };
  10229. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  10230. /** Gets or sets the button color */
  10231. get: function () {
  10232. return this._buttonColor;
  10233. },
  10234. set: function (color) {
  10235. if (this._buttonColor === color) {
  10236. return;
  10237. }
  10238. this._buttonColor = color;
  10239. this._setbuttonColor();
  10240. },
  10241. enumerable: true,
  10242. configurable: true
  10243. });
  10244. SelectionPanel.prototype._setbuttonColor = function () {
  10245. for (var i = 0; i < this._groups.length; i++) {
  10246. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10247. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  10248. }
  10249. }
  10250. };
  10251. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  10252. /** Gets or sets the label color */
  10253. get: function () {
  10254. return this._labelColor;
  10255. },
  10256. set: function (color) {
  10257. if (this._labelColor === color) {
  10258. return;
  10259. }
  10260. this._labelColor = color;
  10261. this._setLabelColor();
  10262. },
  10263. enumerable: true,
  10264. configurable: true
  10265. });
  10266. SelectionPanel.prototype._setLabelColor = function () {
  10267. for (var i = 0; i < this._groups.length; i++) {
  10268. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10269. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  10270. }
  10271. }
  10272. };
  10273. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  10274. /** Gets or sets the button background */
  10275. get: function () {
  10276. return this._buttonBackground;
  10277. },
  10278. set: function (color) {
  10279. if (this._buttonBackground === color) {
  10280. return;
  10281. }
  10282. this._buttonBackground = color;
  10283. this._setButtonBackground();
  10284. },
  10285. enumerable: true,
  10286. configurable: true
  10287. });
  10288. SelectionPanel.prototype._setButtonBackground = function () {
  10289. for (var i = 0; i < this._groups.length; i++) {
  10290. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10291. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  10292. }
  10293. }
  10294. };
  10295. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  10296. /** Gets or sets the color of separator bar */
  10297. get: function () {
  10298. return this._barColor;
  10299. },
  10300. set: function (color) {
  10301. if (this._barColor === color) {
  10302. return;
  10303. }
  10304. this._barColor = color;
  10305. this._setBarColor();
  10306. },
  10307. enumerable: true,
  10308. configurable: true
  10309. });
  10310. SelectionPanel.prototype._setBarColor = function () {
  10311. for (var i = 0; i < this._bars.length; i++) {
  10312. this._bars[i].children[0].background = this._barColor;
  10313. }
  10314. };
  10315. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  10316. /** Gets or sets the height of separator bar */
  10317. get: function () {
  10318. return this._barHeight;
  10319. },
  10320. set: function (value) {
  10321. if (this._barHeight === value) {
  10322. return;
  10323. }
  10324. this._barHeight = value;
  10325. this._setBarHeight();
  10326. },
  10327. enumerable: true,
  10328. configurable: true
  10329. });
  10330. SelectionPanel.prototype._setBarHeight = function () {
  10331. for (var i = 0; i < this._bars.length; i++) {
  10332. this._bars[i].children[0].height = this._barHeight;
  10333. }
  10334. };
  10335. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  10336. /** Gets or sets the height of spacers*/
  10337. get: function () {
  10338. return this._spacerHeight;
  10339. },
  10340. set: function (value) {
  10341. if (this._spacerHeight === value) {
  10342. return;
  10343. }
  10344. this._spacerHeight = value;
  10345. this._setSpacerHeight();
  10346. },
  10347. enumerable: true,
  10348. configurable: true
  10349. });
  10350. SelectionPanel.prototype._setSpacerHeight = function () {
  10351. for (var i = 0; i < this._bars.length; i++) {
  10352. this._bars[i].height = this._spacerHeight;
  10353. }
  10354. };
  10355. /** Adds a bar between groups */
  10356. SelectionPanel.prototype._addSpacer = function () {
  10357. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  10358. separator.width = 1;
  10359. separator.height = this._spacerHeight;
  10360. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10361. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  10362. bar.width = 1;
  10363. bar.height = this._barHeight;
  10364. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10365. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10366. bar.background = this._barColor;
  10367. bar.color = "transparent";
  10368. separator.addControl(bar);
  10369. this._panel.addControl(separator);
  10370. this._bars.push(separator);
  10371. };
  10372. /** Add a group to the selection panel
  10373. * @param group is the selector group to add
  10374. */
  10375. SelectionPanel.prototype.addGroup = function (group) {
  10376. if (this._groups.length > 0) {
  10377. this._addSpacer();
  10378. }
  10379. this._panel.addControl(group.groupPanel);
  10380. this._groups.push(group);
  10381. group.groupPanel.children[0].color = this._headerColor;
  10382. for (var j = 0; j < group.selectors.length; j++) {
  10383. group._setSelectorButtonColor(j, this._buttonColor);
  10384. group._setSelectorButtonBackground(j, this._buttonBackground);
  10385. }
  10386. };
  10387. /** Remove the group from the given position
  10388. * @param groupNb is the position of the group in the list
  10389. */
  10390. SelectionPanel.prototype.removeGroup = function (groupNb) {
  10391. if (groupNb < 0 || groupNb >= this._groups.length) {
  10392. return;
  10393. }
  10394. var group = this._groups[groupNb];
  10395. this._panel.removeControl(group.groupPanel);
  10396. this._groups.splice(groupNb, 1);
  10397. if (groupNb < this._bars.length) {
  10398. this._panel.removeControl(this._bars[groupNb]);
  10399. this._bars.splice(groupNb, 1);
  10400. }
  10401. };
  10402. /** Change a group header label
  10403. * @param label is the new group header label
  10404. * @param groupNb is the number of the group to relabel
  10405. * */
  10406. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  10407. if (groupNb < 0 || groupNb >= this._groups.length) {
  10408. return;
  10409. }
  10410. var group = this._groups[groupNb];
  10411. group.groupPanel.children[0].text = label;
  10412. };
  10413. /** Change selector label to the one given
  10414. * @param label is the new selector label
  10415. * @param groupNb is the number of the groupcontaining the selector
  10416. * @param selectorNb is the number of the selector within a group to relabel
  10417. * */
  10418. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  10419. if (groupNb < 0 || groupNb >= this._groups.length) {
  10420. return;
  10421. }
  10422. var group = this._groups[groupNb];
  10423. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10424. return;
  10425. }
  10426. group._setSelectorLabel(selectorNb, label);
  10427. };
  10428. /** For a given group position remove the selector at the given position
  10429. * @param groupNb is the number of the group to remove the selector from
  10430. * @param selectorNb is the number of the selector within the group
  10431. */
  10432. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  10433. if (groupNb < 0 || groupNb >= this._groups.length) {
  10434. return;
  10435. }
  10436. var group = this._groups[groupNb];
  10437. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10438. return;
  10439. }
  10440. group.removeSelector(selectorNb);
  10441. };
  10442. /** For a given group position of correct type add a checkbox button
  10443. * @param groupNb is the number of the group to remove the selector from
  10444. * @param label is the label for the selector
  10445. * @param func is the function called when the Selector is checked
  10446. * @param checked is true when Selector is checked
  10447. */
  10448. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  10449. if (func === void 0) { func = function () { }; }
  10450. if (checked === void 0) { checked = false; }
  10451. if (groupNb < 0 || groupNb >= this._groups.length) {
  10452. return;
  10453. }
  10454. var group = this._groups[groupNb];
  10455. group.addCheckbox(label, func, checked);
  10456. };
  10457. /** For a given group position of correct type add a radio button
  10458. * @param groupNb is the number of the group to remove the selector from
  10459. * @param label is the label for the selector
  10460. * @param func is the function called when the Selector is checked
  10461. * @param checked is true when Selector is checked
  10462. */
  10463. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  10464. if (func === void 0) { func = function () { }; }
  10465. if (checked === void 0) { checked = false; }
  10466. if (groupNb < 0 || groupNb >= this._groups.length) {
  10467. return;
  10468. }
  10469. var group = this._groups[groupNb];
  10470. group.addRadio(label, func, checked);
  10471. };
  10472. /**
  10473. * For a given slider group add a slider
  10474. * @param groupNb is the number of the group to add the slider to
  10475. * @param label is the label for the Slider
  10476. * @param func is the function called when the Slider moves
  10477. * @param unit is a string describing the units used, eg degrees or metres
  10478. * @param min is the minimum value for the Slider
  10479. * @param max is the maximum value for the Slider
  10480. * @param value is the start value for the Slider between min and max
  10481. * @param onVal is the function used to format the value displayed, eg radians to degrees
  10482. */
  10483. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  10484. if (func === void 0) { func = function () { }; }
  10485. if (unit === void 0) { unit = "Units"; }
  10486. if (min === void 0) { min = 0; }
  10487. if (max === void 0) { max = 0; }
  10488. if (value === void 0) { value = 0; }
  10489. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  10490. if (groupNb < 0 || groupNb >= this._groups.length) {
  10491. return;
  10492. }
  10493. var group = this._groups[groupNb];
  10494. group.addSlider(label, func, unit, min, max, value, onVal);
  10495. };
  10496. return SelectionPanel;
  10497. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10498. /***/ }),
  10499. /***/ "./2D/controls/sliders/baseSlider.ts":
  10500. /*!*******************************************!*\
  10501. !*** ./2D/controls/sliders/baseSlider.ts ***!
  10502. \*******************************************/
  10503. /*! exports provided: BaseSlider */
  10504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10505. "use strict";
  10506. __webpack_require__.r(__webpack_exports__);
  10507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  10508. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10509. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  10510. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10511. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10512. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10513. /**
  10514. * Class used to create slider controls
  10515. */
  10516. var BaseSlider = /** @class */ (function (_super) {
  10517. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  10518. /**
  10519. * Creates a new BaseSlider
  10520. * @param name defines the control name
  10521. */
  10522. function BaseSlider(name) {
  10523. var _this = _super.call(this, name) || this;
  10524. _this.name = name;
  10525. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10526. _this._minimum = 0;
  10527. _this._maximum = 100;
  10528. _this._value = 50;
  10529. _this._isVertical = false;
  10530. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10531. _this._isThumbClamped = false;
  10532. _this._displayThumb = true;
  10533. _this._step = 0;
  10534. _this._lastPointerDownID = -1;
  10535. // Shared rendering info
  10536. _this._effectiveBarOffset = 0;
  10537. /** Observable raised when the sldier value changes */
  10538. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10539. // Events
  10540. _this._pointerIsDown = false;
  10541. _this.isPointerBlocker = true;
  10542. return _this;
  10543. }
  10544. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10545. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10546. get: function () {
  10547. return this._displayThumb;
  10548. },
  10549. set: function (value) {
  10550. if (this._displayThumb === value) {
  10551. return;
  10552. }
  10553. this._displayThumb = value;
  10554. this._markAsDirty();
  10555. },
  10556. enumerable: true,
  10557. configurable: true
  10558. });
  10559. Object.defineProperty(BaseSlider.prototype, "step", {
  10560. /** Gets or sets a step to apply to values (0 by default) */
  10561. get: function () {
  10562. return this._step;
  10563. },
  10564. set: function (value) {
  10565. if (this._step === value) {
  10566. return;
  10567. }
  10568. this._step = value;
  10569. this._markAsDirty();
  10570. },
  10571. enumerable: true,
  10572. configurable: true
  10573. });
  10574. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10575. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10576. get: function () {
  10577. return this._barOffset.toString(this._host);
  10578. },
  10579. set: function (value) {
  10580. if (this._barOffset.toString(this._host) === value) {
  10581. return;
  10582. }
  10583. if (this._barOffset.fromString(value)) {
  10584. this._markAsDirty();
  10585. }
  10586. },
  10587. enumerable: true,
  10588. configurable: true
  10589. });
  10590. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10591. /** Gets main bar offset in pixels*/
  10592. get: function () {
  10593. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10594. },
  10595. enumerable: true,
  10596. configurable: true
  10597. });
  10598. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10599. /** Gets or sets thumb width */
  10600. get: function () {
  10601. return this._thumbWidth.toString(this._host);
  10602. },
  10603. set: function (value) {
  10604. if (this._thumbWidth.toString(this._host) === value) {
  10605. return;
  10606. }
  10607. if (this._thumbWidth.fromString(value)) {
  10608. this._markAsDirty();
  10609. }
  10610. },
  10611. enumerable: true,
  10612. configurable: true
  10613. });
  10614. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10615. /** Gets thumb width in pixels */
  10616. get: function () {
  10617. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10618. },
  10619. enumerable: true,
  10620. configurable: true
  10621. });
  10622. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10623. /** Gets or sets minimum value */
  10624. get: function () {
  10625. return this._minimum;
  10626. },
  10627. set: function (value) {
  10628. if (this._minimum === value) {
  10629. return;
  10630. }
  10631. this._minimum = value;
  10632. this._markAsDirty();
  10633. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10634. },
  10635. enumerable: true,
  10636. configurable: true
  10637. });
  10638. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10639. /** Gets or sets maximum value */
  10640. get: function () {
  10641. return this._maximum;
  10642. },
  10643. set: function (value) {
  10644. if (this._maximum === value) {
  10645. return;
  10646. }
  10647. this._maximum = value;
  10648. this._markAsDirty();
  10649. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10650. },
  10651. enumerable: true,
  10652. configurable: true
  10653. });
  10654. Object.defineProperty(BaseSlider.prototype, "value", {
  10655. /** Gets or sets current value */
  10656. get: function () {
  10657. return this._value;
  10658. },
  10659. set: function (value) {
  10660. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10661. if (this._value === value) {
  10662. return;
  10663. }
  10664. this._value = value;
  10665. this._markAsDirty();
  10666. this.onValueChangedObservable.notifyObservers(this._value);
  10667. },
  10668. enumerable: true,
  10669. configurable: true
  10670. });
  10671. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10672. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10673. get: function () {
  10674. return this._isVertical;
  10675. },
  10676. set: function (value) {
  10677. if (this._isVertical === value) {
  10678. return;
  10679. }
  10680. this._isVertical = value;
  10681. this._markAsDirty();
  10682. },
  10683. enumerable: true,
  10684. configurable: true
  10685. });
  10686. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10687. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10688. get: function () {
  10689. return this._isThumbClamped;
  10690. },
  10691. set: function (value) {
  10692. if (this._isThumbClamped === value) {
  10693. return;
  10694. }
  10695. this._isThumbClamped = value;
  10696. this._markAsDirty();
  10697. },
  10698. enumerable: true,
  10699. configurable: true
  10700. });
  10701. BaseSlider.prototype._getTypeName = function () {
  10702. return "BaseSlider";
  10703. };
  10704. BaseSlider.prototype._getThumbPosition = function () {
  10705. if (this.isVertical) {
  10706. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10707. }
  10708. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10709. };
  10710. BaseSlider.prototype._getThumbThickness = function (type) {
  10711. var thumbThickness = 0;
  10712. switch (type) {
  10713. case "circle":
  10714. if (this._thumbWidth.isPixel) {
  10715. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10716. }
  10717. else {
  10718. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10719. }
  10720. break;
  10721. case "rectangle":
  10722. if (this._thumbWidth.isPixel) {
  10723. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10724. }
  10725. else {
  10726. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10727. }
  10728. }
  10729. return thumbThickness;
  10730. };
  10731. BaseSlider.prototype._prepareRenderingData = function (type) {
  10732. // Main bar
  10733. this._effectiveBarOffset = 0;
  10734. this._renderLeft = this._currentMeasure.left;
  10735. this._renderTop = this._currentMeasure.top;
  10736. this._renderWidth = this._currentMeasure.width;
  10737. this._renderHeight = this._currentMeasure.height;
  10738. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10739. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10740. this._effectiveThumbThickness = this._getThumbThickness(type);
  10741. if (this.displayThumb) {
  10742. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10743. }
  10744. //throw error when height is less than width for vertical slider
  10745. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10746. console.error("Height should be greater than width");
  10747. return;
  10748. }
  10749. if (this._barOffset.isPixel) {
  10750. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10751. }
  10752. else {
  10753. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10754. }
  10755. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10756. if (this.isVertical) {
  10757. this._renderLeft += this._effectiveBarOffset;
  10758. if (!this.isThumbClamped && this.displayThumb) {
  10759. this._renderTop += (this._effectiveThumbThickness / 2);
  10760. }
  10761. this._renderHeight = this._backgroundBoxLength;
  10762. this._renderWidth = this._backgroundBoxThickness;
  10763. }
  10764. else {
  10765. this._renderTop += this._effectiveBarOffset;
  10766. if (!this.isThumbClamped && this.displayThumb) {
  10767. this._renderLeft += (this._effectiveThumbThickness / 2);
  10768. }
  10769. this._renderHeight = this._backgroundBoxThickness;
  10770. this._renderWidth = this._backgroundBoxLength;
  10771. }
  10772. };
  10773. /** @hidden */
  10774. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10775. if (this.rotation != 0) {
  10776. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10777. x = this._transformedPosition.x;
  10778. y = this._transformedPosition.y;
  10779. }
  10780. var value;
  10781. if (this._isVertical) {
  10782. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10783. }
  10784. else {
  10785. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10786. }
  10787. var mult = (1 / this._step) | 0;
  10788. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10789. };
  10790. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10791. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10792. return false;
  10793. }
  10794. this._pointerIsDown = true;
  10795. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10796. this._host._capturingControl[pointerId] = this;
  10797. this._lastPointerDownID = pointerId;
  10798. return true;
  10799. };
  10800. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10801. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10802. if (pointerId != this._lastPointerDownID) {
  10803. return;
  10804. }
  10805. if (this._pointerIsDown) {
  10806. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10807. }
  10808. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10809. };
  10810. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10811. this._pointerIsDown = false;
  10812. delete this._host._capturingControl[pointerId];
  10813. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10814. };
  10815. return BaseSlider;
  10816. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10817. /***/ }),
  10818. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10819. /*!*************************************************!*\
  10820. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10821. \*************************************************/
  10822. /*! exports provided: ImageBasedSlider */
  10823. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10824. "use strict";
  10825. __webpack_require__.r(__webpack_exports__);
  10826. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10827. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10828. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10829. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10830. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  10831. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10832. /**
  10833. * Class used to create slider controls based on images
  10834. */
  10835. var ImageBasedSlider = /** @class */ (function (_super) {
  10836. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  10837. /**
  10838. * Creates a new ImageBasedSlider
  10839. * @param name defines the control name
  10840. */
  10841. function ImageBasedSlider(name) {
  10842. var _this = _super.call(this, name) || this;
  10843. _this.name = name;
  10844. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10845. return _this;
  10846. }
  10847. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10848. get: function () {
  10849. return this._displayThumb && this.thumbImage != null;
  10850. },
  10851. set: function (value) {
  10852. if (this._displayThumb === value) {
  10853. return;
  10854. }
  10855. this._displayThumb = value;
  10856. this._markAsDirty();
  10857. },
  10858. enumerable: true,
  10859. configurable: true
  10860. });
  10861. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10862. /**
  10863. * Gets or sets the image used to render the background
  10864. */
  10865. get: function () {
  10866. return this._backgroundImage;
  10867. },
  10868. set: function (value) {
  10869. var _this = this;
  10870. if (this._backgroundImage === value) {
  10871. return;
  10872. }
  10873. this._backgroundImage = value;
  10874. if (value && !value.isLoaded) {
  10875. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10876. }
  10877. this._markAsDirty();
  10878. },
  10879. enumerable: true,
  10880. configurable: true
  10881. });
  10882. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10883. /**
  10884. * Gets or sets the image used to render the value bar
  10885. */
  10886. get: function () {
  10887. return this._valueBarImage;
  10888. },
  10889. set: function (value) {
  10890. var _this = this;
  10891. if (this._valueBarImage === value) {
  10892. return;
  10893. }
  10894. this._valueBarImage = value;
  10895. if (value && !value.isLoaded) {
  10896. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10897. }
  10898. this._markAsDirty();
  10899. },
  10900. enumerable: true,
  10901. configurable: true
  10902. });
  10903. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10904. /**
  10905. * Gets or sets the image used to render the thumb
  10906. */
  10907. get: function () {
  10908. return this._thumbImage;
  10909. },
  10910. set: function (value) {
  10911. var _this = this;
  10912. if (this._thumbImage === value) {
  10913. return;
  10914. }
  10915. this._thumbImage = value;
  10916. if (value && !value.isLoaded) {
  10917. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10918. }
  10919. this._markAsDirty();
  10920. },
  10921. enumerable: true,
  10922. configurable: true
  10923. });
  10924. ImageBasedSlider.prototype._getTypeName = function () {
  10925. return "ImageBasedSlider";
  10926. };
  10927. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  10928. context.save();
  10929. this._applyStates(context);
  10930. this._prepareRenderingData("rectangle");
  10931. var thumbPosition = this._getThumbPosition();
  10932. var left = this._renderLeft;
  10933. var top = this._renderTop;
  10934. var width = this._renderWidth;
  10935. var height = this._renderHeight;
  10936. // Background
  10937. if (this._backgroundImage) {
  10938. this._tempMeasure.copyFromFloats(left, top, width, height);
  10939. if (this.isThumbClamped && this.displayThumb) {
  10940. if (this.isVertical) {
  10941. this._tempMeasure.height += this._effectiveThumbThickness;
  10942. }
  10943. else {
  10944. this._tempMeasure.width += this._effectiveThumbThickness;
  10945. }
  10946. }
  10947. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10948. this._backgroundImage._draw(context);
  10949. }
  10950. // Bar
  10951. if (this._valueBarImage) {
  10952. if (this.isVertical) {
  10953. if (this.isThumbClamped && this.displayThumb) {
  10954. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10955. }
  10956. else {
  10957. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10958. }
  10959. }
  10960. else {
  10961. if (this.isThumbClamped && this.displayThumb) {
  10962. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10963. }
  10964. else {
  10965. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10966. }
  10967. }
  10968. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10969. this._valueBarImage._draw(context);
  10970. }
  10971. // Thumb
  10972. if (this.displayThumb) {
  10973. if (this.isVertical) {
  10974. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10975. }
  10976. else {
  10977. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10978. }
  10979. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10980. this._thumbImage._draw(context);
  10981. }
  10982. context.restore();
  10983. };
  10984. return ImageBasedSlider;
  10985. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10986. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  10987. /***/ }),
  10988. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  10989. /*!***********************************************!*\
  10990. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  10991. \***********************************************/
  10992. /*! exports provided: ImageScrollBar */
  10993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10994. "use strict";
  10995. __webpack_require__.r(__webpack_exports__);
  10996. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  10997. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10998. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10999. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11000. /**
  11001. * Class used to create slider controls
  11002. */
  11003. var ImageScrollBar = /** @class */ (function (_super) {
  11004. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  11005. /**
  11006. * Creates a new ImageScrollBar
  11007. * @param name defines the control name
  11008. */
  11009. function ImageScrollBar(name) {
  11010. var _this = _super.call(this, name) || this;
  11011. _this.name = name;
  11012. _this._thumbLength = 0.5;
  11013. _this._thumbHeight = 1;
  11014. _this._barImageHeight = 1;
  11015. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11016. return _this;
  11017. }
  11018. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  11019. /**
  11020. * Gets or sets the image used to render the background for horizontal bar
  11021. */
  11022. get: function () {
  11023. return this._backgroundBaseImage;
  11024. },
  11025. set: function (value) {
  11026. var _this = this;
  11027. if (this._backgroundBaseImage === value) {
  11028. return;
  11029. }
  11030. this._backgroundBaseImage = value;
  11031. if (this.isVertical) {
  11032. if (!value.isLoaded) {
  11033. value.onImageLoadedObservable.addOnce(function () {
  11034. var rotatedValue = value._rotate90(1, true);
  11035. _this._backgroundImage = rotatedValue;
  11036. if (!rotatedValue.isLoaded) {
  11037. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11038. _this._markAsDirty();
  11039. });
  11040. }
  11041. _this._markAsDirty();
  11042. });
  11043. }
  11044. else {
  11045. this._backgroundImage = value._rotate90(1, true);
  11046. this._markAsDirty();
  11047. }
  11048. }
  11049. else {
  11050. this._backgroundImage = value;
  11051. if (value && !value.isLoaded) {
  11052. value.onImageLoadedObservable.addOnce(function () {
  11053. _this._markAsDirty();
  11054. });
  11055. }
  11056. this._markAsDirty();
  11057. }
  11058. },
  11059. enumerable: true,
  11060. configurable: true
  11061. });
  11062. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  11063. /**
  11064. * Gets or sets the image used to render the thumb
  11065. */
  11066. get: function () {
  11067. return this._thumbBaseImage;
  11068. },
  11069. set: function (value) {
  11070. var _this = this;
  11071. if (this._thumbBaseImage === value) {
  11072. return;
  11073. }
  11074. this._thumbBaseImage = value;
  11075. if (this.isVertical) {
  11076. if (!value.isLoaded) {
  11077. value.onImageLoadedObservable.addOnce(function () {
  11078. var rotatedValue = value._rotate90(-1, true);
  11079. _this._thumbImage = rotatedValue;
  11080. if (!rotatedValue.isLoaded) {
  11081. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11082. _this._markAsDirty();
  11083. });
  11084. }
  11085. _this._markAsDirty();
  11086. });
  11087. }
  11088. else {
  11089. this._thumbImage = value._rotate90(-1, true);
  11090. this._markAsDirty();
  11091. }
  11092. }
  11093. else {
  11094. this._thumbImage = value;
  11095. if (value && !value.isLoaded) {
  11096. value.onImageLoadedObservable.addOnce(function () {
  11097. _this._markAsDirty();
  11098. });
  11099. }
  11100. this._markAsDirty();
  11101. }
  11102. },
  11103. enumerable: true,
  11104. configurable: true
  11105. });
  11106. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  11107. /**
  11108. * Gets or sets the length of the thumb
  11109. */
  11110. get: function () {
  11111. return this._thumbLength;
  11112. },
  11113. set: function (value) {
  11114. if (this._thumbLength === value) {
  11115. return;
  11116. }
  11117. this._thumbLength = value;
  11118. this._markAsDirty();
  11119. },
  11120. enumerable: true,
  11121. configurable: true
  11122. });
  11123. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  11124. /**
  11125. * Gets or sets the height of the thumb
  11126. */
  11127. get: function () {
  11128. return this._thumbHeight;
  11129. },
  11130. set: function (value) {
  11131. if (this._thumbLength === value) {
  11132. return;
  11133. }
  11134. this._thumbHeight = value;
  11135. this._markAsDirty();
  11136. },
  11137. enumerable: true,
  11138. configurable: true
  11139. });
  11140. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  11141. /**
  11142. * Gets or sets the height of the bar image
  11143. */
  11144. get: function () {
  11145. return this._barImageHeight;
  11146. },
  11147. set: function (value) {
  11148. if (this._barImageHeight === value) {
  11149. return;
  11150. }
  11151. this._barImageHeight = value;
  11152. this._markAsDirty();
  11153. },
  11154. enumerable: true,
  11155. configurable: true
  11156. });
  11157. ImageScrollBar.prototype._getTypeName = function () {
  11158. return "ImageScrollBar";
  11159. };
  11160. ImageScrollBar.prototype._getThumbThickness = function () {
  11161. var thumbThickness = 0;
  11162. if (this._thumbWidth.isPixel) {
  11163. thumbThickness = this._thumbWidth.getValue(this._host);
  11164. }
  11165. else {
  11166. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11167. }
  11168. return thumbThickness;
  11169. };
  11170. ImageScrollBar.prototype._draw = function (context) {
  11171. context.save();
  11172. this._applyStates(context);
  11173. this._prepareRenderingData("rectangle");
  11174. var thumbPosition = this._getThumbPosition();
  11175. var left = this._renderLeft;
  11176. var top = this._renderTop;
  11177. var width = this._renderWidth;
  11178. var height = this._renderHeight;
  11179. // Background
  11180. if (this._backgroundImage) {
  11181. this._tempMeasure.copyFromFloats(left, top, width, height);
  11182. if (this.isVertical) {
  11183. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  11184. this._tempMeasure.height += this._effectiveThumbThickness;
  11185. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11186. }
  11187. else {
  11188. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  11189. this._tempMeasure.width += this._effectiveThumbThickness;
  11190. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11191. }
  11192. this._backgroundImage._draw(context);
  11193. }
  11194. // Thumb
  11195. if (this.isVertical) {
  11196. 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);
  11197. }
  11198. else {
  11199. 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);
  11200. }
  11201. if (this._thumbImage) {
  11202. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11203. this._thumbImage._draw(context);
  11204. }
  11205. context.restore();
  11206. };
  11207. /** @hidden */
  11208. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11209. if (this.rotation != 0) {
  11210. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11211. x = this._transformedPosition.x;
  11212. y = this._transformedPosition.y;
  11213. }
  11214. if (this._first) {
  11215. this._first = false;
  11216. this._originX = x;
  11217. this._originY = y;
  11218. // Check if move is required
  11219. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11220. if (this.isVertical) {
  11221. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11222. }
  11223. else {
  11224. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11225. }
  11226. }
  11227. }
  11228. // Delta mode
  11229. var delta = 0;
  11230. if (this.isVertical) {
  11231. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11232. }
  11233. else {
  11234. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11235. }
  11236. this.value += delta * (this.maximum - this.minimum);
  11237. this._originX = x;
  11238. this._originY = y;
  11239. };
  11240. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11241. this._first = true;
  11242. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11243. };
  11244. return ImageScrollBar;
  11245. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11246. /***/ }),
  11247. /***/ "./2D/controls/sliders/scrollBar.ts":
  11248. /*!******************************************!*\
  11249. !*** ./2D/controls/sliders/scrollBar.ts ***!
  11250. \******************************************/
  11251. /*! exports provided: ScrollBar */
  11252. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11253. "use strict";
  11254. __webpack_require__.r(__webpack_exports__);
  11255. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  11256. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11257. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11258. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11259. /**
  11260. * Class used to create slider controls
  11261. */
  11262. var ScrollBar = /** @class */ (function (_super) {
  11263. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  11264. /**
  11265. * Creates a new Slider
  11266. * @param name defines the control name
  11267. */
  11268. function ScrollBar(name) {
  11269. var _this = _super.call(this, name) || this;
  11270. _this.name = name;
  11271. _this._background = "black";
  11272. _this._borderColor = "white";
  11273. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11274. return _this;
  11275. }
  11276. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  11277. /** Gets or sets border color */
  11278. get: function () {
  11279. return this._borderColor;
  11280. },
  11281. set: function (value) {
  11282. if (this._borderColor === value) {
  11283. return;
  11284. }
  11285. this._borderColor = value;
  11286. this._markAsDirty();
  11287. },
  11288. enumerable: true,
  11289. configurable: true
  11290. });
  11291. Object.defineProperty(ScrollBar.prototype, "background", {
  11292. /** Gets or sets background color */
  11293. get: function () {
  11294. return this._background;
  11295. },
  11296. set: function (value) {
  11297. if (this._background === value) {
  11298. return;
  11299. }
  11300. this._background = value;
  11301. this._markAsDirty();
  11302. },
  11303. enumerable: true,
  11304. configurable: true
  11305. });
  11306. ScrollBar.prototype._getTypeName = function () {
  11307. return "Scrollbar";
  11308. };
  11309. ScrollBar.prototype._getThumbThickness = function () {
  11310. var thumbThickness = 0;
  11311. if (this._thumbWidth.isPixel) {
  11312. thumbThickness = this._thumbWidth.getValue(this._host);
  11313. }
  11314. else {
  11315. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11316. }
  11317. return thumbThickness;
  11318. };
  11319. ScrollBar.prototype._draw = function (context) {
  11320. context.save();
  11321. this._applyStates(context);
  11322. this._prepareRenderingData("rectangle");
  11323. var left = this._renderLeft;
  11324. var thumbPosition = this._getThumbPosition();
  11325. context.fillStyle = this._background;
  11326. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  11327. // Value bar
  11328. context.fillStyle = this.color;
  11329. // Thumb
  11330. if (this.isVertical) {
  11331. this._tempMeasure.left = left - this._effectiveBarOffset;
  11332. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  11333. this._tempMeasure.width = this._currentMeasure.width;
  11334. this._tempMeasure.height = this._effectiveThumbThickness;
  11335. }
  11336. else {
  11337. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  11338. this._tempMeasure.top = this._currentMeasure.top;
  11339. this._tempMeasure.width = this._effectiveThumbThickness;
  11340. this._tempMeasure.height = this._currentMeasure.height;
  11341. }
  11342. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  11343. context.restore();
  11344. };
  11345. /** @hidden */
  11346. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11347. if (this.rotation != 0) {
  11348. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11349. x = this._transformedPosition.x;
  11350. y = this._transformedPosition.y;
  11351. }
  11352. if (this._first) {
  11353. this._first = false;
  11354. this._originX = x;
  11355. this._originY = y;
  11356. // Check if move is required
  11357. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11358. if (this.isVertical) {
  11359. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11360. }
  11361. else {
  11362. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11363. }
  11364. }
  11365. }
  11366. // Delta mode
  11367. var delta = 0;
  11368. if (this.isVertical) {
  11369. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11370. }
  11371. else {
  11372. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11373. }
  11374. this.value += delta * (this.maximum - this.minimum);
  11375. this._originX = x;
  11376. this._originY = y;
  11377. };
  11378. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11379. this._first = true;
  11380. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11381. };
  11382. return ScrollBar;
  11383. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11384. /***/ }),
  11385. /***/ "./2D/controls/sliders/slider.ts":
  11386. /*!***************************************!*\
  11387. !*** ./2D/controls/sliders/slider.ts ***!
  11388. \***************************************/
  11389. /*! exports provided: Slider */
  11390. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11391. "use strict";
  11392. __webpack_require__.r(__webpack_exports__);
  11393. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  11394. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11395. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11396. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  11397. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  11398. /**
  11399. * Class used to create slider controls
  11400. */
  11401. var Slider = /** @class */ (function (_super) {
  11402. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  11403. /**
  11404. * Creates a new Slider
  11405. * @param name defines the control name
  11406. */
  11407. function Slider(name) {
  11408. var _this = _super.call(this, name) || this;
  11409. _this.name = name;
  11410. _this._background = "black";
  11411. _this._borderColor = "white";
  11412. _this._isThumbCircle = false;
  11413. _this._displayValueBar = true;
  11414. return _this;
  11415. }
  11416. Object.defineProperty(Slider.prototype, "displayValueBar", {
  11417. /** Gets or sets a boolean indicating if the value bar must be rendered */
  11418. get: function () {
  11419. return this._displayValueBar;
  11420. },
  11421. set: function (value) {
  11422. if (this._displayValueBar === value) {
  11423. return;
  11424. }
  11425. this._displayValueBar = value;
  11426. this._markAsDirty();
  11427. },
  11428. enumerable: true,
  11429. configurable: true
  11430. });
  11431. Object.defineProperty(Slider.prototype, "borderColor", {
  11432. /** Gets or sets border color */
  11433. get: function () {
  11434. return this._borderColor;
  11435. },
  11436. set: function (value) {
  11437. if (this._borderColor === value) {
  11438. return;
  11439. }
  11440. this._borderColor = value;
  11441. this._markAsDirty();
  11442. },
  11443. enumerable: true,
  11444. configurable: true
  11445. });
  11446. Object.defineProperty(Slider.prototype, "background", {
  11447. /** Gets or sets background color */
  11448. get: function () {
  11449. return this._background;
  11450. },
  11451. set: function (value) {
  11452. if (this._background === value) {
  11453. return;
  11454. }
  11455. this._background = value;
  11456. this._markAsDirty();
  11457. },
  11458. enumerable: true,
  11459. configurable: true
  11460. });
  11461. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  11462. /** Gets or sets a boolean indicating if the thumb should be round or square */
  11463. get: function () {
  11464. return this._isThumbCircle;
  11465. },
  11466. set: function (value) {
  11467. if (this._isThumbCircle === value) {
  11468. return;
  11469. }
  11470. this._isThumbCircle = value;
  11471. this._markAsDirty();
  11472. },
  11473. enumerable: true,
  11474. configurable: true
  11475. });
  11476. Slider.prototype._getTypeName = function () {
  11477. return "Slider";
  11478. };
  11479. Slider.prototype._draw = function (context, invalidatedRectangle) {
  11480. context.save();
  11481. this._applyStates(context);
  11482. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  11483. var left = this._renderLeft;
  11484. var top = this._renderTop;
  11485. var width = this._renderWidth;
  11486. var height = this._renderHeight;
  11487. var radius = 0;
  11488. if (this.isThumbClamped && this.isThumbCircle) {
  11489. if (this.isVertical) {
  11490. top += (this._effectiveThumbThickness / 2);
  11491. }
  11492. else {
  11493. left += (this._effectiveThumbThickness / 2);
  11494. }
  11495. radius = this._backgroundBoxThickness / 2;
  11496. }
  11497. else {
  11498. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  11499. }
  11500. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11501. context.shadowColor = this.shadowColor;
  11502. context.shadowBlur = this.shadowBlur;
  11503. context.shadowOffsetX = this.shadowOffsetX;
  11504. context.shadowOffsetY = this.shadowOffsetY;
  11505. }
  11506. var thumbPosition = this._getThumbPosition();
  11507. context.fillStyle = this._background;
  11508. if (this.isVertical) {
  11509. if (this.isThumbClamped) {
  11510. if (this.isThumbCircle) {
  11511. context.beginPath();
  11512. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  11513. context.fill();
  11514. context.fillRect(left, top, width, height);
  11515. }
  11516. else {
  11517. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  11518. }
  11519. }
  11520. else {
  11521. context.fillRect(left, top, width, height);
  11522. }
  11523. }
  11524. else {
  11525. if (this.isThumbClamped) {
  11526. if (this.isThumbCircle) {
  11527. context.beginPath();
  11528. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11529. context.fill();
  11530. context.fillRect(left, top, width, height);
  11531. }
  11532. else {
  11533. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  11534. }
  11535. }
  11536. else {
  11537. context.fillRect(left, top, width, height);
  11538. }
  11539. }
  11540. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11541. context.shadowBlur = 0;
  11542. context.shadowOffsetX = 0;
  11543. context.shadowOffsetY = 0;
  11544. }
  11545. // Value bar
  11546. context.fillStyle = this.color;
  11547. if (this._displayValueBar) {
  11548. if (this.isVertical) {
  11549. if (this.isThumbClamped) {
  11550. if (this.isThumbCircle) {
  11551. context.beginPath();
  11552. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  11553. context.fill();
  11554. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11555. }
  11556. else {
  11557. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11558. }
  11559. }
  11560. else {
  11561. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11562. }
  11563. }
  11564. else {
  11565. if (this.isThumbClamped) {
  11566. if (this.isThumbCircle) {
  11567. context.beginPath();
  11568. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  11569. context.fill();
  11570. context.fillRect(left, top, thumbPosition, height);
  11571. }
  11572. else {
  11573. context.fillRect(left, top, thumbPosition, height);
  11574. }
  11575. }
  11576. else {
  11577. context.fillRect(left, top, thumbPosition, height);
  11578. }
  11579. }
  11580. }
  11581. // Thumb
  11582. if (this.displayThumb) {
  11583. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11584. context.shadowColor = this.shadowColor;
  11585. context.shadowBlur = this.shadowBlur;
  11586. context.shadowOffsetX = this.shadowOffsetX;
  11587. context.shadowOffsetY = this.shadowOffsetY;
  11588. }
  11589. if (this._isThumbCircle) {
  11590. context.beginPath();
  11591. if (this.isVertical) {
  11592. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11593. }
  11594. else {
  11595. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11596. }
  11597. context.fill();
  11598. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11599. context.shadowBlur = 0;
  11600. context.shadowOffsetX = 0;
  11601. context.shadowOffsetY = 0;
  11602. }
  11603. context.strokeStyle = this._borderColor;
  11604. context.stroke();
  11605. }
  11606. else {
  11607. if (this.isVertical) {
  11608. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11609. }
  11610. else {
  11611. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11612. }
  11613. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11614. context.shadowBlur = 0;
  11615. context.shadowOffsetX = 0;
  11616. context.shadowOffsetY = 0;
  11617. }
  11618. context.strokeStyle = this._borderColor;
  11619. if (this.isVertical) {
  11620. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11621. }
  11622. else {
  11623. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11624. }
  11625. }
  11626. }
  11627. context.restore();
  11628. };
  11629. return Slider;
  11630. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11631. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11632. /***/ }),
  11633. /***/ "./2D/controls/stackPanel.ts":
  11634. /*!***********************************!*\
  11635. !*** ./2D/controls/stackPanel.ts ***!
  11636. \***********************************/
  11637. /*! exports provided: StackPanel */
  11638. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11639. "use strict";
  11640. __webpack_require__.r(__webpack_exports__);
  11641. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11642. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11643. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  11644. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11645. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11646. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11647. /**
  11648. * Class used to create a 2D stack panel container
  11649. */
  11650. var StackPanel = /** @class */ (function (_super) {
  11651. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11652. /**
  11653. * Creates a new StackPanel
  11654. * @param name defines control name
  11655. */
  11656. function StackPanel(name) {
  11657. var _this = _super.call(this, name) || this;
  11658. _this.name = name;
  11659. _this._isVertical = true;
  11660. _this._manualWidth = false;
  11661. _this._manualHeight = false;
  11662. _this._doNotTrackManualChanges = false;
  11663. /**
  11664. * Gets or sets a boolean indicating that layou warnings should be ignored
  11665. */
  11666. _this.ignoreLayoutWarnings = false;
  11667. return _this;
  11668. }
  11669. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11670. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11671. get: function () {
  11672. return this._isVertical;
  11673. },
  11674. set: function (value) {
  11675. if (this._isVertical === value) {
  11676. return;
  11677. }
  11678. this._isVertical = value;
  11679. this._markAsDirty();
  11680. },
  11681. enumerable: true,
  11682. configurable: true
  11683. });
  11684. Object.defineProperty(StackPanel.prototype, "width", {
  11685. get: function () {
  11686. return this._width.toString(this._host);
  11687. },
  11688. /**
  11689. * Gets or sets panel width.
  11690. * This value should not be set when in horizontal mode as it will be computed automatically
  11691. */
  11692. set: function (value) {
  11693. if (!this._doNotTrackManualChanges) {
  11694. this._manualWidth = true;
  11695. }
  11696. if (this._width.toString(this._host) === value) {
  11697. return;
  11698. }
  11699. if (this._width.fromString(value)) {
  11700. this._markAsDirty();
  11701. }
  11702. },
  11703. enumerable: true,
  11704. configurable: true
  11705. });
  11706. Object.defineProperty(StackPanel.prototype, "height", {
  11707. get: function () {
  11708. return this._height.toString(this._host);
  11709. },
  11710. /**
  11711. * Gets or sets panel height.
  11712. * This value should not be set when in vertical mode as it will be computed automatically
  11713. */
  11714. set: function (value) {
  11715. if (!this._doNotTrackManualChanges) {
  11716. this._manualHeight = true;
  11717. }
  11718. if (this._height.toString(this._host) === value) {
  11719. return;
  11720. }
  11721. if (this._height.fromString(value)) {
  11722. this._markAsDirty();
  11723. }
  11724. },
  11725. enumerable: true,
  11726. configurable: true
  11727. });
  11728. StackPanel.prototype._getTypeName = function () {
  11729. return "StackPanel";
  11730. };
  11731. /** @hidden */
  11732. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11733. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11734. var child = _a[_i];
  11735. if (this._isVertical) {
  11736. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11737. }
  11738. else {
  11739. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11740. }
  11741. }
  11742. _super.prototype._preMeasure.call(this, parentMeasure, context);
  11743. };
  11744. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  11745. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  11746. this._measureForChildren.copyFrom(parentMeasure);
  11747. this._measureForChildren.left = this._currentMeasure.left;
  11748. this._measureForChildren.top = this._currentMeasure.top;
  11749. if (!this.isVertical || this._manualWidth) {
  11750. this._measureForChildren.width = this._currentMeasure.width;
  11751. }
  11752. if (this.isVertical || this._manualHeight) {
  11753. this._measureForChildren.height = this._currentMeasure.height;
  11754. }
  11755. };
  11756. StackPanel.prototype._postMeasure = function () {
  11757. var stackWidth = 0;
  11758. var stackHeight = 0;
  11759. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11760. var child = _a[_i];
  11761. if (!child.isVisible || child.notRenderable) {
  11762. continue;
  11763. }
  11764. if (this._isVertical) {
  11765. if (child.top !== stackHeight + "px") {
  11766. child.top = stackHeight + "px";
  11767. this._rebuildLayout = true;
  11768. child._top.ignoreAdaptiveScaling = true;
  11769. }
  11770. if (child._height.isPercentage && !child._automaticSize) {
  11771. if (!this.ignoreLayoutWarnings) {
  11772. 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");
  11773. }
  11774. }
  11775. else {
  11776. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  11777. }
  11778. }
  11779. else {
  11780. if (child.left !== stackWidth + "px") {
  11781. child.left = stackWidth + "px";
  11782. this._rebuildLayout = true;
  11783. child._left.ignoreAdaptiveScaling = true;
  11784. }
  11785. if (child._width.isPercentage && !child._automaticSize) {
  11786. if (!this.ignoreLayoutWarnings) {
  11787. 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");
  11788. }
  11789. }
  11790. else {
  11791. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  11792. }
  11793. }
  11794. }
  11795. this._doNotTrackManualChanges = true;
  11796. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  11797. // User can now define their own height and width for stack panel.
  11798. var panelWidthChanged = false;
  11799. var panelHeightChanged = false;
  11800. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  11801. var previousHeight = this.height;
  11802. this.height = stackHeight + "px";
  11803. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  11804. }
  11805. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  11806. var previousWidth = this.width;
  11807. this.width = stackWidth + "px";
  11808. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  11809. }
  11810. if (panelHeightChanged) {
  11811. this._height.ignoreAdaptiveScaling = true;
  11812. }
  11813. if (panelWidthChanged) {
  11814. this._width.ignoreAdaptiveScaling = true;
  11815. }
  11816. this._doNotTrackManualChanges = false;
  11817. if (panelWidthChanged || panelHeightChanged) {
  11818. this._rebuildLayout = true;
  11819. }
  11820. _super.prototype._postMeasure.call(this);
  11821. };
  11822. return StackPanel;
  11823. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  11824. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  11825. /***/ }),
  11826. /***/ "./2D/controls/statics.ts":
  11827. /*!********************************!*\
  11828. !*** ./2D/controls/statics.ts ***!
  11829. \********************************/
  11830. /*! exports provided: name */
  11831. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11832. "use strict";
  11833. __webpack_require__.r(__webpack_exports__);
  11834. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  11835. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11836. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11837. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  11838. /**
  11839. * Forcing an export so that this code will execute
  11840. * @hidden
  11841. */
  11842. var name = "Statics";
  11843. /**
  11844. * Creates a stack panel that can be used to render headers
  11845. * @param control defines the control to associate with the header
  11846. * @param text defines the text of the header
  11847. * @param size defines the size of the header
  11848. * @param options defines options used to configure the header
  11849. * @returns a new StackPanel
  11850. */
  11851. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  11852. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  11853. var isHorizontal = options ? options.isHorizontal : true;
  11854. var controlFirst = options ? options.controlFirst : true;
  11855. panel.isVertical = !isHorizontal;
  11856. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  11857. header.text = text;
  11858. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11859. if (isHorizontal) {
  11860. header.width = size;
  11861. }
  11862. else {
  11863. header.height = size;
  11864. }
  11865. if (controlFirst) {
  11866. panel.addControl(control);
  11867. panel.addControl(header);
  11868. header.paddingLeft = "5px";
  11869. }
  11870. else {
  11871. panel.addControl(header);
  11872. panel.addControl(control);
  11873. header.paddingRight = "5px";
  11874. }
  11875. header.shadowBlur = control.shadowBlur;
  11876. header.shadowColor = control.shadowColor;
  11877. header.shadowOffsetX = control.shadowOffsetX;
  11878. header.shadowOffsetY = control.shadowOffsetY;
  11879. return panel;
  11880. };
  11881. /***/ }),
  11882. /***/ "./2D/controls/textBlock.ts":
  11883. /*!**********************************!*\
  11884. !*** ./2D/controls/textBlock.ts ***!
  11885. \**********************************/
  11886. /*! exports provided: TextWrapping, TextBlock */
  11887. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11888. "use strict";
  11889. __webpack_require__.r(__webpack_exports__);
  11890. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  11891. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  11892. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11893. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  11894. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11895. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  11896. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11897. /**
  11898. * Enum that determines the text-wrapping mode to use.
  11899. */
  11900. var TextWrapping;
  11901. (function (TextWrapping) {
  11902. /**
  11903. * Clip the text when it's larger than Control.width; this is the default mode.
  11904. */
  11905. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  11906. /**
  11907. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  11908. */
  11909. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  11910. /**
  11911. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  11912. */
  11913. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  11914. })(TextWrapping || (TextWrapping = {}));
  11915. /**
  11916. * Class used to create text block control
  11917. */
  11918. var TextBlock = /** @class */ (function (_super) {
  11919. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  11920. /**
  11921. * Creates a new TextBlock object
  11922. * @param name defines the name of the control
  11923. * @param text defines the text to display (emptry string by default)
  11924. */
  11925. function TextBlock(
  11926. /**
  11927. * Defines the name of the control
  11928. */
  11929. name, text) {
  11930. if (text === void 0) { text = ""; }
  11931. var _this = _super.call(this, name) || this;
  11932. _this.name = name;
  11933. _this._text = "";
  11934. _this._textWrapping = TextWrapping.Clip;
  11935. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  11936. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  11937. _this._resizeToFit = false;
  11938. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  11939. _this._outlineWidth = 0;
  11940. _this._outlineColor = "white";
  11941. /**
  11942. * An event triggered after the text is changed
  11943. */
  11944. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11945. /**
  11946. * An event triggered after the text was broken up into lines
  11947. */
  11948. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11949. _this.text = text;
  11950. return _this;
  11951. }
  11952. Object.defineProperty(TextBlock.prototype, "lines", {
  11953. /**
  11954. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  11955. */
  11956. get: function () {
  11957. return this._lines;
  11958. },
  11959. enumerable: true,
  11960. configurable: true
  11961. });
  11962. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  11963. /**
  11964. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11965. */
  11966. get: function () {
  11967. return this._resizeToFit;
  11968. },
  11969. /**
  11970. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11971. */
  11972. set: function (value) {
  11973. if (this._resizeToFit === value) {
  11974. return;
  11975. }
  11976. this._resizeToFit = value;
  11977. if (this._resizeToFit) {
  11978. this._width.ignoreAdaptiveScaling = true;
  11979. this._height.ignoreAdaptiveScaling = true;
  11980. }
  11981. this._markAsDirty();
  11982. },
  11983. enumerable: true,
  11984. configurable: true
  11985. });
  11986. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  11987. /**
  11988. * Gets or sets a boolean indicating if text must be wrapped
  11989. */
  11990. get: function () {
  11991. return this._textWrapping;
  11992. },
  11993. /**
  11994. * Gets or sets a boolean indicating if text must be wrapped
  11995. */
  11996. set: function (value) {
  11997. if (this._textWrapping === value) {
  11998. return;
  11999. }
  12000. this._textWrapping = +value;
  12001. this._markAsDirty();
  12002. },
  12003. enumerable: true,
  12004. configurable: true
  12005. });
  12006. Object.defineProperty(TextBlock.prototype, "text", {
  12007. /**
  12008. * Gets or sets text to display
  12009. */
  12010. get: function () {
  12011. return this._text;
  12012. },
  12013. /**
  12014. * Gets or sets text to display
  12015. */
  12016. set: function (value) {
  12017. if (this._text === value) {
  12018. return;
  12019. }
  12020. this._text = value;
  12021. this._markAsDirty();
  12022. this.onTextChangedObservable.notifyObservers(this);
  12023. },
  12024. enumerable: true,
  12025. configurable: true
  12026. });
  12027. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  12028. /**
  12029. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12030. */
  12031. get: function () {
  12032. return this._textHorizontalAlignment;
  12033. },
  12034. /**
  12035. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12036. */
  12037. set: function (value) {
  12038. if (this._textHorizontalAlignment === value) {
  12039. return;
  12040. }
  12041. this._textHorizontalAlignment = value;
  12042. this._markAsDirty();
  12043. },
  12044. enumerable: true,
  12045. configurable: true
  12046. });
  12047. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  12048. /**
  12049. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12050. */
  12051. get: function () {
  12052. return this._textVerticalAlignment;
  12053. },
  12054. /**
  12055. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12056. */
  12057. set: function (value) {
  12058. if (this._textVerticalAlignment === value) {
  12059. return;
  12060. }
  12061. this._textVerticalAlignment = value;
  12062. this._markAsDirty();
  12063. },
  12064. enumerable: true,
  12065. configurable: true
  12066. });
  12067. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  12068. /**
  12069. * Gets or sets line spacing value
  12070. */
  12071. get: function () {
  12072. return this._lineSpacing.toString(this._host);
  12073. },
  12074. /**
  12075. * Gets or sets line spacing value
  12076. */
  12077. set: function (value) {
  12078. if (this._lineSpacing.fromString(value)) {
  12079. this._markAsDirty();
  12080. }
  12081. },
  12082. enumerable: true,
  12083. configurable: true
  12084. });
  12085. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  12086. /**
  12087. * Gets or sets outlineWidth of the text to display
  12088. */
  12089. get: function () {
  12090. return this._outlineWidth;
  12091. },
  12092. /**
  12093. * Gets or sets outlineWidth of the text to display
  12094. */
  12095. set: function (value) {
  12096. if (this._outlineWidth === value) {
  12097. return;
  12098. }
  12099. this._outlineWidth = value;
  12100. this._markAsDirty();
  12101. },
  12102. enumerable: true,
  12103. configurable: true
  12104. });
  12105. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  12106. /**
  12107. * Gets or sets outlineColor of the text to display
  12108. */
  12109. get: function () {
  12110. return this._outlineColor;
  12111. },
  12112. /**
  12113. * Gets or sets outlineColor of the text to display
  12114. */
  12115. set: function (value) {
  12116. if (this._outlineColor === value) {
  12117. return;
  12118. }
  12119. this._outlineColor = value;
  12120. this._markAsDirty();
  12121. },
  12122. enumerable: true,
  12123. configurable: true
  12124. });
  12125. TextBlock.prototype._getTypeName = function () {
  12126. return "TextBlock";
  12127. };
  12128. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  12129. if (!this._fontOffset) {
  12130. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  12131. }
  12132. _super.prototype._processMeasures.call(this, parentMeasure, context);
  12133. // Prepare lines
  12134. this._lines = this._breakLines(this._currentMeasure.width, context);
  12135. this.onLinesReadyObservable.notifyObservers(this);
  12136. var maxLineWidth = 0;
  12137. for (var i = 0; i < this._lines.length; i++) {
  12138. var line = this._lines[i];
  12139. if (line.width > maxLineWidth) {
  12140. maxLineWidth = line.width;
  12141. }
  12142. }
  12143. if (this._resizeToFit) {
  12144. if (this._textWrapping === TextWrapping.Clip) {
  12145. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  12146. if (newWidth !== this._width.internalValue) {
  12147. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12148. this._rebuildLayout = true;
  12149. }
  12150. }
  12151. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  12152. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12153. var lineSpacing = 0;
  12154. if (this._lineSpacing.isPixel) {
  12155. lineSpacing = this._lineSpacing.getValue(this._host);
  12156. }
  12157. else {
  12158. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12159. }
  12160. newHeight += (this._lines.length - 1) * lineSpacing;
  12161. }
  12162. if (newHeight !== this._height.internalValue) {
  12163. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12164. this._rebuildLayout = true;
  12165. }
  12166. }
  12167. };
  12168. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  12169. var width = this._currentMeasure.width;
  12170. var x = 0;
  12171. switch (this._textHorizontalAlignment) {
  12172. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  12173. x = 0;
  12174. break;
  12175. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  12176. x = width - textWidth;
  12177. break;
  12178. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  12179. x = (width - textWidth) / 2;
  12180. break;
  12181. }
  12182. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12183. context.shadowColor = this.shadowColor;
  12184. context.shadowBlur = this.shadowBlur;
  12185. context.shadowOffsetX = this.shadowOffsetX;
  12186. context.shadowOffsetY = this.shadowOffsetY;
  12187. }
  12188. if (this.outlineWidth) {
  12189. context.strokeText(text, this._currentMeasure.left + x, y);
  12190. }
  12191. context.fillText(text, this._currentMeasure.left + x, y);
  12192. };
  12193. /** @hidden */
  12194. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  12195. context.save();
  12196. this._applyStates(context);
  12197. // Render lines
  12198. this._renderLines(context);
  12199. context.restore();
  12200. };
  12201. TextBlock.prototype._applyStates = function (context) {
  12202. _super.prototype._applyStates.call(this, context);
  12203. if (this.outlineWidth) {
  12204. context.lineWidth = this.outlineWidth;
  12205. context.strokeStyle = this.outlineColor;
  12206. }
  12207. };
  12208. TextBlock.prototype._breakLines = function (refWidth, context) {
  12209. var lines = [];
  12210. var _lines = this.text.split("\n");
  12211. if (this._textWrapping === TextWrapping.Ellipsis) {
  12212. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  12213. var _line = _lines_1[_i];
  12214. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  12215. }
  12216. }
  12217. else if (this._textWrapping === TextWrapping.WordWrap) {
  12218. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  12219. var _line = _lines_2[_a];
  12220. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  12221. }
  12222. }
  12223. else {
  12224. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  12225. var _line = _lines_3[_b];
  12226. lines.push(this._parseLine(_line, context));
  12227. }
  12228. }
  12229. return lines;
  12230. };
  12231. TextBlock.prototype._parseLine = function (line, context) {
  12232. if (line === void 0) { line = ''; }
  12233. return { text: line, width: context.measureText(line).width };
  12234. };
  12235. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  12236. if (line === void 0) { line = ''; }
  12237. var lineWidth = context.measureText(line).width;
  12238. if (lineWidth > width) {
  12239. line += '…';
  12240. }
  12241. while (line.length > 2 && lineWidth > width) {
  12242. line = line.slice(0, -2) + '…';
  12243. lineWidth = context.measureText(line).width;
  12244. }
  12245. return { text: line, width: lineWidth };
  12246. };
  12247. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  12248. if (line === void 0) { line = ''; }
  12249. var lines = [];
  12250. var words = line.split(' ');
  12251. var lineWidth = 0;
  12252. for (var n = 0; n < words.length; n++) {
  12253. var testLine = n > 0 ? line + " " + words[n] : words[0];
  12254. var metrics = context.measureText(testLine);
  12255. var testWidth = metrics.width;
  12256. if (testWidth > width && n > 0) {
  12257. lines.push({ text: line, width: lineWidth });
  12258. line = words[n];
  12259. lineWidth = context.measureText(line).width;
  12260. }
  12261. else {
  12262. lineWidth = testWidth;
  12263. line = testLine;
  12264. }
  12265. }
  12266. lines.push({ text: line, width: lineWidth });
  12267. return lines;
  12268. };
  12269. TextBlock.prototype._renderLines = function (context) {
  12270. var height = this._currentMeasure.height;
  12271. var rootY = 0;
  12272. switch (this._textVerticalAlignment) {
  12273. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  12274. rootY = this._fontOffset.ascent;
  12275. break;
  12276. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  12277. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  12278. break;
  12279. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  12280. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  12281. break;
  12282. }
  12283. rootY += this._currentMeasure.top;
  12284. for (var i = 0; i < this._lines.length; i++) {
  12285. var line = this._lines[i];
  12286. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  12287. if (this._lineSpacing.isPixel) {
  12288. rootY += this._lineSpacing.getValue(this._host);
  12289. }
  12290. else {
  12291. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12292. }
  12293. }
  12294. this._drawText(line.text, line.width, rootY, context);
  12295. rootY += this._fontOffset.height;
  12296. }
  12297. };
  12298. /**
  12299. * Given a width constraint applied on the text block, find the expected height
  12300. * @returns expected height
  12301. */
  12302. TextBlock.prototype.computeExpectedHeight = function () {
  12303. if (this.text && this.widthInPixels) {
  12304. var context_1 = document.createElement('canvas').getContext('2d');
  12305. if (context_1) {
  12306. this._applyStates(context_1);
  12307. if (!this._fontOffset) {
  12308. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  12309. }
  12310. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  12311. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  12312. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12313. var lineSpacing = 0;
  12314. if (this._lineSpacing.isPixel) {
  12315. lineSpacing = this._lineSpacing.getValue(this._host);
  12316. }
  12317. else {
  12318. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12319. }
  12320. newHeight += (lines.length - 1) * lineSpacing;
  12321. }
  12322. return newHeight;
  12323. }
  12324. }
  12325. return 0;
  12326. };
  12327. TextBlock.prototype.dispose = function () {
  12328. _super.prototype.dispose.call(this);
  12329. this.onTextChangedObservable.clear();
  12330. };
  12331. return TextBlock;
  12332. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  12333. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  12334. /***/ }),
  12335. /***/ "./2D/controls/virtualKeyboard.ts":
  12336. /*!****************************************!*\
  12337. !*** ./2D/controls/virtualKeyboard.ts ***!
  12338. \****************************************/
  12339. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  12340. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12341. "use strict";
  12342. __webpack_require__.r(__webpack_exports__);
  12343. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  12344. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  12345. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12346. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12347. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12348. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12349. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  12350. /**
  12351. * Class used to store key control properties
  12352. */
  12353. var KeyPropertySet = /** @class */ (function () {
  12354. function KeyPropertySet() {
  12355. }
  12356. return KeyPropertySet;
  12357. }());
  12358. /**
  12359. * Class used to create virtual keyboard
  12360. */
  12361. var VirtualKeyboard = /** @class */ (function (_super) {
  12362. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  12363. function VirtualKeyboard() {
  12364. var _this = _super !== null && _super.apply(this, arguments) || this;
  12365. /** Observable raised when a key is pressed */
  12366. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12367. /** Gets or sets default key button width */
  12368. _this.defaultButtonWidth = "40px";
  12369. /** Gets or sets default key button height */
  12370. _this.defaultButtonHeight = "40px";
  12371. /** Gets or sets default key button left padding */
  12372. _this.defaultButtonPaddingLeft = "2px";
  12373. /** Gets or sets default key button right padding */
  12374. _this.defaultButtonPaddingRight = "2px";
  12375. /** Gets or sets default key button top padding */
  12376. _this.defaultButtonPaddingTop = "2px";
  12377. /** Gets or sets default key button bottom padding */
  12378. _this.defaultButtonPaddingBottom = "2px";
  12379. /** Gets or sets default key button foreground color */
  12380. _this.defaultButtonColor = "#DDD";
  12381. /** Gets or sets default key button background color */
  12382. _this.defaultButtonBackground = "#070707";
  12383. /** Gets or sets shift button foreground color */
  12384. _this.shiftButtonColor = "#7799FF";
  12385. /** Gets or sets shift button thickness*/
  12386. _this.selectedShiftThickness = 1;
  12387. /** Gets shift key state */
  12388. _this.shiftState = 0;
  12389. _this._currentlyConnectedInputText = null;
  12390. _this._connectedInputTexts = [];
  12391. _this._onKeyPressObserver = null;
  12392. return _this;
  12393. }
  12394. VirtualKeyboard.prototype._getTypeName = function () {
  12395. return "VirtualKeyboard";
  12396. };
  12397. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  12398. var _this = this;
  12399. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  12400. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  12401. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  12402. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  12403. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  12404. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  12405. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  12406. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  12407. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  12408. button.thickness = 0;
  12409. button.isFocusInvisible = true;
  12410. button.shadowColor = this.shadowColor;
  12411. button.shadowBlur = this.shadowBlur;
  12412. button.shadowOffsetX = this.shadowOffsetX;
  12413. button.shadowOffsetY = this.shadowOffsetY;
  12414. button.onPointerUpObservable.add(function () {
  12415. _this.onKeyPressObservable.notifyObservers(key);
  12416. });
  12417. return button;
  12418. };
  12419. /**
  12420. * Adds a new row of keys
  12421. * @param keys defines the list of keys to add
  12422. * @param propertySets defines the associated property sets
  12423. */
  12424. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  12425. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  12426. panel.isVertical = false;
  12427. panel.isFocusInvisible = true;
  12428. var maxKey = null;
  12429. for (var i = 0; i < keys.length; i++) {
  12430. var properties = null;
  12431. if (propertySets && propertySets.length === keys.length) {
  12432. properties = propertySets[i];
  12433. }
  12434. var key = this._createKey(keys[i], properties);
  12435. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  12436. maxKey = key;
  12437. }
  12438. panel.addControl(key);
  12439. }
  12440. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  12441. this.addControl(panel);
  12442. };
  12443. /**
  12444. * Set the shift key to a specific state
  12445. * @param shiftState defines the new shift state
  12446. */
  12447. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  12448. if (!this.children) {
  12449. return;
  12450. }
  12451. for (var i = 0; i < this.children.length; i++) {
  12452. var row = this.children[i];
  12453. if (!row || !row.children) {
  12454. continue;
  12455. }
  12456. var rowContainer = row;
  12457. for (var j = 0; j < rowContainer.children.length; j++) {
  12458. var button = rowContainer.children[j];
  12459. if (!button || !button.children[0]) {
  12460. continue;
  12461. }
  12462. var button_tblock = button.children[0];
  12463. if (button_tblock.text === "\u21E7") {
  12464. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  12465. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  12466. }
  12467. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  12468. }
  12469. }
  12470. };
  12471. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  12472. /** Gets the input text control currently attached to the keyboard */
  12473. get: function () {
  12474. return this._currentlyConnectedInputText;
  12475. },
  12476. enumerable: true,
  12477. configurable: true
  12478. });
  12479. /**
  12480. * Connects the keyboard with an input text control
  12481. *
  12482. * @param input defines the target control
  12483. */
  12484. VirtualKeyboard.prototype.connect = function (input) {
  12485. var _this = this;
  12486. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  12487. if (inputTextAlreadyConnected) {
  12488. return;
  12489. }
  12490. if (this._onKeyPressObserver === null) {
  12491. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  12492. if (!_this._currentlyConnectedInputText) {
  12493. return;
  12494. }
  12495. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  12496. switch (key) {
  12497. case "\u21E7":
  12498. _this.shiftState++;
  12499. if (_this.shiftState > 2) {
  12500. _this.shiftState = 0;
  12501. }
  12502. _this.applyShiftState(_this.shiftState);
  12503. return;
  12504. case "\u2190":
  12505. _this._currentlyConnectedInputText.processKey(8);
  12506. return;
  12507. case "\u21B5":
  12508. _this._currentlyConnectedInputText.processKey(13);
  12509. return;
  12510. }
  12511. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  12512. if (_this.shiftState === 1) {
  12513. _this.shiftState = 0;
  12514. _this.applyShiftState(_this.shiftState);
  12515. }
  12516. });
  12517. }
  12518. this.isVisible = false;
  12519. this._currentlyConnectedInputText = input;
  12520. input._connectedVirtualKeyboard = this;
  12521. // Events hooking
  12522. var onFocusObserver = input.onFocusObservable.add(function () {
  12523. _this._currentlyConnectedInputText = input;
  12524. input._connectedVirtualKeyboard = _this;
  12525. _this.isVisible = true;
  12526. });
  12527. var onBlurObserver = input.onBlurObservable.add(function () {
  12528. input._connectedVirtualKeyboard = null;
  12529. _this._currentlyConnectedInputText = null;
  12530. _this.isVisible = false;
  12531. });
  12532. this._connectedInputTexts.push({
  12533. input: input,
  12534. onBlurObserver: onBlurObserver,
  12535. onFocusObserver: onFocusObserver
  12536. });
  12537. };
  12538. /**
  12539. * Disconnects the keyboard from connected InputText controls
  12540. *
  12541. * @param input optionally defines a target control, otherwise all are disconnected
  12542. */
  12543. VirtualKeyboard.prototype.disconnect = function (input) {
  12544. var _this = this;
  12545. if (input) {
  12546. // .find not available on IE
  12547. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  12548. if (filtered.length === 1) {
  12549. this._removeConnectedInputObservables(filtered[0]);
  12550. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  12551. if (this._currentlyConnectedInputText === input) {
  12552. this._currentlyConnectedInputText = null;
  12553. }
  12554. }
  12555. }
  12556. else {
  12557. this._connectedInputTexts.forEach(function (connectedInputText) {
  12558. _this._removeConnectedInputObservables(connectedInputText);
  12559. });
  12560. this._connectedInputTexts = [];
  12561. }
  12562. if (this._connectedInputTexts.length === 0) {
  12563. this._currentlyConnectedInputText = null;
  12564. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  12565. this._onKeyPressObserver = null;
  12566. }
  12567. };
  12568. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  12569. connectedInputText.input._connectedVirtualKeyboard = null;
  12570. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  12571. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  12572. };
  12573. /**
  12574. * Release all resources
  12575. */
  12576. VirtualKeyboard.prototype.dispose = function () {
  12577. _super.prototype.dispose.call(this);
  12578. this.disconnect();
  12579. };
  12580. // Statics
  12581. /**
  12582. * Creates a new keyboard using a default layout
  12583. *
  12584. * @param name defines control name
  12585. * @returns a new VirtualKeyboard
  12586. */
  12587. VirtualKeyboard.CreateDefaultLayout = function (name) {
  12588. var returnValue = new VirtualKeyboard(name);
  12589. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  12590. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  12591. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  12592. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  12593. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  12594. return returnValue;
  12595. };
  12596. return VirtualKeyboard;
  12597. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  12598. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  12599. /***/ }),
  12600. /***/ "./2D/index.ts":
  12601. /*!*********************!*\
  12602. !*** ./2D/index.ts ***!
  12603. \*********************/
  12604. /*! 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 */
  12605. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12606. "use strict";
  12607. __webpack_require__.r(__webpack_exports__);
  12608. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  12609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  12610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  12611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  12612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  12613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  12614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  12615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  12616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  12617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  12618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  12619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  12620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  12621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  12622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  12623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  12624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  12625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  12626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  12627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  12628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  12629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  12630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  12631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  12632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  12633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  12634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  12635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  12636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  12637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  12638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  12639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  12640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  12641. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  12643. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  12644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  12645. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  12646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  12647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  12648. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  12649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  12650. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  12651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  12652. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  12653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  12654. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  12656. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  12657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  12658. /***/ }),
  12659. /***/ "./2D/math2D.ts":
  12660. /*!**********************!*\
  12661. !*** ./2D/math2D.ts ***!
  12662. \**********************/
  12663. /*! exports provided: Vector2WithInfo, Matrix2D */
  12664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12665. "use strict";
  12666. __webpack_require__.r(__webpack_exports__);
  12667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  12668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  12669. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12670. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12671. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12672. /**
  12673. * Class used to transport Vector2 information for pointer events
  12674. */
  12675. var Vector2WithInfo = /** @class */ (function (_super) {
  12676. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  12677. /**
  12678. * Creates a new Vector2WithInfo
  12679. * @param source defines the vector2 data to transport
  12680. * @param buttonIndex defines the current mouse button index
  12681. */
  12682. function Vector2WithInfo(source,
  12683. /** defines the current mouse button index */
  12684. buttonIndex) {
  12685. if (buttonIndex === void 0) { buttonIndex = 0; }
  12686. var _this = _super.call(this, source.x, source.y) || this;
  12687. _this.buttonIndex = buttonIndex;
  12688. return _this;
  12689. }
  12690. return Vector2WithInfo;
  12691. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  12692. /** Class used to provide 2D matrix features */
  12693. var Matrix2D = /** @class */ (function () {
  12694. /**
  12695. * Creates a new matrix
  12696. * @param m00 defines value for (0, 0)
  12697. * @param m01 defines value for (0, 1)
  12698. * @param m10 defines value for (1, 0)
  12699. * @param m11 defines value for (1, 1)
  12700. * @param m20 defines value for (2, 0)
  12701. * @param m21 defines value for (2, 1)
  12702. */
  12703. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  12704. /** Gets the internal array of 6 floats used to store matrix data */
  12705. this.m = new Float32Array(6);
  12706. this.fromValues(m00, m01, m10, m11, m20, m21);
  12707. }
  12708. /**
  12709. * Fills the matrix from direct values
  12710. * @param m00 defines value for (0, 0)
  12711. * @param m01 defines value for (0, 1)
  12712. * @param m10 defines value for (1, 0)
  12713. * @param m11 defines value for (1, 1)
  12714. * @param m20 defines value for (2, 0)
  12715. * @param m21 defines value for (2, 1)
  12716. * @returns the current modified matrix
  12717. */
  12718. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  12719. this.m[0] = m00;
  12720. this.m[1] = m01;
  12721. this.m[2] = m10;
  12722. this.m[3] = m11;
  12723. this.m[4] = m20;
  12724. this.m[5] = m21;
  12725. return this;
  12726. };
  12727. /**
  12728. * Gets matrix determinant
  12729. * @returns the determinant
  12730. */
  12731. Matrix2D.prototype.determinant = function () {
  12732. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  12733. };
  12734. /**
  12735. * Inverses the matrix and stores it in a target matrix
  12736. * @param result defines the target matrix
  12737. * @returns the current matrix
  12738. */
  12739. Matrix2D.prototype.invertToRef = function (result) {
  12740. var l0 = this.m[0];
  12741. var l1 = this.m[1];
  12742. var l2 = this.m[2];
  12743. var l3 = this.m[3];
  12744. var l4 = this.m[4];
  12745. var l5 = this.m[5];
  12746. var det = this.determinant();
  12747. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  12748. result.m[0] = 0;
  12749. result.m[1] = 0;
  12750. result.m[2] = 0;
  12751. result.m[3] = 0;
  12752. result.m[4] = 0;
  12753. result.m[5] = 0;
  12754. return this;
  12755. }
  12756. var detDiv = 1 / det;
  12757. var det4 = l2 * l5 - l3 * l4;
  12758. var det5 = l1 * l4 - l0 * l5;
  12759. result.m[0] = l3 * detDiv;
  12760. result.m[1] = -l1 * detDiv;
  12761. result.m[2] = -l2 * detDiv;
  12762. result.m[3] = l0 * detDiv;
  12763. result.m[4] = det4 * detDiv;
  12764. result.m[5] = det5 * detDiv;
  12765. return this;
  12766. };
  12767. /**
  12768. * Multiplies the current matrix with another one
  12769. * @param other defines the second operand
  12770. * @param result defines the target matrix
  12771. * @returns the current matrix
  12772. */
  12773. Matrix2D.prototype.multiplyToRef = function (other, result) {
  12774. var l0 = this.m[0];
  12775. var l1 = this.m[1];
  12776. var l2 = this.m[2];
  12777. var l3 = this.m[3];
  12778. var l4 = this.m[4];
  12779. var l5 = this.m[5];
  12780. var r0 = other.m[0];
  12781. var r1 = other.m[1];
  12782. var r2 = other.m[2];
  12783. var r3 = other.m[3];
  12784. var r4 = other.m[4];
  12785. var r5 = other.m[5];
  12786. result.m[0] = l0 * r0 + l1 * r2;
  12787. result.m[1] = l0 * r1 + l1 * r3;
  12788. result.m[2] = l2 * r0 + l3 * r2;
  12789. result.m[3] = l2 * r1 + l3 * r3;
  12790. result.m[4] = l4 * r0 + l5 * r2 + r4;
  12791. result.m[5] = l4 * r1 + l5 * r3 + r5;
  12792. return this;
  12793. };
  12794. /**
  12795. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  12796. * @param x defines the x coordinate to transform
  12797. * @param y defines the x coordinate to transform
  12798. * @param result defines the target vector2
  12799. * @returns the current matrix
  12800. */
  12801. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  12802. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  12803. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  12804. return this;
  12805. };
  12806. // Statics
  12807. /**
  12808. * Creates an identity matrix
  12809. * @returns a new matrix
  12810. */
  12811. Matrix2D.Identity = function () {
  12812. return new Matrix2D(1, 0, 0, 1, 0, 0);
  12813. };
  12814. /**
  12815. * Creates a translation matrix and stores it in a target matrix
  12816. * @param x defines the x coordinate of the translation
  12817. * @param y defines the y coordinate of the translation
  12818. * @param result defines the target matrix
  12819. */
  12820. Matrix2D.TranslationToRef = function (x, y, result) {
  12821. result.fromValues(1, 0, 0, 1, x, y);
  12822. };
  12823. /**
  12824. * Creates a scaling matrix and stores it in a target matrix
  12825. * @param x defines the x coordinate of the scaling
  12826. * @param y defines the y coordinate of the scaling
  12827. * @param result defines the target matrix
  12828. */
  12829. Matrix2D.ScalingToRef = function (x, y, result) {
  12830. result.fromValues(x, 0, 0, y, 0, 0);
  12831. };
  12832. /**
  12833. * Creates a rotation matrix and stores it in a target matrix
  12834. * @param angle defines the rotation angle
  12835. * @param result defines the target matrix
  12836. */
  12837. Matrix2D.RotationToRef = function (angle, result) {
  12838. var s = Math.sin(angle);
  12839. var c = Math.cos(angle);
  12840. result.fromValues(c, s, -s, c, 0, 0);
  12841. };
  12842. /**
  12843. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  12844. * @param tx defines the x coordinate of the translation
  12845. * @param ty defines the y coordinate of the translation
  12846. * @param angle defines the rotation angle
  12847. * @param scaleX defines the x coordinate of the scaling
  12848. * @param scaleY defines the y coordinate of the scaling
  12849. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  12850. * @param result defines the target matrix
  12851. */
  12852. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  12853. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  12854. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  12855. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  12856. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  12857. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  12858. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  12859. if (parentMatrix) {
  12860. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  12861. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  12862. }
  12863. else {
  12864. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  12865. }
  12866. };
  12867. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  12868. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  12869. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  12870. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  12871. Matrix2D._TempCompose0 = Matrix2D.Identity();
  12872. Matrix2D._TempCompose1 = Matrix2D.Identity();
  12873. Matrix2D._TempCompose2 = Matrix2D.Identity();
  12874. return Matrix2D;
  12875. }());
  12876. /***/ }),
  12877. /***/ "./2D/measure.ts":
  12878. /*!***********************!*\
  12879. !*** ./2D/measure.ts ***!
  12880. \***********************/
  12881. /*! exports provided: Measure */
  12882. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12883. "use strict";
  12884. __webpack_require__.r(__webpack_exports__);
  12885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  12886. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12887. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12888. var tmpRect = [
  12889. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12890. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12891. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12892. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12893. ];
  12894. var tmpRect2 = [
  12895. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12896. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12897. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12898. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12899. ];
  12900. var tmpV1 = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12901. var tmpV2 = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12902. /**
  12903. * Class used to store 2D control sizes
  12904. */
  12905. var Measure = /** @class */ (function () {
  12906. /**
  12907. * Creates a new measure
  12908. * @param left defines left coordinate
  12909. * @param top defines top coordinate
  12910. * @param width defines width dimension
  12911. * @param height defines height dimension
  12912. */
  12913. function Measure(
  12914. /** defines left coordinate */
  12915. left,
  12916. /** defines top coordinate */
  12917. top,
  12918. /** defines width dimension */
  12919. width,
  12920. /** defines height dimension */
  12921. height) {
  12922. this.left = left;
  12923. this.top = top;
  12924. this.width = width;
  12925. this.height = height;
  12926. }
  12927. /**
  12928. * Copy from another measure
  12929. * @param other defines the other measure to copy from
  12930. */
  12931. Measure.prototype.copyFrom = function (other) {
  12932. this.left = other.left;
  12933. this.top = other.top;
  12934. this.width = other.width;
  12935. this.height = other.height;
  12936. };
  12937. /**
  12938. * Copy from a group of 4 floats
  12939. * @param left defines left coordinate
  12940. * @param top defines top coordinate
  12941. * @param width defines width dimension
  12942. * @param height defines height dimension
  12943. */
  12944. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  12945. this.left = left;
  12946. this.top = top;
  12947. this.width = width;
  12948. this.height = height;
  12949. };
  12950. /**
  12951. * Computes the axis aligned bounding box measure for two given measures
  12952. * @param a Input measure
  12953. * @param b Input measure
  12954. * @param result the resulting bounding measure
  12955. */
  12956. Measure.CombineToRef = function (a, b, result) {
  12957. var left = Math.min(a.left, b.left);
  12958. var top = Math.min(a.top, b.top);
  12959. var right = Math.max(a.left + a.width, b.left + b.width);
  12960. var bottom = Math.max(a.top + a.height, b.top + b.height);
  12961. result.left = left;
  12962. result.top = top;
  12963. result.width = right - left;
  12964. result.height = bottom - top;
  12965. };
  12966. /**
  12967. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  12968. * @param transform the matrix to transform the measure before computing the AABB
  12969. * @param result the resulting AABB
  12970. */
  12971. Measure.prototype.transformToRef = function (transform, result) {
  12972. tmpRect[0].copyFromFloats(this.left, this.top);
  12973. tmpRect[1].copyFromFloats(this.left + this.width, this.top);
  12974. tmpRect[2].copyFromFloats(this.left + this.width, this.top + this.height);
  12975. tmpRect[3].copyFromFloats(this.left, this.top + this.height);
  12976. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  12977. tmpV2.copyFromFloats(0, 0);
  12978. for (var i = 0; i < 4; i++) {
  12979. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  12980. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  12981. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  12982. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  12983. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  12984. }
  12985. result.left = tmpV1.x;
  12986. result.top = tmpV1.y;
  12987. result.width = tmpV2.x - tmpV1.x;
  12988. result.height = tmpV2.y - tmpV1.y;
  12989. };
  12990. /**
  12991. * Check equality between this measure and another one
  12992. * @param other defines the other measures
  12993. * @returns true if both measures are equals
  12994. */
  12995. Measure.prototype.isEqualsTo = function (other) {
  12996. if (this.left !== other.left) {
  12997. return false;
  12998. }
  12999. if (this.top !== other.top) {
  13000. return false;
  13001. }
  13002. if (this.width !== other.width) {
  13003. return false;
  13004. }
  13005. if (this.height !== other.height) {
  13006. return false;
  13007. }
  13008. return true;
  13009. };
  13010. /**
  13011. * Creates an empty measure
  13012. * @returns a new measure
  13013. */
  13014. Measure.Empty = function () {
  13015. return new Measure(0, 0, 0, 0);
  13016. };
  13017. return Measure;
  13018. }());
  13019. /***/ }),
  13020. /***/ "./2D/multiLinePoint.ts":
  13021. /*!******************************!*\
  13022. !*** ./2D/multiLinePoint.ts ***!
  13023. \******************************/
  13024. /*! exports provided: MultiLinePoint */
  13025. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13026. "use strict";
  13027. __webpack_require__.r(__webpack_exports__);
  13028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  13029. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  13030. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  13031. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13032. /**
  13033. * Class used to store a point for a MultiLine object.
  13034. * The point can be pure 2D coordinates, a mesh or a control
  13035. */
  13036. var MultiLinePoint = /** @class */ (function () {
  13037. /**
  13038. * Creates a new MultiLinePoint
  13039. * @param multiLine defines the source MultiLine object
  13040. */
  13041. function MultiLinePoint(multiLine) {
  13042. this._multiLine = multiLine;
  13043. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13044. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13045. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13046. }
  13047. Object.defineProperty(MultiLinePoint.prototype, "x", {
  13048. /** Gets or sets x coordinate */
  13049. get: function () {
  13050. return this._x.toString(this._multiLine._host);
  13051. },
  13052. set: function (value) {
  13053. if (this._x.toString(this._multiLine._host) === value) {
  13054. return;
  13055. }
  13056. if (this._x.fromString(value)) {
  13057. this._multiLine._markAsDirty();
  13058. }
  13059. },
  13060. enumerable: true,
  13061. configurable: true
  13062. });
  13063. Object.defineProperty(MultiLinePoint.prototype, "y", {
  13064. /** Gets or sets y coordinate */
  13065. get: function () {
  13066. return this._y.toString(this._multiLine._host);
  13067. },
  13068. set: function (value) {
  13069. if (this._y.toString(this._multiLine._host) === value) {
  13070. return;
  13071. }
  13072. if (this._y.fromString(value)) {
  13073. this._multiLine._markAsDirty();
  13074. }
  13075. },
  13076. enumerable: true,
  13077. configurable: true
  13078. });
  13079. Object.defineProperty(MultiLinePoint.prototype, "control", {
  13080. /** Gets or sets the control associated with this point */
  13081. get: function () {
  13082. return this._control;
  13083. },
  13084. set: function (value) {
  13085. if (this._control === value) {
  13086. return;
  13087. }
  13088. if (this._control && this._controlObserver) {
  13089. this._control.onDirtyObservable.remove(this._controlObserver);
  13090. this._controlObserver = null;
  13091. }
  13092. this._control = value;
  13093. if (this._control) {
  13094. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  13095. }
  13096. this._multiLine._markAsDirty();
  13097. },
  13098. enumerable: true,
  13099. configurable: true
  13100. });
  13101. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  13102. /** Gets or sets the mesh associated with this point */
  13103. get: function () {
  13104. return this._mesh;
  13105. },
  13106. set: function (value) {
  13107. if (this._mesh === value) {
  13108. return;
  13109. }
  13110. if (this._mesh && this._meshObserver) {
  13111. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  13112. }
  13113. this._mesh = value;
  13114. if (this._mesh) {
  13115. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  13116. }
  13117. this._multiLine._markAsDirty();
  13118. },
  13119. enumerable: true,
  13120. configurable: true
  13121. });
  13122. /** Resets links */
  13123. MultiLinePoint.prototype.resetLinks = function () {
  13124. this.control = null;
  13125. this.mesh = null;
  13126. };
  13127. /**
  13128. * Gets a translation vector
  13129. * @returns the translation vector
  13130. */
  13131. MultiLinePoint.prototype.translate = function () {
  13132. this._point = this._translatePoint();
  13133. return this._point;
  13134. };
  13135. MultiLinePoint.prototype._translatePoint = function () {
  13136. if (this._mesh != null) {
  13137. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  13138. }
  13139. else if (this._control != null) {
  13140. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  13141. }
  13142. else {
  13143. var host = this._multiLine._host;
  13144. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  13145. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  13146. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  13147. }
  13148. };
  13149. /** Release associated resources */
  13150. MultiLinePoint.prototype.dispose = function () {
  13151. this.resetLinks();
  13152. };
  13153. return MultiLinePoint;
  13154. }());
  13155. /***/ }),
  13156. /***/ "./2D/style.ts":
  13157. /*!*********************!*\
  13158. !*** ./2D/style.ts ***!
  13159. \*********************/
  13160. /*! exports provided: Style */
  13161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13162. "use strict";
  13163. __webpack_require__.r(__webpack_exports__);
  13164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  13165. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  13166. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13167. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13168. /**
  13169. * Define a style used by control to automatically setup properties based on a template.
  13170. * Only support font related properties so far
  13171. */
  13172. var Style = /** @class */ (function () {
  13173. /**
  13174. * Creates a new style object
  13175. * @param host defines the AdvancedDynamicTexture which hosts this style
  13176. */
  13177. function Style(host) {
  13178. this._fontFamily = "Arial";
  13179. this._fontStyle = "";
  13180. this._fontWeight = "";
  13181. /** @hidden */
  13182. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  13183. /**
  13184. * Observable raised when the style values are changed
  13185. */
  13186. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13187. this._host = host;
  13188. }
  13189. Object.defineProperty(Style.prototype, "fontSize", {
  13190. /**
  13191. * Gets or sets the font size
  13192. */
  13193. get: function () {
  13194. return this._fontSize.toString(this._host);
  13195. },
  13196. set: function (value) {
  13197. if (this._fontSize.toString(this._host) === value) {
  13198. return;
  13199. }
  13200. if (this._fontSize.fromString(value)) {
  13201. this.onChangedObservable.notifyObservers(this);
  13202. }
  13203. },
  13204. enumerable: true,
  13205. configurable: true
  13206. });
  13207. Object.defineProperty(Style.prototype, "fontFamily", {
  13208. /**
  13209. * Gets or sets the font family
  13210. */
  13211. get: function () {
  13212. return this._fontFamily;
  13213. },
  13214. set: function (value) {
  13215. if (this._fontFamily === value) {
  13216. return;
  13217. }
  13218. this._fontFamily = value;
  13219. this.onChangedObservable.notifyObservers(this);
  13220. },
  13221. enumerable: true,
  13222. configurable: true
  13223. });
  13224. Object.defineProperty(Style.prototype, "fontStyle", {
  13225. /**
  13226. * Gets or sets the font style
  13227. */
  13228. get: function () {
  13229. return this._fontStyle;
  13230. },
  13231. set: function (value) {
  13232. if (this._fontStyle === value) {
  13233. return;
  13234. }
  13235. this._fontStyle = value;
  13236. this.onChangedObservable.notifyObservers(this);
  13237. },
  13238. enumerable: true,
  13239. configurable: true
  13240. });
  13241. Object.defineProperty(Style.prototype, "fontWeight", {
  13242. /** Gets or sets font weight */
  13243. get: function () {
  13244. return this._fontWeight;
  13245. },
  13246. set: function (value) {
  13247. if (this._fontWeight === value) {
  13248. return;
  13249. }
  13250. this._fontWeight = value;
  13251. this.onChangedObservable.notifyObservers(this);
  13252. },
  13253. enumerable: true,
  13254. configurable: true
  13255. });
  13256. /** Dispose all associated resources */
  13257. Style.prototype.dispose = function () {
  13258. this.onChangedObservable.clear();
  13259. };
  13260. return Style;
  13261. }());
  13262. /***/ }),
  13263. /***/ "./2D/valueAndUnit.ts":
  13264. /*!****************************!*\
  13265. !*** ./2D/valueAndUnit.ts ***!
  13266. \****************************/
  13267. /*! exports provided: ValueAndUnit */
  13268. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13269. "use strict";
  13270. __webpack_require__.r(__webpack_exports__);
  13271. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  13272. /**
  13273. * Class used to specific a value and its associated unit
  13274. */
  13275. var ValueAndUnit = /** @class */ (function () {
  13276. /**
  13277. * Creates a new ValueAndUnit
  13278. * @param value defines the value to store
  13279. * @param unit defines the unit to store
  13280. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  13281. */
  13282. function ValueAndUnit(value,
  13283. /** defines the unit to store */
  13284. unit,
  13285. /** defines a boolean indicating if the value can be negative */
  13286. negativeValueAllowed) {
  13287. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13288. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  13289. this.unit = unit;
  13290. this.negativeValueAllowed = negativeValueAllowed;
  13291. this._value = 1;
  13292. /**
  13293. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  13294. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  13295. */
  13296. this.ignoreAdaptiveScaling = false;
  13297. this._value = value;
  13298. this._originalUnit = unit;
  13299. }
  13300. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  13301. /** Gets a boolean indicating if the value is a percentage */
  13302. get: function () {
  13303. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  13304. },
  13305. enumerable: true,
  13306. configurable: true
  13307. });
  13308. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  13309. /** Gets a boolean indicating if the value is store as pixel */
  13310. get: function () {
  13311. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  13312. },
  13313. enumerable: true,
  13314. configurable: true
  13315. });
  13316. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  13317. /** Gets direct internal value */
  13318. get: function () {
  13319. return this._value;
  13320. },
  13321. enumerable: true,
  13322. configurable: true
  13323. });
  13324. /**
  13325. * Gets value as pixel
  13326. * @param host defines the root host
  13327. * @param refValue defines the reference value for percentages
  13328. * @returns the value as pixel
  13329. */
  13330. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  13331. if (this.isPixel) {
  13332. return this.getValue(host);
  13333. }
  13334. return this.getValue(host) * refValue;
  13335. };
  13336. /**
  13337. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  13338. * @param value defines the value to store
  13339. * @param unit defines the unit to store
  13340. * @returns the current ValueAndUnit
  13341. */
  13342. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  13343. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13344. this._value = value;
  13345. this.unit = unit;
  13346. return this;
  13347. };
  13348. /**
  13349. * Gets the value accordingly to its unit
  13350. * @param host defines the root host
  13351. * @returns the value
  13352. */
  13353. ValueAndUnit.prototype.getValue = function (host) {
  13354. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  13355. var width = 0;
  13356. var height = 0;
  13357. if (host.idealWidth) {
  13358. width = (this._value * host.getSize().width) / host.idealWidth;
  13359. }
  13360. if (host.idealHeight) {
  13361. height = (this._value * host.getSize().height) / host.idealHeight;
  13362. }
  13363. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  13364. return window.innerWidth < window.innerHeight ? width : height;
  13365. }
  13366. if (host.idealWidth) { // horizontal
  13367. return width;
  13368. }
  13369. if (host.idealHeight) { // vertical
  13370. return height;
  13371. }
  13372. }
  13373. return this._value;
  13374. };
  13375. /**
  13376. * Gets a string representation of the value
  13377. * @param host defines the root host
  13378. * @param decimals defines an optional number of decimals to display
  13379. * @returns a string
  13380. */
  13381. ValueAndUnit.prototype.toString = function (host, decimals) {
  13382. switch (this.unit) {
  13383. case ValueAndUnit.UNITMODE_PERCENTAGE:
  13384. var percentage = this.getValue(host) * 100;
  13385. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  13386. case ValueAndUnit.UNITMODE_PIXEL:
  13387. var pixels = this.getValue(host);
  13388. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  13389. }
  13390. return this.unit.toString();
  13391. };
  13392. /**
  13393. * Store a value parsed from a string
  13394. * @param source defines the source string
  13395. * @returns true if the value was successfully parsed
  13396. */
  13397. ValueAndUnit.prototype.fromString = function (source) {
  13398. var match = ValueAndUnit._Regex.exec(source.toString());
  13399. if (!match || match.length === 0) {
  13400. return false;
  13401. }
  13402. var sourceValue = parseFloat(match[1]);
  13403. var sourceUnit = this._originalUnit;
  13404. if (!this.negativeValueAllowed) {
  13405. if (sourceValue < 0) {
  13406. sourceValue = 0;
  13407. }
  13408. }
  13409. if (match.length === 4) {
  13410. switch (match[3]) {
  13411. case "px":
  13412. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  13413. break;
  13414. case "%":
  13415. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  13416. sourceValue /= 100.0;
  13417. break;
  13418. }
  13419. }
  13420. if (sourceValue === this._value && sourceUnit === this.unit) {
  13421. return false;
  13422. }
  13423. this._value = sourceValue;
  13424. this.unit = sourceUnit;
  13425. return true;
  13426. };
  13427. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  13428. /** UNITMODE_PERCENTAGE */
  13429. get: function () {
  13430. return ValueAndUnit._UNITMODE_PERCENTAGE;
  13431. },
  13432. enumerable: true,
  13433. configurable: true
  13434. });
  13435. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  13436. /** UNITMODE_PIXEL */
  13437. get: function () {
  13438. return ValueAndUnit._UNITMODE_PIXEL;
  13439. },
  13440. enumerable: true,
  13441. configurable: true
  13442. });
  13443. // Static
  13444. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  13445. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  13446. ValueAndUnit._UNITMODE_PIXEL = 1;
  13447. return ValueAndUnit;
  13448. }());
  13449. /***/ }),
  13450. /***/ "./2D/xmlLoader.ts":
  13451. /*!*************************!*\
  13452. !*** ./2D/xmlLoader.ts ***!
  13453. \*************************/
  13454. /*! exports provided: XmlLoader */
  13455. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13456. "use strict";
  13457. __webpack_require__.r(__webpack_exports__);
  13458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  13459. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  13460. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  13461. /**
  13462. * Class used to load GUI via XML.
  13463. */
  13464. var XmlLoader = /** @class */ (function () {
  13465. /**
  13466. * Create a new xml loader
  13467. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  13468. */
  13469. function XmlLoader(parentClass) {
  13470. if (parentClass === void 0) { parentClass = null; }
  13471. this._nodes = {};
  13472. this._nodeTypes = {
  13473. element: 1,
  13474. attribute: 2,
  13475. text: 3
  13476. };
  13477. this._isLoaded = false;
  13478. this._objectAttributes = {
  13479. "textHorizontalAlignment": 1,
  13480. "textVerticalAlignment": 2,
  13481. "horizontalAlignment": 3,
  13482. "verticalAlignment": 4,
  13483. "stretch": 5,
  13484. };
  13485. if (parentClass) {
  13486. this._parentClass = parentClass;
  13487. }
  13488. }
  13489. XmlLoader.prototype._getChainElement = function (attributeValue) {
  13490. var element = window;
  13491. if (this._parentClass) {
  13492. element = this._parentClass;
  13493. }
  13494. var value = attributeValue;
  13495. value = value.split(".");
  13496. for (var i = 0; i < value.length; i++) {
  13497. element = element[value[i]];
  13498. }
  13499. return element;
  13500. };
  13501. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  13502. var attribute = attributeName.split(".");
  13503. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  13504. return className[attribute[1]];
  13505. };
  13506. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  13507. if (linkParent === void 0) { linkParent = true; }
  13508. try {
  13509. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  13510. var guiNode = new className();
  13511. if (parent && linkParent) {
  13512. parent.addControl(guiNode);
  13513. }
  13514. for (var i = 0; i < node.attributes.length; i++) {
  13515. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  13516. continue;
  13517. }
  13518. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  13519. var element = this._getChainElement(node.attributes[i].value);
  13520. guiNode[node.attributes[i].name].add(element);
  13521. continue;
  13522. }
  13523. else if (node.attributes[i].name == "linkWithMesh") {
  13524. if (this._parentClass) {
  13525. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  13526. }
  13527. else {
  13528. guiNode.linkWithMesh(window[node.attributes[i].value]);
  13529. }
  13530. }
  13531. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  13532. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  13533. guiNode[node.attributes[i].name] = element;
  13534. }
  13535. else if (!this._objectAttributes[node.attributes[i].name]) {
  13536. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  13537. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  13538. }
  13539. else {
  13540. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  13541. }
  13542. }
  13543. else {
  13544. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  13545. }
  13546. }
  13547. if (!node.attributes.getNamedItem("id")) {
  13548. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  13549. return guiNode;
  13550. }
  13551. var id = node.attributes.getNamedItem("id").value;
  13552. if (id.startsWith("{{") && id.endsWith("}}")) {
  13553. id = this._getChainElement(id.substring(2, id.length - 2));
  13554. }
  13555. if (!this._nodes[id]) {
  13556. this._nodes[id] = guiNode;
  13557. }
  13558. else {
  13559. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  13560. }
  13561. return guiNode;
  13562. }
  13563. catch (e) {
  13564. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  13565. }
  13566. };
  13567. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  13568. var width;
  13569. var height;
  13570. var columns;
  13571. var rows = node.children;
  13572. var cells;
  13573. var isPixel = false;
  13574. var cellNode;
  13575. var rowNumber = -1;
  13576. var columnNumber = -1;
  13577. var totalColumnsNumber = 0;
  13578. for (var i = 0; i < rows.length; i++) {
  13579. if (rows[i].nodeType != this._nodeTypes.element) {
  13580. continue;
  13581. }
  13582. if (rows[i].nodeName != "Row") {
  13583. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  13584. }
  13585. rowNumber += 1;
  13586. columns = rows[i].children;
  13587. if (!rows[i].attributes.getNamedItem("height")) {
  13588. throw "XmlLoader Exception : Height must be defined for grid rows";
  13589. }
  13590. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  13591. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  13592. guiNode.addRowDefinition(height, isPixel);
  13593. for (var j = 0; j < columns.length; j++) {
  13594. if (columns[j].nodeType != this._nodeTypes.element) {
  13595. continue;
  13596. }
  13597. if (columns[j].nodeName != "Column") {
  13598. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  13599. }
  13600. columnNumber += 1;
  13601. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  13602. 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.";
  13603. }
  13604. if (rowNumber == 0) {
  13605. if (!columns[j].attributes.getNamedItem("width")) {
  13606. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  13607. }
  13608. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  13609. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  13610. guiNode.addColumnDefinition(width, isPixel);
  13611. }
  13612. cells = columns[j].children;
  13613. for (var k = 0; k < cells.length; k++) {
  13614. if (cells[k].nodeType != this._nodeTypes.element) {
  13615. continue;
  13616. }
  13617. cellNode = this._createGuiElement(cells[k], guiNode, false);
  13618. guiNode.addControl(cellNode, rowNumber, columnNumber);
  13619. if (cells[k].firstChild) {
  13620. this._parseXml(cells[k].firstChild, cellNode);
  13621. }
  13622. }
  13623. }
  13624. if (rowNumber == 0) {
  13625. totalColumnsNumber = columnNumber;
  13626. }
  13627. columnNumber = -1;
  13628. }
  13629. if (node.nextSibling) {
  13630. this._parseXml(node.nextSibling, parent);
  13631. }
  13632. };
  13633. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  13634. if (node.firstChild) {
  13635. this._parseXml(node.firstChild, guiNode);
  13636. }
  13637. if (node.nextSibling) {
  13638. this._parseXml(node.nextSibling, parent);
  13639. }
  13640. };
  13641. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  13642. if (this._parentClass) {
  13643. this._parentClass[variable] = source[iterator];
  13644. }
  13645. else {
  13646. window[variable] = source[iterator];
  13647. }
  13648. if (node.firstChild) {
  13649. this._parseXml(node.firstChild, guiNode, true);
  13650. }
  13651. };
  13652. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  13653. var dataSource = node.attributes.getNamedItem("dataSource").value;
  13654. if (!dataSource.includes(" in ")) {
  13655. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  13656. }
  13657. else {
  13658. var isArray = true;
  13659. var splittedSource = dataSource.split(" in ");
  13660. if (splittedSource.length < 2) {
  13661. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  13662. }
  13663. var source = splittedSource[1];
  13664. if (source.startsWith("{") && source.endsWith("}")) {
  13665. isArray = false;
  13666. }
  13667. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  13668. source = source.substring(1, source.length - 1);
  13669. }
  13670. if (this._parentClass) {
  13671. source = this._parentClass[source];
  13672. }
  13673. else {
  13674. source = window[source];
  13675. }
  13676. if (isArray) {
  13677. for (var i = 0; i < source.length; i++) {
  13678. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13679. }
  13680. }
  13681. else {
  13682. for (var i in source) {
  13683. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13684. }
  13685. }
  13686. if (node.nextSibling) {
  13687. this._parseXml(node.nextSibling, parent);
  13688. }
  13689. }
  13690. };
  13691. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  13692. if (generated === void 0) { generated = false; }
  13693. if (node.nodeType != this._nodeTypes.element) {
  13694. if (node.nextSibling) {
  13695. this._parseXml(node.nextSibling, parent, generated);
  13696. }
  13697. return;
  13698. }
  13699. if (generated) {
  13700. node.setAttribute("id", parent.id + (parent._children.length + 1));
  13701. }
  13702. var guiNode = this._createGuiElement(node, parent);
  13703. if (node.nodeName == "Grid") {
  13704. this._parseGrid(node, guiNode, parent);
  13705. }
  13706. else if (!node.attributes.getNamedItem("dataSource")) {
  13707. this._parseElement(node, guiNode, parent);
  13708. }
  13709. else {
  13710. this._parseElementsFromSource(node, guiNode, parent);
  13711. }
  13712. };
  13713. /**
  13714. * Gets if the loading has finished.
  13715. * @returns whether the loading has finished or not
  13716. */
  13717. XmlLoader.prototype.isLoaded = function () {
  13718. return this._isLoaded;
  13719. };
  13720. /**
  13721. * Gets a loaded node / control by id.
  13722. * @param id the Controls id set in the xml
  13723. * @returns element of type Control
  13724. */
  13725. XmlLoader.prototype.getNodeById = function (id) {
  13726. return this._nodes[id];
  13727. };
  13728. /**
  13729. * Gets all loaded nodes / controls
  13730. * @returns Array of controls
  13731. */
  13732. XmlLoader.prototype.getNodes = function () {
  13733. return this._nodes;
  13734. };
  13735. /**
  13736. * Initiates the xml layout loading
  13737. * @param xmlFile defines the xml layout to load
  13738. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  13739. * @param callback defines the callback called on layout load.
  13740. */
  13741. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  13742. var xhttp = new XMLHttpRequest();
  13743. xhttp.onreadystatechange = function () {
  13744. if (xhttp.readyState == 4 && xhttp.status == 200) {
  13745. if (!xhttp.responseXML) {
  13746. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  13747. }
  13748. var xmlDoc = xhttp.responseXML.documentElement;
  13749. this._parseXml(xmlDoc.firstChild, rootNode);
  13750. this._isLoaded = true;
  13751. if (callback) {
  13752. callback();
  13753. }
  13754. }
  13755. }.bind(this);
  13756. xhttp.open("GET", xmlFile, true);
  13757. xhttp.send();
  13758. };
  13759. return XmlLoader;
  13760. }());
  13761. /***/ }),
  13762. /***/ "./3D/controls/abstractButton3D.ts":
  13763. /*!*****************************************!*\
  13764. !*** ./3D/controls/abstractButton3D.ts ***!
  13765. \*****************************************/
  13766. /*! exports provided: AbstractButton3D */
  13767. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13768. "use strict";
  13769. __webpack_require__.r(__webpack_exports__);
  13770. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  13771. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13772. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  13773. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13774. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13775. /**
  13776. * Class used as a root to all buttons
  13777. */
  13778. var AbstractButton3D = /** @class */ (function (_super) {
  13779. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  13780. /**
  13781. * Creates a new button
  13782. * @param name defines the control name
  13783. */
  13784. function AbstractButton3D(name) {
  13785. return _super.call(this, name) || this;
  13786. }
  13787. AbstractButton3D.prototype._getTypeName = function () {
  13788. return "AbstractButton3D";
  13789. };
  13790. // Mesh association
  13791. AbstractButton3D.prototype._createNode = function (scene) {
  13792. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  13793. };
  13794. return AbstractButton3D;
  13795. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13796. /***/ }),
  13797. /***/ "./3D/controls/button3D.ts":
  13798. /*!*********************************!*\
  13799. !*** ./3D/controls/button3D.ts ***!
  13800. \*********************************/
  13801. /*! exports provided: Button3D */
  13802. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13803. "use strict";
  13804. __webpack_require__.r(__webpack_exports__);
  13805. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  13806. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13807. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  13808. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13809. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13810. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13811. /**
  13812. * Class used to create a button in 3D
  13813. */
  13814. var Button3D = /** @class */ (function (_super) {
  13815. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  13816. /**
  13817. * Creates a new button
  13818. * @param name defines the control name
  13819. */
  13820. function Button3D(name) {
  13821. var _this = _super.call(this, name) || this;
  13822. _this._contentResolution = 512;
  13823. _this._contentScaleRatio = 2;
  13824. // Default animations
  13825. _this.pointerEnterAnimation = function () {
  13826. if (!_this.mesh) {
  13827. return;
  13828. }
  13829. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  13830. };
  13831. _this.pointerOutAnimation = function () {
  13832. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13833. };
  13834. _this.pointerDownAnimation = function () {
  13835. if (!_this.mesh) {
  13836. return;
  13837. }
  13838. _this.mesh.scaling.scaleInPlace(0.95);
  13839. };
  13840. _this.pointerUpAnimation = function () {
  13841. if (!_this.mesh) {
  13842. return;
  13843. }
  13844. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13845. };
  13846. return _this;
  13847. }
  13848. Object.defineProperty(Button3D.prototype, "contentResolution", {
  13849. /**
  13850. * Gets or sets the texture resolution used to render content (512 by default)
  13851. */
  13852. get: function () {
  13853. return this._contentResolution;
  13854. },
  13855. set: function (value) {
  13856. if (this._contentResolution === value) {
  13857. return;
  13858. }
  13859. this._contentResolution = value;
  13860. this._resetContent();
  13861. },
  13862. enumerable: true,
  13863. configurable: true
  13864. });
  13865. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  13866. /**
  13867. * Gets or sets the texture scale ratio used to render content (2 by default)
  13868. */
  13869. get: function () {
  13870. return this._contentScaleRatio;
  13871. },
  13872. set: function (value) {
  13873. if (this._contentScaleRatio === value) {
  13874. return;
  13875. }
  13876. this._contentScaleRatio = value;
  13877. this._resetContent();
  13878. },
  13879. enumerable: true,
  13880. configurable: true
  13881. });
  13882. Button3D.prototype._disposeFacadeTexture = function () {
  13883. if (this._facadeTexture) {
  13884. this._facadeTexture.dispose();
  13885. this._facadeTexture = null;
  13886. }
  13887. };
  13888. Button3D.prototype._resetContent = function () {
  13889. this._disposeFacadeTexture();
  13890. this.content = this._content;
  13891. };
  13892. Object.defineProperty(Button3D.prototype, "content", {
  13893. /**
  13894. * Gets or sets the GUI 2D content used to display the button's facade
  13895. */
  13896. get: function () {
  13897. return this._content;
  13898. },
  13899. set: function (value) {
  13900. this._content = value;
  13901. if (!this._host || !this._host.utilityLayer) {
  13902. return;
  13903. }
  13904. if (!this._facadeTexture) {
  13905. this._facadeTexture = new _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__["AdvancedDynamicTexture"]("Facade", this._contentResolution, this._contentResolution, this._host.utilityLayer.utilityLayerScene, true, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  13906. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  13907. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  13908. this._facadeTexture.premulAlpha = true;
  13909. }
  13910. else {
  13911. this._facadeTexture.rootContainer.clearControls();
  13912. }
  13913. this._facadeTexture.addControl(value);
  13914. this._applyFacade(this._facadeTexture);
  13915. },
  13916. enumerable: true,
  13917. configurable: true
  13918. });
  13919. /**
  13920. * Apply the facade texture (created from the content property).
  13921. * This function can be overloaded by child classes
  13922. * @param facadeTexture defines the AdvancedDynamicTexture to use
  13923. */
  13924. Button3D.prototype._applyFacade = function (facadeTexture) {
  13925. this._currentMaterial.emissiveTexture = facadeTexture;
  13926. };
  13927. Button3D.prototype._getTypeName = function () {
  13928. return "Button3D";
  13929. };
  13930. // Mesh association
  13931. Button3D.prototype._createNode = function (scene) {
  13932. var faceUV = new Array(6);
  13933. for (var i = 0; i < 6; i++) {
  13934. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  13935. }
  13936. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  13937. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  13938. width: 1.0,
  13939. height: 1.0,
  13940. depth: 0.08,
  13941. faceUV: faceUV
  13942. }, scene);
  13943. return mesh;
  13944. };
  13945. Button3D.prototype._affectMaterial = function (mesh) {
  13946. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  13947. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13948. mesh.material = material;
  13949. this._currentMaterial = material;
  13950. this._resetContent();
  13951. };
  13952. /**
  13953. * Releases all associated resources
  13954. */
  13955. Button3D.prototype.dispose = function () {
  13956. _super.prototype.dispose.call(this);
  13957. this._disposeFacadeTexture();
  13958. if (this._currentMaterial) {
  13959. this._currentMaterial.dispose();
  13960. }
  13961. };
  13962. return Button3D;
  13963. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  13964. /***/ }),
  13965. /***/ "./3D/controls/container3D.ts":
  13966. /*!************************************!*\
  13967. !*** ./3D/controls/container3D.ts ***!
  13968. \************************************/
  13969. /*! exports provided: Container3D */
  13970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13971. "use strict";
  13972. __webpack_require__.r(__webpack_exports__);
  13973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  13974. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13975. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  13976. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13977. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13978. /**
  13979. * Class used to create containers for controls
  13980. */
  13981. var Container3D = /** @class */ (function (_super) {
  13982. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  13983. /**
  13984. * Creates a new container
  13985. * @param name defines the container name
  13986. */
  13987. function Container3D(name) {
  13988. var _this = _super.call(this, name) || this;
  13989. _this._blockLayout = false;
  13990. /**
  13991. * Gets the list of child controls
  13992. */
  13993. _this._children = new Array();
  13994. return _this;
  13995. }
  13996. Object.defineProperty(Container3D.prototype, "children", {
  13997. /**
  13998. * Gets the list of child controls
  13999. */
  14000. get: function () {
  14001. return this._children;
  14002. },
  14003. enumerable: true,
  14004. configurable: true
  14005. });
  14006. Object.defineProperty(Container3D.prototype, "blockLayout", {
  14007. /**
  14008. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  14009. * This is helpful to optimize layout operation when adding multiple children in a row
  14010. */
  14011. get: function () {
  14012. return this._blockLayout;
  14013. },
  14014. set: function (value) {
  14015. if (this._blockLayout === value) {
  14016. return;
  14017. }
  14018. this._blockLayout = value;
  14019. if (!this._blockLayout) {
  14020. this._arrangeChildren();
  14021. }
  14022. },
  14023. enumerable: true,
  14024. configurable: true
  14025. });
  14026. /**
  14027. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  14028. * @returns the current container
  14029. */
  14030. Container3D.prototype.updateLayout = function () {
  14031. this._arrangeChildren();
  14032. return this;
  14033. };
  14034. /**
  14035. * Gets a boolean indicating if the given control is in the children of this control
  14036. * @param control defines the control to check
  14037. * @returns true if the control is in the child list
  14038. */
  14039. Container3D.prototype.containsControl = function (control) {
  14040. return this._children.indexOf(control) !== -1;
  14041. };
  14042. /**
  14043. * Adds a control to the children of this control
  14044. * @param control defines the control to add
  14045. * @returns the current container
  14046. */
  14047. Container3D.prototype.addControl = function (control) {
  14048. var index = this._children.indexOf(control);
  14049. if (index !== -1) {
  14050. return this;
  14051. }
  14052. control.parent = this;
  14053. control._host = this._host;
  14054. this._children.push(control);
  14055. if (this._host.utilityLayer) {
  14056. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  14057. if (control.node) {
  14058. control.node.parent = this.node;
  14059. }
  14060. if (!this.blockLayout) {
  14061. this._arrangeChildren();
  14062. }
  14063. }
  14064. return this;
  14065. };
  14066. /**
  14067. * This function will be called everytime a new control is added
  14068. */
  14069. Container3D.prototype._arrangeChildren = function () {
  14070. };
  14071. Container3D.prototype._createNode = function (scene) {
  14072. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  14073. };
  14074. /**
  14075. * Removes a control from the children of this control
  14076. * @param control defines the control to remove
  14077. * @returns the current container
  14078. */
  14079. Container3D.prototype.removeControl = function (control) {
  14080. var index = this._children.indexOf(control);
  14081. if (index !== -1) {
  14082. this._children.splice(index, 1);
  14083. control.parent = null;
  14084. control._disposeNode();
  14085. }
  14086. return this;
  14087. };
  14088. Container3D.prototype._getTypeName = function () {
  14089. return "Container3D";
  14090. };
  14091. /**
  14092. * Releases all associated resources
  14093. */
  14094. Container3D.prototype.dispose = function () {
  14095. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14096. var control = _a[_i];
  14097. control.dispose();
  14098. }
  14099. this._children = [];
  14100. _super.prototype.dispose.call(this);
  14101. };
  14102. /** Control rotation will remain unchanged */
  14103. Container3D.UNSET_ORIENTATION = 0;
  14104. /** Control will rotate to make it look at sphere central axis */
  14105. Container3D.FACEORIGIN_ORIENTATION = 1;
  14106. /** Control will rotate to make it look back at sphere central axis */
  14107. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  14108. /** Control will rotate to look at z axis (0, 0, 1) */
  14109. Container3D.FACEFORWARD_ORIENTATION = 3;
  14110. /** Control will rotate to look at negative z axis (0, 0, -1) */
  14111. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  14112. return Container3D;
  14113. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14114. /***/ }),
  14115. /***/ "./3D/controls/control3D.ts":
  14116. /*!**********************************!*\
  14117. !*** ./3D/controls/control3D.ts ***!
  14118. \**********************************/
  14119. /*! exports provided: Control3D */
  14120. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14121. "use strict";
  14122. __webpack_require__.r(__webpack_exports__);
  14123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  14124. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  14125. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14126. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14127. /**
  14128. * Class used as base class for controls
  14129. */
  14130. var Control3D = /** @class */ (function () {
  14131. /**
  14132. * Creates a new control
  14133. * @param name defines the control name
  14134. */
  14135. function Control3D(
  14136. /** Defines the control name */
  14137. name) {
  14138. this.name = name;
  14139. this._downCount = 0;
  14140. this._enterCount = -1;
  14141. this._downPointerIds = {};
  14142. this._isVisible = true;
  14143. /**
  14144. * An event triggered when the pointer move over the control
  14145. */
  14146. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14147. /**
  14148. * An event triggered when the pointer move out of the control
  14149. */
  14150. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14151. /**
  14152. * An event triggered when the pointer taps the control
  14153. */
  14154. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14155. /**
  14156. * An event triggered when pointer is up
  14157. */
  14158. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14159. /**
  14160. * An event triggered when a control is clicked on (with a mouse)
  14161. */
  14162. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14163. /**
  14164. * An event triggered when pointer enters the control
  14165. */
  14166. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14167. // Behaviors
  14168. this._behaviors = new Array();
  14169. }
  14170. Object.defineProperty(Control3D.prototype, "position", {
  14171. /** Gets or sets the control position in world space */
  14172. get: function () {
  14173. if (!this._node) {
  14174. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  14175. }
  14176. return this._node.position;
  14177. },
  14178. set: function (value) {
  14179. if (!this._node) {
  14180. return;
  14181. }
  14182. this._node.position = value;
  14183. },
  14184. enumerable: true,
  14185. configurable: true
  14186. });
  14187. Object.defineProperty(Control3D.prototype, "scaling", {
  14188. /** Gets or sets the control scaling in world space */
  14189. get: function () {
  14190. if (!this._node) {
  14191. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  14192. }
  14193. return this._node.scaling;
  14194. },
  14195. set: function (value) {
  14196. if (!this._node) {
  14197. return;
  14198. }
  14199. this._node.scaling = value;
  14200. },
  14201. enumerable: true,
  14202. configurable: true
  14203. });
  14204. Object.defineProperty(Control3D.prototype, "behaviors", {
  14205. /**
  14206. * Gets the list of attached behaviors
  14207. * @see http://doc.babylonjs.com/features/behaviour
  14208. */
  14209. get: function () {
  14210. return this._behaviors;
  14211. },
  14212. enumerable: true,
  14213. configurable: true
  14214. });
  14215. /**
  14216. * Attach a behavior to the control
  14217. * @see http://doc.babylonjs.com/features/behaviour
  14218. * @param behavior defines the behavior to attach
  14219. * @returns the current control
  14220. */
  14221. Control3D.prototype.addBehavior = function (behavior) {
  14222. var _this = this;
  14223. var index = this._behaviors.indexOf(behavior);
  14224. if (index !== -1) {
  14225. return this;
  14226. }
  14227. behavior.init();
  14228. var scene = this._host.scene;
  14229. if (scene.isLoading) {
  14230. // We defer the attach when the scene will be loaded
  14231. scene.onDataLoadedObservable.addOnce(function () {
  14232. behavior.attach(_this);
  14233. });
  14234. }
  14235. else {
  14236. behavior.attach(this);
  14237. }
  14238. this._behaviors.push(behavior);
  14239. return this;
  14240. };
  14241. /**
  14242. * Remove an attached behavior
  14243. * @see http://doc.babylonjs.com/features/behaviour
  14244. * @param behavior defines the behavior to attach
  14245. * @returns the current control
  14246. */
  14247. Control3D.prototype.removeBehavior = function (behavior) {
  14248. var index = this._behaviors.indexOf(behavior);
  14249. if (index === -1) {
  14250. return this;
  14251. }
  14252. this._behaviors[index].detach();
  14253. this._behaviors.splice(index, 1);
  14254. return this;
  14255. };
  14256. /**
  14257. * Gets an attached behavior by name
  14258. * @param name defines the name of the behavior to look for
  14259. * @see http://doc.babylonjs.com/features/behaviour
  14260. * @returns null if behavior was not found else the requested behavior
  14261. */
  14262. Control3D.prototype.getBehaviorByName = function (name) {
  14263. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14264. var behavior = _a[_i];
  14265. if (behavior.name === name) {
  14266. return behavior;
  14267. }
  14268. }
  14269. return null;
  14270. };
  14271. Object.defineProperty(Control3D.prototype, "isVisible", {
  14272. /** Gets or sets a boolean indicating if the control is visible */
  14273. get: function () {
  14274. return this._isVisible;
  14275. },
  14276. set: function (value) {
  14277. if (this._isVisible === value) {
  14278. return;
  14279. }
  14280. this._isVisible = value;
  14281. var mesh = this.mesh;
  14282. if (mesh) {
  14283. mesh.setEnabled(value);
  14284. }
  14285. },
  14286. enumerable: true,
  14287. configurable: true
  14288. });
  14289. Object.defineProperty(Control3D.prototype, "typeName", {
  14290. /**
  14291. * Gets a string representing the class name
  14292. */
  14293. get: function () {
  14294. return this._getTypeName();
  14295. },
  14296. enumerable: true,
  14297. configurable: true
  14298. });
  14299. /**
  14300. * Get the current class name of the control.
  14301. * @returns current class name
  14302. */
  14303. Control3D.prototype.getClassName = function () {
  14304. return this._getTypeName();
  14305. };
  14306. Control3D.prototype._getTypeName = function () {
  14307. return "Control3D";
  14308. };
  14309. Object.defineProperty(Control3D.prototype, "node", {
  14310. /**
  14311. * Gets the transform node used by this control
  14312. */
  14313. get: function () {
  14314. return this._node;
  14315. },
  14316. enumerable: true,
  14317. configurable: true
  14318. });
  14319. Object.defineProperty(Control3D.prototype, "mesh", {
  14320. /**
  14321. * Gets the mesh used to render this control
  14322. */
  14323. get: function () {
  14324. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  14325. return this._node;
  14326. }
  14327. return null;
  14328. },
  14329. enumerable: true,
  14330. configurable: true
  14331. });
  14332. /**
  14333. * Link the control as child of the given node
  14334. * @param node defines the node to link to. Use null to unlink the control
  14335. * @returns the current control
  14336. */
  14337. Control3D.prototype.linkToTransformNode = function (node) {
  14338. if (this._node) {
  14339. this._node.parent = node;
  14340. }
  14341. return this;
  14342. };
  14343. /** @hidden **/
  14344. Control3D.prototype._prepareNode = function (scene) {
  14345. if (!this._node) {
  14346. this._node = this._createNode(scene);
  14347. if (!this.node) {
  14348. return;
  14349. }
  14350. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  14351. this._node.position = this.position;
  14352. this._node.scaling = this.scaling;
  14353. var mesh = this.mesh;
  14354. if (mesh) {
  14355. mesh.isPickable = true;
  14356. this._affectMaterial(mesh);
  14357. }
  14358. }
  14359. };
  14360. /**
  14361. * Node creation.
  14362. * Can be overriden by children
  14363. * @param scene defines the scene where the node must be attached
  14364. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  14365. */
  14366. Control3D.prototype._createNode = function (scene) {
  14367. // Do nothing by default
  14368. return null;
  14369. };
  14370. /**
  14371. * Affect a material to the given mesh
  14372. * @param mesh defines the mesh which will represent the control
  14373. */
  14374. Control3D.prototype._affectMaterial = function (mesh) {
  14375. mesh.material = null;
  14376. };
  14377. // Pointers
  14378. /** @hidden */
  14379. Control3D.prototype._onPointerMove = function (target, coordinates) {
  14380. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  14381. };
  14382. /** @hidden */
  14383. Control3D.prototype._onPointerEnter = function (target) {
  14384. if (this._enterCount > 0) {
  14385. return false;
  14386. }
  14387. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  14388. this._enterCount = 0;
  14389. }
  14390. this._enterCount++;
  14391. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  14392. if (this.pointerEnterAnimation) {
  14393. this.pointerEnterAnimation();
  14394. }
  14395. return true;
  14396. };
  14397. /** @hidden */
  14398. Control3D.prototype._onPointerOut = function (target) {
  14399. this._enterCount = 0;
  14400. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  14401. if (this.pointerOutAnimation) {
  14402. this.pointerOutAnimation();
  14403. }
  14404. };
  14405. /** @hidden */
  14406. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  14407. if (this._downCount !== 0) {
  14408. this._downCount++;
  14409. return false;
  14410. }
  14411. this._downCount++;
  14412. this._downPointerIds[pointerId] = true;
  14413. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14414. if (this.pointerDownAnimation) {
  14415. this.pointerDownAnimation();
  14416. }
  14417. return true;
  14418. };
  14419. /** @hidden */
  14420. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  14421. this._downCount--;
  14422. delete this._downPointerIds[pointerId];
  14423. if (this._downCount < 0) {
  14424. // Handle if forcePointerUp was called prior to this
  14425. this._downCount = 0;
  14426. return;
  14427. }
  14428. if (this._downCount == 0) {
  14429. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  14430. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14431. }
  14432. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14433. if (this.pointerUpAnimation) {
  14434. this.pointerUpAnimation();
  14435. }
  14436. }
  14437. };
  14438. /** @hidden */
  14439. Control3D.prototype.forcePointerUp = function (pointerId) {
  14440. if (pointerId === void 0) { pointerId = null; }
  14441. if (pointerId !== null) {
  14442. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  14443. }
  14444. else {
  14445. for (var key in this._downPointerIds) {
  14446. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  14447. }
  14448. if (this._downCount > 0) {
  14449. this._downCount = 1;
  14450. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  14451. }
  14452. }
  14453. };
  14454. /** @hidden */
  14455. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  14456. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14457. this._onPointerMove(this, pickedPoint);
  14458. var previousControlOver = this._host._lastControlOver[pointerId];
  14459. if (previousControlOver && previousControlOver !== this) {
  14460. previousControlOver._onPointerOut(this);
  14461. }
  14462. if (previousControlOver !== this) {
  14463. this._onPointerEnter(this);
  14464. }
  14465. this._host._lastControlOver[pointerId] = this;
  14466. return true;
  14467. }
  14468. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  14469. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  14470. this._host._lastControlDown[pointerId] = this;
  14471. this._host._lastPickedControl = this;
  14472. return true;
  14473. }
  14474. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14475. if (this._host._lastControlDown[pointerId]) {
  14476. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  14477. }
  14478. delete this._host._lastControlDown[pointerId];
  14479. return true;
  14480. }
  14481. return false;
  14482. };
  14483. /** @hidden */
  14484. Control3D.prototype._disposeNode = function () {
  14485. if (this._node) {
  14486. this._node.dispose();
  14487. this._node = null;
  14488. }
  14489. };
  14490. /**
  14491. * Releases all associated resources
  14492. */
  14493. Control3D.prototype.dispose = function () {
  14494. this.onPointerDownObservable.clear();
  14495. this.onPointerEnterObservable.clear();
  14496. this.onPointerMoveObservable.clear();
  14497. this.onPointerOutObservable.clear();
  14498. this.onPointerUpObservable.clear();
  14499. this.onPointerClickObservable.clear();
  14500. this._disposeNode();
  14501. // Behaviors
  14502. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14503. var behavior = _a[_i];
  14504. behavior.detach();
  14505. }
  14506. };
  14507. return Control3D;
  14508. }());
  14509. /***/ }),
  14510. /***/ "./3D/controls/cylinderPanel.ts":
  14511. /*!**************************************!*\
  14512. !*** ./3D/controls/cylinderPanel.ts ***!
  14513. \**************************************/
  14514. /*! exports provided: CylinderPanel */
  14515. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14516. "use strict";
  14517. __webpack_require__.r(__webpack_exports__);
  14518. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  14519. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14520. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  14521. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14522. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14523. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14524. /**
  14525. * Class used to create a container panel deployed on the surface of a cylinder
  14526. */
  14527. var CylinderPanel = /** @class */ (function (_super) {
  14528. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  14529. function CylinderPanel() {
  14530. var _this = _super !== null && _super.apply(this, arguments) || this;
  14531. _this._radius = 5.0;
  14532. return _this;
  14533. }
  14534. Object.defineProperty(CylinderPanel.prototype, "radius", {
  14535. /**
  14536. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  14537. */
  14538. get: function () {
  14539. return this._radius;
  14540. },
  14541. set: function (value) {
  14542. var _this = this;
  14543. if (this._radius === value) {
  14544. return;
  14545. }
  14546. this._radius = value;
  14547. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14548. _this._arrangeChildren();
  14549. });
  14550. },
  14551. enumerable: true,
  14552. configurable: true
  14553. });
  14554. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  14555. var mesh = control.mesh;
  14556. if (!mesh) {
  14557. return;
  14558. }
  14559. var newPos = this._cylindricalMapping(nodePosition);
  14560. control.position = newPos;
  14561. switch (this.orientation) {
  14562. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14563. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  14564. break;
  14565. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14566. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  14567. break;
  14568. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14569. break;
  14570. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14571. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14572. break;
  14573. }
  14574. };
  14575. CylinderPanel.prototype._cylindricalMapping = function (source) {
  14576. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  14577. var yAngle = (source.x / this._radius);
  14578. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14579. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14580. };
  14581. return CylinderPanel;
  14582. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14583. /***/ }),
  14584. /***/ "./3D/controls/holographicButton.ts":
  14585. /*!******************************************!*\
  14586. !*** ./3D/controls/holographicButton.ts ***!
  14587. \******************************************/
  14588. /*! exports provided: HolographicButton */
  14589. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14590. "use strict";
  14591. __webpack_require__.r(__webpack_exports__);
  14592. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  14593. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14594. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14595. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  14596. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  14597. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14598. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  14599. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  14600. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  14601. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14602. /**
  14603. * Class used to create a holographic button in 3D
  14604. */
  14605. var HolographicButton = /** @class */ (function (_super) {
  14606. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  14607. /**
  14608. * Creates a new button
  14609. * @param name defines the control name
  14610. */
  14611. function HolographicButton(name, shareMaterials) {
  14612. if (shareMaterials === void 0) { shareMaterials = true; }
  14613. var _this = _super.call(this, name) || this;
  14614. _this._shareMaterials = true;
  14615. _this._shareMaterials = shareMaterials;
  14616. // Default animations
  14617. _this.pointerEnterAnimation = function () {
  14618. if (!_this.mesh) {
  14619. return;
  14620. }
  14621. _this._frontPlate.setEnabled(true);
  14622. };
  14623. _this.pointerOutAnimation = function () {
  14624. if (!_this.mesh) {
  14625. return;
  14626. }
  14627. _this._frontPlate.setEnabled(false);
  14628. };
  14629. return _this;
  14630. }
  14631. HolographicButton.prototype._disposeTooltip = function () {
  14632. this._tooltipFade = null;
  14633. if (this._tooltipTextBlock) {
  14634. this._tooltipTextBlock.dispose();
  14635. }
  14636. if (this._tooltipTexture) {
  14637. this._tooltipTexture.dispose();
  14638. }
  14639. if (this._tooltipMesh) {
  14640. this._tooltipMesh.dispose();
  14641. }
  14642. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  14643. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  14644. };
  14645. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  14646. get: function () {
  14647. return this._backPlate.renderingGroupId;
  14648. },
  14649. /**
  14650. * Rendering ground id of all the mesh in the button
  14651. */
  14652. set: function (id) {
  14653. this._backPlate.renderingGroupId = id;
  14654. this._textPlate.renderingGroupId = id;
  14655. this._frontPlate.renderingGroupId = id;
  14656. if (this._tooltipMesh) {
  14657. this._tooltipMesh.renderingGroupId = id;
  14658. }
  14659. },
  14660. enumerable: true,
  14661. configurable: true
  14662. });
  14663. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  14664. get: function () {
  14665. if (this._tooltipTextBlock) {
  14666. return this._tooltipTextBlock.text;
  14667. }
  14668. return null;
  14669. },
  14670. /**
  14671. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  14672. */
  14673. set: function (text) {
  14674. var _this = this;
  14675. if (!text) {
  14676. this._disposeTooltip();
  14677. return;
  14678. }
  14679. if (!this._tooltipFade) {
  14680. // Create tooltip with mesh and text
  14681. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  14682. var tooltipBackground = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1, sideOrientation: babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Mesh"].DOUBLESIDE }, this._backPlate._scene);
  14683. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  14684. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  14685. tooltipBackground.material = mat;
  14686. tooltipBackground.isPickable = false;
  14687. this._tooltipMesh.addChild(tooltipBackground);
  14688. tooltipBackground.position.z = 0.05;
  14689. this._tooltipMesh.scaling.y = 1 / 3;
  14690. this._tooltipMesh.position.y = 0.7;
  14691. this._tooltipMesh.position.z = -0.15;
  14692. this._tooltipMesh.isPickable = false;
  14693. this._tooltipMesh.parent = this._backPlate;
  14694. // Create text texture for the tooltip
  14695. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  14696. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14697. this._tooltipTextBlock.scaleY = 3;
  14698. this._tooltipTextBlock.color = "white";
  14699. this._tooltipTextBlock.fontSize = 130;
  14700. this._tooltipTexture.addControl(this._tooltipTextBlock);
  14701. // Add hover action to tooltip
  14702. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  14703. this._tooltipFade.delay = 500;
  14704. this._tooltipMesh.addBehavior(this._tooltipFade);
  14705. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  14706. if (_this._tooltipFade) {
  14707. _this._tooltipFade.fadeIn(true);
  14708. }
  14709. });
  14710. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  14711. if (_this._tooltipFade) {
  14712. _this._tooltipFade.fadeIn(false);
  14713. }
  14714. });
  14715. }
  14716. if (this._tooltipTextBlock) {
  14717. this._tooltipTextBlock.text = text;
  14718. }
  14719. },
  14720. enumerable: true,
  14721. configurable: true
  14722. });
  14723. Object.defineProperty(HolographicButton.prototype, "text", {
  14724. /**
  14725. * Gets or sets text for the button
  14726. */
  14727. get: function () {
  14728. return this._text;
  14729. },
  14730. set: function (value) {
  14731. if (this._text === value) {
  14732. return;
  14733. }
  14734. this._text = value;
  14735. this._rebuildContent();
  14736. },
  14737. enumerable: true,
  14738. configurable: true
  14739. });
  14740. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  14741. /**
  14742. * Gets or sets the image url for the button
  14743. */
  14744. get: function () {
  14745. return this._imageUrl;
  14746. },
  14747. set: function (value) {
  14748. if (this._imageUrl === value) {
  14749. return;
  14750. }
  14751. this._imageUrl = value;
  14752. this._rebuildContent();
  14753. },
  14754. enumerable: true,
  14755. configurable: true
  14756. });
  14757. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  14758. /**
  14759. * Gets the back material used by this button
  14760. */
  14761. get: function () {
  14762. return this._backMaterial;
  14763. },
  14764. enumerable: true,
  14765. configurable: true
  14766. });
  14767. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  14768. /**
  14769. * Gets the front material used by this button
  14770. */
  14771. get: function () {
  14772. return this._frontMaterial;
  14773. },
  14774. enumerable: true,
  14775. configurable: true
  14776. });
  14777. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  14778. /**
  14779. * Gets the plate material used by this button
  14780. */
  14781. get: function () {
  14782. return this._plateMaterial;
  14783. },
  14784. enumerable: true,
  14785. configurable: true
  14786. });
  14787. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  14788. /**
  14789. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  14790. */
  14791. get: function () {
  14792. return this._shareMaterials;
  14793. },
  14794. enumerable: true,
  14795. configurable: true
  14796. });
  14797. HolographicButton.prototype._getTypeName = function () {
  14798. return "HolographicButton";
  14799. };
  14800. HolographicButton.prototype._rebuildContent = function () {
  14801. this._disposeFacadeTexture();
  14802. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  14803. panel.isVertical = true;
  14804. if (this._imageUrl) {
  14805. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  14806. image.source = this._imageUrl;
  14807. image.paddingTop = "40px";
  14808. image.height = "180px";
  14809. image.width = "100px";
  14810. image.paddingBottom = "40px";
  14811. panel.addControl(image);
  14812. }
  14813. if (this._text) {
  14814. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14815. text.text = this._text;
  14816. text.color = "white";
  14817. text.height = "30px";
  14818. text.fontSize = 24;
  14819. panel.addControl(text);
  14820. }
  14821. if (this._frontPlate) {
  14822. this.content = panel;
  14823. }
  14824. };
  14825. // Mesh association
  14826. HolographicButton.prototype._createNode = function (scene) {
  14827. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  14828. width: 1.0,
  14829. height: 1.0,
  14830. depth: 0.08
  14831. }, scene);
  14832. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  14833. width: 1.0,
  14834. height: 1.0,
  14835. depth: 0.08
  14836. }, scene);
  14837. this._frontPlate.parent = this._backPlate;
  14838. this._frontPlate.position.z = -0.08;
  14839. this._frontPlate.isPickable = false;
  14840. this._frontPlate.setEnabled(false);
  14841. this._textPlate = _super.prototype._createNode.call(this, scene);
  14842. this._textPlate.parent = this._backPlate;
  14843. this._textPlate.position.z = -0.08;
  14844. this._textPlate.isPickable = false;
  14845. return this._backPlate;
  14846. };
  14847. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  14848. this._plateMaterial.emissiveTexture = facadeTexture;
  14849. this._plateMaterial.opacityTexture = facadeTexture;
  14850. };
  14851. HolographicButton.prototype._createBackMaterial = function (mesh) {
  14852. var _this = this;
  14853. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  14854. this._backMaterial.renderHoverLight = true;
  14855. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  14856. if (pickedPoint) {
  14857. _this._backMaterial.hoverPosition = pickedPoint;
  14858. _this._backMaterial.hoverColor.a = 1.0;
  14859. }
  14860. else {
  14861. _this._backMaterial.hoverColor.a = 0;
  14862. }
  14863. });
  14864. };
  14865. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  14866. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  14867. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  14868. this._frontMaterial.alpha = 0.5; // Additive
  14869. this._frontMaterial.renderBorders = true;
  14870. };
  14871. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  14872. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  14873. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  14874. };
  14875. HolographicButton.prototype._affectMaterial = function (mesh) {
  14876. // Back
  14877. if (this._shareMaterials) {
  14878. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  14879. this._createBackMaterial(mesh);
  14880. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  14881. }
  14882. else {
  14883. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  14884. }
  14885. // Front
  14886. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  14887. this._createFrontMaterial(mesh);
  14888. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  14889. }
  14890. else {
  14891. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  14892. }
  14893. }
  14894. else {
  14895. this._createBackMaterial(mesh);
  14896. this._createFrontMaterial(mesh);
  14897. }
  14898. this._createPlateMaterial(mesh);
  14899. this._backPlate.material = this._backMaterial;
  14900. this._frontPlate.material = this._frontMaterial;
  14901. this._textPlate.material = this._plateMaterial;
  14902. this._rebuildContent();
  14903. };
  14904. /**
  14905. * Releases all associated resources
  14906. */
  14907. HolographicButton.prototype.dispose = function () {
  14908. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  14909. this._disposeTooltip();
  14910. if (!this.shareMaterials) {
  14911. this._backMaterial.dispose();
  14912. this._frontMaterial.dispose();
  14913. this._plateMaterial.dispose();
  14914. if (this._pickedPointObserver) {
  14915. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  14916. this._pickedPointObserver = null;
  14917. }
  14918. }
  14919. };
  14920. return HolographicButton;
  14921. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14922. /***/ }),
  14923. /***/ "./3D/controls/index.ts":
  14924. /*!******************************!*\
  14925. !*** ./3D/controls/index.ts ***!
  14926. \******************************/
  14927. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  14928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14929. "use strict";
  14930. __webpack_require__.r(__webpack_exports__);
  14931. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  14932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14933. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14935. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  14937. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  14939. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  14940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  14941. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  14942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  14943. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  14944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  14945. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  14946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  14947. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  14948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  14949. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  14950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  14951. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  14952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  14953. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  14955. /***/ }),
  14956. /***/ "./3D/controls/meshButton3D.ts":
  14957. /*!*************************************!*\
  14958. !*** ./3D/controls/meshButton3D.ts ***!
  14959. \*************************************/
  14960. /*! exports provided: MeshButton3D */
  14961. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14962. "use strict";
  14963. __webpack_require__.r(__webpack_exports__);
  14964. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  14965. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14966. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14967. /**
  14968. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  14969. */
  14970. var MeshButton3D = /** @class */ (function (_super) {
  14971. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  14972. /**
  14973. * Creates a new 3D button based on a mesh
  14974. * @param mesh mesh to become a 3D button
  14975. * @param name defines the control name
  14976. */
  14977. function MeshButton3D(mesh, name) {
  14978. var _this = _super.call(this, name) || this;
  14979. _this._currentMesh = mesh;
  14980. /**
  14981. * Provides a default behavior on hover/out & up/down
  14982. * Override those function to create your own desired behavior specific to your mesh
  14983. */
  14984. _this.pointerEnterAnimation = function () {
  14985. if (!_this.mesh) {
  14986. return;
  14987. }
  14988. _this.mesh.scaling.scaleInPlace(1.1);
  14989. };
  14990. _this.pointerOutAnimation = function () {
  14991. if (!_this.mesh) {
  14992. return;
  14993. }
  14994. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  14995. };
  14996. _this.pointerDownAnimation = function () {
  14997. if (!_this.mesh) {
  14998. return;
  14999. }
  15000. _this.mesh.scaling.scaleInPlace(0.95);
  15001. };
  15002. _this.pointerUpAnimation = function () {
  15003. if (!_this.mesh) {
  15004. return;
  15005. }
  15006. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  15007. };
  15008. return _this;
  15009. }
  15010. MeshButton3D.prototype._getTypeName = function () {
  15011. return "MeshButton3D";
  15012. };
  15013. // Mesh association
  15014. MeshButton3D.prototype._createNode = function (scene) {
  15015. var _this = this;
  15016. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  15017. mesh.metadata = _this;
  15018. });
  15019. return this._currentMesh;
  15020. };
  15021. MeshButton3D.prototype._affectMaterial = function (mesh) {
  15022. };
  15023. return MeshButton3D;
  15024. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15025. /***/ }),
  15026. /***/ "./3D/controls/planePanel.ts":
  15027. /*!***********************************!*\
  15028. !*** ./3D/controls/planePanel.ts ***!
  15029. \***********************************/
  15030. /*! exports provided: PlanePanel */
  15031. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15032. "use strict";
  15033. __webpack_require__.r(__webpack_exports__);
  15034. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  15035. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15036. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  15037. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  15038. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15039. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15040. /**
  15041. * Class used to create a container panel deployed on the surface of a plane
  15042. */
  15043. var PlanePanel = /** @class */ (function (_super) {
  15044. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  15045. function PlanePanel() {
  15046. return _super !== null && _super.apply(this, arguments) || this;
  15047. }
  15048. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  15049. var mesh = control.mesh;
  15050. if (!mesh) {
  15051. return;
  15052. }
  15053. control.position = nodePosition.clone();
  15054. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15055. target.copyFrom(nodePosition);
  15056. switch (this.orientation) {
  15057. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  15058. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  15059. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15060. mesh.lookAt(target);
  15061. break;
  15062. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15063. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15064. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15065. mesh.lookAt(target);
  15066. break;
  15067. }
  15068. };
  15069. return PlanePanel;
  15070. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  15071. /***/ }),
  15072. /***/ "./3D/controls/scatterPanel.ts":
  15073. /*!*************************************!*\
  15074. !*** ./3D/controls/scatterPanel.ts ***!
  15075. \*************************************/
  15076. /*! exports provided: ScatterPanel */
  15077. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15078. "use strict";
  15079. __webpack_require__.r(__webpack_exports__);
  15080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  15081. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15082. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15083. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15084. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15085. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15086. /**
  15087. * Class used to create a container panel where items get randomized planar mapping
  15088. */
  15089. var ScatterPanel = /** @class */ (function (_super) {
  15090. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  15091. function ScatterPanel() {
  15092. var _this = _super !== null && _super.apply(this, arguments) || this;
  15093. _this._iteration = 100.0;
  15094. return _this;
  15095. }
  15096. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  15097. /**
  15098. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  15099. */
  15100. get: function () {
  15101. return this._iteration;
  15102. },
  15103. set: function (value) {
  15104. var _this = this;
  15105. if (this._iteration === value) {
  15106. return;
  15107. }
  15108. this._iteration = value;
  15109. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15110. _this._arrangeChildren();
  15111. });
  15112. },
  15113. enumerable: true,
  15114. configurable: true
  15115. });
  15116. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  15117. var mesh = control.mesh;
  15118. var newPos = this._scatterMapping(nodePosition);
  15119. if (!mesh) {
  15120. return;
  15121. }
  15122. switch (this.orientation) {
  15123. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15124. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15125. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15126. break;
  15127. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15128. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15129. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15130. break;
  15131. }
  15132. control.position = newPos;
  15133. };
  15134. ScatterPanel.prototype._scatterMapping = function (source) {
  15135. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  15136. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  15137. return source;
  15138. };
  15139. ScatterPanel.prototype._finalProcessing = function () {
  15140. var meshes = [];
  15141. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15142. var child = _a[_i];
  15143. if (!child.mesh) {
  15144. continue;
  15145. }
  15146. meshes.push(child.mesh);
  15147. }
  15148. for (var count = 0; count < this._iteration; count++) {
  15149. meshes.sort(function (a, b) {
  15150. var distance1 = a.position.lengthSquared();
  15151. var distance2 = b.position.lengthSquared();
  15152. if (distance1 < distance2) {
  15153. return 1;
  15154. }
  15155. else if (distance1 > distance2) {
  15156. return -1;
  15157. }
  15158. return 0;
  15159. });
  15160. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  15161. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  15162. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  15163. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15164. for (var i = 0; i < meshes.length - 1; i++) {
  15165. for (var j = i + 1; j < meshes.length; j++) {
  15166. if (i != j) {
  15167. meshes[j].position.subtractToRef(meshes[i].position, difference);
  15168. // Ignore Z axis
  15169. difference2D.x = difference.x;
  15170. difference2D.y = difference.y;
  15171. var combinedRadius = cellSize;
  15172. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  15173. var minSeparation = Math.min(distance, radiusPaddingSquared);
  15174. distance -= minSeparation;
  15175. if (distance < (Math.pow(combinedRadius, 2.0))) {
  15176. difference2D.normalize();
  15177. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  15178. meshes[j].position.addInPlace(difference);
  15179. meshes[i].position.subtractInPlace(difference);
  15180. }
  15181. }
  15182. }
  15183. }
  15184. }
  15185. };
  15186. return ScatterPanel;
  15187. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15188. /***/ }),
  15189. /***/ "./3D/controls/spherePanel.ts":
  15190. /*!************************************!*\
  15191. !*** ./3D/controls/spherePanel.ts ***!
  15192. \************************************/
  15193. /*! exports provided: SpherePanel */
  15194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15195. "use strict";
  15196. __webpack_require__.r(__webpack_exports__);
  15197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  15198. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15199. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15200. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15201. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15202. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15203. /**
  15204. * Class used to create a container panel deployed on the surface of a sphere
  15205. */
  15206. var SpherePanel = /** @class */ (function (_super) {
  15207. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  15208. function SpherePanel() {
  15209. var _this = _super !== null && _super.apply(this, arguments) || this;
  15210. _this._radius = 5.0;
  15211. return _this;
  15212. }
  15213. Object.defineProperty(SpherePanel.prototype, "radius", {
  15214. /**
  15215. * Gets or sets the radius of the sphere where to project controls (5 by default)
  15216. */
  15217. get: function () {
  15218. return this._radius;
  15219. },
  15220. set: function (value) {
  15221. var _this = this;
  15222. if (this._radius === value) {
  15223. return;
  15224. }
  15225. this._radius = value;
  15226. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15227. _this._arrangeChildren();
  15228. });
  15229. },
  15230. enumerable: true,
  15231. configurable: true
  15232. });
  15233. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  15234. var mesh = control.mesh;
  15235. if (!mesh) {
  15236. return;
  15237. }
  15238. var newPos = this._sphericalMapping(nodePosition);
  15239. control.position = newPos;
  15240. switch (this.orientation) {
  15241. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15242. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  15243. break;
  15244. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15245. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  15246. break;
  15247. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15248. break;
  15249. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15250. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  15251. break;
  15252. }
  15253. };
  15254. SpherePanel.prototype._sphericalMapping = function (source) {
  15255. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  15256. var xAngle = (source.y / this._radius);
  15257. var yAngle = -(source.x / this._radius);
  15258. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15259. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15260. };
  15261. return SpherePanel;
  15262. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15263. /***/ }),
  15264. /***/ "./3D/controls/stackPanel3D.ts":
  15265. /*!*************************************!*\
  15266. !*** ./3D/controls/stackPanel3D.ts ***!
  15267. \*************************************/
  15268. /*! exports provided: StackPanel3D */
  15269. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15270. "use strict";
  15271. __webpack_require__.r(__webpack_exports__);
  15272. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  15273. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15274. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15275. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15276. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15277. /**
  15278. * Class used to create a stack panel in 3D on XY plane
  15279. */
  15280. var StackPanel3D = /** @class */ (function (_super) {
  15281. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  15282. /**
  15283. * Creates new StackPanel
  15284. * @param isVertical
  15285. */
  15286. function StackPanel3D(isVertical) {
  15287. if (isVertical === void 0) { isVertical = false; }
  15288. var _this = _super.call(this) || this;
  15289. _this._isVertical = false;
  15290. /**
  15291. * Gets or sets the distance between elements
  15292. */
  15293. _this.margin = 0.1;
  15294. _this._isVertical = isVertical;
  15295. return _this;
  15296. }
  15297. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  15298. /**
  15299. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  15300. */
  15301. get: function () {
  15302. return this._isVertical;
  15303. },
  15304. set: function (value) {
  15305. var _this = this;
  15306. if (this._isVertical === value) {
  15307. return;
  15308. }
  15309. this._isVertical = value;
  15310. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15311. _this._arrangeChildren();
  15312. });
  15313. },
  15314. enumerable: true,
  15315. configurable: true
  15316. });
  15317. StackPanel3D.prototype._arrangeChildren = function () {
  15318. var width = 0;
  15319. var height = 0;
  15320. var controlCount = 0;
  15321. var extendSizes = [];
  15322. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15323. // Measure
  15324. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15325. var child = _a[_i];
  15326. if (!child.mesh) {
  15327. continue;
  15328. }
  15329. controlCount++;
  15330. child.mesh.computeWorldMatrix(true);
  15331. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15332. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  15333. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15334. extendSizes.push(extendSize);
  15335. if (this._isVertical) {
  15336. height += extendSize.y;
  15337. }
  15338. else {
  15339. width += extendSize.x;
  15340. }
  15341. }
  15342. if (this._isVertical) {
  15343. height += (controlCount - 1) * this.margin / 2;
  15344. }
  15345. else {
  15346. width += (controlCount - 1) * this.margin / 2;
  15347. }
  15348. // Arrange
  15349. var offset;
  15350. if (this._isVertical) {
  15351. offset = -height;
  15352. }
  15353. else {
  15354. offset = -width;
  15355. }
  15356. var index = 0;
  15357. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15358. var child = _c[_b];
  15359. if (!child.mesh) {
  15360. continue;
  15361. }
  15362. controlCount--;
  15363. var extendSize = extendSizes[index++];
  15364. if (this._isVertical) {
  15365. child.position.y = offset + extendSize.y;
  15366. child.position.x = 0;
  15367. offset += extendSize.y * 2;
  15368. }
  15369. else {
  15370. child.position.x = offset + extendSize.x;
  15371. child.position.y = 0;
  15372. offset += extendSize.x * 2;
  15373. }
  15374. offset += (controlCount > 0 ? this.margin : 0);
  15375. }
  15376. };
  15377. return StackPanel3D;
  15378. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15379. /***/ }),
  15380. /***/ "./3D/controls/volumeBasedPanel.ts":
  15381. /*!*****************************************!*\
  15382. !*** ./3D/controls/volumeBasedPanel.ts ***!
  15383. \*****************************************/
  15384. /*! exports provided: VolumeBasedPanel */
  15385. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15386. "use strict";
  15387. __webpack_require__.r(__webpack_exports__);
  15388. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  15389. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15390. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15391. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15392. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15393. /**
  15394. * Abstract class used to create a container panel deployed on the surface of a volume
  15395. */
  15396. var VolumeBasedPanel = /** @class */ (function (_super) {
  15397. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  15398. /**
  15399. * Creates new VolumeBasedPanel
  15400. */
  15401. function VolumeBasedPanel() {
  15402. var _this = _super.call(this) || this;
  15403. _this._columns = 10;
  15404. _this._rows = 0;
  15405. _this._rowThenColum = true;
  15406. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  15407. /**
  15408. * Gets or sets the distance between elements
  15409. */
  15410. _this.margin = 0;
  15411. return _this;
  15412. }
  15413. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  15414. /**
  15415. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  15416. * | Value | Type | Description |
  15417. * | ----- | ----------------------------------- | ----------- |
  15418. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  15419. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  15420. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  15421. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  15422. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  15423. */
  15424. get: function () {
  15425. return this._orientation;
  15426. },
  15427. set: function (value) {
  15428. var _this = this;
  15429. if (this._orientation === value) {
  15430. return;
  15431. }
  15432. this._orientation = value;
  15433. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15434. _this._arrangeChildren();
  15435. });
  15436. },
  15437. enumerable: true,
  15438. configurable: true
  15439. });
  15440. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  15441. /**
  15442. * Gets or sets the number of columns requested (10 by default).
  15443. * The panel will automatically compute the number of rows based on number of child controls.
  15444. */
  15445. get: function () {
  15446. return this._columns;
  15447. },
  15448. set: function (value) {
  15449. var _this = this;
  15450. if (this._columns === value) {
  15451. return;
  15452. }
  15453. this._columns = value;
  15454. this._rowThenColum = true;
  15455. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15456. _this._arrangeChildren();
  15457. });
  15458. },
  15459. enumerable: true,
  15460. configurable: true
  15461. });
  15462. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  15463. /**
  15464. * Gets or sets a the number of rows requested.
  15465. * The panel will automatically compute the number of columns based on number of child controls.
  15466. */
  15467. get: function () {
  15468. return this._rows;
  15469. },
  15470. set: function (value) {
  15471. var _this = this;
  15472. if (this._rows === value) {
  15473. return;
  15474. }
  15475. this._rows = value;
  15476. this._rowThenColum = false;
  15477. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15478. _this._arrangeChildren();
  15479. });
  15480. },
  15481. enumerable: true,
  15482. configurable: true
  15483. });
  15484. VolumeBasedPanel.prototype._arrangeChildren = function () {
  15485. this._cellWidth = 0;
  15486. this._cellHeight = 0;
  15487. var rows = 0;
  15488. var columns = 0;
  15489. var controlCount = 0;
  15490. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15491. // Measure
  15492. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15493. var child = _a[_i];
  15494. if (!child.mesh) {
  15495. continue;
  15496. }
  15497. controlCount++;
  15498. child.mesh.computeWorldMatrix(true);
  15499. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  15500. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  15501. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15502. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  15503. boundingBox.max.subtractToRef(boundingBox.min, diff);
  15504. diff.scaleInPlace(0.5);
  15505. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  15506. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  15507. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  15508. }
  15509. this._cellWidth += this.margin * 2;
  15510. this._cellHeight += this.margin * 2;
  15511. // Arrange
  15512. if (this._rowThenColum) {
  15513. columns = this._columns;
  15514. rows = Math.ceil(controlCount / this._columns);
  15515. }
  15516. else {
  15517. rows = this._rows;
  15518. columns = Math.ceil(controlCount / this._rows);
  15519. }
  15520. var startOffsetX = (columns * 0.5) * this._cellWidth;
  15521. var startOffsetY = (rows * 0.5) * this._cellHeight;
  15522. var nodeGrid = [];
  15523. var cellCounter = 0;
  15524. if (this._rowThenColum) {
  15525. for (var r = 0; r < rows; r++) {
  15526. for (var c = 0; c < columns; c++) {
  15527. 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));
  15528. cellCounter++;
  15529. if (cellCounter > controlCount) {
  15530. break;
  15531. }
  15532. }
  15533. }
  15534. }
  15535. else {
  15536. for (var c = 0; c < columns; c++) {
  15537. for (var r = 0; r < rows; r++) {
  15538. 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));
  15539. cellCounter++;
  15540. if (cellCounter > controlCount) {
  15541. break;
  15542. }
  15543. }
  15544. }
  15545. }
  15546. cellCounter = 0;
  15547. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15548. var child = _c[_b];
  15549. if (!child.mesh) {
  15550. continue;
  15551. }
  15552. this._mapGridNode(child, nodeGrid[cellCounter]);
  15553. cellCounter++;
  15554. }
  15555. this._finalProcessing();
  15556. };
  15557. /** Child classes can implement this function to provide additional processing */
  15558. VolumeBasedPanel.prototype._finalProcessing = function () {
  15559. };
  15560. return VolumeBasedPanel;
  15561. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15562. /***/ }),
  15563. /***/ "./3D/gui3DManager.ts":
  15564. /*!****************************!*\
  15565. !*** ./3D/gui3DManager.ts ***!
  15566. \****************************/
  15567. /*! exports provided: GUI3DManager */
  15568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15569. "use strict";
  15570. __webpack_require__.r(__webpack_exports__);
  15571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  15572. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  15573. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15574. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  15575. /**
  15576. * Class used to manage 3D user interface
  15577. * @see http://doc.babylonjs.com/how_to/gui3d
  15578. */
  15579. var GUI3DManager = /** @class */ (function () {
  15580. /**
  15581. * Creates a new GUI3DManager
  15582. * @param scene
  15583. */
  15584. function GUI3DManager(scene) {
  15585. var _this = this;
  15586. /** @hidden */
  15587. this._lastControlOver = {};
  15588. /** @hidden */
  15589. this._lastControlDown = {};
  15590. /**
  15591. * Observable raised when the point picked by the pointer events changed
  15592. */
  15593. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15594. // Shared resources
  15595. /** @hidden */
  15596. this._sharedMaterials = {};
  15597. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  15598. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  15599. _this._sceneDisposeObserver = null;
  15600. _this._utilityLayer = null;
  15601. _this.dispose();
  15602. });
  15603. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  15604. this._utilityLayer.onlyCheckPointerDownEvents = false;
  15605. this._utilityLayer.pickUtilitySceneFirst = false;
  15606. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  15607. return mesh && mesh.metadata && mesh.metadata._node;
  15608. };
  15609. // Root
  15610. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  15611. this._rootContainer._host = this;
  15612. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  15613. // Events
  15614. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  15615. _this._handlePointerOut(pointerId, true);
  15616. });
  15617. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  15618. _this._doPicking(pi);
  15619. });
  15620. // Scene
  15621. this._utilityLayer.utilityLayerScene.autoClear = false;
  15622. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  15623. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  15624. }
  15625. Object.defineProperty(GUI3DManager.prototype, "scene", {
  15626. /** Gets the hosting scene */
  15627. get: function () {
  15628. return this._scene;
  15629. },
  15630. enumerable: true,
  15631. configurable: true
  15632. });
  15633. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  15634. /** Gets associated utility layer */
  15635. get: function () {
  15636. return this._utilityLayer;
  15637. },
  15638. enumerable: true,
  15639. configurable: true
  15640. });
  15641. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  15642. var previousControlOver = this._lastControlOver[pointerId];
  15643. if (previousControlOver) {
  15644. previousControlOver._onPointerOut(previousControlOver);
  15645. delete this._lastControlOver[pointerId];
  15646. }
  15647. if (isPointerUp) {
  15648. if (this._lastControlDown[pointerId]) {
  15649. this._lastControlDown[pointerId].forcePointerUp();
  15650. delete this._lastControlDown[pointerId];
  15651. }
  15652. }
  15653. this.onPickedPointChangedObservable.notifyObservers(null);
  15654. };
  15655. GUI3DManager.prototype._doPicking = function (pi) {
  15656. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  15657. return false;
  15658. }
  15659. var pointerEvent = (pi.event);
  15660. var pointerId = pointerEvent.pointerId || 0;
  15661. var buttonIndex = pointerEvent.button;
  15662. var pickingInfo = pi.pickInfo;
  15663. if (!pickingInfo || !pickingInfo.hit) {
  15664. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  15665. return false;
  15666. }
  15667. var control = (pickingInfo.pickedMesh.metadata);
  15668. if (pickingInfo.pickedPoint) {
  15669. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  15670. }
  15671. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  15672. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15673. if (this._lastControlOver[pointerId]) {
  15674. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  15675. }
  15676. delete this._lastControlOver[pointerId];
  15677. }
  15678. }
  15679. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  15680. if (this._lastControlDown[pointerEvent.pointerId]) {
  15681. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  15682. delete this._lastControlDown[pointerEvent.pointerId];
  15683. }
  15684. if (pointerEvent.pointerType === "touch") {
  15685. this._handlePointerOut(pointerId, false);
  15686. }
  15687. }
  15688. return true;
  15689. };
  15690. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  15691. /**
  15692. * Gets the root container
  15693. */
  15694. get: function () {
  15695. return this._rootContainer;
  15696. },
  15697. enumerable: true,
  15698. configurable: true
  15699. });
  15700. /**
  15701. * Gets a boolean indicating if the given control is in the root child list
  15702. * @param control defines the control to check
  15703. * @returns true if the control is in the root child list
  15704. */
  15705. GUI3DManager.prototype.containsControl = function (control) {
  15706. return this._rootContainer.containsControl(control);
  15707. };
  15708. /**
  15709. * Adds a control to the root child list
  15710. * @param control defines the control to add
  15711. * @returns the current manager
  15712. */
  15713. GUI3DManager.prototype.addControl = function (control) {
  15714. this._rootContainer.addControl(control);
  15715. return this;
  15716. };
  15717. /**
  15718. * Removes a control from the root child list
  15719. * @param control defines the control to remove
  15720. * @returns the current container
  15721. */
  15722. GUI3DManager.prototype.removeControl = function (control) {
  15723. this._rootContainer.removeControl(control);
  15724. return this;
  15725. };
  15726. /**
  15727. * Releases all associated resources
  15728. */
  15729. GUI3DManager.prototype.dispose = function () {
  15730. this._rootContainer.dispose();
  15731. for (var materialName in this._sharedMaterials) {
  15732. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  15733. continue;
  15734. }
  15735. this._sharedMaterials[materialName].dispose();
  15736. }
  15737. this._sharedMaterials = {};
  15738. if (this._pointerOutObserver && this._utilityLayer) {
  15739. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  15740. this._pointerOutObserver = null;
  15741. }
  15742. this.onPickedPointChangedObservable.clear();
  15743. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  15744. if (utilityLayerScene) {
  15745. if (this._pointerObserver) {
  15746. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  15747. this._pointerObserver = null;
  15748. }
  15749. }
  15750. if (this._scene) {
  15751. if (this._sceneDisposeObserver) {
  15752. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  15753. this._sceneDisposeObserver = null;
  15754. }
  15755. }
  15756. if (this._utilityLayer) {
  15757. this._utilityLayer.dispose();
  15758. }
  15759. };
  15760. return GUI3DManager;
  15761. }());
  15762. /***/ }),
  15763. /***/ "./3D/index.ts":
  15764. /*!*********************!*\
  15765. !*** ./3D/index.ts ***!
  15766. \*********************/
  15767. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15768. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15769. "use strict";
  15770. __webpack_require__.r(__webpack_exports__);
  15771. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  15772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15784. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  15785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15787. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  15788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  15789. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  15790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  15791. /***/ }),
  15792. /***/ "./3D/materials/fluentMaterial.ts":
  15793. /*!****************************************!*\
  15794. !*** ./3D/materials/fluentMaterial.ts ***!
  15795. \****************************************/
  15796. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15797. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15798. "use strict";
  15799. __webpack_require__.r(__webpack_exports__);
  15800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  15801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  15802. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15803. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  15804. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  15805. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  15806. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  15807. /** @hidden */
  15808. var FluentMaterialDefines = /** @class */ (function (_super) {
  15809. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  15810. function FluentMaterialDefines() {
  15811. var _this = _super.call(this) || this;
  15812. _this.INNERGLOW = false;
  15813. _this.BORDER = false;
  15814. _this.HOVERLIGHT = false;
  15815. _this.TEXTURE = false;
  15816. _this.rebuild();
  15817. return _this;
  15818. }
  15819. return FluentMaterialDefines;
  15820. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  15821. /**
  15822. * Class used to render controls with fluent desgin
  15823. */
  15824. var FluentMaterial = /** @class */ (function (_super) {
  15825. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  15826. /**
  15827. * Creates a new Fluent material
  15828. * @param name defines the name of the material
  15829. * @param scene defines the hosting scene
  15830. */
  15831. function FluentMaterial(name, scene) {
  15832. var _this = _super.call(this, name, scene) || this;
  15833. /**
  15834. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  15835. */
  15836. _this.innerGlowColorIntensity = 0.5;
  15837. /**
  15838. * Gets or sets the inner glow color (white by default)
  15839. */
  15840. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  15841. /**
  15842. * Gets or sets alpha value (default is 1.0)
  15843. */
  15844. _this.alpha = 1.0;
  15845. /**
  15846. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  15847. */
  15848. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  15849. /**
  15850. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  15851. */
  15852. _this.renderBorders = false;
  15853. /**
  15854. * Gets or sets border width (default is 0.5)
  15855. */
  15856. _this.borderWidth = 0.5;
  15857. /**
  15858. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  15859. */
  15860. _this.edgeSmoothingValue = 0.02;
  15861. /**
  15862. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  15863. */
  15864. _this.borderMinValue = 0.1;
  15865. /**
  15866. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  15867. */
  15868. _this.renderHoverLight = false;
  15869. /**
  15870. * Gets or sets the radius used to render the hover light (default is 1.0)
  15871. */
  15872. _this.hoverRadius = 1.0;
  15873. /**
  15874. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  15875. */
  15876. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  15877. /**
  15878. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  15879. */
  15880. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  15881. return _this;
  15882. }
  15883. FluentMaterial.prototype.needAlphaBlending = function () {
  15884. return this.alpha !== 1.0;
  15885. };
  15886. FluentMaterial.prototype.needAlphaTesting = function () {
  15887. return false;
  15888. };
  15889. FluentMaterial.prototype.getAlphaTestTexture = function () {
  15890. return null;
  15891. };
  15892. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  15893. if (this.isFrozen) {
  15894. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  15895. return true;
  15896. }
  15897. }
  15898. if (!subMesh._materialDefines) {
  15899. subMesh._materialDefines = new FluentMaterialDefines();
  15900. }
  15901. var scene = this.getScene();
  15902. var defines = subMesh._materialDefines;
  15903. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  15904. if (defines._renderId === scene.getRenderId()) {
  15905. return true;
  15906. }
  15907. }
  15908. if (defines._areTexturesDirty) {
  15909. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  15910. defines.BORDER = this.renderBorders;
  15911. defines.HOVERLIGHT = this.renderHoverLight;
  15912. if (this._albedoTexture) {
  15913. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  15914. return false;
  15915. }
  15916. else {
  15917. defines.TEXTURE = true;
  15918. }
  15919. }
  15920. else {
  15921. defines.TEXTURE = false;
  15922. }
  15923. }
  15924. var engine = scene.getEngine();
  15925. // Get correct effect
  15926. if (defines.isDirty) {
  15927. defines.markAsProcessed();
  15928. scene.resetCachedMaterial();
  15929. //Attributes
  15930. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  15931. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  15932. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  15933. var shaderName = "fluent";
  15934. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  15935. "hoverColor", "hoverPosition", "hoverRadius"
  15936. ];
  15937. var samplers = ["albedoSampler"];
  15938. var uniformBuffers = new Array();
  15939. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  15940. uniformsNames: uniforms,
  15941. uniformBuffersNames: uniformBuffers,
  15942. samplers: samplers,
  15943. defines: defines,
  15944. maxSimultaneousLights: 4
  15945. });
  15946. var join = defines.toString();
  15947. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  15948. attributes: attribs,
  15949. uniformsNames: uniforms,
  15950. uniformBuffersNames: uniformBuffers,
  15951. samplers: samplers,
  15952. defines: join,
  15953. fallbacks: null,
  15954. onCompiled: this.onCompiled,
  15955. onError: this.onError,
  15956. indexParameters: { maxSimultaneousLights: 4 }
  15957. }, engine));
  15958. }
  15959. if (!subMesh.effect || !subMesh.effect.isReady()) {
  15960. return false;
  15961. }
  15962. defines._renderId = scene.getRenderId();
  15963. subMesh.effect._wasPreviouslyReady = true;
  15964. return true;
  15965. };
  15966. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  15967. var scene = this.getScene();
  15968. var defines = subMesh._materialDefines;
  15969. if (!defines) {
  15970. return;
  15971. }
  15972. var effect = subMesh.effect;
  15973. if (!effect) {
  15974. return;
  15975. }
  15976. this._activeEffect = effect;
  15977. // Matrices
  15978. this.bindOnlyWorldMatrix(world);
  15979. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  15980. if (this._mustRebind(scene, effect)) {
  15981. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  15982. if (defines.INNERGLOW) {
  15983. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  15984. }
  15985. if (defines.BORDER) {
  15986. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  15987. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  15988. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  15989. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15990. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15991. }
  15992. if (defines.HOVERLIGHT) {
  15993. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  15994. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  15995. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  15996. }
  15997. if (defines.TEXTURE) {
  15998. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  15999. }
  16000. }
  16001. this._afterBind(mesh, this._activeEffect);
  16002. };
  16003. FluentMaterial.prototype.getActiveTextures = function () {
  16004. var activeTextures = _super.prototype.getActiveTextures.call(this);
  16005. return activeTextures;
  16006. };
  16007. FluentMaterial.prototype.hasTexture = function (texture) {
  16008. if (_super.prototype.hasTexture.call(this, texture)) {
  16009. return true;
  16010. }
  16011. return false;
  16012. };
  16013. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  16014. _super.prototype.dispose.call(this, forceDisposeEffect);
  16015. };
  16016. FluentMaterial.prototype.clone = function (name) {
  16017. var _this = this;
  16018. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  16019. };
  16020. FluentMaterial.prototype.serialize = function () {
  16021. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  16022. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  16023. return serializationObject;
  16024. };
  16025. FluentMaterial.prototype.getClassName = function () {
  16026. return "FluentMaterial";
  16027. };
  16028. // Statics
  16029. FluentMaterial.Parse = function (source, scene, rootUrl) {
  16030. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  16031. };
  16032. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16033. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16034. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16035. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  16036. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16037. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16038. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  16039. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16040. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16041. ], FluentMaterial.prototype, "alpha", void 0);
  16042. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16043. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16044. ], FluentMaterial.prototype, "albedoColor", void 0);
  16045. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16046. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16047. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16048. ], FluentMaterial.prototype, "renderBorders", void 0);
  16049. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16050. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16051. ], FluentMaterial.prototype, "borderWidth", void 0);
  16052. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16053. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16054. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  16055. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16056. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16057. ], FluentMaterial.prototype, "borderMinValue", void 0);
  16058. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16059. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16060. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16061. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  16062. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16063. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16064. ], FluentMaterial.prototype, "hoverRadius", void 0);
  16065. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16066. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  16067. ], FluentMaterial.prototype, "hoverColor", void 0);
  16068. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16069. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  16070. ], FluentMaterial.prototype, "hoverPosition", void 0);
  16071. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16072. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  16073. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  16074. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16075. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  16076. ], FluentMaterial.prototype, "albedoTexture", void 0);
  16077. return FluentMaterial;
  16078. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  16079. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  16080. /***/ }),
  16081. /***/ "./3D/materials/index.ts":
  16082. /*!*******************************!*\
  16083. !*** ./3D/materials/index.ts ***!
  16084. \*******************************/
  16085. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16086. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16087. "use strict";
  16088. __webpack_require__.r(__webpack_exports__);
  16089. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  16090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16092. /***/ }),
  16093. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  16094. /*!*************************************************!*\
  16095. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  16096. \*************************************************/
  16097. /*! exports provided: fluentPixelShader */
  16098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16099. "use strict";
  16100. __webpack_require__.r(__webpack_exports__);
  16101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  16102. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  16103. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16104. var name = 'fluentPixelShader';
  16105. 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}";
  16106. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16107. /** @hidden */
  16108. var fluentPixelShader = { name: name, shader: shader };
  16109. /***/ }),
  16110. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  16111. /*!***********************************************!*\
  16112. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  16113. \***********************************************/
  16114. /*! exports provided: fluentVertexShader */
  16115. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16116. "use strict";
  16117. __webpack_require__.r(__webpack_exports__);
  16118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  16119. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  16120. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16121. var name = 'fluentVertexShader';
  16122. 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";
  16123. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16124. /** @hidden */
  16125. var fluentVertexShader = { name: name, shader: shader };
  16126. /***/ }),
  16127. /***/ "./3D/vector3WithInfo.ts":
  16128. /*!*******************************!*\
  16129. !*** ./3D/vector3WithInfo.ts ***!
  16130. \*******************************/
  16131. /*! exports provided: Vector3WithInfo */
  16132. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16133. "use strict";
  16134. __webpack_require__.r(__webpack_exports__);
  16135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  16136. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16137. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  16138. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  16139. /**
  16140. * Class used to transport Vector3 information for pointer events
  16141. */
  16142. var Vector3WithInfo = /** @class */ (function (_super) {
  16143. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  16144. /**
  16145. * Creates a new Vector3WithInfo
  16146. * @param source defines the vector3 data to transport
  16147. * @param buttonIndex defines the current mouse button index
  16148. */
  16149. function Vector3WithInfo(source,
  16150. /** defines the current mouse button index */
  16151. buttonIndex) {
  16152. if (buttonIndex === void 0) { buttonIndex = 0; }
  16153. var _this = _super.call(this, source.x, source.y, source.z) || this;
  16154. _this.buttonIndex = buttonIndex;
  16155. return _this;
  16156. }
  16157. return Vector3WithInfo;
  16158. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  16159. /***/ }),
  16160. /***/ "./index.ts":
  16161. /*!******************!*\
  16162. !*** ./index.ts ***!
  16163. \******************/
  16164. /*! 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 */
  16165. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16166. "use strict";
  16167. __webpack_require__.r(__webpack_exports__);
  16168. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  16169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16210. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  16211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  16212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  16213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  16214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  16215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  16216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  16217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  16218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  16219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  16220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  16221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  16222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  16223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  16224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  16225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16227. /***/ }),
  16228. /***/ "./legacy/legacy.ts":
  16229. /*!**************************!*\
  16230. !*** ./legacy/legacy.ts ***!
  16231. \**************************/
  16232. /*! 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 */
  16233. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16234. "use strict";
  16235. __webpack_require__.r(__webpack_exports__);
  16236. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  16237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  16247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  16248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16294. /**
  16295. * Legacy support, defining window.BABYLON.GUI (global variable).
  16296. *
  16297. * This is the entry point for the UMD module.
  16298. * The entry point for a future ESM package should be index.ts
  16299. */
  16300. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  16301. if (typeof globalObject !== "undefined") {
  16302. globalObject.BABYLON = globalObject.BABYLON || {};
  16303. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  16304. }
  16305. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  16306. /***/ }),
  16307. /***/ "babylonjs/Misc/perfCounter":
  16308. /*!****************************************************************************************************!*\
  16309. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  16310. \****************************************************************************************************/
  16311. /*! no static exports found */
  16312. /***/ (function(module, exports) {
  16313. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__;
  16314. /***/ })
  16315. /******/ });
  16316. });
  16317. //# sourceMappingURL=babylon.gui.js.map