babylon.gui.js 738 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951
  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, "layer", {
  728. /**
  729. * Gets the underlying layer used to render the texture when in fullscreen mode
  730. */
  731. get: function () {
  732. return this._layerToDispose;
  733. },
  734. enumerable: true,
  735. configurable: true
  736. });
  737. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  738. /**
  739. * Gets the root container control
  740. */
  741. get: function () {
  742. return this._rootContainer;
  743. },
  744. enumerable: true,
  745. configurable: true
  746. });
  747. /**
  748. * Returns an array containing the root container.
  749. * This is mostly used to let the Inspector introspects the ADT
  750. * @returns an array containing the rootContainer
  751. */
  752. AdvancedDynamicTexture.prototype.getChildren = function () {
  753. return [this._rootContainer];
  754. };
  755. /**
  756. * Will return all controls that are inside this texture
  757. * @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
  758. * @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
  759. * @return all child controls
  760. */
  761. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  762. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  763. };
  764. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  765. /**
  766. * Gets or sets the current focused control
  767. */
  768. get: function () {
  769. return this._focusedControl;
  770. },
  771. set: function (control) {
  772. if (this._focusedControl == control) {
  773. return;
  774. }
  775. if (this._focusedControl) {
  776. this._focusedControl.onBlur();
  777. }
  778. if (control) {
  779. control.onFocus();
  780. }
  781. this._focusedControl = control;
  782. },
  783. enumerable: true,
  784. configurable: true
  785. });
  786. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  787. /**
  788. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  789. */
  790. get: function () {
  791. if (!this.layer) {
  792. return true;
  793. }
  794. return (!this.layer.isBackground);
  795. },
  796. set: function (value) {
  797. if (!this.layer) {
  798. return;
  799. }
  800. if (this.layer.isBackground === !value) {
  801. return;
  802. }
  803. this.layer.isBackground = !value;
  804. },
  805. enumerable: true,
  806. configurable: true
  807. });
  808. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  809. /**
  810. * Gets or set information about clipboardData
  811. */
  812. get: function () {
  813. return this._clipboardData;
  814. },
  815. set: function (value) {
  816. this._clipboardData = value;
  817. },
  818. enumerable: true,
  819. configurable: true
  820. });
  821. /**
  822. * Get the current class name of the texture useful for serialization or dynamic coding.
  823. * @returns "AdvancedDynamicTexture"
  824. */
  825. AdvancedDynamicTexture.prototype.getClassName = function () {
  826. return "AdvancedDynamicTexture";
  827. };
  828. /**
  829. * Function used to execute a function on all controls
  830. * @param func defines the function to execute
  831. * @param container defines the container where controls belong. If null the root container will be used
  832. */
  833. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  834. if (!container) {
  835. container = this._rootContainer;
  836. }
  837. func(container);
  838. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  839. var child = _a[_i];
  840. if (child.children) {
  841. this.executeOnAllControls(func, child);
  842. continue;
  843. }
  844. func(child);
  845. }
  846. };
  847. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  848. /**
  849. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  850. */
  851. get: function () {
  852. return this._useInvalidateRectOptimization;
  853. },
  854. set: function (value) {
  855. this._useInvalidateRectOptimization = value;
  856. },
  857. enumerable: true,
  858. configurable: true
  859. });
  860. /**
  861. * Invalidates a rectangle area on the gui texture
  862. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  863. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  864. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  865. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  866. */
  867. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  868. if (!this._useInvalidateRectOptimization) {
  869. return;
  870. }
  871. if (!this._invalidatedRectangle) {
  872. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  873. }
  874. else {
  875. // Compute intersection
  876. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  877. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  878. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  879. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  880. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  881. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  882. }
  883. };
  884. /**
  885. * Marks the texture as dirty forcing a complete update
  886. */
  887. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  888. this._isDirty = true;
  889. };
  890. /**
  891. * Helper function used to create a new style
  892. * @returns a new style
  893. * @see http://doc.babylonjs.com/how_to/gui#styles
  894. */
  895. AdvancedDynamicTexture.prototype.createStyle = function () {
  896. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  897. };
  898. /**
  899. * Adds a new control to the root container
  900. * @param control defines the control to add
  901. * @returns the current texture
  902. */
  903. AdvancedDynamicTexture.prototype.addControl = function (control) {
  904. this._rootContainer.addControl(control);
  905. return this;
  906. };
  907. /**
  908. * Removes a control from the root container
  909. * @param control defines the control to remove
  910. * @returns the current texture
  911. */
  912. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  913. this._rootContainer.removeControl(control);
  914. return this;
  915. };
  916. /**
  917. * Release all resources
  918. */
  919. AdvancedDynamicTexture.prototype.dispose = function () {
  920. var scene = this.getScene();
  921. if (!scene) {
  922. return;
  923. }
  924. this._rootElement = null;
  925. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  926. if (this._resizeObserver) {
  927. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  928. }
  929. if (this._pointerMoveObserver) {
  930. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  931. }
  932. if (this._pointerObserver) {
  933. scene.onPointerObservable.remove(this._pointerObserver);
  934. }
  935. if (this._preKeyboardObserver) {
  936. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  937. }
  938. if (this._canvasPointerOutObserver) {
  939. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  940. }
  941. if (this._layerToDispose) {
  942. this._layerToDispose.texture = null;
  943. this._layerToDispose.dispose();
  944. this._layerToDispose = null;
  945. }
  946. this._rootContainer.dispose();
  947. this.onClipboardObservable.clear();
  948. this.onControlPickedObservable.clear();
  949. this.onBeginRenderObservable.clear();
  950. this.onEndRenderObservable.clear();
  951. this.onBeginLayoutObservable.clear();
  952. this.onEndLayoutObservable.clear();
  953. _super.prototype.dispose.call(this);
  954. };
  955. AdvancedDynamicTexture.prototype._onResize = function () {
  956. var scene = this.getScene();
  957. if (!scene) {
  958. return;
  959. }
  960. // Check size
  961. var engine = scene.getEngine();
  962. var textureSize = this.getSize();
  963. var renderWidth = engine.getRenderWidth() * this._renderScale;
  964. var renderHeight = engine.getRenderHeight() * this._renderScale;
  965. if (this._renderAtIdealSize) {
  966. if (this._idealWidth) {
  967. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  968. renderWidth = this._idealWidth;
  969. }
  970. else if (this._idealHeight) {
  971. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  972. renderHeight = this._idealHeight;
  973. }
  974. }
  975. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  976. this.scaleTo(renderWidth, renderHeight);
  977. this.markAsDirty();
  978. if (this._idealWidth || this._idealHeight) {
  979. this._rootContainer._markAllAsDirty();
  980. }
  981. }
  982. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  983. };
  984. /** @hidden */
  985. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  986. var engine = scene.getEngine();
  987. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  988. };
  989. /**
  990. * Get screen coordinates for a vector3
  991. * @param position defines the position to project
  992. * @param worldMatrix defines the world matrix to use
  993. * @returns the projected position
  994. */
  995. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  996. var scene = this.getScene();
  997. if (!scene) {
  998. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  999. }
  1000. var globalViewport = this._getGlobalViewport(scene);
  1001. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1002. projectedPosition.scaleInPlace(this.renderScale);
  1003. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  1004. };
  1005. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  1006. if (this._layerToDispose) {
  1007. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  1008. return;
  1009. }
  1010. }
  1011. if (this._isFullscreen && this._linkedControls.length) {
  1012. var scene = this.getScene();
  1013. if (!scene) {
  1014. return;
  1015. }
  1016. var globalViewport = this._getGlobalViewport(scene);
  1017. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  1018. var control = _a[_i];
  1019. if (!control.isVisible) {
  1020. continue;
  1021. }
  1022. var mesh = control._linkedMesh;
  1023. if (!mesh || mesh.isDisposed()) {
  1024. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1025. control.linkWithMesh(null);
  1026. });
  1027. continue;
  1028. }
  1029. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1030. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1031. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1032. control.notRenderable = true;
  1033. continue;
  1034. }
  1035. control.notRenderable = false;
  1036. // Account for RenderScale.
  1037. projectedPosition.scaleInPlace(this.renderScale);
  1038. control._moveToProjectedPosition(projectedPosition);
  1039. }
  1040. }
  1041. if (!this._isDirty && !this._rootContainer.isDirty) {
  1042. return;
  1043. }
  1044. this._isDirty = false;
  1045. this._render();
  1046. this.update(true, this.premulAlpha);
  1047. };
  1048. AdvancedDynamicTexture.prototype._render = function () {
  1049. var textureSize = this.getSize();
  1050. var renderWidth = textureSize.width;
  1051. var renderHeight = textureSize.height;
  1052. var context = this.getContext();
  1053. context.font = "18px Arial";
  1054. context.strokeStyle = "white";
  1055. // Layout
  1056. this.onBeginLayoutObservable.notifyObservers(this);
  1057. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1058. this._numLayoutCalls = 0;
  1059. this._rootContainer._layout(measure, context);
  1060. this.onEndLayoutObservable.notifyObservers(this);
  1061. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1062. // Clear
  1063. if (this._invalidatedRectangle) {
  1064. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1065. }
  1066. else {
  1067. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1068. }
  1069. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1070. if (this._background) {
  1071. context.save();
  1072. context.fillStyle = this._background;
  1073. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1074. context.restore();
  1075. }
  1076. // Render
  1077. this.onBeginRenderObservable.notifyObservers(this);
  1078. this._numRenderCalls = 0;
  1079. this._rootContainer._render(context, this._invalidatedRectangle);
  1080. this.onEndRenderObservable.notifyObservers(this);
  1081. this._invalidatedRectangle = null;
  1082. };
  1083. /** @hidden */
  1084. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1085. if (this._rootElement) {
  1086. this._rootElement.style.cursor = cursor;
  1087. this._cursorChanged = true;
  1088. }
  1089. };
  1090. /** @hidden */
  1091. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1092. this._lastControlDown[pointerId] = control;
  1093. this.onControlPickedObservable.notifyObservers(control);
  1094. };
  1095. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1096. var scene = this.getScene();
  1097. if (!scene) {
  1098. return;
  1099. }
  1100. var engine = scene.getEngine();
  1101. var textureSize = this.getSize();
  1102. if (this._isFullscreen) {
  1103. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1104. var viewport = camera.viewport;
  1105. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1106. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1107. }
  1108. if (this._capturingControl[pointerId]) {
  1109. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1110. return;
  1111. }
  1112. this._cursorChanged = false;
  1113. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1114. this._changeCursor("");
  1115. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1116. if (this._lastControlOver[pointerId]) {
  1117. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1118. delete this._lastControlOver[pointerId];
  1119. }
  1120. }
  1121. }
  1122. if (!this._cursorChanged) {
  1123. this._changeCursor("");
  1124. }
  1125. this._manageFocus();
  1126. };
  1127. /** @hidden */
  1128. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1129. for (var pointerId in list) {
  1130. if (!list.hasOwnProperty(pointerId)) {
  1131. continue;
  1132. }
  1133. var lastControlOver = list[pointerId];
  1134. if (lastControlOver === control) {
  1135. delete list[pointerId];
  1136. }
  1137. }
  1138. };
  1139. /** @hidden */
  1140. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1141. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1142. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1143. };
  1144. /** Attach to all scene events required to support pointer events */
  1145. AdvancedDynamicTexture.prototype.attach = function () {
  1146. var _this = this;
  1147. var scene = this.getScene();
  1148. if (!scene) {
  1149. return;
  1150. }
  1151. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1152. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1153. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1154. return;
  1155. }
  1156. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1157. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1158. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1159. return;
  1160. }
  1161. if (!scene) {
  1162. return;
  1163. }
  1164. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1165. var engine = scene.getEngine();
  1166. if (!camera) {
  1167. tempViewport.x = 0;
  1168. tempViewport.y = 0;
  1169. tempViewport.width = engine.getRenderWidth();
  1170. tempViewport.height = engine.getRenderHeight();
  1171. }
  1172. else {
  1173. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1174. }
  1175. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1176. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1177. _this._shouldBlockPointer = false;
  1178. // Do picking modifies _shouldBlockPointer
  1179. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1180. // Avoid overwriting a true skipOnPointerObservable to false
  1181. if (_this._shouldBlockPointer) {
  1182. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1183. }
  1184. });
  1185. this._attachToOnPointerOut(scene);
  1186. };
  1187. /**
  1188. * Register the clipboard Events onto the canvas
  1189. */
  1190. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1191. self.addEventListener("copy", this.onClipboardCopy, false);
  1192. self.addEventListener("cut", this.onClipboardCut, false);
  1193. self.addEventListener("paste", this.onClipboardPaste, false);
  1194. };
  1195. /**
  1196. * Unregister the clipboard Events from the canvas
  1197. */
  1198. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1199. self.removeEventListener("copy", this.onClipboardCopy);
  1200. self.removeEventListener("cut", this.onClipboardCut);
  1201. self.removeEventListener("paste", this.onClipboardPaste);
  1202. };
  1203. /**
  1204. * Connect the texture to a hosting mesh to enable interactions
  1205. * @param mesh defines the mesh to attach to
  1206. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1207. */
  1208. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1209. var _this = this;
  1210. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1211. var scene = this.getScene();
  1212. if (!scene) {
  1213. return;
  1214. }
  1215. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1216. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1217. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1218. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1219. return;
  1220. }
  1221. var pointerId = pi.event.pointerId || 0;
  1222. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1223. var uv = pi.pickInfo.getTextureCoordinates();
  1224. if (uv) {
  1225. var size = _this.getSize();
  1226. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1227. }
  1228. }
  1229. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1230. if (_this._lastControlDown[pointerId]) {
  1231. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1232. }
  1233. delete _this._lastControlDown[pointerId];
  1234. if (_this.focusedControl) {
  1235. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1236. var canMoveFocus = true;
  1237. if (friendlyControls) {
  1238. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1239. var control = friendlyControls_1[_i];
  1240. // Same host, no need to keep the focus
  1241. if (_this === control._host) {
  1242. continue;
  1243. }
  1244. // Different hosts
  1245. var otherHost = control._host;
  1246. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1247. canMoveFocus = false;
  1248. break;
  1249. }
  1250. }
  1251. }
  1252. if (canMoveFocus) {
  1253. _this.focusedControl = null;
  1254. }
  1255. }
  1256. }
  1257. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1258. if (_this._lastControlOver[pointerId]) {
  1259. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1260. }
  1261. delete _this._lastControlOver[pointerId];
  1262. }
  1263. });
  1264. mesh.enablePointerMoveEvents = supportPointerMove;
  1265. this._attachToOnPointerOut(scene);
  1266. };
  1267. /**
  1268. * Move the focus to a specific control
  1269. * @param control defines the control which will receive the focus
  1270. */
  1271. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1272. this.focusedControl = control;
  1273. this._lastPickedControl = control;
  1274. this._blockNextFocusCheck = true;
  1275. };
  1276. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1277. if (this._blockNextFocusCheck) {
  1278. this._blockNextFocusCheck = false;
  1279. this._lastPickedControl = this._focusedControl;
  1280. return;
  1281. }
  1282. // Focus management
  1283. if (this._focusedControl) {
  1284. if (this._focusedControl !== this._lastPickedControl) {
  1285. if (this._lastPickedControl.isFocusInvisible) {
  1286. return;
  1287. }
  1288. this.focusedControl = null;
  1289. }
  1290. }
  1291. };
  1292. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1293. var _this = this;
  1294. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1295. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1296. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1297. }
  1298. delete _this._lastControlOver[pointerEvent.pointerId];
  1299. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1300. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1301. delete _this._lastControlDown[pointerEvent.pointerId];
  1302. }
  1303. });
  1304. };
  1305. // Statics
  1306. /**
  1307. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1308. * @param mesh defines the mesh which will receive the texture
  1309. * @param width defines the texture width (1024 by default)
  1310. * @param height defines the texture height (1024 by default)
  1311. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1312. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1313. * @returns a new AdvancedDynamicTexture
  1314. */
  1315. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1316. if (width === void 0) { width = 1024; }
  1317. if (height === void 0) { height = 1024; }
  1318. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1319. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1320. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1321. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1322. material.backFaceCulling = false;
  1323. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1324. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1325. if (onlyAlphaTesting) {
  1326. material.diffuseTexture = result;
  1327. material.emissiveTexture = result;
  1328. result.hasAlpha = true;
  1329. }
  1330. else {
  1331. material.emissiveTexture = result;
  1332. material.opacityTexture = result;
  1333. }
  1334. mesh.material = material;
  1335. result.attachToMesh(mesh, supportPointerMove);
  1336. return result;
  1337. };
  1338. /**
  1339. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1340. * In this mode the texture will rely on a layer for its rendering.
  1341. * This allows it to be treated like any other layer.
  1342. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1343. * LayerMask is set through advancedTexture.layer.layerMask
  1344. * @param name defines name for the texture
  1345. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1346. * @param scene defines the hsoting scene
  1347. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1348. * @returns a new AdvancedDynamicTexture
  1349. */
  1350. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1351. if (foreground === void 0) { foreground = true; }
  1352. if (scene === void 0) { scene = null; }
  1353. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1354. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1355. // Display
  1356. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1357. layer.texture = result;
  1358. result._layerToDispose = layer;
  1359. result._isFullscreen = true;
  1360. // Attach
  1361. result.attach();
  1362. return result;
  1363. };
  1364. return AdvancedDynamicTexture;
  1365. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1366. /***/ }),
  1367. /***/ "./2D/controls/button.ts":
  1368. /*!*******************************!*\
  1369. !*** ./2D/controls/button.ts ***!
  1370. \*******************************/
  1371. /*! exports provided: Button */
  1372. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1373. "use strict";
  1374. __webpack_require__.r(__webpack_exports__);
  1375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1376. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1377. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1378. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1379. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1380. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1381. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  1382. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1383. /**
  1384. * Class used to create 2D buttons
  1385. */
  1386. var Button = /** @class */ (function (_super) {
  1387. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1388. /**
  1389. * Creates a new Button
  1390. * @param name defines the name of the button
  1391. */
  1392. function Button(name) {
  1393. var _this = _super.call(this, name) || this;
  1394. _this.name = name;
  1395. /**
  1396. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1397. */
  1398. _this.delegatePickingToChildren = false;
  1399. _this.thickness = 1;
  1400. _this.isPointerBlocker = true;
  1401. var alphaStore = null;
  1402. _this.pointerEnterAnimation = function () {
  1403. alphaStore = _this.alpha;
  1404. _this.alpha -= 0.1;
  1405. };
  1406. _this.pointerOutAnimation = function () {
  1407. if (alphaStore !== null) {
  1408. _this.alpha = alphaStore;
  1409. }
  1410. };
  1411. _this.pointerDownAnimation = function () {
  1412. _this.scaleX -= 0.05;
  1413. _this.scaleY -= 0.05;
  1414. };
  1415. _this.pointerUpAnimation = function () {
  1416. _this.scaleX += 0.05;
  1417. _this.scaleY += 0.05;
  1418. };
  1419. return _this;
  1420. }
  1421. Object.defineProperty(Button.prototype, "image", {
  1422. /**
  1423. * Returns the image part of the button (if any)
  1424. */
  1425. get: function () {
  1426. return this._image;
  1427. },
  1428. enumerable: true,
  1429. configurable: true
  1430. });
  1431. Object.defineProperty(Button.prototype, "textBlock", {
  1432. /**
  1433. * Returns the image part of the button (if any)
  1434. */
  1435. get: function () {
  1436. return this._textBlock;
  1437. },
  1438. enumerable: true,
  1439. configurable: true
  1440. });
  1441. Button.prototype._getTypeName = function () {
  1442. return "Button";
  1443. };
  1444. // While being a container, the button behaves like a control.
  1445. /** @hidden */
  1446. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1447. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1448. return false;
  1449. }
  1450. if (!_super.prototype.contains.call(this, x, y)) {
  1451. return false;
  1452. }
  1453. if (this.delegatePickingToChildren) {
  1454. var contains = false;
  1455. for (var index = this._children.length - 1; index >= 0; index--) {
  1456. var child = this._children[index];
  1457. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1458. contains = true;
  1459. break;
  1460. }
  1461. }
  1462. if (!contains) {
  1463. return false;
  1464. }
  1465. }
  1466. this._processObservables(type, x, y, pointerId, buttonIndex);
  1467. return true;
  1468. };
  1469. /** @hidden */
  1470. Button.prototype._onPointerEnter = function (target) {
  1471. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1472. return false;
  1473. }
  1474. if (this.pointerEnterAnimation) {
  1475. this.pointerEnterAnimation();
  1476. }
  1477. return true;
  1478. };
  1479. /** @hidden */
  1480. Button.prototype._onPointerOut = function (target, force) {
  1481. if (force === void 0) { force = false; }
  1482. if (this.pointerOutAnimation) {
  1483. this.pointerOutAnimation();
  1484. }
  1485. _super.prototype._onPointerOut.call(this, target, force);
  1486. };
  1487. /** @hidden */
  1488. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1489. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1490. return false;
  1491. }
  1492. if (this.pointerDownAnimation) {
  1493. this.pointerDownAnimation();
  1494. }
  1495. return true;
  1496. };
  1497. /** @hidden */
  1498. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1499. if (this.pointerUpAnimation) {
  1500. this.pointerUpAnimation();
  1501. }
  1502. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1503. };
  1504. // Statics
  1505. /**
  1506. * Creates a new button made with an image and a text
  1507. * @param name defines the name of the button
  1508. * @param text defines the text of the button
  1509. * @param imageUrl defines the url of the image
  1510. * @returns a new Button
  1511. */
  1512. Button.CreateImageButton = function (name, text, imageUrl) {
  1513. var result = new Button(name);
  1514. // Adding text
  1515. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1516. textBlock.textWrapping = true;
  1517. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1518. textBlock.paddingLeft = "20%";
  1519. result.addControl(textBlock);
  1520. // Adding image
  1521. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1522. iconImage.width = "20%";
  1523. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1524. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1525. result.addControl(iconImage);
  1526. // Store
  1527. result._image = iconImage;
  1528. result._textBlock = textBlock;
  1529. return result;
  1530. };
  1531. /**
  1532. * Creates a new button made with an image
  1533. * @param name defines the name of the button
  1534. * @param imageUrl defines the url of the image
  1535. * @returns a new Button
  1536. */
  1537. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1538. var result = new Button(name);
  1539. // Adding image
  1540. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1541. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1542. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1543. result.addControl(iconImage);
  1544. // Store
  1545. result._image = iconImage;
  1546. return result;
  1547. };
  1548. /**
  1549. * Creates a new button made with a text
  1550. * @param name defines the name of the button
  1551. * @param text defines the text of the button
  1552. * @returns a new Button
  1553. */
  1554. Button.CreateSimpleButton = function (name, text) {
  1555. var result = new Button(name);
  1556. // Adding text
  1557. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1558. textBlock.textWrapping = true;
  1559. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1560. result.addControl(textBlock);
  1561. // Store
  1562. result._textBlock = textBlock;
  1563. return result;
  1564. };
  1565. /**
  1566. * Creates a new button made with an image and a centered text
  1567. * @param name defines the name of the button
  1568. * @param text defines the text of the button
  1569. * @param imageUrl defines the url of the image
  1570. * @returns a new Button
  1571. */
  1572. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1573. var result = new Button(name);
  1574. // Adding image
  1575. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1576. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1577. result.addControl(iconImage);
  1578. // Adding text
  1579. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1580. textBlock.textWrapping = true;
  1581. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1582. result.addControl(textBlock);
  1583. // Store
  1584. result._image = iconImage;
  1585. result._textBlock = textBlock;
  1586. return result;
  1587. };
  1588. return Button;
  1589. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1590. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1591. /***/ }),
  1592. /***/ "./2D/controls/checkbox.ts":
  1593. /*!*********************************!*\
  1594. !*** ./2D/controls/checkbox.ts ***!
  1595. \*********************************/
  1596. /*! exports provided: Checkbox */
  1597. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1598. "use strict";
  1599. __webpack_require__.r(__webpack_exports__);
  1600. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1601. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1602. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1603. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1604. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1605. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1606. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1607. /**
  1608. * Class used to represent a 2D checkbox
  1609. */
  1610. var Checkbox = /** @class */ (function (_super) {
  1611. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1612. /**
  1613. * Creates a new CheckBox
  1614. * @param name defines the control name
  1615. */
  1616. function Checkbox(name) {
  1617. var _this = _super.call(this, name) || this;
  1618. _this.name = name;
  1619. _this._isChecked = false;
  1620. _this._background = "black";
  1621. _this._checkSizeRatio = 0.8;
  1622. _this._thickness = 1;
  1623. /**
  1624. * Observable raised when isChecked property changes
  1625. */
  1626. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1627. _this.isPointerBlocker = true;
  1628. return _this;
  1629. }
  1630. Object.defineProperty(Checkbox.prototype, "thickness", {
  1631. /** Gets or sets border thickness */
  1632. get: function () {
  1633. return this._thickness;
  1634. },
  1635. set: function (value) {
  1636. if (this._thickness === value) {
  1637. return;
  1638. }
  1639. this._thickness = value;
  1640. this._markAsDirty();
  1641. },
  1642. enumerable: true,
  1643. configurable: true
  1644. });
  1645. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1646. /** Gets or sets a value indicating the ratio between overall size and check size */
  1647. get: function () {
  1648. return this._checkSizeRatio;
  1649. },
  1650. set: function (value) {
  1651. value = Math.max(Math.min(1, value), 0);
  1652. if (this._checkSizeRatio === value) {
  1653. return;
  1654. }
  1655. this._checkSizeRatio = value;
  1656. this._markAsDirty();
  1657. },
  1658. enumerable: true,
  1659. configurable: true
  1660. });
  1661. Object.defineProperty(Checkbox.prototype, "background", {
  1662. /** Gets or sets background color */
  1663. get: function () {
  1664. return this._background;
  1665. },
  1666. set: function (value) {
  1667. if (this._background === value) {
  1668. return;
  1669. }
  1670. this._background = value;
  1671. this._markAsDirty();
  1672. },
  1673. enumerable: true,
  1674. configurable: true
  1675. });
  1676. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1677. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1678. get: function () {
  1679. return this._isChecked;
  1680. },
  1681. set: function (value) {
  1682. if (this._isChecked === value) {
  1683. return;
  1684. }
  1685. this._isChecked = value;
  1686. this._markAsDirty();
  1687. this.onIsCheckedChangedObservable.notifyObservers(value);
  1688. },
  1689. enumerable: true,
  1690. configurable: true
  1691. });
  1692. Checkbox.prototype._getTypeName = function () {
  1693. return "Checkbox";
  1694. };
  1695. /** @hidden */
  1696. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1697. context.save();
  1698. this._applyStates(context);
  1699. var actualWidth = this._currentMeasure.width - this._thickness;
  1700. var actualHeight = this._currentMeasure.height - this._thickness;
  1701. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1702. context.shadowColor = this.shadowColor;
  1703. context.shadowBlur = this.shadowBlur;
  1704. context.shadowOffsetX = this.shadowOffsetX;
  1705. context.shadowOffsetY = this.shadowOffsetY;
  1706. }
  1707. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1708. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1709. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1710. context.shadowBlur = 0;
  1711. context.shadowOffsetX = 0;
  1712. context.shadowOffsetY = 0;
  1713. }
  1714. if (this._isChecked) {
  1715. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1716. var offsetWidth = actualWidth * this._checkSizeRatio;
  1717. var offseHeight = actualHeight * this._checkSizeRatio;
  1718. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1719. }
  1720. context.strokeStyle = this.color;
  1721. context.lineWidth = this._thickness;
  1722. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1723. context.restore();
  1724. };
  1725. // Events
  1726. /** @hidden */
  1727. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1728. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1729. return false;
  1730. }
  1731. this.isChecked = !this.isChecked;
  1732. return true;
  1733. };
  1734. /**
  1735. * Utility function to easily create a checkbox with a header
  1736. * @param title defines the label to use for the header
  1737. * @param onValueChanged defines the callback to call when value changes
  1738. * @returns a StackPanel containing the checkbox and a textBlock
  1739. */
  1740. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1741. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1742. panel.isVertical = false;
  1743. panel.height = "30px";
  1744. var checkbox = new Checkbox();
  1745. checkbox.width = "20px";
  1746. checkbox.height = "20px";
  1747. checkbox.isChecked = true;
  1748. checkbox.color = "green";
  1749. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1750. panel.addControl(checkbox);
  1751. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1752. header.text = title;
  1753. header.width = "180px";
  1754. header.paddingLeft = "5px";
  1755. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1756. header.color = "white";
  1757. panel.addControl(header);
  1758. return panel;
  1759. };
  1760. return Checkbox;
  1761. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1762. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1763. /***/ }),
  1764. /***/ "./2D/controls/colorpicker.ts":
  1765. /*!************************************!*\
  1766. !*** ./2D/controls/colorpicker.ts ***!
  1767. \************************************/
  1768. /*! exports provided: ColorPicker */
  1769. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1770. "use strict";
  1771. __webpack_require__.r(__webpack_exports__);
  1772. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1773. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1774. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1775. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1776. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1777. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1778. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1779. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1780. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1781. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1782. /** Class used to create color pickers */
  1783. var ColorPicker = /** @class */ (function (_super) {
  1784. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1785. /**
  1786. * Creates a new ColorPicker
  1787. * @param name defines the control name
  1788. */
  1789. function ColorPicker(name) {
  1790. var _this = _super.call(this, name) || this;
  1791. _this.name = name;
  1792. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1793. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1794. _this._pointerStartedOnSquare = false;
  1795. _this._pointerStartedOnWheel = false;
  1796. _this._squareLeft = 0;
  1797. _this._squareTop = 0;
  1798. _this._squareSize = 0;
  1799. _this._h = 360;
  1800. _this._s = 1;
  1801. _this._v = 1;
  1802. _this._lastPointerDownID = -1;
  1803. /**
  1804. * Observable raised when the value changes
  1805. */
  1806. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1807. // Events
  1808. _this._pointerIsDown = false;
  1809. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1810. _this.size = "200px";
  1811. _this.isPointerBlocker = true;
  1812. return _this;
  1813. }
  1814. Object.defineProperty(ColorPicker.prototype, "value", {
  1815. /** Gets or sets the color of the color picker */
  1816. get: function () {
  1817. return this._value;
  1818. },
  1819. set: function (value) {
  1820. if (this._value.equals(value)) {
  1821. return;
  1822. }
  1823. this._value.copyFrom(value);
  1824. this._value.toHSVToRef(this._tmpColor);
  1825. this._h = this._tmpColor.r;
  1826. this._s = Math.max(this._tmpColor.g, 0.00001);
  1827. this._v = Math.max(this._tmpColor.b, 0.00001);
  1828. this._markAsDirty();
  1829. if (this._value.r <= ColorPicker._Epsilon) {
  1830. this._value.r = 0;
  1831. }
  1832. if (this._value.g <= ColorPicker._Epsilon) {
  1833. this._value.g = 0;
  1834. }
  1835. if (this._value.b <= ColorPicker._Epsilon) {
  1836. this._value.b = 0;
  1837. }
  1838. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1839. this._value.r = 1.0;
  1840. }
  1841. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1842. this._value.g = 1.0;
  1843. }
  1844. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1845. this._value.b = 1.0;
  1846. }
  1847. this.onValueChangedObservable.notifyObservers(this._value);
  1848. },
  1849. enumerable: true,
  1850. configurable: true
  1851. });
  1852. Object.defineProperty(ColorPicker.prototype, "width", {
  1853. /**
  1854. * Gets or sets control width
  1855. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1856. */
  1857. get: function () {
  1858. return this._width.toString(this._host);
  1859. },
  1860. set: function (value) {
  1861. if (this._width.toString(this._host) === value) {
  1862. return;
  1863. }
  1864. if (this._width.fromString(value)) {
  1865. this._height.fromString(value);
  1866. this._markAsDirty();
  1867. }
  1868. },
  1869. enumerable: true,
  1870. configurable: true
  1871. });
  1872. Object.defineProperty(ColorPicker.prototype, "height", {
  1873. /**
  1874. * Gets or sets control height
  1875. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1876. */
  1877. get: function () {
  1878. return this._height.toString(this._host);
  1879. },
  1880. /** Gets or sets control height */
  1881. set: function (value) {
  1882. if (this._height.toString(this._host) === value) {
  1883. return;
  1884. }
  1885. if (this._height.fromString(value)) {
  1886. this._width.fromString(value);
  1887. this._markAsDirty();
  1888. }
  1889. },
  1890. enumerable: true,
  1891. configurable: true
  1892. });
  1893. Object.defineProperty(ColorPicker.prototype, "size", {
  1894. /** Gets or sets control size */
  1895. get: function () {
  1896. return this.width;
  1897. },
  1898. set: function (value) {
  1899. this.width = value;
  1900. },
  1901. enumerable: true,
  1902. configurable: true
  1903. });
  1904. ColorPicker.prototype._getTypeName = function () {
  1905. return "ColorPicker";
  1906. };
  1907. /** @hidden */
  1908. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1909. if (parentMeasure.width < parentMeasure.height) {
  1910. this._currentMeasure.height = parentMeasure.width;
  1911. }
  1912. else {
  1913. this._currentMeasure.width = parentMeasure.height;
  1914. }
  1915. };
  1916. ColorPicker.prototype._updateSquareProps = function () {
  1917. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1918. var wheelThickness = radius * .2;
  1919. var innerDiameter = (radius - wheelThickness) * 2;
  1920. var squareSize = innerDiameter / (Math.sqrt(2));
  1921. var offset = radius - squareSize * .5;
  1922. this._squareLeft = this._currentMeasure.left + offset;
  1923. this._squareTop = this._currentMeasure.top + offset;
  1924. this._squareSize = squareSize;
  1925. };
  1926. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1927. var lgh = context.createLinearGradient(left, top, width + left, top);
  1928. lgh.addColorStop(0, '#fff');
  1929. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1930. context.fillStyle = lgh;
  1931. context.fillRect(left, top, width, height);
  1932. var lgv = context.createLinearGradient(left, top, left, height + top);
  1933. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1934. lgv.addColorStop(1, '#000');
  1935. context.fillStyle = lgv;
  1936. context.fillRect(left, top, width, height);
  1937. };
  1938. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1939. context.beginPath();
  1940. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1941. context.lineWidth = 3;
  1942. context.strokeStyle = '#333333';
  1943. context.stroke();
  1944. context.beginPath();
  1945. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1946. context.lineWidth = 3;
  1947. context.strokeStyle = '#ffffff';
  1948. context.stroke();
  1949. };
  1950. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1951. var canvas = document.createElement("canvas");
  1952. canvas.width = radius * 2;
  1953. canvas.height = radius * 2;
  1954. var context = canvas.getContext("2d");
  1955. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1956. var data = image.data;
  1957. var color = this._tmpColor;
  1958. var maxDistSq = radius * radius;
  1959. var innerRadius = radius - thickness;
  1960. var minDistSq = innerRadius * innerRadius;
  1961. for (var x = -radius; x < radius; x++) {
  1962. for (var y = -radius; y < radius; y++) {
  1963. var distSq = x * x + y * y;
  1964. if (distSq > maxDistSq || distSq < minDistSq) {
  1965. continue;
  1966. }
  1967. var dist = Math.sqrt(distSq);
  1968. var ang = Math.atan2(y, x);
  1969. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1970. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1971. data[index] = color.r * 255;
  1972. data[index + 1] = color.g * 255;
  1973. data[index + 2] = color.b * 255;
  1974. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1975. //apply less alpha to bigger color pickers
  1976. var alphaAmount = .2;
  1977. var maxAlpha = .2;
  1978. var minAlpha = .04;
  1979. var lowerRadius = 50;
  1980. var upperRadius = 150;
  1981. if (radius < lowerRadius) {
  1982. alphaAmount = maxAlpha;
  1983. }
  1984. else if (radius > upperRadius) {
  1985. alphaAmount = minAlpha;
  1986. }
  1987. else {
  1988. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1989. }
  1990. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1991. if (alphaRatio < alphaAmount) {
  1992. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1993. }
  1994. else if (alphaRatio > 1 - alphaAmount) {
  1995. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1996. }
  1997. else {
  1998. data[index + 3] = 255;
  1999. }
  2000. }
  2001. }
  2002. context.putImageData(image, 0, 0);
  2003. return canvas;
  2004. };
  2005. /** @hidden */
  2006. ColorPicker.prototype._draw = function (context) {
  2007. context.save();
  2008. this._applyStates(context);
  2009. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2010. var wheelThickness = radius * .2;
  2011. var left = this._currentMeasure.left;
  2012. var top = this._currentMeasure.top;
  2013. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2014. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2015. }
  2016. this._updateSquareProps();
  2017. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2018. context.shadowColor = this.shadowColor;
  2019. context.shadowBlur = this.shadowBlur;
  2020. context.shadowOffsetX = this.shadowOffsetX;
  2021. context.shadowOffsetY = this.shadowOffsetY;
  2022. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2023. }
  2024. context.drawImage(this._colorWheelCanvas, left, top);
  2025. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2026. context.shadowBlur = 0;
  2027. context.shadowOffsetX = 0;
  2028. context.shadowOffsetY = 0;
  2029. }
  2030. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2031. var cx = this._squareLeft + this._squareSize * this._s;
  2032. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2033. this._drawCircle(cx, cy, radius * .04, context);
  2034. var dist = radius - wheelThickness * .5;
  2035. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2036. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2037. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2038. context.restore();
  2039. };
  2040. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2041. if (this._pointerStartedOnWheel) {
  2042. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2043. var centerX = radius + this._currentMeasure.left;
  2044. var centerY = radius + this._currentMeasure.top;
  2045. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2046. }
  2047. else if (this._pointerStartedOnSquare) {
  2048. this._updateSquareProps();
  2049. this._s = (x - this._squareLeft) / this._squareSize;
  2050. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2051. this._s = Math.min(this._s, 1);
  2052. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2053. this._v = Math.min(this._v, 1);
  2054. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2055. }
  2056. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2057. this.value = this._tmpColor;
  2058. };
  2059. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2060. this._updateSquareProps();
  2061. var left = this._squareLeft;
  2062. var top = this._squareTop;
  2063. var size = this._squareSize;
  2064. if (x >= left && x <= left + size &&
  2065. y >= top && y <= top + size) {
  2066. return true;
  2067. }
  2068. return false;
  2069. };
  2070. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2071. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2072. var centerX = radius + this._currentMeasure.left;
  2073. var centerY = radius + this._currentMeasure.top;
  2074. var wheelThickness = radius * .2;
  2075. var innerRadius = radius - wheelThickness;
  2076. var radiusSq = radius * radius;
  2077. var innerRadiusSq = innerRadius * innerRadius;
  2078. var dx = x - centerX;
  2079. var dy = y - centerY;
  2080. var distSq = dx * dx + dy * dy;
  2081. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2082. return true;
  2083. }
  2084. return false;
  2085. };
  2086. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2087. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2088. return false;
  2089. }
  2090. this._pointerIsDown = true;
  2091. this._pointerStartedOnSquare = false;
  2092. this._pointerStartedOnWheel = false;
  2093. // Invert transform
  2094. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2095. var x = this._transformedPosition.x;
  2096. var y = this._transformedPosition.y;
  2097. if (this._isPointOnSquare(x, y)) {
  2098. this._pointerStartedOnSquare = true;
  2099. }
  2100. else if (this._isPointOnWheel(x, y)) {
  2101. this._pointerStartedOnWheel = true;
  2102. }
  2103. this._updateValueFromPointer(x, y);
  2104. this._host._capturingControl[pointerId] = this;
  2105. this._lastPointerDownID = pointerId;
  2106. return true;
  2107. };
  2108. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2109. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2110. if (pointerId != this._lastPointerDownID) {
  2111. return;
  2112. }
  2113. // Invert transform
  2114. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2115. var x = this._transformedPosition.x;
  2116. var y = this._transformedPosition.y;
  2117. if (this._pointerIsDown) {
  2118. this._updateValueFromPointer(x, y);
  2119. }
  2120. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2121. };
  2122. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2123. this._pointerIsDown = false;
  2124. delete this._host._capturingControl[pointerId];
  2125. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2126. };
  2127. /**
  2128. * This function expands the color picker by creating a color picker dialog with manual
  2129. * color value input and the ability to save colors into an array to be used later in
  2130. * subsequent launches of the dialogue.
  2131. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2132. * @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.
  2133. * @returns picked color as a hex string and the saved colors array as hex strings.
  2134. */
  2135. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2136. return new Promise(function (resolve, reject) {
  2137. // Default options
  2138. options.pickerWidth = options.pickerWidth || "640px";
  2139. options.pickerHeight = options.pickerHeight || "400px";
  2140. options.headerHeight = options.headerHeight || "35px";
  2141. options.lastColor = options.lastColor || "#000000";
  2142. options.swatchLimit = options.swatchLimit || 20;
  2143. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2144. // Window size settings
  2145. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2146. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2147. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2148. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2149. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2150. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2151. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2152. // Button Colors
  2153. var buttonColor = "#c0c0c0";
  2154. var buttonBackgroundColor = "#535353";
  2155. var buttonBackgroundHoverColor = "#414141";
  2156. var buttonBackgroundClickColor = "515151";
  2157. var buttonDisabledColor = "#555555";
  2158. var buttonDisabledBackgroundColor = "#454545";
  2159. var currentSwatchesOutlineColor = "#404040";
  2160. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2161. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2162. var iconColorDark = "#aaaaaa";
  2163. var iconColorLight = "#ffffff";
  2164. var closeIconColor;
  2165. // Button settings
  2166. var buttonFontSize;
  2167. var butEdit;
  2168. var buttonWidth;
  2169. var buttonHeight;
  2170. // Input Text Colors
  2171. var inputFieldLabels = ["R", "G", "B"];
  2172. var inputTextBackgroundColor = "#454545";
  2173. var inputTextColor = "#f0f0f0";
  2174. // This is the current color as set by either the picker or by entering a value
  2175. var currentColor;
  2176. // This int is used for naming swatches and serves as the index for calling them from the list
  2177. var swatchNumber;
  2178. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2179. var swatchDrawer;
  2180. var editSwatchMode = false;
  2181. // Color InputText fields that will be updated upon value change
  2182. var picker;
  2183. var rValInt;
  2184. var gValInt;
  2185. var bValInt;
  2186. var rValDec;
  2187. var gValDec;
  2188. var bValDec;
  2189. var hexVal;
  2190. var newSwatch;
  2191. var lastVal;
  2192. var activeField;
  2193. /**
  2194. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2195. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2196. * are will receive no update. This is to prevent the input from the user being overwritten.
  2197. */
  2198. function updateValues(value, inputField) {
  2199. activeField = inputField;
  2200. var pickedColor = value.toHexString();
  2201. newSwatch.background = pickedColor;
  2202. if (rValInt.name != activeField) {
  2203. rValInt.text = Math.floor(value.r * 255).toString();
  2204. }
  2205. if (gValInt.name != activeField) {
  2206. gValInt.text = Math.floor(value.g * 255).toString();
  2207. }
  2208. if (bValInt.name != activeField) {
  2209. bValInt.text = Math.floor(value.b * 255).toString();
  2210. }
  2211. if (rValDec.name != activeField) {
  2212. rValDec.text = value.r.toString();
  2213. }
  2214. if (gValDec.name != activeField) {
  2215. gValDec.text = value.g.toString();
  2216. }
  2217. if (bValDec.name != activeField) {
  2218. bValDec.text = value.b.toString();
  2219. }
  2220. if (hexVal.name != activeField) {
  2221. var minusPound = pickedColor.split("#");
  2222. hexVal.text = minusPound[1];
  2223. }
  2224. if (picker.name != activeField) {
  2225. picker.value = value;
  2226. }
  2227. }
  2228. // 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.
  2229. function updateInt(field, channel) {
  2230. var newValue = field.text;
  2231. var checkVal = /[^0-9]/g.test(newValue);
  2232. if (checkVal) {
  2233. field.text = lastVal;
  2234. return;
  2235. }
  2236. else {
  2237. if (newValue != "") {
  2238. if (Math.floor(parseInt(newValue)) < 0) {
  2239. newValue = "0";
  2240. }
  2241. else if (Math.floor(parseInt(newValue)) > 255) {
  2242. newValue = "255";
  2243. }
  2244. else if (isNaN(parseInt(newValue))) {
  2245. newValue = "0";
  2246. }
  2247. }
  2248. if (activeField == field.name) {
  2249. lastVal = newValue;
  2250. }
  2251. }
  2252. if (newValue != "") {
  2253. newValue = parseInt(newValue).toString();
  2254. field.text = newValue;
  2255. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2256. if (activeField == field.name) {
  2257. if (channel == "r") {
  2258. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2259. }
  2260. else if (channel == "g") {
  2261. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2262. }
  2263. else {
  2264. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2265. }
  2266. }
  2267. }
  2268. }
  2269. // 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.
  2270. function updateFloat(field, channel) {
  2271. var newValue = field.text;
  2272. var checkVal = /[^0-9\.]/g.test(newValue);
  2273. if (checkVal) {
  2274. field.text = lastVal;
  2275. return;
  2276. }
  2277. else {
  2278. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2279. if (parseFloat(newValue) < 0.0) {
  2280. newValue = "0.0";
  2281. }
  2282. else if (parseFloat(newValue) > 1.0) {
  2283. newValue = "1.0";
  2284. }
  2285. else if (isNaN(parseFloat(newValue))) {
  2286. newValue = "0.0";
  2287. }
  2288. }
  2289. if (activeField == field.name) {
  2290. lastVal = newValue;
  2291. }
  2292. }
  2293. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2294. newValue = parseFloat(newValue).toString();
  2295. field.text = newValue;
  2296. }
  2297. else {
  2298. newValue = "0.0";
  2299. }
  2300. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2301. if (activeField == field.name) {
  2302. if (channel == "r") {
  2303. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2304. }
  2305. else if (channel == "g") {
  2306. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2307. }
  2308. else {
  2309. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2310. }
  2311. }
  2312. }
  2313. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2314. function deleteSwatch(index) {
  2315. if (options.savedColors) {
  2316. options.savedColors.splice(index, 1);
  2317. }
  2318. if (options.savedColors && options.savedColors.length == 0) {
  2319. setEditButtonVisibility(false);
  2320. editSwatchMode = false;
  2321. }
  2322. }
  2323. // Creates and styles an individual swatch when updateSwatches is called.
  2324. function createSwatch() {
  2325. if (options.savedColors && options.savedColors[swatchNumber]) {
  2326. if (editSwatchMode) {
  2327. var icon = "b";
  2328. }
  2329. else {
  2330. var icon = "";
  2331. }
  2332. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2333. swatch.fontFamily = "BabylonJSglyphs";
  2334. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2335. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2336. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2337. if (swatchLuminence > luminanceLimit) {
  2338. swatch.color = iconColorDark;
  2339. }
  2340. else {
  2341. swatch.color = iconColorLight;
  2342. }
  2343. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2344. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2345. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2346. swatch.background = options.savedColors[swatchNumber];
  2347. swatch.thickness = 2;
  2348. var metadata_1 = swatchNumber;
  2349. swatch.pointerDownAnimation = function () {
  2350. swatch.thickness = 4;
  2351. };
  2352. swatch.pointerUpAnimation = function () {
  2353. swatch.thickness = 3;
  2354. };
  2355. swatch.pointerEnterAnimation = function () {
  2356. swatch.thickness = 3;
  2357. };
  2358. swatch.pointerOutAnimation = function () {
  2359. swatch.thickness = 2;
  2360. };
  2361. swatch.onPointerClickObservable.add(function () {
  2362. if (!editSwatchMode) {
  2363. if (options.savedColors) {
  2364. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2365. }
  2366. }
  2367. else {
  2368. deleteSwatch(metadata_1);
  2369. updateSwatches("", butSave);
  2370. }
  2371. });
  2372. return swatch;
  2373. }
  2374. else {
  2375. return null;
  2376. }
  2377. }
  2378. // Mode switch to render button text and close symbols on swatch controls
  2379. function editSwatches(mode) {
  2380. if (mode !== undefined) {
  2381. editSwatchMode = mode;
  2382. }
  2383. if (editSwatchMode) {
  2384. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2385. var thisButton = swatchDrawer.children[i];
  2386. thisButton.textBlock.text = "b";
  2387. }
  2388. if (butEdit !== undefined) {
  2389. butEdit.textBlock.text = "Done";
  2390. }
  2391. }
  2392. else {
  2393. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2394. var thisButton = swatchDrawer.children[i];
  2395. thisButton.textBlock.text = "";
  2396. }
  2397. if (butEdit !== undefined) {
  2398. butEdit.textBlock.text = "Edit";
  2399. }
  2400. }
  2401. }
  2402. /**
  2403. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2404. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2405. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2406. * saved colors there are and how many can be stored per row.
  2407. */
  2408. function updateSwatches(color, button) {
  2409. if (options.savedColors) {
  2410. if (color != "") {
  2411. options.savedColors.push(color);
  2412. }
  2413. swatchNumber = 0;
  2414. swatchDrawer.clearControls();
  2415. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2416. if (rowCount == 0) {
  2417. var gutterCount = 0;
  2418. }
  2419. else {
  2420. var gutterCount = rowCount + 1;
  2421. }
  2422. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2423. var currentRows = swatchDrawer.rowCount;
  2424. for (var i = 0; i < currentRows; i++) {
  2425. swatchDrawer.removeRowDefinition(0);
  2426. }
  2427. for (var i = 0; i < rowCount + gutterCount; i++) {
  2428. if (i % 2) {
  2429. swatchDrawer.addRowDefinition(swatchSize, true);
  2430. }
  2431. else {
  2432. swatchDrawer.addRowDefinition(gutterSize, true);
  2433. }
  2434. }
  2435. }
  2436. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2437. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2438. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2439. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2440. var totalButtonsThisRow = options.numSwatchesPerLine;
  2441. }
  2442. else {
  2443. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2444. }
  2445. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2446. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2447. if (x > options.numSwatchesPerLine) {
  2448. continue;
  2449. }
  2450. var swatch = createSwatch();
  2451. if (swatch != null) {
  2452. swatchDrawer.addControl(swatch, y, w);
  2453. w += 2;
  2454. swatchNumber++;
  2455. }
  2456. else {
  2457. continue;
  2458. }
  2459. }
  2460. }
  2461. if (options.savedColors.length >= options.swatchLimit) {
  2462. disableButton(button, true);
  2463. }
  2464. else {
  2465. disableButton(button, false);
  2466. }
  2467. }
  2468. }
  2469. // Shows or hides edit swatches button depending on if there are saved swatches
  2470. function setEditButtonVisibility(enableButton) {
  2471. if (enableButton) {
  2472. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2473. butEdit.width = buttonWidth;
  2474. butEdit.height = buttonHeight;
  2475. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2476. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2477. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2478. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2479. butEdit.thickness = 2;
  2480. butEdit.color = buttonColor;
  2481. butEdit.fontSize = buttonFontSize;
  2482. butEdit.background = buttonBackgroundColor;
  2483. butEdit.onPointerEnterObservable.add(function () {
  2484. butEdit.background = buttonBackgroundHoverColor;
  2485. });
  2486. butEdit.onPointerOutObservable.add(function () {
  2487. butEdit.background = buttonBackgroundColor;
  2488. });
  2489. butEdit.pointerDownAnimation = function () {
  2490. butEdit.background = buttonBackgroundClickColor;
  2491. };
  2492. butEdit.pointerUpAnimation = function () {
  2493. butEdit.background = buttonBackgroundHoverColor;
  2494. };
  2495. butEdit.onPointerClickObservable.add(function () {
  2496. if (editSwatchMode) {
  2497. editSwatchMode = false;
  2498. }
  2499. else {
  2500. editSwatchMode = true;
  2501. }
  2502. editSwatches();
  2503. });
  2504. pickerGrid.addControl(butEdit, 1, 0);
  2505. }
  2506. else {
  2507. pickerGrid.removeControl(butEdit);
  2508. }
  2509. }
  2510. // Called when the user hits the limit of saved colors in the drawer.
  2511. function disableButton(button, disabled) {
  2512. if (disabled) {
  2513. button.color = buttonDisabledColor;
  2514. button.background = buttonDisabledBackgroundColor;
  2515. }
  2516. else {
  2517. button.color = buttonColor;
  2518. button.background = buttonBackgroundColor;
  2519. }
  2520. }
  2521. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2522. function closePicker(color) {
  2523. if (options.savedColors && options.savedColors.length > 0) {
  2524. resolve({
  2525. savedColors: options.savedColors,
  2526. pickedColor: color
  2527. });
  2528. }
  2529. else {
  2530. resolve({
  2531. pickedColor: color
  2532. });
  2533. }
  2534. advancedTexture.removeControl(dialogContainer);
  2535. }
  2536. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2537. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2538. dialogContainer.name = "Dialog Container";
  2539. dialogContainer.width = options.pickerWidth;
  2540. if (options.savedColors) {
  2541. dialogContainer.height = containerSize;
  2542. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2543. dialogContainer.addRowDefinition(topRow, false);
  2544. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2545. }
  2546. else {
  2547. dialogContainer.height = options.pickerHeight;
  2548. dialogContainer.addRowDefinition(1.0, false);
  2549. }
  2550. advancedTexture.addControl(dialogContainer);
  2551. // Swatch drawer which contains all saved color buttons
  2552. if (options.savedColors) {
  2553. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2554. swatchDrawer.name = "Swatch Drawer";
  2555. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2556. swatchDrawer.background = buttonBackgroundColor;
  2557. swatchDrawer.width = options.pickerWidth;
  2558. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2559. if (initialRows == 0) {
  2560. var gutterCount = 0;
  2561. }
  2562. else {
  2563. var gutterCount = initialRows + 1;
  2564. }
  2565. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2566. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2567. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2568. if (i % 2 != 0) {
  2569. swatchDrawer.addRowDefinition(swatchSize, true);
  2570. }
  2571. else {
  2572. swatchDrawer.addRowDefinition(gutterSize, true);
  2573. }
  2574. }
  2575. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2576. if (i % 2 != 0) {
  2577. swatchDrawer.addColumnDefinition(swatchSize, true);
  2578. }
  2579. else {
  2580. swatchDrawer.addColumnDefinition(gutterSize, true);
  2581. }
  2582. }
  2583. dialogContainer.addControl(swatchDrawer, 1, 0);
  2584. }
  2585. // Picker container
  2586. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2587. pickerPanel.name = "Picker Panel";
  2588. pickerPanel.height = options.pickerHeight;
  2589. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2590. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2591. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2592. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2593. dialogContainer.addControl(pickerPanel, 0, 0);
  2594. // Picker container header
  2595. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2596. header.name = "Dialogue Header Bar";
  2597. header.background = "#cccccc";
  2598. header.thickness = 0;
  2599. pickerPanel.addControl(header, 0, 0);
  2600. // Header close button
  2601. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2602. closeButton.fontFamily = "BabylonJSglyphs";
  2603. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2604. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2605. closeButton.color = closeIconColor.toHexString();
  2606. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2607. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2608. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2609. closeButton.height = closeButton.width = options.headerHeight;
  2610. closeButton.background = header.background;
  2611. closeButton.thickness = 0;
  2612. closeButton.pointerDownAnimation = function () {
  2613. };
  2614. closeButton.pointerUpAnimation = function () {
  2615. closeButton.background = header.background;
  2616. };
  2617. closeButton.pointerEnterAnimation = function () {
  2618. closeButton.color = header.background;
  2619. closeButton.background = "red";
  2620. };
  2621. closeButton.pointerOutAnimation = function () {
  2622. closeButton.color = closeIconColor.toHexString();
  2623. closeButton.background = header.background;
  2624. };
  2625. closeButton.onPointerClickObservable.add(function () {
  2626. closePicker(currentSwatch.background);
  2627. });
  2628. pickerPanel.addControl(closeButton, 0, 0);
  2629. // Dialog container body
  2630. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2631. dialogBody.name = "Dialogue Body";
  2632. dialogBody.background = buttonBackgroundColor;
  2633. var dialogBodyCols = [0.4375, 0.5625];
  2634. dialogBody.addRowDefinition(1.0, false);
  2635. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2636. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2637. pickerPanel.addControl(dialogBody, 1, 0);
  2638. // Picker grid
  2639. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2640. pickerGrid.name = "Picker Grid";
  2641. pickerGrid.addRowDefinition(0.85, false);
  2642. pickerGrid.addRowDefinition(0.15, false);
  2643. dialogBody.addControl(pickerGrid, 0, 0);
  2644. // Picker control
  2645. picker = new ColorPicker();
  2646. picker.name = "GUI Color Picker";
  2647. if (options.pickerHeight < options.pickerWidth) {
  2648. picker.width = 0.89;
  2649. }
  2650. else {
  2651. picker.height = 0.89;
  2652. }
  2653. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2654. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2655. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2656. picker.onPointerDownObservable.add(function () {
  2657. activeField = picker.name;
  2658. lastVal = "";
  2659. editSwatches(false);
  2660. });
  2661. picker.onValueChangedObservable.add(function (value) {
  2662. if (activeField == picker.name) {
  2663. updateValues(value, picker.name);
  2664. }
  2665. });
  2666. pickerGrid.addControl(picker, 0, 0);
  2667. // Picker body right quarant
  2668. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2669. pickerBodyRight.name = "Dialogue Right Half";
  2670. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2671. var pickerBodyRightRows = [0.514, 0.486];
  2672. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2673. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2674. dialogBody.addControl(pickerBodyRight, 1, 1);
  2675. // Picker container swatches and buttons
  2676. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2677. pickerSwatchesButtons.name = "Swatches and Buttons";
  2678. var pickerButtonsCol = [0.417, 0.583];
  2679. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2680. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2681. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2682. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2683. // Picker Swatches quadrant
  2684. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2685. pickerSwatches.name = "New and Current Swatches";
  2686. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2687. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2688. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2689. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2690. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2691. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2692. // Active swatches
  2693. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2694. activeSwatches.name = "Active Swatches";
  2695. activeSwatches.width = 0.67;
  2696. activeSwatches.addRowDefinition(0.5, false);
  2697. activeSwatches.addRowDefinition(0.5, false);
  2698. pickerSwatches.addControl(activeSwatches, 2, 0);
  2699. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2700. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2701. if (options.pickerWidth > options.pickerHeight) {
  2702. var labelTextSize = labelHeight;
  2703. }
  2704. else {
  2705. var labelTextSize = labelWidth;
  2706. }
  2707. // New color swatch and previous color button
  2708. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2709. newText.text = "new";
  2710. newText.name = "New Color Label";
  2711. newText.color = buttonColor;
  2712. newText.fontSize = labelTextSize;
  2713. pickerSwatches.addControl(newText, 1, 0);
  2714. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2715. newSwatch.name = "New Color Swatch";
  2716. newSwatch.background = options.lastColor;
  2717. newSwatch.thickness = 0;
  2718. activeSwatches.addControl(newSwatch, 0, 0);
  2719. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2720. currentSwatch.background = options.lastColor;
  2721. currentSwatch.thickness = 0;
  2722. currentSwatch.onPointerClickObservable.add(function () {
  2723. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2724. updateValues(revertColor, currentSwatch.name);
  2725. editSwatches(false);
  2726. });
  2727. currentSwatch.pointerDownAnimation = function () { };
  2728. currentSwatch.pointerUpAnimation = function () { };
  2729. currentSwatch.pointerEnterAnimation = function () { };
  2730. currentSwatch.pointerOutAnimation = function () { };
  2731. activeSwatches.addControl(currentSwatch, 1, 0);
  2732. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2733. swatchOutline.name = "Swatch Outline";
  2734. swatchOutline.width = 0.67;
  2735. swatchOutline.thickness = 2;
  2736. swatchOutline.color = currentSwatchesOutlineColor;
  2737. swatchOutline.isHitTestVisible = false;
  2738. pickerSwatches.addControl(swatchOutline, 2, 0);
  2739. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2740. currentText.name = "Current Color Label";
  2741. currentText.text = "current";
  2742. currentText.color = buttonColor;
  2743. currentText.fontSize = labelTextSize;
  2744. pickerSwatches.addControl(currentText, 3, 0);
  2745. // Buttons grid
  2746. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2747. buttonGrid.name = "Button Grid";
  2748. buttonGrid.height = 0.8;
  2749. var buttonGridRows = 1 / 3;
  2750. buttonGrid.addRowDefinition(buttonGridRows, false);
  2751. buttonGrid.addRowDefinition(buttonGridRows, false);
  2752. buttonGrid.addRowDefinition(buttonGridRows, false);
  2753. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2754. // Determine pixel width and height for all buttons from overall panel dimensions
  2755. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2756. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2757. // Determine button type size
  2758. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2759. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2760. }
  2761. else {
  2762. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2763. }
  2764. // Panel Buttons
  2765. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2766. butOK.width = buttonWidth;
  2767. butOK.height = buttonHeight;
  2768. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2769. butOK.thickness = 2;
  2770. butOK.color = buttonColor;
  2771. butOK.fontSize = buttonFontSize;
  2772. butOK.background = buttonBackgroundColor;
  2773. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2774. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2775. butOK.pointerDownAnimation = function () {
  2776. butOK.background = buttonBackgroundClickColor;
  2777. };
  2778. butOK.pointerUpAnimation = function () {
  2779. butOK.background = buttonBackgroundHoverColor;
  2780. };
  2781. butOK.onPointerClickObservable.add(function () {
  2782. editSwatches(false);
  2783. closePicker(newSwatch.background);
  2784. });
  2785. buttonGrid.addControl(butOK, 0, 0);
  2786. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2787. butCancel.width = buttonWidth;
  2788. butCancel.height = buttonHeight;
  2789. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2790. butCancel.thickness = 2;
  2791. butCancel.color = buttonColor;
  2792. butCancel.fontSize = buttonFontSize;
  2793. butCancel.background = buttonBackgroundColor;
  2794. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2795. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2796. butCancel.pointerDownAnimation = function () {
  2797. butCancel.background = buttonBackgroundClickColor;
  2798. };
  2799. butCancel.pointerUpAnimation = function () {
  2800. butCancel.background = buttonBackgroundHoverColor;
  2801. };
  2802. butCancel.onPointerClickObservable.add(function () {
  2803. editSwatches(false);
  2804. closePicker(currentSwatch.background);
  2805. });
  2806. buttonGrid.addControl(butCancel, 1, 0);
  2807. if (options.savedColors) {
  2808. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2809. butSave.width = buttonWidth;
  2810. butSave.height = buttonHeight;
  2811. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2812. butSave.thickness = 2;
  2813. butSave.fontSize = buttonFontSize;
  2814. if (options.savedColors.length < options.swatchLimit) {
  2815. butSave.color = buttonColor;
  2816. butSave.background = buttonBackgroundColor;
  2817. }
  2818. else {
  2819. disableButton(butSave, true);
  2820. }
  2821. butSave.onPointerEnterObservable.add(function () {
  2822. if (options.savedColors) {
  2823. if (options.savedColors.length < options.swatchLimit) {
  2824. butSave.background = buttonBackgroundHoverColor;
  2825. }
  2826. }
  2827. });
  2828. butSave.onPointerOutObservable.add(function () {
  2829. if (options.savedColors) {
  2830. if (options.savedColors.length < options.swatchLimit) {
  2831. butSave.background = buttonBackgroundColor;
  2832. }
  2833. }
  2834. });
  2835. butSave.pointerDownAnimation = function () {
  2836. if (options.savedColors) {
  2837. if (options.savedColors.length < options.swatchLimit) {
  2838. butSave.background = buttonBackgroundClickColor;
  2839. }
  2840. }
  2841. };
  2842. butSave.pointerUpAnimation = function () {
  2843. if (options.savedColors) {
  2844. if (options.savedColors.length < options.swatchLimit) {
  2845. butSave.background = buttonBackgroundHoverColor;
  2846. }
  2847. }
  2848. };
  2849. butSave.onPointerClickObservable.add(function () {
  2850. if (options.savedColors) {
  2851. if (options.savedColors.length == 0) {
  2852. setEditButtonVisibility(true);
  2853. }
  2854. if (options.savedColors.length < options.swatchLimit) {
  2855. updateSwatches(newSwatch.background, butSave);
  2856. }
  2857. editSwatches(false);
  2858. }
  2859. });
  2860. if (options.savedColors.length > 0) {
  2861. setEditButtonVisibility(true);
  2862. }
  2863. buttonGrid.addControl(butSave, 2, 0);
  2864. }
  2865. // Picker color values input
  2866. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2867. pickerColorValues.name = "Dialog Lower Right";
  2868. pickerColorValues.addRowDefinition(0.02, false);
  2869. pickerColorValues.addRowDefinition(0.63, false);
  2870. pickerColorValues.addRowDefinition(0.21, false);
  2871. pickerColorValues.addRowDefinition(0.14, false);
  2872. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2873. // RGB values text boxes
  2874. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2875. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2876. rgbValuesQuadrant.name = "RGB Values";
  2877. rgbValuesQuadrant.width = 0.82;
  2878. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2879. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2880. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2881. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2882. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2883. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2884. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2885. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2886. for (var i = 0; i < inputFieldLabels.length; i++) {
  2887. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2888. labelText.text = inputFieldLabels[i];
  2889. labelText.color = buttonColor;
  2890. labelText.fontSize = buttonFontSize;
  2891. rgbValuesQuadrant.addControl(labelText, i, 0);
  2892. }
  2893. // Input fields for RGB values
  2894. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2895. rValInt.width = 0.83;
  2896. rValInt.height = 0.72;
  2897. rValInt.name = "rIntField";
  2898. rValInt.fontSize = buttonFontSize;
  2899. rValInt.text = (currentColor.r * 255).toString();
  2900. rValInt.color = inputTextColor;
  2901. rValInt.background = inputTextBackgroundColor;
  2902. rValInt.onFocusObservable.add(function () {
  2903. activeField = rValInt.name;
  2904. lastVal = rValInt.text;
  2905. editSwatches(false);
  2906. });
  2907. rValInt.onBlurObservable.add(function () {
  2908. if (rValInt.text == "") {
  2909. rValInt.text = "0";
  2910. }
  2911. updateInt(rValInt, "r");
  2912. if (activeField == rValInt.name) {
  2913. activeField = "";
  2914. }
  2915. });
  2916. rValInt.onTextChangedObservable.add(function () {
  2917. if (activeField == rValInt.name) {
  2918. updateInt(rValInt, "r");
  2919. }
  2920. });
  2921. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2922. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2923. gValInt.width = 0.83;
  2924. gValInt.height = 0.72;
  2925. gValInt.name = "gIntField";
  2926. gValInt.fontSize = buttonFontSize;
  2927. gValInt.text = (currentColor.g * 255).toString();
  2928. gValInt.color = inputTextColor;
  2929. gValInt.background = inputTextBackgroundColor;
  2930. gValInt.onFocusObservable.add(function () {
  2931. activeField = gValInt.name;
  2932. lastVal = gValInt.text;
  2933. editSwatches(false);
  2934. });
  2935. gValInt.onBlurObservable.add(function () {
  2936. if (gValInt.text == "") {
  2937. gValInt.text = "0";
  2938. }
  2939. updateInt(gValInt, "g");
  2940. if (activeField == gValInt.name) {
  2941. activeField = "";
  2942. }
  2943. });
  2944. gValInt.onTextChangedObservable.add(function () {
  2945. if (activeField == gValInt.name) {
  2946. updateInt(gValInt, "g");
  2947. }
  2948. });
  2949. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2950. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2951. bValInt.width = 0.83;
  2952. bValInt.height = 0.72;
  2953. bValInt.name = "bIntField";
  2954. bValInt.fontSize = buttonFontSize;
  2955. bValInt.text = (currentColor.b * 255).toString();
  2956. bValInt.color = inputTextColor;
  2957. bValInt.background = inputTextBackgroundColor;
  2958. bValInt.onFocusObservable.add(function () {
  2959. activeField = bValInt.name;
  2960. lastVal = bValInt.text;
  2961. editSwatches(false);
  2962. });
  2963. bValInt.onBlurObservable.add(function () {
  2964. if (bValInt.text == "") {
  2965. bValInt.text = "0";
  2966. }
  2967. updateInt(bValInt, "b");
  2968. if (activeField == bValInt.name) {
  2969. activeField = "";
  2970. }
  2971. });
  2972. bValInt.onTextChangedObservable.add(function () {
  2973. if (activeField == bValInt.name) {
  2974. updateInt(bValInt, "b");
  2975. }
  2976. });
  2977. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2978. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2979. rValDec.width = 0.95;
  2980. rValDec.height = 0.72;
  2981. rValDec.name = "rDecField";
  2982. rValDec.fontSize = buttonFontSize;
  2983. rValDec.text = currentColor.r.toString();
  2984. rValDec.color = inputTextColor;
  2985. rValDec.background = inputTextBackgroundColor;
  2986. rValDec.onFocusObservable.add(function () {
  2987. activeField = rValDec.name;
  2988. lastVal = rValDec.text;
  2989. editSwatches(false);
  2990. });
  2991. rValDec.onBlurObservable.add(function () {
  2992. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2993. rValDec.text = "0";
  2994. updateFloat(rValDec, "r");
  2995. }
  2996. if (activeField == rValDec.name) {
  2997. activeField = "";
  2998. }
  2999. });
  3000. rValDec.onTextChangedObservable.add(function () {
  3001. if (activeField == rValDec.name) {
  3002. updateFloat(rValDec, "r");
  3003. }
  3004. });
  3005. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3006. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3007. gValDec.width = 0.95;
  3008. gValDec.height = 0.72;
  3009. gValDec.name = "gDecField";
  3010. gValDec.fontSize = buttonFontSize;
  3011. gValDec.text = currentColor.g.toString();
  3012. gValDec.color = inputTextColor;
  3013. gValDec.background = inputTextBackgroundColor;
  3014. gValDec.onFocusObservable.add(function () {
  3015. activeField = gValDec.name;
  3016. lastVal = gValDec.text;
  3017. editSwatches(false);
  3018. });
  3019. gValDec.onBlurObservable.add(function () {
  3020. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3021. gValDec.text = "0";
  3022. updateFloat(gValDec, "g");
  3023. }
  3024. if (activeField == gValDec.name) {
  3025. activeField = "";
  3026. }
  3027. });
  3028. gValDec.onTextChangedObservable.add(function () {
  3029. if (activeField == gValDec.name) {
  3030. updateFloat(gValDec, "g");
  3031. }
  3032. });
  3033. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3034. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3035. bValDec.width = 0.95;
  3036. bValDec.height = 0.72;
  3037. bValDec.name = "bDecField";
  3038. bValDec.fontSize = buttonFontSize;
  3039. bValDec.text = currentColor.b.toString();
  3040. bValDec.color = inputTextColor;
  3041. bValDec.background = inputTextBackgroundColor;
  3042. bValDec.onFocusObservable.add(function () {
  3043. activeField = bValDec.name;
  3044. lastVal = bValDec.text;
  3045. editSwatches(false);
  3046. });
  3047. bValDec.onBlurObservable.add(function () {
  3048. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3049. bValDec.text = "0";
  3050. updateFloat(bValDec, "b");
  3051. }
  3052. if (activeField == bValDec.name) {
  3053. activeField = "";
  3054. }
  3055. });
  3056. bValDec.onTextChangedObservable.add(function () {
  3057. if (activeField == bValDec.name) {
  3058. updateFloat(bValDec, "b");
  3059. }
  3060. });
  3061. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3062. // Hex value input
  3063. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3064. hexValueQuadrant.name = "Hex Value";
  3065. hexValueQuadrant.width = 0.82;
  3066. hexValueQuadrant.addRowDefinition(1.0, false);
  3067. hexValueQuadrant.addColumnDefinition(0.1, false);
  3068. hexValueQuadrant.addColumnDefinition(0.9, false);
  3069. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3070. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3071. labelText.text = "#";
  3072. labelText.color = buttonColor;
  3073. labelText.fontSize = buttonFontSize;
  3074. hexValueQuadrant.addControl(labelText, 0, 0);
  3075. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3076. hexVal.width = 0.96;
  3077. hexVal.height = 0.72;
  3078. hexVal.name = "hexField";
  3079. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3080. hexVal.fontSize = buttonFontSize;
  3081. var minusPound = options.lastColor.split("#");
  3082. hexVal.text = minusPound[1];
  3083. hexVal.color = inputTextColor;
  3084. hexVal.background = inputTextBackgroundColor;
  3085. hexVal.onFocusObservable.add(function () {
  3086. activeField = hexVal.name;
  3087. lastVal = hexVal.text;
  3088. editSwatches(false);
  3089. });
  3090. hexVal.onBlurObservable.add(function () {
  3091. if (hexVal.text.length == 3) {
  3092. var val = hexVal.text.split("");
  3093. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3094. }
  3095. if (hexVal.text == "") {
  3096. hexVal.text = "000000";
  3097. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3098. }
  3099. if (activeField == hexVal.name) {
  3100. activeField = "";
  3101. }
  3102. });
  3103. hexVal.onTextChangedObservable.add(function () {
  3104. var newHexValue = hexVal.text;
  3105. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3106. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3107. hexVal.text = lastVal;
  3108. }
  3109. else {
  3110. if (hexVal.text.length < 6) {
  3111. var leadingZero = 6 - hexVal.text.length;
  3112. for (var i = 0; i < leadingZero; i++) {
  3113. newHexValue = "0" + newHexValue;
  3114. }
  3115. }
  3116. if (hexVal.text.length == 3) {
  3117. var val = hexVal.text.split("");
  3118. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3119. }
  3120. newHexValue = "#" + newHexValue;
  3121. if (activeField == hexVal.name) {
  3122. lastVal = hexVal.text;
  3123. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3124. }
  3125. }
  3126. });
  3127. hexValueQuadrant.addControl(hexVal, 0, 1);
  3128. if (options.savedColors && options.savedColors.length > 0) {
  3129. updateSwatches("", butSave);
  3130. }
  3131. });
  3132. };
  3133. ColorPicker._Epsilon = 0.000001;
  3134. return ColorPicker;
  3135. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3136. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3137. /***/ }),
  3138. /***/ "./2D/controls/container.ts":
  3139. /*!**********************************!*\
  3140. !*** ./2D/controls/container.ts ***!
  3141. \**********************************/
  3142. /*! exports provided: Container */
  3143. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3144. "use strict";
  3145. __webpack_require__.r(__webpack_exports__);
  3146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3147. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3148. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/perfCounter");
  3149. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3150. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3151. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3152. /**
  3153. * Root class for 2D containers
  3154. * @see http://doc.babylonjs.com/how_to/gui#containers
  3155. */
  3156. var Container = /** @class */ (function (_super) {
  3157. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3158. /**
  3159. * Creates a new Container
  3160. * @param name defines the name of the container
  3161. */
  3162. function Container(name) {
  3163. var _this = _super.call(this, name) || this;
  3164. _this.name = name;
  3165. /** @hidden */
  3166. _this._children = new Array();
  3167. /** @hidden */
  3168. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3169. /** @hidden */
  3170. _this._background = "";
  3171. /** @hidden */
  3172. _this._adaptWidthToChildren = false;
  3173. /** @hidden */
  3174. _this._adaptHeightToChildren = false;
  3175. /**
  3176. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3177. */
  3178. _this.logLayoutCycleErrors = false;
  3179. /**
  3180. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3181. */
  3182. _this.maxLayoutCycle = 3;
  3183. return _this;
  3184. }
  3185. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3186. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3187. get: function () {
  3188. return this._adaptHeightToChildren;
  3189. },
  3190. set: function (value) {
  3191. if (this._adaptHeightToChildren === value) {
  3192. return;
  3193. }
  3194. this._adaptHeightToChildren = value;
  3195. if (value) {
  3196. this.height = "100%";
  3197. }
  3198. this._markAsDirty();
  3199. },
  3200. enumerable: true,
  3201. configurable: true
  3202. });
  3203. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3204. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3205. get: function () {
  3206. return this._adaptWidthToChildren;
  3207. },
  3208. set: function (value) {
  3209. if (this._adaptWidthToChildren === value) {
  3210. return;
  3211. }
  3212. this._adaptWidthToChildren = value;
  3213. if (value) {
  3214. this.width = "100%";
  3215. }
  3216. this._markAsDirty();
  3217. },
  3218. enumerable: true,
  3219. configurable: true
  3220. });
  3221. Object.defineProperty(Container.prototype, "background", {
  3222. /** Gets or sets background color */
  3223. get: function () {
  3224. return this._background;
  3225. },
  3226. set: function (value) {
  3227. if (this._background === value) {
  3228. return;
  3229. }
  3230. this._background = value;
  3231. this._markAsDirty();
  3232. },
  3233. enumerable: true,
  3234. configurable: true
  3235. });
  3236. Object.defineProperty(Container.prototype, "children", {
  3237. /** Gets the list of children */
  3238. get: function () {
  3239. return this._children;
  3240. },
  3241. enumerable: true,
  3242. configurable: true
  3243. });
  3244. Container.prototype._getTypeName = function () {
  3245. return "Container";
  3246. };
  3247. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3248. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3249. var child = _a[_i];
  3250. child._markMatrixAsDirty();
  3251. }
  3252. };
  3253. /**
  3254. * Gets a child using its name
  3255. * @param name defines the child name to look for
  3256. * @returns the child control if found
  3257. */
  3258. Container.prototype.getChildByName = function (name) {
  3259. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3260. var child = _a[_i];
  3261. if (child.name === name) {
  3262. return child;
  3263. }
  3264. }
  3265. return null;
  3266. };
  3267. /**
  3268. * Gets a child using its type and its name
  3269. * @param name defines the child name to look for
  3270. * @param type defines the child type to look for
  3271. * @returns the child control if found
  3272. */
  3273. Container.prototype.getChildByType = function (name, type) {
  3274. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3275. var child = _a[_i];
  3276. if (child.typeName === type) {
  3277. return child;
  3278. }
  3279. }
  3280. return null;
  3281. };
  3282. /**
  3283. * Search for a specific control in children
  3284. * @param control defines the control to look for
  3285. * @returns true if the control is in child list
  3286. */
  3287. Container.prototype.containsControl = function (control) {
  3288. return this.children.indexOf(control) !== -1;
  3289. };
  3290. /**
  3291. * Adds a new control to the current container
  3292. * @param control defines the control to add
  3293. * @returns the current container
  3294. */
  3295. Container.prototype.addControl = function (control) {
  3296. if (!control) {
  3297. return this;
  3298. }
  3299. var index = this._children.indexOf(control);
  3300. if (index !== -1) {
  3301. return this;
  3302. }
  3303. control._link(this._host);
  3304. control._markAllAsDirty();
  3305. this._reOrderControl(control);
  3306. this._markAsDirty();
  3307. return this;
  3308. };
  3309. /**
  3310. * Removes all controls from the current container
  3311. * @returns the current container
  3312. */
  3313. Container.prototype.clearControls = function () {
  3314. var children = this.children.slice();
  3315. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3316. var child = children_1[_i];
  3317. this.removeControl(child);
  3318. }
  3319. return this;
  3320. };
  3321. /**
  3322. * Removes a control from the current container
  3323. * @param control defines the control to remove
  3324. * @returns the current container
  3325. */
  3326. Container.prototype.removeControl = function (control) {
  3327. var index = this._children.indexOf(control);
  3328. if (index !== -1) {
  3329. this._children.splice(index, 1);
  3330. control.parent = null;
  3331. }
  3332. control.linkWithMesh(null);
  3333. if (this._host) {
  3334. this._host._cleanControlAfterRemoval(control);
  3335. }
  3336. this._markAsDirty();
  3337. return this;
  3338. };
  3339. /** @hidden */
  3340. Container.prototype._reOrderControl = function (control) {
  3341. this.removeControl(control);
  3342. var wasAdded = false;
  3343. for (var index = 0; index < this._children.length; index++) {
  3344. if (this._children[index].zIndex > control.zIndex) {
  3345. this._children.splice(index, 0, control);
  3346. wasAdded = true;
  3347. break;
  3348. }
  3349. }
  3350. if (!wasAdded) {
  3351. this._children.push(control);
  3352. }
  3353. control.parent = this;
  3354. this._markAsDirty();
  3355. };
  3356. /** @hidden */
  3357. Container.prototype._offsetLeft = function (offset) {
  3358. _super.prototype._offsetLeft.call(this, offset);
  3359. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3360. var child = _a[_i];
  3361. child._offsetLeft(offset);
  3362. }
  3363. };
  3364. /** @hidden */
  3365. Container.prototype._offsetTop = function (offset) {
  3366. _super.prototype._offsetTop.call(this, offset);
  3367. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3368. var child = _a[_i];
  3369. child._offsetTop(offset);
  3370. }
  3371. };
  3372. /** @hidden */
  3373. Container.prototype._markAllAsDirty = function () {
  3374. _super.prototype._markAllAsDirty.call(this);
  3375. for (var index = 0; index < this._children.length; index++) {
  3376. this._children[index]._markAllAsDirty();
  3377. }
  3378. };
  3379. /** @hidden */
  3380. Container.prototype._localDraw = function (context) {
  3381. if (this._background) {
  3382. context.save();
  3383. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3384. context.shadowColor = this.shadowColor;
  3385. context.shadowBlur = this.shadowBlur;
  3386. context.shadowOffsetX = this.shadowOffsetX;
  3387. context.shadowOffsetY = this.shadowOffsetY;
  3388. }
  3389. context.fillStyle = this._background;
  3390. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3391. context.restore();
  3392. }
  3393. };
  3394. /** @hidden */
  3395. Container.prototype._link = function (host) {
  3396. _super.prototype._link.call(this, host);
  3397. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3398. var child = _a[_i];
  3399. child._link(host);
  3400. }
  3401. };
  3402. /** @hidden */
  3403. Container.prototype._beforeLayout = function () {
  3404. // Do nothing
  3405. };
  3406. /** @hidden */
  3407. Container.prototype._processMeasures = function (parentMeasure, context) {
  3408. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3409. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3410. this._evaluateClippingState(parentMeasure);
  3411. }
  3412. };
  3413. /** @hidden */
  3414. Container.prototype._layout = function (parentMeasure, context) {
  3415. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3416. return false;
  3417. }
  3418. this.host._numLayoutCalls++;
  3419. if (this._isDirty) {
  3420. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3421. }
  3422. var rebuildCount = 0;
  3423. context.save();
  3424. this._applyStates(context);
  3425. this._beforeLayout();
  3426. do {
  3427. var computedWidth = -1;
  3428. var computedHeight = -1;
  3429. this._rebuildLayout = false;
  3430. this._processMeasures(parentMeasure, context);
  3431. if (!this._isClipped) {
  3432. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3433. var child = _a[_i];
  3434. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3435. if (child._layout(this._measureForChildren, context)) {
  3436. if (this.adaptWidthToChildren && child._width.isPixel) {
  3437. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3438. }
  3439. if (this.adaptHeightToChildren && child._height.isPixel) {
  3440. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3441. }
  3442. }
  3443. }
  3444. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3445. if (this.width !== computedWidth + "px") {
  3446. this.width = computedWidth + "px";
  3447. this._rebuildLayout = true;
  3448. }
  3449. }
  3450. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3451. if (this.height !== computedHeight + "px") {
  3452. this.height = computedHeight + "px";
  3453. this._rebuildLayout = true;
  3454. }
  3455. }
  3456. this._postMeasure();
  3457. }
  3458. rebuildCount++;
  3459. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3460. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3461. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3462. }
  3463. context.restore();
  3464. if (this._isDirty) {
  3465. this.invalidateRect();
  3466. this._isDirty = false;
  3467. }
  3468. return true;
  3469. };
  3470. Container.prototype._postMeasure = function () {
  3471. // Do nothing by default
  3472. };
  3473. /** @hidden */
  3474. Container.prototype._draw = function (context, invalidatedRectangle) {
  3475. this._localDraw(context);
  3476. if (this.clipChildren) {
  3477. this._clipForChildren(context);
  3478. }
  3479. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3480. var child = _a[_i];
  3481. // Only redraw parts of the screen that are invalidated
  3482. if (invalidatedRectangle) {
  3483. if (!child._intersectsRect(invalidatedRectangle)) {
  3484. continue;
  3485. }
  3486. }
  3487. child._render(context, invalidatedRectangle);
  3488. }
  3489. };
  3490. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3491. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3492. if (!this.children) {
  3493. return;
  3494. }
  3495. for (var index = 0; index < this.children.length; index++) {
  3496. var item = this.children[index];
  3497. if (!predicate || predicate(item)) {
  3498. results.push(item);
  3499. }
  3500. if (!directDescendantsOnly) {
  3501. item.getDescendantsToRef(results, false, predicate);
  3502. }
  3503. }
  3504. };
  3505. /** @hidden */
  3506. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3507. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3508. return false;
  3509. }
  3510. if (!_super.prototype.contains.call(this, x, y)) {
  3511. return false;
  3512. }
  3513. // Checking backwards to pick closest first
  3514. for (var index = this._children.length - 1; index >= 0; index--) {
  3515. var child = this._children[index];
  3516. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3517. if (child.hoverCursor) {
  3518. this._host._changeCursor(child.hoverCursor);
  3519. }
  3520. return true;
  3521. }
  3522. }
  3523. if (!this.isHitTestVisible) {
  3524. return false;
  3525. }
  3526. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3527. };
  3528. /** @hidden */
  3529. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3530. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3531. this._measureForChildren.copyFrom(this._currentMeasure);
  3532. };
  3533. /** Releases associated resources */
  3534. Container.prototype.dispose = function () {
  3535. _super.prototype.dispose.call(this);
  3536. for (var index = this.children.length - 1; index >= 0; index--) {
  3537. this.children[index].dispose();
  3538. }
  3539. };
  3540. return Container;
  3541. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3542. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3543. /***/ }),
  3544. /***/ "./2D/controls/control.ts":
  3545. /*!********************************!*\
  3546. !*** ./2D/controls/control.ts ***!
  3547. \********************************/
  3548. /*! exports provided: Control */
  3549. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3550. "use strict";
  3551. __webpack_require__.r(__webpack_exports__);
  3552. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3553. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  3554. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3555. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3556. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3557. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3558. /**
  3559. * Root class used for all 2D controls
  3560. * @see http://doc.babylonjs.com/how_to/gui#controls
  3561. */
  3562. var Control = /** @class */ (function () {
  3563. // Functions
  3564. /**
  3565. * Creates a new control
  3566. * @param name defines the name of the control
  3567. */
  3568. function Control(
  3569. /** defines the name of the control */
  3570. name) {
  3571. this.name = name;
  3572. this._alpha = 1;
  3573. this._alphaSet = false;
  3574. this._zIndex = 0;
  3575. /** @hidden */
  3576. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3577. this._fontFamily = "Arial";
  3578. this._fontStyle = "";
  3579. this._fontWeight = "";
  3580. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3581. /** @hidden */
  3582. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3583. /** @hidden */
  3584. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3585. this._color = "";
  3586. this._style = null;
  3587. /** @hidden */
  3588. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3589. /** @hidden */
  3590. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3591. /** @hidden */
  3592. this._isDirty = true;
  3593. /** @hidden */
  3594. this._wasDirty = false;
  3595. /** @hidden */
  3596. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3597. /** @hidden */
  3598. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3599. /** @hidden */
  3600. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3601. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3602. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3603. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3604. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3605. /** @hidden */
  3606. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3607. /** @hidden */
  3608. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3609. this._scaleX = 1.0;
  3610. this._scaleY = 1.0;
  3611. this._rotation = 0;
  3612. this._transformCenterX = 0.5;
  3613. this._transformCenterY = 0.5;
  3614. /** @hidden */
  3615. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3616. /** @hidden */
  3617. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3618. /** @hidden */
  3619. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3620. this._isMatrixDirty = true;
  3621. this._isVisible = true;
  3622. this._isHighlighted = false;
  3623. this._fontSet = false;
  3624. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3625. this._downCount = 0;
  3626. this._enterCount = -1;
  3627. this._doNotRender = false;
  3628. this._downPointerIds = {};
  3629. this._isEnabled = true;
  3630. this._disabledColor = "#9a9a9a";
  3631. /** @hidden */
  3632. this._rebuildLayout = false;
  3633. /** @hidden */
  3634. this._customData = {};
  3635. /** @hidden */
  3636. this._isClipped = false;
  3637. /** @hidden */
  3638. this._automaticSize = false;
  3639. /**
  3640. * Gets or sets an object used to store user defined information for the node
  3641. */
  3642. this.metadata = null;
  3643. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3644. this.isHitTestVisible = true;
  3645. /** Gets or sets a boolean indicating if the control can block pointer events */
  3646. this.isPointerBlocker = false;
  3647. /** Gets or sets a boolean indicating if the control can be focusable */
  3648. this.isFocusInvisible = false;
  3649. /**
  3650. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3651. * 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
  3652. */
  3653. this.clipChildren = true;
  3654. /**
  3655. * Gets or sets a boolean indicating that control content must be clipped
  3656. * 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
  3657. */
  3658. this.clipContent = true;
  3659. /**
  3660. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3661. */
  3662. this.useBitmapCache = false;
  3663. this._shadowOffsetX = 0;
  3664. this._shadowOffsetY = 0;
  3665. this._shadowBlur = 0;
  3666. this._shadowColor = 'black';
  3667. /** Gets or sets the cursor to use when the control is hovered */
  3668. this.hoverCursor = "";
  3669. /** @hidden */
  3670. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3671. /** @hidden */
  3672. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3673. /**
  3674. * An event triggered when the pointer move over the control.
  3675. */
  3676. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3677. /**
  3678. * An event triggered when the pointer move out of the control.
  3679. */
  3680. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3681. /**
  3682. * An event triggered when the pointer taps the control
  3683. */
  3684. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3685. /**
  3686. * An event triggered when pointer up
  3687. */
  3688. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3689. /**
  3690. * An event triggered when a control is clicked on
  3691. */
  3692. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3693. /**
  3694. * An event triggered when pointer enters the control
  3695. */
  3696. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3697. /**
  3698. * An event triggered when the control is marked as dirty
  3699. */
  3700. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3701. /**
  3702. * An event triggered before drawing the control
  3703. */
  3704. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3705. /**
  3706. * An event triggered after the control was drawn
  3707. */
  3708. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3709. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3710. }
  3711. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3712. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3713. get: function () {
  3714. return this._shadowOffsetX;
  3715. },
  3716. set: function (value) {
  3717. if (this._shadowOffsetX === value) {
  3718. return;
  3719. }
  3720. this._shadowOffsetX = value;
  3721. this._markAsDirty();
  3722. },
  3723. enumerable: true,
  3724. configurable: true
  3725. });
  3726. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3727. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3728. get: function () {
  3729. return this._shadowOffsetY;
  3730. },
  3731. set: function (value) {
  3732. if (this._shadowOffsetY === value) {
  3733. return;
  3734. }
  3735. this._shadowOffsetY = value;
  3736. this._markAsDirty();
  3737. },
  3738. enumerable: true,
  3739. configurable: true
  3740. });
  3741. Object.defineProperty(Control.prototype, "shadowBlur", {
  3742. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3743. get: function () {
  3744. return this._shadowBlur;
  3745. },
  3746. set: function (value) {
  3747. if (this._shadowBlur === value) {
  3748. return;
  3749. }
  3750. this._shadowBlur = value;
  3751. this._markAsDirty();
  3752. },
  3753. enumerable: true,
  3754. configurable: true
  3755. });
  3756. Object.defineProperty(Control.prototype, "shadowColor", {
  3757. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3758. get: function () {
  3759. return this._shadowColor;
  3760. },
  3761. set: function (value) {
  3762. if (this._shadowColor === value) {
  3763. return;
  3764. }
  3765. this._shadowColor = value;
  3766. this._markAsDirty();
  3767. },
  3768. enumerable: true,
  3769. configurable: true
  3770. });
  3771. Object.defineProperty(Control.prototype, "typeName", {
  3772. // Properties
  3773. /** Gets the control type name */
  3774. get: function () {
  3775. return this._getTypeName();
  3776. },
  3777. enumerable: true,
  3778. configurable: true
  3779. });
  3780. /**
  3781. * Get the current class name of the control.
  3782. * @returns current class name
  3783. */
  3784. Control.prototype.getClassName = function () {
  3785. return this._getTypeName();
  3786. };
  3787. Object.defineProperty(Control.prototype, "host", {
  3788. /**
  3789. * Get the hosting AdvancedDynamicTexture
  3790. */
  3791. get: function () {
  3792. return this._host;
  3793. },
  3794. enumerable: true,
  3795. configurable: true
  3796. });
  3797. Object.defineProperty(Control.prototype, "fontOffset", {
  3798. /** Gets or set information about font offsets (used to render and align text) */
  3799. get: function () {
  3800. return this._fontOffset;
  3801. },
  3802. set: function (offset) {
  3803. this._fontOffset = offset;
  3804. },
  3805. enumerable: true,
  3806. configurable: true
  3807. });
  3808. Object.defineProperty(Control.prototype, "alpha", {
  3809. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3810. get: function () {
  3811. return this._alpha;
  3812. },
  3813. set: function (value) {
  3814. if (this._alpha === value) {
  3815. return;
  3816. }
  3817. this._alphaSet = true;
  3818. this._alpha = value;
  3819. this._markAsDirty();
  3820. },
  3821. enumerable: true,
  3822. configurable: true
  3823. });
  3824. Object.defineProperty(Control.prototype, "isHighlighted", {
  3825. /**
  3826. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3827. */
  3828. get: function () {
  3829. return this._isHighlighted;
  3830. },
  3831. set: function (value) {
  3832. if (this._isHighlighted === value) {
  3833. return;
  3834. }
  3835. this._isHighlighted = value;
  3836. this._markAsDirty();
  3837. },
  3838. enumerable: true,
  3839. configurable: true
  3840. });
  3841. Object.defineProperty(Control.prototype, "scaleX", {
  3842. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3843. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3844. */
  3845. get: function () {
  3846. return this._scaleX;
  3847. },
  3848. set: function (value) {
  3849. if (this._scaleX === value) {
  3850. return;
  3851. }
  3852. this._scaleX = value;
  3853. this._markAsDirty();
  3854. this._markMatrixAsDirty();
  3855. },
  3856. enumerable: true,
  3857. configurable: true
  3858. });
  3859. Object.defineProperty(Control.prototype, "scaleY", {
  3860. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3861. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3862. */
  3863. get: function () {
  3864. return this._scaleY;
  3865. },
  3866. set: function (value) {
  3867. if (this._scaleY === value) {
  3868. return;
  3869. }
  3870. this._scaleY = value;
  3871. this._markAsDirty();
  3872. this._markMatrixAsDirty();
  3873. },
  3874. enumerable: true,
  3875. configurable: true
  3876. });
  3877. Object.defineProperty(Control.prototype, "rotation", {
  3878. /** Gets or sets the rotation angle (0 by default)
  3879. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3880. */
  3881. get: function () {
  3882. return this._rotation;
  3883. },
  3884. set: function (value) {
  3885. if (this._rotation === value) {
  3886. return;
  3887. }
  3888. this._rotation = value;
  3889. this._markAsDirty();
  3890. this._markMatrixAsDirty();
  3891. },
  3892. enumerable: true,
  3893. configurable: true
  3894. });
  3895. Object.defineProperty(Control.prototype, "transformCenterY", {
  3896. /** Gets or sets the transformation center on Y axis (0 by default)
  3897. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3898. */
  3899. get: function () {
  3900. return this._transformCenterY;
  3901. },
  3902. set: function (value) {
  3903. if (this._transformCenterY === value) {
  3904. return;
  3905. }
  3906. this._transformCenterY = value;
  3907. this._markAsDirty();
  3908. this._markMatrixAsDirty();
  3909. },
  3910. enumerable: true,
  3911. configurable: true
  3912. });
  3913. Object.defineProperty(Control.prototype, "transformCenterX", {
  3914. /** Gets or sets the transformation center on X axis (0 by default)
  3915. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3916. */
  3917. get: function () {
  3918. return this._transformCenterX;
  3919. },
  3920. set: function (value) {
  3921. if (this._transformCenterX === value) {
  3922. return;
  3923. }
  3924. this._transformCenterX = value;
  3925. this._markAsDirty();
  3926. this._markMatrixAsDirty();
  3927. },
  3928. enumerable: true,
  3929. configurable: true
  3930. });
  3931. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3932. /**
  3933. * Gets or sets the horizontal alignment
  3934. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3935. */
  3936. get: function () {
  3937. return this._horizontalAlignment;
  3938. },
  3939. set: function (value) {
  3940. if (this._horizontalAlignment === value) {
  3941. return;
  3942. }
  3943. this._horizontalAlignment = value;
  3944. this._markAsDirty();
  3945. },
  3946. enumerable: true,
  3947. configurable: true
  3948. });
  3949. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3950. /**
  3951. * Gets or sets the vertical alignment
  3952. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3953. */
  3954. get: function () {
  3955. return this._verticalAlignment;
  3956. },
  3957. set: function (value) {
  3958. if (this._verticalAlignment === value) {
  3959. return;
  3960. }
  3961. this._verticalAlignment = value;
  3962. this._markAsDirty();
  3963. },
  3964. enumerable: true,
  3965. configurable: true
  3966. });
  3967. Object.defineProperty(Control.prototype, "width", {
  3968. /**
  3969. * Gets or sets control width
  3970. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3971. */
  3972. get: function () {
  3973. return this._width.toString(this._host);
  3974. },
  3975. set: function (value) {
  3976. if (this._width.toString(this._host) === value) {
  3977. return;
  3978. }
  3979. if (this._width.fromString(value)) {
  3980. this._markAsDirty();
  3981. }
  3982. },
  3983. enumerable: true,
  3984. configurable: true
  3985. });
  3986. Object.defineProperty(Control.prototype, "widthInPixels", {
  3987. /**
  3988. * Gets or sets the control width in pixel
  3989. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3990. */
  3991. get: function () {
  3992. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3993. },
  3994. set: function (value) {
  3995. if (isNaN(value)) {
  3996. return;
  3997. }
  3998. this.width = value + "px";
  3999. },
  4000. enumerable: true,
  4001. configurable: true
  4002. });
  4003. Object.defineProperty(Control.prototype, "height", {
  4004. /**
  4005. * Gets or sets control height
  4006. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4007. */
  4008. get: function () {
  4009. return this._height.toString(this._host);
  4010. },
  4011. set: function (value) {
  4012. if (this._height.toString(this._host) === value) {
  4013. return;
  4014. }
  4015. if (this._height.fromString(value)) {
  4016. this._markAsDirty();
  4017. }
  4018. },
  4019. enumerable: true,
  4020. configurable: true
  4021. });
  4022. Object.defineProperty(Control.prototype, "heightInPixels", {
  4023. /**
  4024. * Gets or sets control height in pixel
  4025. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4026. */
  4027. get: function () {
  4028. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4029. },
  4030. set: function (value) {
  4031. if (isNaN(value)) {
  4032. return;
  4033. }
  4034. this.height = value + "px";
  4035. },
  4036. enumerable: true,
  4037. configurable: true
  4038. });
  4039. Object.defineProperty(Control.prototype, "fontFamily", {
  4040. /** Gets or set font family */
  4041. get: function () {
  4042. if (!this._fontSet) {
  4043. return "";
  4044. }
  4045. return this._fontFamily;
  4046. },
  4047. set: function (value) {
  4048. if (this._fontFamily === value) {
  4049. return;
  4050. }
  4051. this._fontFamily = value;
  4052. this._resetFontCache();
  4053. },
  4054. enumerable: true,
  4055. configurable: true
  4056. });
  4057. Object.defineProperty(Control.prototype, "fontStyle", {
  4058. /** Gets or sets font style */
  4059. get: function () {
  4060. return this._fontStyle;
  4061. },
  4062. set: function (value) {
  4063. if (this._fontStyle === value) {
  4064. return;
  4065. }
  4066. this._fontStyle = value;
  4067. this._resetFontCache();
  4068. },
  4069. enumerable: true,
  4070. configurable: true
  4071. });
  4072. Object.defineProperty(Control.prototype, "fontWeight", {
  4073. /** Gets or sets font weight */
  4074. get: function () {
  4075. return this._fontWeight;
  4076. },
  4077. set: function (value) {
  4078. if (this._fontWeight === value) {
  4079. return;
  4080. }
  4081. this._fontWeight = value;
  4082. this._resetFontCache();
  4083. },
  4084. enumerable: true,
  4085. configurable: true
  4086. });
  4087. Object.defineProperty(Control.prototype, "style", {
  4088. /**
  4089. * Gets or sets style
  4090. * @see http://doc.babylonjs.com/how_to/gui#styles
  4091. */
  4092. get: function () {
  4093. return this._style;
  4094. },
  4095. set: function (value) {
  4096. var _this = this;
  4097. if (this._style) {
  4098. this._style.onChangedObservable.remove(this._styleObserver);
  4099. this._styleObserver = null;
  4100. }
  4101. this._style = value;
  4102. if (this._style) {
  4103. this._styleObserver = this._style.onChangedObservable.add(function () {
  4104. _this._markAsDirty();
  4105. _this._resetFontCache();
  4106. });
  4107. }
  4108. this._markAsDirty();
  4109. this._resetFontCache();
  4110. },
  4111. enumerable: true,
  4112. configurable: true
  4113. });
  4114. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4115. /** @hidden */
  4116. get: function () {
  4117. return this._fontSize.isPercentage;
  4118. },
  4119. enumerable: true,
  4120. configurable: true
  4121. });
  4122. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4123. /** Gets or sets font size in pixels */
  4124. get: function () {
  4125. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4126. if (fontSizeToUse.isPixel) {
  4127. return fontSizeToUse.getValue(this._host);
  4128. }
  4129. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4130. },
  4131. set: function (value) {
  4132. if (isNaN(value)) {
  4133. return;
  4134. }
  4135. this.fontSize = value + "px";
  4136. },
  4137. enumerable: true,
  4138. configurable: true
  4139. });
  4140. Object.defineProperty(Control.prototype, "fontSize", {
  4141. /** Gets or sets font size */
  4142. get: function () {
  4143. return this._fontSize.toString(this._host);
  4144. },
  4145. set: function (value) {
  4146. if (this._fontSize.toString(this._host) === value) {
  4147. return;
  4148. }
  4149. if (this._fontSize.fromString(value)) {
  4150. this._markAsDirty();
  4151. this._resetFontCache();
  4152. }
  4153. },
  4154. enumerable: true,
  4155. configurable: true
  4156. });
  4157. Object.defineProperty(Control.prototype, "color", {
  4158. /** Gets or sets foreground color */
  4159. get: function () {
  4160. return this._color;
  4161. },
  4162. set: function (value) {
  4163. if (this._color === value) {
  4164. return;
  4165. }
  4166. this._color = value;
  4167. this._markAsDirty();
  4168. },
  4169. enumerable: true,
  4170. configurable: true
  4171. });
  4172. Object.defineProperty(Control.prototype, "zIndex", {
  4173. /** Gets or sets z index which is used to reorder controls on the z axis */
  4174. get: function () {
  4175. return this._zIndex;
  4176. },
  4177. set: function (value) {
  4178. if (this.zIndex === value) {
  4179. return;
  4180. }
  4181. this._zIndex = value;
  4182. if (this.parent) {
  4183. this.parent._reOrderControl(this);
  4184. }
  4185. },
  4186. enumerable: true,
  4187. configurable: true
  4188. });
  4189. Object.defineProperty(Control.prototype, "notRenderable", {
  4190. /** Gets or sets a boolean indicating if the control can be rendered */
  4191. get: function () {
  4192. return this._doNotRender;
  4193. },
  4194. set: function (value) {
  4195. if (this._doNotRender === value) {
  4196. return;
  4197. }
  4198. this._doNotRender = value;
  4199. this._markAsDirty();
  4200. },
  4201. enumerable: true,
  4202. configurable: true
  4203. });
  4204. Object.defineProperty(Control.prototype, "isVisible", {
  4205. /** Gets or sets a boolean indicating if the control is visible */
  4206. get: function () {
  4207. return this._isVisible;
  4208. },
  4209. set: function (value) {
  4210. if (this._isVisible === value) {
  4211. return;
  4212. }
  4213. this._isVisible = value;
  4214. this._markAsDirty(true);
  4215. },
  4216. enumerable: true,
  4217. configurable: true
  4218. });
  4219. Object.defineProperty(Control.prototype, "isDirty", {
  4220. /** Gets a boolean indicating that the control needs to update its rendering */
  4221. get: function () {
  4222. return this._isDirty;
  4223. },
  4224. enumerable: true,
  4225. configurable: true
  4226. });
  4227. Object.defineProperty(Control.prototype, "linkedMesh", {
  4228. /**
  4229. * Gets the current linked mesh (or null if none)
  4230. */
  4231. get: function () {
  4232. return this._linkedMesh;
  4233. },
  4234. enumerable: true,
  4235. configurable: true
  4236. });
  4237. Object.defineProperty(Control.prototype, "paddingLeft", {
  4238. /**
  4239. * Gets or sets a value indicating the padding to use on the left of the control
  4240. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4241. */
  4242. get: function () {
  4243. return this._paddingLeft.toString(this._host);
  4244. },
  4245. set: function (value) {
  4246. if (this._paddingLeft.fromString(value)) {
  4247. this._markAsDirty();
  4248. }
  4249. },
  4250. enumerable: true,
  4251. configurable: true
  4252. });
  4253. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4254. /**
  4255. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4256. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4257. */
  4258. get: function () {
  4259. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4260. },
  4261. set: function (value) {
  4262. if (isNaN(value)) {
  4263. return;
  4264. }
  4265. this.paddingLeft = value + "px";
  4266. },
  4267. enumerable: true,
  4268. configurable: true
  4269. });
  4270. Object.defineProperty(Control.prototype, "paddingRight", {
  4271. /**
  4272. * Gets or sets a value indicating the padding to use on the right of the control
  4273. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4274. */
  4275. get: function () {
  4276. return this._paddingRight.toString(this._host);
  4277. },
  4278. set: function (value) {
  4279. if (this._paddingRight.fromString(value)) {
  4280. this._markAsDirty();
  4281. }
  4282. },
  4283. enumerable: true,
  4284. configurable: true
  4285. });
  4286. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4287. /**
  4288. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4289. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4290. */
  4291. get: function () {
  4292. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4293. },
  4294. set: function (value) {
  4295. if (isNaN(value)) {
  4296. return;
  4297. }
  4298. this.paddingRight = value + "px";
  4299. },
  4300. enumerable: true,
  4301. configurable: true
  4302. });
  4303. Object.defineProperty(Control.prototype, "paddingTop", {
  4304. /**
  4305. * Gets or sets a value indicating the padding to use on the top of the control
  4306. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4307. */
  4308. get: function () {
  4309. return this._paddingTop.toString(this._host);
  4310. },
  4311. set: function (value) {
  4312. if (this._paddingTop.fromString(value)) {
  4313. this._markAsDirty();
  4314. }
  4315. },
  4316. enumerable: true,
  4317. configurable: true
  4318. });
  4319. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4320. /**
  4321. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4322. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4323. */
  4324. get: function () {
  4325. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4326. },
  4327. set: function (value) {
  4328. if (isNaN(value)) {
  4329. return;
  4330. }
  4331. this.paddingTop = value + "px";
  4332. },
  4333. enumerable: true,
  4334. configurable: true
  4335. });
  4336. Object.defineProperty(Control.prototype, "paddingBottom", {
  4337. /**
  4338. * Gets or sets a value indicating the padding to use on the bottom of the control
  4339. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4340. */
  4341. get: function () {
  4342. return this._paddingBottom.toString(this._host);
  4343. },
  4344. set: function (value) {
  4345. if (this._paddingBottom.fromString(value)) {
  4346. this._markAsDirty();
  4347. }
  4348. },
  4349. enumerable: true,
  4350. configurable: true
  4351. });
  4352. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4353. /**
  4354. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4355. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4356. */
  4357. get: function () {
  4358. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4359. },
  4360. set: function (value) {
  4361. if (isNaN(value)) {
  4362. return;
  4363. }
  4364. this.paddingBottom = value + "px";
  4365. },
  4366. enumerable: true,
  4367. configurable: true
  4368. });
  4369. Object.defineProperty(Control.prototype, "left", {
  4370. /**
  4371. * Gets or sets a value indicating the left coordinate of the control
  4372. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4373. */
  4374. get: function () {
  4375. return this._left.toString(this._host);
  4376. },
  4377. set: function (value) {
  4378. if (this._left.fromString(value)) {
  4379. this._markAsDirty();
  4380. }
  4381. },
  4382. enumerable: true,
  4383. configurable: true
  4384. });
  4385. Object.defineProperty(Control.prototype, "leftInPixels", {
  4386. /**
  4387. * Gets or sets a value indicating the left coordinate in pixels of the control
  4388. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4389. */
  4390. get: function () {
  4391. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4392. },
  4393. set: function (value) {
  4394. if (isNaN(value)) {
  4395. return;
  4396. }
  4397. this.left = value + "px";
  4398. },
  4399. enumerable: true,
  4400. configurable: true
  4401. });
  4402. Object.defineProperty(Control.prototype, "top", {
  4403. /**
  4404. * Gets or sets a value indicating the top coordinate of the control
  4405. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4406. */
  4407. get: function () {
  4408. return this._top.toString(this._host);
  4409. },
  4410. set: function (value) {
  4411. if (this._top.fromString(value)) {
  4412. this._markAsDirty();
  4413. }
  4414. },
  4415. enumerable: true,
  4416. configurable: true
  4417. });
  4418. Object.defineProperty(Control.prototype, "topInPixels", {
  4419. /**
  4420. * Gets or sets a value indicating the top coordinate in pixels of the control
  4421. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4422. */
  4423. get: function () {
  4424. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4425. },
  4426. set: function (value) {
  4427. if (isNaN(value)) {
  4428. return;
  4429. }
  4430. this.top = value + "px";
  4431. },
  4432. enumerable: true,
  4433. configurable: true
  4434. });
  4435. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4436. /**
  4437. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4438. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4439. */
  4440. get: function () {
  4441. return this._linkOffsetX.toString(this._host);
  4442. },
  4443. set: function (value) {
  4444. if (this._linkOffsetX.fromString(value)) {
  4445. this._markAsDirty();
  4446. }
  4447. },
  4448. enumerable: true,
  4449. configurable: true
  4450. });
  4451. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4452. /**
  4453. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4454. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4455. */
  4456. get: function () {
  4457. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4458. },
  4459. set: function (value) {
  4460. if (isNaN(value)) {
  4461. return;
  4462. }
  4463. this.linkOffsetX = value + "px";
  4464. },
  4465. enumerable: true,
  4466. configurable: true
  4467. });
  4468. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4469. /**
  4470. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4471. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4472. */
  4473. get: function () {
  4474. return this._linkOffsetY.toString(this._host);
  4475. },
  4476. set: function (value) {
  4477. if (this._linkOffsetY.fromString(value)) {
  4478. this._markAsDirty();
  4479. }
  4480. },
  4481. enumerable: true,
  4482. configurable: true
  4483. });
  4484. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4485. /**
  4486. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4487. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4488. */
  4489. get: function () {
  4490. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4491. },
  4492. set: function (value) {
  4493. if (isNaN(value)) {
  4494. return;
  4495. }
  4496. this.linkOffsetY = value + "px";
  4497. },
  4498. enumerable: true,
  4499. configurable: true
  4500. });
  4501. Object.defineProperty(Control.prototype, "centerX", {
  4502. /** Gets the center coordinate on X axis */
  4503. get: function () {
  4504. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4505. },
  4506. enumerable: true,
  4507. configurable: true
  4508. });
  4509. Object.defineProperty(Control.prototype, "centerY", {
  4510. /** Gets the center coordinate on Y axis */
  4511. get: function () {
  4512. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4513. },
  4514. enumerable: true,
  4515. configurable: true
  4516. });
  4517. Object.defineProperty(Control.prototype, "isEnabled", {
  4518. /** Gets or sets if control is Enabled*/
  4519. get: function () {
  4520. return this._isEnabled;
  4521. },
  4522. set: function (value) {
  4523. if (this._isEnabled === value) {
  4524. return;
  4525. }
  4526. this._isEnabled = value;
  4527. this._markAsDirty();
  4528. },
  4529. enumerable: true,
  4530. configurable: true
  4531. });
  4532. Object.defineProperty(Control.prototype, "disabledColor", {
  4533. /** Gets or sets background color of control if it's disabled*/
  4534. get: function () {
  4535. return this._disabledColor;
  4536. },
  4537. set: function (value) {
  4538. if (this._disabledColor === value) {
  4539. return;
  4540. }
  4541. this._disabledColor = value;
  4542. this._markAsDirty();
  4543. },
  4544. enumerable: true,
  4545. configurable: true
  4546. });
  4547. /** @hidden */
  4548. Control.prototype._getTypeName = function () {
  4549. return "Control";
  4550. };
  4551. /**
  4552. * Gets the first ascendant in the hierarchy of the given type
  4553. * @param className defines the required type
  4554. * @returns the ascendant or null if not found
  4555. */
  4556. Control.prototype.getAscendantOfClass = function (className) {
  4557. if (!this.parent) {
  4558. return null;
  4559. }
  4560. if (this.parent.getClassName() === className) {
  4561. return this.parent;
  4562. }
  4563. return this.parent.getAscendantOfClass(className);
  4564. };
  4565. /** @hidden */
  4566. Control.prototype._resetFontCache = function () {
  4567. this._fontSet = true;
  4568. this._markAsDirty();
  4569. };
  4570. /**
  4571. * Determines if a container is an ascendant of the current control
  4572. * @param container defines the container to look for
  4573. * @returns true if the container is one of the ascendant of the control
  4574. */
  4575. Control.prototype.isAscendant = function (container) {
  4576. if (!this.parent) {
  4577. return false;
  4578. }
  4579. if (this.parent === container) {
  4580. return true;
  4581. }
  4582. return this.parent.isAscendant(container);
  4583. };
  4584. /**
  4585. * Gets coordinates in local control space
  4586. * @param globalCoordinates defines the coordinates to transform
  4587. * @returns the new coordinates in local space
  4588. */
  4589. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4590. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4591. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4592. return result;
  4593. };
  4594. /**
  4595. * Gets coordinates in local control space
  4596. * @param globalCoordinates defines the coordinates to transform
  4597. * @param result defines the target vector2 where to store the result
  4598. * @returns the current control
  4599. */
  4600. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4601. result.x = globalCoordinates.x - this._currentMeasure.left;
  4602. result.y = globalCoordinates.y - this._currentMeasure.top;
  4603. return this;
  4604. };
  4605. /**
  4606. * Gets coordinates in parent local control space
  4607. * @param globalCoordinates defines the coordinates to transform
  4608. * @returns the new coordinates in parent local space
  4609. */
  4610. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4611. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4612. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4613. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4614. return result;
  4615. };
  4616. /**
  4617. * Move the current control to a vector3 position projected onto the screen.
  4618. * @param position defines the target position
  4619. * @param scene defines the hosting scene
  4620. */
  4621. Control.prototype.moveToVector3 = function (position, scene) {
  4622. if (!this._host || this.parent !== this._host._rootContainer) {
  4623. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4624. return;
  4625. }
  4626. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4627. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4628. var globalViewport = this._host._getGlobalViewport(scene);
  4629. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4630. this._moveToProjectedPosition(projectedPosition);
  4631. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4632. this.notRenderable = true;
  4633. return;
  4634. }
  4635. this.notRenderable = false;
  4636. };
  4637. /**
  4638. * Will store all controls that have this control as ascendant in a given array
  4639. * @param results defines the array where to store the descendants
  4640. * @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
  4641. * @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
  4642. */
  4643. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4644. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4645. // Do nothing by default
  4646. };
  4647. /**
  4648. * Will return all controls that have this control as ascendant
  4649. * @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
  4650. * @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
  4651. * @return all child controls
  4652. */
  4653. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4654. var results = new Array();
  4655. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4656. return results;
  4657. };
  4658. /**
  4659. * Link current control with a target mesh
  4660. * @param mesh defines the mesh to link with
  4661. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4662. */
  4663. Control.prototype.linkWithMesh = function (mesh) {
  4664. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4665. if (mesh) {
  4666. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4667. }
  4668. return;
  4669. }
  4670. var index = this._host._linkedControls.indexOf(this);
  4671. if (index !== -1) {
  4672. this._linkedMesh = mesh;
  4673. if (!mesh) {
  4674. this._host._linkedControls.splice(index, 1);
  4675. }
  4676. return;
  4677. }
  4678. else if (!mesh) {
  4679. return;
  4680. }
  4681. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4682. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4683. this._linkedMesh = mesh;
  4684. this._host._linkedControls.push(this);
  4685. };
  4686. /** @hidden */
  4687. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4688. var oldLeft = this._left.getValue(this._host);
  4689. var oldTop = this._top.getValue(this._host);
  4690. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4691. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4692. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4693. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4694. newLeft = oldLeft;
  4695. }
  4696. if (Math.abs(newTop - oldTop) < 0.5) {
  4697. newTop = oldTop;
  4698. }
  4699. }
  4700. this.left = newLeft + "px";
  4701. this.top = newTop + "px";
  4702. this._left.ignoreAdaptiveScaling = true;
  4703. this._top.ignoreAdaptiveScaling = true;
  4704. this._markAsDirty();
  4705. };
  4706. /** @hidden */
  4707. Control.prototype._offsetLeft = function (offset) {
  4708. this._isDirty = true;
  4709. this._currentMeasure.left += offset;
  4710. };
  4711. /** @hidden */
  4712. Control.prototype._offsetTop = function (offset) {
  4713. this._isDirty = true;
  4714. this._currentMeasure.top += offset;
  4715. };
  4716. /** @hidden */
  4717. Control.prototype._markMatrixAsDirty = function () {
  4718. this._isMatrixDirty = true;
  4719. this._flagDescendantsAsMatrixDirty();
  4720. };
  4721. /** @hidden */
  4722. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4723. // No child
  4724. };
  4725. /** @hidden */
  4726. Control.prototype._intersectsRect = function (rect) {
  4727. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4728. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4729. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4730. return false;
  4731. }
  4732. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4733. return false;
  4734. }
  4735. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4736. return false;
  4737. }
  4738. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4739. return false;
  4740. }
  4741. return true;
  4742. };
  4743. /** @hidden */
  4744. Control.prototype.invalidateRect = function () {
  4745. this._transform();
  4746. if (this.host && this.host.useInvalidateRectOptimization) {
  4747. // Rotate by transform to get the measure transformed to global space
  4748. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4749. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4750. // the previous measure is used to properly clear a control that is scaled down
  4751. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4752. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4753. // Expand rect based on shadows
  4754. var shadowOffsetX = this.shadowOffsetX;
  4755. var shadowOffsetY = this.shadowOffsetY;
  4756. var shadowBlur = this.shadowBlur;
  4757. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4758. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4759. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4760. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4761. 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));
  4762. }
  4763. else {
  4764. 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));
  4765. }
  4766. }
  4767. };
  4768. /** @hidden */
  4769. Control.prototype._markAsDirty = function (force) {
  4770. if (force === void 0) { force = false; }
  4771. if (!this._isVisible && !force) {
  4772. return;
  4773. }
  4774. this._isDirty = true;
  4775. // Redraw only this rectangle
  4776. if (this._host) {
  4777. this._host.markAsDirty();
  4778. }
  4779. };
  4780. /** @hidden */
  4781. Control.prototype._markAllAsDirty = function () {
  4782. this._markAsDirty();
  4783. if (this._font) {
  4784. this._prepareFont();
  4785. }
  4786. };
  4787. /** @hidden */
  4788. Control.prototype._link = function (host) {
  4789. this._host = host;
  4790. if (this._host) {
  4791. this.uniqueId = this._host.getScene().getUniqueId();
  4792. }
  4793. };
  4794. /** @hidden */
  4795. Control.prototype._transform = function (context) {
  4796. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4797. return;
  4798. }
  4799. // postTranslate
  4800. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4801. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4802. if (context) {
  4803. context.translate(offsetX, offsetY);
  4804. // rotate
  4805. context.rotate(this._rotation);
  4806. // scale
  4807. context.scale(this._scaleX, this._scaleY);
  4808. // preTranslate
  4809. context.translate(-offsetX, -offsetY);
  4810. }
  4811. // Need to update matrices?
  4812. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4813. this._cachedOffsetX = offsetX;
  4814. this._cachedOffsetY = offsetY;
  4815. this._isMatrixDirty = false;
  4816. this._flagDescendantsAsMatrixDirty();
  4817. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4818. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4819. }
  4820. };
  4821. /** @hidden */
  4822. Control.prototype._renderHighlight = function (context) {
  4823. if (!this.isHighlighted) {
  4824. return;
  4825. }
  4826. context.save();
  4827. context.strokeStyle = "#4affff";
  4828. context.lineWidth = 2;
  4829. this._renderHighlightSpecific(context);
  4830. context.restore();
  4831. };
  4832. /** @hidden */
  4833. Control.prototype._renderHighlightSpecific = function (context) {
  4834. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4835. };
  4836. /** @hidden */
  4837. Control.prototype._applyStates = function (context) {
  4838. if (this._isFontSizeInPercentage) {
  4839. this._fontSet = true;
  4840. }
  4841. if (this._fontSet) {
  4842. this._prepareFont();
  4843. this._fontSet = false;
  4844. }
  4845. if (this._font) {
  4846. context.font = this._font;
  4847. }
  4848. if (this._color) {
  4849. context.fillStyle = this._color;
  4850. }
  4851. if (Control.AllowAlphaInheritance) {
  4852. context.globalAlpha *= this._alpha;
  4853. }
  4854. else if (this._alphaSet) {
  4855. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4856. }
  4857. };
  4858. /** @hidden */
  4859. Control.prototype._layout = function (parentMeasure, context) {
  4860. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4861. return false;
  4862. }
  4863. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4864. this.host._numLayoutCalls++;
  4865. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4866. context.save();
  4867. this._applyStates(context);
  4868. var rebuildCount = 0;
  4869. do {
  4870. this._rebuildLayout = false;
  4871. this._processMeasures(parentMeasure, context);
  4872. rebuildCount++;
  4873. } while (this._rebuildLayout && rebuildCount < 3);
  4874. if (rebuildCount >= 3) {
  4875. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4876. }
  4877. context.restore();
  4878. this.invalidateRect();
  4879. this._evaluateClippingState(parentMeasure);
  4880. }
  4881. this._wasDirty = this._isDirty;
  4882. this._isDirty = false;
  4883. return true;
  4884. };
  4885. /** @hidden */
  4886. Control.prototype._processMeasures = function (parentMeasure, context) {
  4887. this._currentMeasure.copyFrom(parentMeasure);
  4888. // Let children take some pre-measurement actions
  4889. this._preMeasure(parentMeasure, context);
  4890. this._measure();
  4891. this._computeAlignment(parentMeasure, context);
  4892. // Convert to int values
  4893. this._currentMeasure.left = this._currentMeasure.left | 0;
  4894. this._currentMeasure.top = this._currentMeasure.top | 0;
  4895. this._currentMeasure.width = this._currentMeasure.width | 0;
  4896. this._currentMeasure.height = this._currentMeasure.height | 0;
  4897. // Let children add more features
  4898. this._additionalProcessing(parentMeasure, context);
  4899. this._cachedParentMeasure.copyFrom(parentMeasure);
  4900. if (this.onDirtyObservable.hasObservers()) {
  4901. this.onDirtyObservable.notifyObservers(this);
  4902. }
  4903. };
  4904. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4905. if (this.parent && this.parent.clipChildren) {
  4906. // Early clip
  4907. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4908. this._isClipped = true;
  4909. return;
  4910. }
  4911. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4912. this._isClipped = true;
  4913. return;
  4914. }
  4915. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4916. this._isClipped = true;
  4917. return;
  4918. }
  4919. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4920. this._isClipped = true;
  4921. return;
  4922. }
  4923. }
  4924. this._isClipped = false;
  4925. };
  4926. /** @hidden */
  4927. Control.prototype._measure = function () {
  4928. // Width / Height
  4929. if (this._width.isPixel) {
  4930. this._currentMeasure.width = this._width.getValue(this._host);
  4931. }
  4932. else {
  4933. this._currentMeasure.width *= this._width.getValue(this._host);
  4934. }
  4935. if (this._height.isPixel) {
  4936. this._currentMeasure.height = this._height.getValue(this._host);
  4937. }
  4938. else {
  4939. this._currentMeasure.height *= this._height.getValue(this._host);
  4940. }
  4941. };
  4942. /** @hidden */
  4943. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4944. var width = this._currentMeasure.width;
  4945. var height = this._currentMeasure.height;
  4946. var parentWidth = parentMeasure.width;
  4947. var parentHeight = parentMeasure.height;
  4948. // Left / top
  4949. var x = 0;
  4950. var y = 0;
  4951. switch (this.horizontalAlignment) {
  4952. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4953. x = 0;
  4954. break;
  4955. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4956. x = parentWidth - width;
  4957. break;
  4958. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4959. x = (parentWidth - width) / 2;
  4960. break;
  4961. }
  4962. switch (this.verticalAlignment) {
  4963. case Control.VERTICAL_ALIGNMENT_TOP:
  4964. y = 0;
  4965. break;
  4966. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4967. y = parentHeight - height;
  4968. break;
  4969. case Control.VERTICAL_ALIGNMENT_CENTER:
  4970. y = (parentHeight - height) / 2;
  4971. break;
  4972. }
  4973. if (this._paddingLeft.isPixel) {
  4974. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4975. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4976. }
  4977. else {
  4978. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4979. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4980. }
  4981. if (this._paddingRight.isPixel) {
  4982. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4983. }
  4984. else {
  4985. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4986. }
  4987. if (this._paddingTop.isPixel) {
  4988. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4989. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4990. }
  4991. else {
  4992. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4993. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4994. }
  4995. if (this._paddingBottom.isPixel) {
  4996. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4997. }
  4998. else {
  4999. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  5000. }
  5001. if (this._left.isPixel) {
  5002. this._currentMeasure.left += this._left.getValue(this._host);
  5003. }
  5004. else {
  5005. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  5006. }
  5007. if (this._top.isPixel) {
  5008. this._currentMeasure.top += this._top.getValue(this._host);
  5009. }
  5010. else {
  5011. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5012. }
  5013. this._currentMeasure.left += x;
  5014. this._currentMeasure.top += y;
  5015. };
  5016. /** @hidden */
  5017. Control.prototype._preMeasure = function (parentMeasure, context) {
  5018. // Do nothing
  5019. };
  5020. /** @hidden */
  5021. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5022. // Do nothing
  5023. };
  5024. /** @hidden */
  5025. Control.prototype._clipForChildren = function (context) {
  5026. // DO nothing
  5027. };
  5028. Control.prototype._clip = function (context, invalidatedRectangle) {
  5029. context.beginPath();
  5030. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5031. if (invalidatedRectangle) {
  5032. // Rotate the invalidated rect into the control's space
  5033. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5034. // Get the intersection of the rect in context space and the current context
  5035. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5036. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5037. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5038. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5039. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5040. Control._ClipMeasure.copyFrom(intersection);
  5041. }
  5042. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5043. var shadowOffsetX = this.shadowOffsetX;
  5044. var shadowOffsetY = this.shadowOffsetY;
  5045. var shadowBlur = this.shadowBlur;
  5046. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5047. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5048. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5049. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5050. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5051. }
  5052. else {
  5053. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5054. }
  5055. context.clip();
  5056. };
  5057. /** @hidden */
  5058. Control.prototype._render = function (context, invalidatedRectangle) {
  5059. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5060. this._isDirty = false;
  5061. return false;
  5062. }
  5063. this.host._numRenderCalls++;
  5064. context.save();
  5065. this._applyStates(context);
  5066. // Transform
  5067. this._transform(context);
  5068. // Clip
  5069. if (this.clipContent) {
  5070. this._clip(context, invalidatedRectangle);
  5071. }
  5072. if (this.onBeforeDrawObservable.hasObservers()) {
  5073. this.onBeforeDrawObservable.notifyObservers(this);
  5074. }
  5075. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5076. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5077. }
  5078. else {
  5079. this._draw(context, invalidatedRectangle);
  5080. }
  5081. if (this.useBitmapCache && this._wasDirty) {
  5082. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5083. }
  5084. this._renderHighlight(context);
  5085. if (this.onAfterDrawObservable.hasObservers()) {
  5086. this.onAfterDrawObservable.notifyObservers(this);
  5087. }
  5088. context.restore();
  5089. return true;
  5090. };
  5091. /** @hidden */
  5092. Control.prototype._draw = function (context, invalidatedRectangle) {
  5093. // Do nothing
  5094. };
  5095. /**
  5096. * Tests if a given coordinates belong to the current control
  5097. * @param x defines x coordinate to test
  5098. * @param y defines y coordinate to test
  5099. * @returns true if the coordinates are inside the control
  5100. */
  5101. Control.prototype.contains = function (x, y) {
  5102. // Invert transform
  5103. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5104. x = this._transformedPosition.x;
  5105. y = this._transformedPosition.y;
  5106. // Check
  5107. if (x < this._currentMeasure.left) {
  5108. return false;
  5109. }
  5110. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5111. return false;
  5112. }
  5113. if (y < this._currentMeasure.top) {
  5114. return false;
  5115. }
  5116. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5117. return false;
  5118. }
  5119. if (this.isPointerBlocker) {
  5120. this._host._shouldBlockPointer = true;
  5121. }
  5122. return true;
  5123. };
  5124. /** @hidden */
  5125. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5126. if (!this._isEnabled) {
  5127. return false;
  5128. }
  5129. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5130. return false;
  5131. }
  5132. if (!this.contains(x, y)) {
  5133. return false;
  5134. }
  5135. this._processObservables(type, x, y, pointerId, buttonIndex);
  5136. return true;
  5137. };
  5138. /** @hidden */
  5139. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5140. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5141. if (canNotify && this.parent != null) {
  5142. this.parent._onPointerMove(target, coordinates, pointerId);
  5143. }
  5144. };
  5145. /** @hidden */
  5146. Control.prototype._onPointerEnter = function (target) {
  5147. if (!this._isEnabled) {
  5148. return false;
  5149. }
  5150. if (this._enterCount > 0) {
  5151. return false;
  5152. }
  5153. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5154. this._enterCount = 0;
  5155. }
  5156. this._enterCount++;
  5157. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5158. if (canNotify && this.parent != null) {
  5159. this.parent._onPointerEnter(target);
  5160. }
  5161. return true;
  5162. };
  5163. /** @hidden */
  5164. Control.prototype._onPointerOut = function (target, force) {
  5165. if (force === void 0) { force = false; }
  5166. if (!force && (!this._isEnabled || target === this)) {
  5167. return;
  5168. }
  5169. this._enterCount = 0;
  5170. var canNotify = true;
  5171. if (!target.isAscendant(this)) {
  5172. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5173. }
  5174. if (canNotify && this.parent != null) {
  5175. this.parent._onPointerOut(target, force);
  5176. }
  5177. };
  5178. /** @hidden */
  5179. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5180. // Prevent pointerout to lose control context.
  5181. // Event redundancy is checked inside the function.
  5182. this._onPointerEnter(this);
  5183. if (this._downCount !== 0) {
  5184. return false;
  5185. }
  5186. this._downCount++;
  5187. this._downPointerIds[pointerId] = true;
  5188. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5189. if (canNotify && this.parent != null) {
  5190. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5191. }
  5192. return true;
  5193. };
  5194. /** @hidden */
  5195. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5196. if (!this._isEnabled) {
  5197. return;
  5198. }
  5199. this._downCount = 0;
  5200. delete this._downPointerIds[pointerId];
  5201. var canNotifyClick = notifyClick;
  5202. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5203. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5204. }
  5205. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5206. if (canNotify && this.parent != null) {
  5207. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5208. }
  5209. };
  5210. /** @hidden */
  5211. Control.prototype._forcePointerUp = function (pointerId) {
  5212. if (pointerId === void 0) { pointerId = null; }
  5213. if (pointerId !== null) {
  5214. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5215. }
  5216. else {
  5217. for (var key in this._downPointerIds) {
  5218. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5219. }
  5220. }
  5221. };
  5222. /** @hidden */
  5223. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5224. if (!this._isEnabled) {
  5225. return false;
  5226. }
  5227. this._dummyVector2.copyFromFloats(x, y);
  5228. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5229. this._onPointerMove(this, this._dummyVector2, pointerId);
  5230. var previousControlOver = this._host._lastControlOver[pointerId];
  5231. if (previousControlOver && previousControlOver !== this) {
  5232. previousControlOver._onPointerOut(this);
  5233. }
  5234. if (previousControlOver !== this) {
  5235. this._onPointerEnter(this);
  5236. }
  5237. this._host._lastControlOver[pointerId] = this;
  5238. return true;
  5239. }
  5240. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5241. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5242. this._host._registerLastControlDown(this, pointerId);
  5243. this._host._lastPickedControl = this;
  5244. return true;
  5245. }
  5246. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5247. if (this._host._lastControlDown[pointerId]) {
  5248. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5249. }
  5250. delete this._host._lastControlDown[pointerId];
  5251. return true;
  5252. }
  5253. return false;
  5254. };
  5255. Control.prototype._prepareFont = function () {
  5256. if (!this._font && !this._fontSet) {
  5257. return;
  5258. }
  5259. if (this._style) {
  5260. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5261. }
  5262. else {
  5263. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5264. }
  5265. this._fontOffset = Control._GetFontOffset(this._font);
  5266. };
  5267. /** Releases associated resources */
  5268. Control.prototype.dispose = function () {
  5269. this.onDirtyObservable.clear();
  5270. this.onBeforeDrawObservable.clear();
  5271. this.onAfterDrawObservable.clear();
  5272. this.onPointerDownObservable.clear();
  5273. this.onPointerEnterObservable.clear();
  5274. this.onPointerMoveObservable.clear();
  5275. this.onPointerOutObservable.clear();
  5276. this.onPointerUpObservable.clear();
  5277. this.onPointerClickObservable.clear();
  5278. if (this._styleObserver && this._style) {
  5279. this._style.onChangedObservable.remove(this._styleObserver);
  5280. this._styleObserver = null;
  5281. }
  5282. if (this.parent) {
  5283. this.parent.removeControl(this);
  5284. this.parent = null;
  5285. }
  5286. if (this._host) {
  5287. var index = this._host._linkedControls.indexOf(this);
  5288. if (index > -1) {
  5289. this.linkWithMesh(null);
  5290. }
  5291. }
  5292. };
  5293. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5294. /** HORIZONTAL_ALIGNMENT_LEFT */
  5295. get: function () {
  5296. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5297. },
  5298. enumerable: true,
  5299. configurable: true
  5300. });
  5301. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5302. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5303. get: function () {
  5304. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5305. },
  5306. enumerable: true,
  5307. configurable: true
  5308. });
  5309. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5310. /** HORIZONTAL_ALIGNMENT_CENTER */
  5311. get: function () {
  5312. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5313. },
  5314. enumerable: true,
  5315. configurable: true
  5316. });
  5317. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5318. /** VERTICAL_ALIGNMENT_TOP */
  5319. get: function () {
  5320. return Control._VERTICAL_ALIGNMENT_TOP;
  5321. },
  5322. enumerable: true,
  5323. configurable: true
  5324. });
  5325. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5326. /** VERTICAL_ALIGNMENT_BOTTOM */
  5327. get: function () {
  5328. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5329. },
  5330. enumerable: true,
  5331. configurable: true
  5332. });
  5333. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5334. /** VERTICAL_ALIGNMENT_CENTER */
  5335. get: function () {
  5336. return Control._VERTICAL_ALIGNMENT_CENTER;
  5337. },
  5338. enumerable: true,
  5339. configurable: true
  5340. });
  5341. /** @hidden */
  5342. Control._GetFontOffset = function (font) {
  5343. if (Control._FontHeightSizes[font]) {
  5344. return Control._FontHeightSizes[font];
  5345. }
  5346. var text = document.createElement("span");
  5347. text.innerHTML = "Hg";
  5348. text.style.font = font;
  5349. var block = document.createElement("div");
  5350. block.style.display = "inline-block";
  5351. block.style.width = "1px";
  5352. block.style.height = "0px";
  5353. block.style.verticalAlign = "bottom";
  5354. var div = document.createElement("div");
  5355. div.appendChild(text);
  5356. div.appendChild(block);
  5357. document.body.appendChild(div);
  5358. var fontAscent = 0;
  5359. var fontHeight = 0;
  5360. try {
  5361. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5362. block.style.verticalAlign = "baseline";
  5363. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5364. }
  5365. finally {
  5366. document.body.removeChild(div);
  5367. }
  5368. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5369. Control._FontHeightSizes[font] = result;
  5370. return result;
  5371. };
  5372. /** @hidden */
  5373. Control.drawEllipse = function (x, y, width, height, context) {
  5374. context.translate(x, y);
  5375. context.scale(width, height);
  5376. context.beginPath();
  5377. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5378. context.closePath();
  5379. context.scale(1 / width, 1 / height);
  5380. context.translate(-x, -y);
  5381. };
  5382. /**
  5383. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5384. */
  5385. Control.AllowAlphaInheritance = false;
  5386. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5387. // Statics
  5388. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5389. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5390. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5391. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5392. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5393. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5394. Control._FontHeightSizes = {};
  5395. /**
  5396. * Creates a stack panel that can be used to render headers
  5397. * @param control defines the control to associate with the header
  5398. * @param text defines the text of the header
  5399. * @param size defines the size of the header
  5400. * @param options defines options used to configure the header
  5401. * @returns a new StackPanel
  5402. * @ignore
  5403. * @hidden
  5404. */
  5405. Control.AddHeader = function () { };
  5406. return Control;
  5407. }());
  5408. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5409. /***/ }),
  5410. /***/ "./2D/controls/displayGrid.ts":
  5411. /*!************************************!*\
  5412. !*** ./2D/controls/displayGrid.ts ***!
  5413. \************************************/
  5414. /*! exports provided: DisplayGrid */
  5415. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5416. "use strict";
  5417. __webpack_require__.r(__webpack_exports__);
  5418. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5419. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5420. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5421. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5422. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5423. /** Class used to render a grid */
  5424. var DisplayGrid = /** @class */ (function (_super) {
  5425. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5426. /**
  5427. * Creates a new GridDisplayRectangle
  5428. * @param name defines the control name
  5429. */
  5430. function DisplayGrid(name) {
  5431. var _this = _super.call(this, name) || this;
  5432. _this.name = name;
  5433. _this._cellWidth = 20;
  5434. _this._cellHeight = 20;
  5435. _this._minorLineTickness = 1;
  5436. _this._minorLineColor = "DarkGray";
  5437. _this._majorLineTickness = 2;
  5438. _this._majorLineColor = "White";
  5439. _this._majorLineFrequency = 5;
  5440. _this._background = "Black";
  5441. _this._displayMajorLines = true;
  5442. _this._displayMinorLines = true;
  5443. return _this;
  5444. }
  5445. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5446. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5447. get: function () {
  5448. return this._displayMinorLines;
  5449. },
  5450. set: function (value) {
  5451. if (this._displayMinorLines === value) {
  5452. return;
  5453. }
  5454. this._displayMinorLines = value;
  5455. this._markAsDirty();
  5456. },
  5457. enumerable: true,
  5458. configurable: true
  5459. });
  5460. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5461. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5462. get: function () {
  5463. return this._displayMajorLines;
  5464. },
  5465. set: function (value) {
  5466. if (this._displayMajorLines === value) {
  5467. return;
  5468. }
  5469. this._displayMajorLines = value;
  5470. this._markAsDirty();
  5471. },
  5472. enumerable: true,
  5473. configurable: true
  5474. });
  5475. Object.defineProperty(DisplayGrid.prototype, "background", {
  5476. /** Gets or sets background color (Black by default) */
  5477. get: function () {
  5478. return this._background;
  5479. },
  5480. set: function (value) {
  5481. if (this._background === value) {
  5482. return;
  5483. }
  5484. this._background = value;
  5485. this._markAsDirty();
  5486. },
  5487. enumerable: true,
  5488. configurable: true
  5489. });
  5490. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5491. /** Gets or sets the width of each cell (20 by default) */
  5492. get: function () {
  5493. return this._cellWidth;
  5494. },
  5495. set: function (value) {
  5496. this._cellWidth = value;
  5497. this._markAsDirty();
  5498. },
  5499. enumerable: true,
  5500. configurable: true
  5501. });
  5502. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5503. /** Gets or sets the height of each cell (20 by default) */
  5504. get: function () {
  5505. return this._cellHeight;
  5506. },
  5507. set: function (value) {
  5508. this._cellHeight = value;
  5509. this._markAsDirty();
  5510. },
  5511. enumerable: true,
  5512. configurable: true
  5513. });
  5514. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5515. /** Gets or sets the tickness of minor lines (1 by default) */
  5516. get: function () {
  5517. return this._minorLineTickness;
  5518. },
  5519. set: function (value) {
  5520. this._minorLineTickness = value;
  5521. this._markAsDirty();
  5522. },
  5523. enumerable: true,
  5524. configurable: true
  5525. });
  5526. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5527. /** Gets or sets the color of minor lines (DarkGray by default) */
  5528. get: function () {
  5529. return this._minorLineColor;
  5530. },
  5531. set: function (value) {
  5532. this._minorLineColor = value;
  5533. this._markAsDirty();
  5534. },
  5535. enumerable: true,
  5536. configurable: true
  5537. });
  5538. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5539. /** Gets or sets the tickness of major lines (2 by default) */
  5540. get: function () {
  5541. return this._majorLineTickness;
  5542. },
  5543. set: function (value) {
  5544. this._majorLineTickness = value;
  5545. this._markAsDirty();
  5546. },
  5547. enumerable: true,
  5548. configurable: true
  5549. });
  5550. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5551. /** Gets or sets the color of major lines (White by default) */
  5552. get: function () {
  5553. return this._majorLineColor;
  5554. },
  5555. set: function (value) {
  5556. this._majorLineColor = value;
  5557. this._markAsDirty();
  5558. },
  5559. enumerable: true,
  5560. configurable: true
  5561. });
  5562. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5563. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5564. get: function () {
  5565. return this._majorLineFrequency;
  5566. },
  5567. set: function (value) {
  5568. this._majorLineFrequency = value;
  5569. this._markAsDirty();
  5570. },
  5571. enumerable: true,
  5572. configurable: true
  5573. });
  5574. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5575. context.save();
  5576. this._applyStates(context);
  5577. if (this._isEnabled) {
  5578. if (this._background) {
  5579. context.fillStyle = this._background;
  5580. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5581. }
  5582. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5583. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5584. // Minor lines
  5585. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5586. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5587. if (this._displayMinorLines) {
  5588. context.strokeStyle = this._minorLineColor;
  5589. context.lineWidth = this._minorLineTickness;
  5590. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5591. var cellX = left + x * this.cellWidth;
  5592. context.beginPath();
  5593. context.moveTo(cellX, this._currentMeasure.top);
  5594. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5595. context.stroke();
  5596. }
  5597. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5598. var cellY = top_1 + y * this.cellHeight;
  5599. context.beginPath();
  5600. context.moveTo(this._currentMeasure.left, cellY);
  5601. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5602. context.stroke();
  5603. }
  5604. }
  5605. // Major lines
  5606. if (this._displayMajorLines) {
  5607. context.strokeStyle = this._majorLineColor;
  5608. context.lineWidth = this._majorLineTickness;
  5609. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5610. var cellX = left + x * this.cellWidth;
  5611. context.beginPath();
  5612. context.moveTo(cellX, this._currentMeasure.top);
  5613. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5614. context.stroke();
  5615. }
  5616. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5617. var cellY = top_1 + y * this.cellHeight;
  5618. context.moveTo(this._currentMeasure.left, cellY);
  5619. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5620. context.closePath();
  5621. context.stroke();
  5622. }
  5623. }
  5624. }
  5625. context.restore();
  5626. };
  5627. DisplayGrid.prototype._getTypeName = function () {
  5628. return "DisplayGrid";
  5629. };
  5630. return DisplayGrid;
  5631. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5632. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5633. /***/ }),
  5634. /***/ "./2D/controls/ellipse.ts":
  5635. /*!********************************!*\
  5636. !*** ./2D/controls/ellipse.ts ***!
  5637. \********************************/
  5638. /*! exports provided: Ellipse */
  5639. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5640. "use strict";
  5641. __webpack_require__.r(__webpack_exports__);
  5642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5643. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5644. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5645. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5646. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5647. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5648. /** Class used to create 2D ellipse containers */
  5649. var Ellipse = /** @class */ (function (_super) {
  5650. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5651. /**
  5652. * Creates a new Ellipse
  5653. * @param name defines the control name
  5654. */
  5655. function Ellipse(name) {
  5656. var _this = _super.call(this, name) || this;
  5657. _this.name = name;
  5658. _this._thickness = 1;
  5659. return _this;
  5660. }
  5661. Object.defineProperty(Ellipse.prototype, "thickness", {
  5662. /** Gets or sets border thickness */
  5663. get: function () {
  5664. return this._thickness;
  5665. },
  5666. set: function (value) {
  5667. if (this._thickness === value) {
  5668. return;
  5669. }
  5670. this._thickness = value;
  5671. this._markAsDirty();
  5672. },
  5673. enumerable: true,
  5674. configurable: true
  5675. });
  5676. Ellipse.prototype._getTypeName = function () {
  5677. return "Ellipse";
  5678. };
  5679. Ellipse.prototype._localDraw = function (context) {
  5680. context.save();
  5681. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5682. context.shadowColor = this.shadowColor;
  5683. context.shadowBlur = this.shadowBlur;
  5684. context.shadowOffsetX = this.shadowOffsetX;
  5685. context.shadowOffsetY = this.shadowOffsetY;
  5686. }
  5687. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2 - this._thickness / 2, this._currentMeasure.height / 2 - this._thickness / 2, context);
  5688. if (this._background) {
  5689. context.fillStyle = this._background;
  5690. context.fill();
  5691. }
  5692. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5693. context.shadowBlur = 0;
  5694. context.shadowOffsetX = 0;
  5695. context.shadowOffsetY = 0;
  5696. }
  5697. if (this._thickness) {
  5698. if (this.color) {
  5699. context.strokeStyle = this.color;
  5700. }
  5701. context.lineWidth = this._thickness;
  5702. context.stroke();
  5703. }
  5704. context.restore();
  5705. };
  5706. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5707. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5708. this._measureForChildren.width -= 2 * this._thickness;
  5709. this._measureForChildren.height -= 2 * this._thickness;
  5710. this._measureForChildren.left += this._thickness;
  5711. this._measureForChildren.top += this._thickness;
  5712. };
  5713. Ellipse.prototype._clipForChildren = function (context) {
  5714. _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);
  5715. context.clip();
  5716. };
  5717. return Ellipse;
  5718. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5719. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5720. /***/ }),
  5721. /***/ "./2D/controls/grid.ts":
  5722. /*!*****************************!*\
  5723. !*** ./2D/controls/grid.ts ***!
  5724. \*****************************/
  5725. /*! exports provided: Grid */
  5726. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5727. "use strict";
  5728. __webpack_require__.r(__webpack_exports__);
  5729. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5730. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5731. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5732. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5733. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5734. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  5735. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5736. /**
  5737. * Class used to create a 2D grid container
  5738. */
  5739. var Grid = /** @class */ (function (_super) {
  5740. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5741. /**
  5742. * Creates a new Grid
  5743. * @param name defines control name
  5744. */
  5745. function Grid(name) {
  5746. var _this = _super.call(this, name) || this;
  5747. _this.name = name;
  5748. _this._rowDefinitions = new Array();
  5749. _this._columnDefinitions = new Array();
  5750. _this._cells = {};
  5751. _this._childControls = new Array();
  5752. return _this;
  5753. }
  5754. Object.defineProperty(Grid.prototype, "columnCount", {
  5755. /**
  5756. * Gets the number of columns
  5757. */
  5758. get: function () {
  5759. return this._columnDefinitions.length;
  5760. },
  5761. enumerable: true,
  5762. configurable: true
  5763. });
  5764. Object.defineProperty(Grid.prototype, "rowCount", {
  5765. /**
  5766. * Gets the number of rows
  5767. */
  5768. get: function () {
  5769. return this._rowDefinitions.length;
  5770. },
  5771. enumerable: true,
  5772. configurable: true
  5773. });
  5774. Object.defineProperty(Grid.prototype, "children", {
  5775. /** Gets the list of children */
  5776. get: function () {
  5777. return this._childControls;
  5778. },
  5779. enumerable: true,
  5780. configurable: true
  5781. });
  5782. Object.defineProperty(Grid.prototype, "cells", {
  5783. /** Gets the list of cells (e.g. the containers) */
  5784. get: function () {
  5785. return this._cells;
  5786. },
  5787. enumerable: true,
  5788. configurable: true
  5789. });
  5790. /**
  5791. * Gets the definition of a specific row
  5792. * @param index defines the index of the row
  5793. * @returns the row definition
  5794. */
  5795. Grid.prototype.getRowDefinition = function (index) {
  5796. if (index < 0 || index >= this._rowDefinitions.length) {
  5797. return null;
  5798. }
  5799. return this._rowDefinitions[index];
  5800. };
  5801. /**
  5802. * Gets the definition of a specific column
  5803. * @param index defines the index of the column
  5804. * @returns the column definition
  5805. */
  5806. Grid.prototype.getColumnDefinition = function (index) {
  5807. if (index < 0 || index >= this._columnDefinitions.length) {
  5808. return null;
  5809. }
  5810. return this._columnDefinitions[index];
  5811. };
  5812. /**
  5813. * Adds a new row to the grid
  5814. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5815. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5816. * @returns the current grid
  5817. */
  5818. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5819. if (isPixel === void 0) { isPixel = false; }
  5820. 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));
  5821. this._markAsDirty();
  5822. return this;
  5823. };
  5824. /**
  5825. * Adds a new column to the grid
  5826. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5827. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5828. * @returns the current grid
  5829. */
  5830. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5831. if (isPixel === void 0) { isPixel = false; }
  5832. 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));
  5833. this._markAsDirty();
  5834. return this;
  5835. };
  5836. /**
  5837. * Update a row definition
  5838. * @param index defines the index of the row to update
  5839. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5840. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5841. * @returns the current grid
  5842. */
  5843. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5844. if (isPixel === void 0) { isPixel = false; }
  5845. if (index < 0 || index >= this._rowDefinitions.length) {
  5846. return this;
  5847. }
  5848. var current = this._rowDefinitions[index];
  5849. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5850. return this;
  5851. }
  5852. 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);
  5853. this._markAsDirty();
  5854. return this;
  5855. };
  5856. /**
  5857. * Update a column definition
  5858. * @param index defines the index of the column to update
  5859. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5860. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5861. * @returns the current grid
  5862. */
  5863. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5864. if (isPixel === void 0) { isPixel = false; }
  5865. if (index < 0 || index >= this._columnDefinitions.length) {
  5866. return this;
  5867. }
  5868. var current = this._columnDefinitions[index];
  5869. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5870. return this;
  5871. }
  5872. 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);
  5873. this._markAsDirty();
  5874. return this;
  5875. };
  5876. /**
  5877. * Gets the list of children stored in a specific cell
  5878. * @param row defines the row to check
  5879. * @param column defines the column to check
  5880. * @returns the list of controls
  5881. */
  5882. Grid.prototype.getChildrenAt = function (row, column) {
  5883. var cell = this._cells[row + ":" + column];
  5884. if (!cell) {
  5885. return null;
  5886. }
  5887. return cell.children;
  5888. };
  5889. /**
  5890. * Gets a string representing the child cell info (row x column)
  5891. * @param child defines the control to get info from
  5892. * @returns a string containing the child cell info (row x column)
  5893. */
  5894. Grid.prototype.getChildCellInfo = function (child) {
  5895. return child._tag;
  5896. };
  5897. Grid.prototype._removeCell = function (cell, key) {
  5898. if (!cell) {
  5899. return;
  5900. }
  5901. _super.prototype.removeControl.call(this, cell);
  5902. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5903. var control = _a[_i];
  5904. var childIndex = this._childControls.indexOf(control);
  5905. if (childIndex !== -1) {
  5906. this._childControls.splice(childIndex, 1);
  5907. }
  5908. }
  5909. delete this._cells[key];
  5910. };
  5911. Grid.prototype._offsetCell = function (previousKey, key) {
  5912. if (!this._cells[key]) {
  5913. return;
  5914. }
  5915. this._cells[previousKey] = this._cells[key];
  5916. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5917. var control = _a[_i];
  5918. control._tag = previousKey;
  5919. }
  5920. delete this._cells[key];
  5921. };
  5922. /**
  5923. * Remove a column definition at specified index
  5924. * @param index defines the index of the column to remove
  5925. * @returns the current grid
  5926. */
  5927. Grid.prototype.removeColumnDefinition = function (index) {
  5928. if (index < 0 || index >= this._columnDefinitions.length) {
  5929. return this;
  5930. }
  5931. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5932. var key = x + ":" + index;
  5933. var cell = this._cells[key];
  5934. this._removeCell(cell, key);
  5935. }
  5936. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5937. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5938. var previousKey = x + ":" + (y - 1);
  5939. var key = x + ":" + y;
  5940. this._offsetCell(previousKey, key);
  5941. }
  5942. }
  5943. this._columnDefinitions.splice(index, 1);
  5944. this._markAsDirty();
  5945. return this;
  5946. };
  5947. /**
  5948. * Remove a row definition at specified index
  5949. * @param index defines the index of the row to remove
  5950. * @returns the current grid
  5951. */
  5952. Grid.prototype.removeRowDefinition = function (index) {
  5953. if (index < 0 || index >= this._rowDefinitions.length) {
  5954. return this;
  5955. }
  5956. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5957. var key = index + ":" + y;
  5958. var cell = this._cells[key];
  5959. this._removeCell(cell, key);
  5960. }
  5961. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5962. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5963. var previousKey = x - 1 + ":" + y;
  5964. var key = x + ":" + y;
  5965. this._offsetCell(previousKey, key);
  5966. }
  5967. }
  5968. this._rowDefinitions.splice(index, 1);
  5969. this._markAsDirty();
  5970. return this;
  5971. };
  5972. /**
  5973. * Adds a new control to the current grid
  5974. * @param control defines the control to add
  5975. * @param row defines the row where to add the control (0 by default)
  5976. * @param column defines the column where to add the control (0 by default)
  5977. * @returns the current grid
  5978. */
  5979. Grid.prototype.addControl = function (control, row, column) {
  5980. if (row === void 0) { row = 0; }
  5981. if (column === void 0) { column = 0; }
  5982. if (this._rowDefinitions.length === 0) {
  5983. // Add default row definition
  5984. this.addRowDefinition(1, false);
  5985. }
  5986. if (this._columnDefinitions.length === 0) {
  5987. // Add default column definition
  5988. this.addColumnDefinition(1, false);
  5989. }
  5990. if (this._childControls.indexOf(control) !== -1) {
  5991. 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");
  5992. return this;
  5993. }
  5994. var x = Math.min(row, this._rowDefinitions.length - 1);
  5995. var y = Math.min(column, this._columnDefinitions.length - 1);
  5996. var key = x + ":" + y;
  5997. var goodContainer = this._cells[key];
  5998. if (!goodContainer) {
  5999. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6000. this._cells[key] = goodContainer;
  6001. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6002. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6003. _super.prototype.addControl.call(this, goodContainer);
  6004. }
  6005. goodContainer.addControl(control);
  6006. this._childControls.push(control);
  6007. control._tag = key;
  6008. control.parent = this;
  6009. this._markAsDirty();
  6010. return this;
  6011. };
  6012. /**
  6013. * Removes a control from the current container
  6014. * @param control defines the control to remove
  6015. * @returns the current container
  6016. */
  6017. Grid.prototype.removeControl = function (control) {
  6018. var index = this._childControls.indexOf(control);
  6019. if (index !== -1) {
  6020. this._childControls.splice(index, 1);
  6021. }
  6022. var cell = this._cells[control._tag];
  6023. if (cell) {
  6024. cell.removeControl(control);
  6025. control._tag = null;
  6026. }
  6027. this._markAsDirty();
  6028. return this;
  6029. };
  6030. Grid.prototype._getTypeName = function () {
  6031. return "Grid";
  6032. };
  6033. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6034. var widths = [];
  6035. var heights = [];
  6036. var lefts = [];
  6037. var tops = [];
  6038. var availableWidth = this._currentMeasure.width;
  6039. var globalWidthPercentage = 0;
  6040. var availableHeight = this._currentMeasure.height;
  6041. var globalHeightPercentage = 0;
  6042. // Heights
  6043. var index = 0;
  6044. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6045. var value = _a[_i];
  6046. if (value.isPixel) {
  6047. var height = value.getValue(this._host);
  6048. availableHeight -= height;
  6049. heights[index] = height;
  6050. }
  6051. else {
  6052. globalHeightPercentage += value.internalValue;
  6053. }
  6054. index++;
  6055. }
  6056. var top = 0;
  6057. index = 0;
  6058. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6059. var value = _c[_b];
  6060. tops.push(top);
  6061. if (!value.isPixel) {
  6062. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6063. top += height;
  6064. heights[index] = height;
  6065. }
  6066. else {
  6067. top += value.getValue(this._host);
  6068. }
  6069. index++;
  6070. }
  6071. // Widths
  6072. index = 0;
  6073. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6074. var value = _e[_d];
  6075. if (value.isPixel) {
  6076. var width = value.getValue(this._host);
  6077. availableWidth -= width;
  6078. widths[index] = width;
  6079. }
  6080. else {
  6081. globalWidthPercentage += value.internalValue;
  6082. }
  6083. index++;
  6084. }
  6085. var left = 0;
  6086. index = 0;
  6087. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6088. var value = _g[_f];
  6089. lefts.push(left);
  6090. if (!value.isPixel) {
  6091. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6092. left += width;
  6093. widths[index] = width;
  6094. }
  6095. else {
  6096. left += value.getValue(this._host);
  6097. }
  6098. index++;
  6099. }
  6100. definitionCallback(lefts, tops, widths, heights);
  6101. };
  6102. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6103. var _this = this;
  6104. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6105. // Setting child sizes
  6106. for (var key in _this._cells) {
  6107. if (!_this._cells.hasOwnProperty(key)) {
  6108. continue;
  6109. }
  6110. var split = key.split(":");
  6111. var x = parseInt(split[0]);
  6112. var y = parseInt(split[1]);
  6113. var cell = _this._cells[key];
  6114. cell.left = lefts[y] + "px";
  6115. cell.top = tops[x] + "px";
  6116. cell.width = widths[y] + "px";
  6117. cell.height = heights[x] + "px";
  6118. cell._left.ignoreAdaptiveScaling = true;
  6119. cell._top.ignoreAdaptiveScaling = true;
  6120. cell._width.ignoreAdaptiveScaling = true;
  6121. cell._height.ignoreAdaptiveScaling = true;
  6122. }
  6123. });
  6124. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6125. };
  6126. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6127. for (var key in this._cells) {
  6128. if (!this._cells.hasOwnProperty(key)) {
  6129. continue;
  6130. }
  6131. var child = this._cells[key];
  6132. child._markMatrixAsDirty();
  6133. }
  6134. };
  6135. Grid.prototype._renderHighlightSpecific = function (context) {
  6136. var _this = this;
  6137. _super.prototype._renderHighlightSpecific.call(this, context);
  6138. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6139. // Columns
  6140. for (var index = 0; index < lefts.length; index++) {
  6141. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6142. context.beginPath();
  6143. context.moveTo(left, _this._currentMeasure.top);
  6144. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6145. context.stroke();
  6146. }
  6147. // Rows
  6148. for (var index = 0; index < tops.length; index++) {
  6149. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6150. context.beginPath();
  6151. context.moveTo(_this._currentMeasure.left, top_1);
  6152. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6153. context.stroke();
  6154. }
  6155. });
  6156. context.restore();
  6157. };
  6158. /** Releases associated resources */
  6159. Grid.prototype.dispose = function () {
  6160. _super.prototype.dispose.call(this);
  6161. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6162. var control = _a[_i];
  6163. control.dispose();
  6164. }
  6165. this._childControls = [];
  6166. };
  6167. return Grid;
  6168. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6169. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6170. /***/ }),
  6171. /***/ "./2D/controls/image.ts":
  6172. /*!******************************!*\
  6173. !*** ./2D/controls/image.ts ***!
  6174. \******************************/
  6175. /*! exports provided: Image */
  6176. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6177. "use strict";
  6178. __webpack_require__.r(__webpack_exports__);
  6179. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6180. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6181. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6182. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6183. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6184. /**
  6185. * Class used to create 2D images
  6186. */
  6187. var Image = /** @class */ (function (_super) {
  6188. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6189. /**
  6190. * Creates a new Image
  6191. * @param name defines the control name
  6192. * @param url defines the image url
  6193. */
  6194. function Image(name, url) {
  6195. if (url === void 0) { url = null; }
  6196. var _this = _super.call(this, name) || this;
  6197. _this.name = name;
  6198. _this._workingCanvas = null;
  6199. _this._loaded = false;
  6200. _this._stretch = Image.STRETCH_FILL;
  6201. _this._autoScale = false;
  6202. _this._sourceLeft = 0;
  6203. _this._sourceTop = 0;
  6204. _this._sourceWidth = 0;
  6205. _this._sourceHeight = 0;
  6206. _this._cellWidth = 0;
  6207. _this._cellHeight = 0;
  6208. _this._cellId = -1;
  6209. _this._populateNinePatchSlicesFromImage = false;
  6210. /**
  6211. * Observable notified when the content is loaded
  6212. */
  6213. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6214. /**
  6215. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6216. */
  6217. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6218. _this.source = url;
  6219. return _this;
  6220. }
  6221. Object.defineProperty(Image.prototype, "isLoaded", {
  6222. /**
  6223. * Gets a boolean indicating that the content is loaded
  6224. */
  6225. get: function () {
  6226. return this._loaded;
  6227. },
  6228. enumerable: true,
  6229. configurable: true
  6230. });
  6231. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6232. /**
  6233. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6234. */
  6235. get: function () {
  6236. return this._populateNinePatchSlicesFromImage;
  6237. },
  6238. set: function (value) {
  6239. if (this._populateNinePatchSlicesFromImage === value) {
  6240. return;
  6241. }
  6242. this._populateNinePatchSlicesFromImage = value;
  6243. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6244. this._extractNinePatchSliceDataFromImage();
  6245. }
  6246. },
  6247. enumerable: true,
  6248. configurable: true
  6249. });
  6250. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6251. /**
  6252. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6253. * Beware using this as this will comsume more memory as the image has to be stored twice
  6254. */
  6255. get: function () {
  6256. return this._detectPointerOnOpaqueOnly;
  6257. },
  6258. set: function (value) {
  6259. if (this._detectPointerOnOpaqueOnly === value) {
  6260. return;
  6261. }
  6262. this._detectPointerOnOpaqueOnly = value;
  6263. },
  6264. enumerable: true,
  6265. configurable: true
  6266. });
  6267. Object.defineProperty(Image.prototype, "sliceLeft", {
  6268. /**
  6269. * Gets or sets the left value for slicing (9-patch)
  6270. */
  6271. get: function () {
  6272. return this._sliceLeft;
  6273. },
  6274. set: function (value) {
  6275. if (this._sliceLeft === value) {
  6276. return;
  6277. }
  6278. this._sliceLeft = value;
  6279. this._markAsDirty();
  6280. },
  6281. enumerable: true,
  6282. configurable: true
  6283. });
  6284. Object.defineProperty(Image.prototype, "sliceRight", {
  6285. /**
  6286. * Gets or sets the right value for slicing (9-patch)
  6287. */
  6288. get: function () {
  6289. return this._sliceRight;
  6290. },
  6291. set: function (value) {
  6292. if (this._sliceRight === value) {
  6293. return;
  6294. }
  6295. this._sliceRight = value;
  6296. this._markAsDirty();
  6297. },
  6298. enumerable: true,
  6299. configurable: true
  6300. });
  6301. Object.defineProperty(Image.prototype, "sliceTop", {
  6302. /**
  6303. * Gets or sets the top value for slicing (9-patch)
  6304. */
  6305. get: function () {
  6306. return this._sliceTop;
  6307. },
  6308. set: function (value) {
  6309. if (this._sliceTop === value) {
  6310. return;
  6311. }
  6312. this._sliceTop = value;
  6313. this._markAsDirty();
  6314. },
  6315. enumerable: true,
  6316. configurable: true
  6317. });
  6318. Object.defineProperty(Image.prototype, "sliceBottom", {
  6319. /**
  6320. * Gets or sets the bottom value for slicing (9-patch)
  6321. */
  6322. get: function () {
  6323. return this._sliceBottom;
  6324. },
  6325. set: function (value) {
  6326. if (this._sliceBottom === value) {
  6327. return;
  6328. }
  6329. this._sliceBottom = value;
  6330. this._markAsDirty();
  6331. },
  6332. enumerable: true,
  6333. configurable: true
  6334. });
  6335. Object.defineProperty(Image.prototype, "sourceLeft", {
  6336. /**
  6337. * Gets or sets the left coordinate in the source image
  6338. */
  6339. get: function () {
  6340. return this._sourceLeft;
  6341. },
  6342. set: function (value) {
  6343. if (this._sourceLeft === value) {
  6344. return;
  6345. }
  6346. this._sourceLeft = value;
  6347. this._markAsDirty();
  6348. },
  6349. enumerable: true,
  6350. configurable: true
  6351. });
  6352. Object.defineProperty(Image.prototype, "sourceTop", {
  6353. /**
  6354. * Gets or sets the top coordinate in the source image
  6355. */
  6356. get: function () {
  6357. return this._sourceTop;
  6358. },
  6359. set: function (value) {
  6360. if (this._sourceTop === value) {
  6361. return;
  6362. }
  6363. this._sourceTop = value;
  6364. this._markAsDirty();
  6365. },
  6366. enumerable: true,
  6367. configurable: true
  6368. });
  6369. Object.defineProperty(Image.prototype, "sourceWidth", {
  6370. /**
  6371. * Gets or sets the width to capture in the source image
  6372. */
  6373. get: function () {
  6374. return this._sourceWidth;
  6375. },
  6376. set: function (value) {
  6377. if (this._sourceWidth === value) {
  6378. return;
  6379. }
  6380. this._sourceWidth = value;
  6381. this._markAsDirty();
  6382. },
  6383. enumerable: true,
  6384. configurable: true
  6385. });
  6386. Object.defineProperty(Image.prototype, "sourceHeight", {
  6387. /**
  6388. * Gets or sets the height to capture in the source image
  6389. */
  6390. get: function () {
  6391. return this._sourceHeight;
  6392. },
  6393. set: function (value) {
  6394. if (this._sourceHeight === value) {
  6395. return;
  6396. }
  6397. this._sourceHeight = value;
  6398. this._markAsDirty();
  6399. },
  6400. enumerable: true,
  6401. configurable: true
  6402. });
  6403. Object.defineProperty(Image.prototype, "autoScale", {
  6404. /**
  6405. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6406. * @see http://doc.babylonjs.com/how_to/gui#image
  6407. */
  6408. get: function () {
  6409. return this._autoScale;
  6410. },
  6411. set: function (value) {
  6412. if (this._autoScale === value) {
  6413. return;
  6414. }
  6415. this._autoScale = value;
  6416. if (value && this._loaded) {
  6417. this.synchronizeSizeWithContent();
  6418. }
  6419. },
  6420. enumerable: true,
  6421. configurable: true
  6422. });
  6423. Object.defineProperty(Image.prototype, "stretch", {
  6424. /** Gets or sets the streching mode used by the image */
  6425. get: function () {
  6426. return this._stretch;
  6427. },
  6428. set: function (value) {
  6429. if (this._stretch === value) {
  6430. return;
  6431. }
  6432. this._stretch = value;
  6433. this._markAsDirty();
  6434. },
  6435. enumerable: true,
  6436. configurable: true
  6437. });
  6438. /** @hidden */
  6439. Image.prototype._rotate90 = function (n) {
  6440. var canvas = document.createElement('canvas');
  6441. var context = canvas.getContext('2d');
  6442. var width = this._domImage.width;
  6443. var height = this._domImage.height;
  6444. canvas.width = height;
  6445. canvas.height = width;
  6446. context.translate(canvas.width / 2, canvas.height / 2);
  6447. context.rotate(n * Math.PI / 2);
  6448. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  6449. var dataUrl = canvas.toDataURL("image/jpg");
  6450. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  6451. return rotatedImage;
  6452. };
  6453. Object.defineProperty(Image.prototype, "domImage", {
  6454. get: function () {
  6455. return this._domImage;
  6456. },
  6457. /**
  6458. * Gets or sets the internal DOM image used to render the control
  6459. */
  6460. set: function (value) {
  6461. var _this = this;
  6462. this._domImage = value;
  6463. this._loaded = false;
  6464. if (this._domImage.width) {
  6465. this._onImageLoaded();
  6466. }
  6467. else {
  6468. this._domImage.onload = function () {
  6469. _this._onImageLoaded();
  6470. };
  6471. }
  6472. },
  6473. enumerable: true,
  6474. configurable: true
  6475. });
  6476. Image.prototype._onImageLoaded = function () {
  6477. this._imageWidth = this._domImage.width;
  6478. this._imageHeight = this._domImage.height;
  6479. this._loaded = true;
  6480. if (this._populateNinePatchSlicesFromImage) {
  6481. this._extractNinePatchSliceDataFromImage();
  6482. }
  6483. if (this._autoScale) {
  6484. this.synchronizeSizeWithContent();
  6485. }
  6486. this.onImageLoadedObservable.notifyObservers(this);
  6487. this._markAsDirty();
  6488. };
  6489. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6490. if (!this._workingCanvas) {
  6491. this._workingCanvas = document.createElement('canvas');
  6492. }
  6493. var canvas = this._workingCanvas;
  6494. var context = canvas.getContext('2d');
  6495. var width = this._domImage.width;
  6496. var height = this._domImage.height;
  6497. canvas.width = width;
  6498. canvas.height = height;
  6499. context.drawImage(this._domImage, 0, 0, width, height);
  6500. var imageData = context.getImageData(0, 0, width, height);
  6501. // Left and right
  6502. this._sliceLeft = -1;
  6503. this._sliceRight = -1;
  6504. for (var x = 0; x < width; x++) {
  6505. var alpha = imageData.data[x * 4 + 3];
  6506. if (alpha > 127 && this._sliceLeft === -1) {
  6507. this._sliceLeft = x;
  6508. continue;
  6509. }
  6510. if (alpha < 127 && this._sliceLeft > -1) {
  6511. this._sliceRight = x;
  6512. break;
  6513. }
  6514. }
  6515. // top and bottom
  6516. this._sliceTop = -1;
  6517. this._sliceBottom = -1;
  6518. for (var y = 0; y < height; y++) {
  6519. var alpha = imageData.data[y * width * 4 + 3];
  6520. if (alpha > 127 && this._sliceTop === -1) {
  6521. this._sliceTop = y;
  6522. continue;
  6523. }
  6524. if (alpha < 127 && this._sliceTop > -1) {
  6525. this._sliceBottom = y;
  6526. break;
  6527. }
  6528. }
  6529. };
  6530. Object.defineProperty(Image.prototype, "source", {
  6531. /**
  6532. * Gets or sets image source url
  6533. */
  6534. set: function (value) {
  6535. var _this = this;
  6536. if (this._source === value) {
  6537. return;
  6538. }
  6539. this._loaded = false;
  6540. this._source = value;
  6541. if (value) {
  6542. value = this._svgCheck(value);
  6543. }
  6544. this._domImage = document.createElement("img");
  6545. this._domImage.onload = function () {
  6546. _this._onImageLoaded();
  6547. };
  6548. if (value) {
  6549. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6550. this._domImage.src = value;
  6551. }
  6552. },
  6553. enumerable: true,
  6554. configurable: true
  6555. });
  6556. /**
  6557. * Checks for svg document with icon id present
  6558. */
  6559. Image.prototype._svgCheck = function (value) {
  6560. var _this = this;
  6561. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6562. var svgsrc = value.split('#')[0];
  6563. var elemid = value.split('#')[1];
  6564. // check if object alr exist in document
  6565. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6566. if (svgExist) {
  6567. var svgDoc = svgExist.contentDocument;
  6568. // get viewbox width and height, get svg document width and height in px
  6569. if (svgDoc && svgDoc.documentElement) {
  6570. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6571. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6572. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6573. if (vb && docwidth && docheight) {
  6574. this._getSVGAttribs(svgExist, elemid);
  6575. return value;
  6576. }
  6577. }
  6578. // wait for object to load
  6579. svgExist.addEventListener("load", function () {
  6580. _this._getSVGAttribs(svgExist, elemid);
  6581. });
  6582. }
  6583. else {
  6584. // create document object
  6585. var svgImage = document.createElement("object");
  6586. svgImage.data = svgsrc;
  6587. svgImage.type = "image/svg+xml";
  6588. svgImage.width = "0%";
  6589. svgImage.height = "0%";
  6590. document.body.appendChild(svgImage);
  6591. // when the object has loaded, get the element attribs
  6592. svgImage.onload = function () {
  6593. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6594. if (svgobj) {
  6595. _this._getSVGAttribs(svgobj, elemid);
  6596. }
  6597. };
  6598. }
  6599. return svgsrc;
  6600. }
  6601. else {
  6602. return value;
  6603. }
  6604. };
  6605. /**
  6606. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6607. * given external svg file and icon id
  6608. */
  6609. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6610. var svgDoc = svgsrc.contentDocument;
  6611. // get viewbox width and height, get svg document width and height in px
  6612. if (svgDoc && svgDoc.documentElement) {
  6613. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6614. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6615. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6616. // get element bbox and matrix transform
  6617. var elem = svgDoc.getElementById(elemid);
  6618. if (vb && docwidth && docheight) {
  6619. var vb_width = Number(vb.split(" ")[2]);
  6620. var vb_height = Number(vb.split(" ")[3]);
  6621. var elem_bbox = elem.getBBox();
  6622. var elem_matrix_a = 1;
  6623. var elem_matrix_d = 1;
  6624. var elem_matrix_e = 0;
  6625. var elem_matrix_f = 0;
  6626. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6627. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6628. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6629. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6630. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6631. }
  6632. // compute source coordinates and dimensions
  6633. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6634. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6635. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6636. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6637. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6638. }
  6639. }
  6640. };
  6641. Object.defineProperty(Image.prototype, "cellWidth", {
  6642. /**
  6643. * Gets or sets the cell width to use when animation sheet is enabled
  6644. * @see http://doc.babylonjs.com/how_to/gui#image
  6645. */
  6646. get: function () {
  6647. return this._cellWidth;
  6648. },
  6649. set: function (value) {
  6650. if (this._cellWidth === value) {
  6651. return;
  6652. }
  6653. this._cellWidth = value;
  6654. this._markAsDirty();
  6655. },
  6656. enumerable: true,
  6657. configurable: true
  6658. });
  6659. Object.defineProperty(Image.prototype, "cellHeight", {
  6660. /**
  6661. * Gets or sets the cell height to use when animation sheet is enabled
  6662. * @see http://doc.babylonjs.com/how_to/gui#image
  6663. */
  6664. get: function () {
  6665. return this._cellHeight;
  6666. },
  6667. set: function (value) {
  6668. if (this._cellHeight === value) {
  6669. return;
  6670. }
  6671. this._cellHeight = value;
  6672. this._markAsDirty();
  6673. },
  6674. enumerable: true,
  6675. configurable: true
  6676. });
  6677. Object.defineProperty(Image.prototype, "cellId", {
  6678. /**
  6679. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6680. * @see http://doc.babylonjs.com/how_to/gui#image
  6681. */
  6682. get: function () {
  6683. return this._cellId;
  6684. },
  6685. set: function (value) {
  6686. if (this._cellId === value) {
  6687. return;
  6688. }
  6689. this._cellId = value;
  6690. this._markAsDirty();
  6691. },
  6692. enumerable: true,
  6693. configurable: true
  6694. });
  6695. /**
  6696. * Tests if a given coordinates belong to the current control
  6697. * @param x defines x coordinate to test
  6698. * @param y defines y coordinate to test
  6699. * @returns true if the coordinates are inside the control
  6700. */
  6701. Image.prototype.contains = function (x, y) {
  6702. if (!_super.prototype.contains.call(this, x, y)) {
  6703. return false;
  6704. }
  6705. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6706. return true;
  6707. }
  6708. var canvas = this._workingCanvas;
  6709. var context = canvas.getContext("2d");
  6710. var width = this._currentMeasure.width | 0;
  6711. var height = this._currentMeasure.height | 0;
  6712. var imageData = context.getImageData(0, 0, width, height).data;
  6713. x = (x - this._currentMeasure.left) | 0;
  6714. y = (y - this._currentMeasure.top) | 0;
  6715. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6716. return pickedPixel > 0;
  6717. };
  6718. Image.prototype._getTypeName = function () {
  6719. return "Image";
  6720. };
  6721. /** Force the control to synchronize with its content */
  6722. Image.prototype.synchronizeSizeWithContent = function () {
  6723. if (!this._loaded) {
  6724. return;
  6725. }
  6726. this.width = this._domImage.width + "px";
  6727. this.height = this._domImage.height + "px";
  6728. };
  6729. Image.prototype._processMeasures = function (parentMeasure, context) {
  6730. if (this._loaded) {
  6731. switch (this._stretch) {
  6732. case Image.STRETCH_NONE:
  6733. break;
  6734. case Image.STRETCH_FILL:
  6735. break;
  6736. case Image.STRETCH_UNIFORM:
  6737. break;
  6738. case Image.STRETCH_NINE_PATCH:
  6739. break;
  6740. case Image.STRETCH_EXTEND:
  6741. if (this._autoScale) {
  6742. this.synchronizeSizeWithContent();
  6743. }
  6744. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6745. this.parent.adaptWidthToChildren = true;
  6746. this.parent.adaptHeightToChildren = true;
  6747. }
  6748. break;
  6749. }
  6750. }
  6751. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6752. };
  6753. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6754. if (!this._detectPointerOnOpaqueOnly) {
  6755. return;
  6756. }
  6757. if (!this._workingCanvas) {
  6758. this._workingCanvas = document.createElement('canvas');
  6759. }
  6760. var canvas = this._workingCanvas;
  6761. var width = this._currentMeasure.width;
  6762. var height = this._currentMeasure.height;
  6763. var context = canvas.getContext("2d");
  6764. canvas.width = width;
  6765. canvas.height = height;
  6766. context.clearRect(0, 0, width, height);
  6767. };
  6768. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6769. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6770. if (!this._detectPointerOnOpaqueOnly) {
  6771. return;
  6772. }
  6773. var canvas = this._workingCanvas;
  6774. context = canvas.getContext("2d");
  6775. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6776. };
  6777. Image.prototype._draw = function (context) {
  6778. context.save();
  6779. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6780. context.shadowColor = this.shadowColor;
  6781. context.shadowBlur = this.shadowBlur;
  6782. context.shadowOffsetX = this.shadowOffsetX;
  6783. context.shadowOffsetY = this.shadowOffsetY;
  6784. }
  6785. var x, y, width, height;
  6786. if (this.cellId == -1) {
  6787. x = this._sourceLeft;
  6788. y = this._sourceTop;
  6789. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6790. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6791. }
  6792. else {
  6793. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6794. var column = (this.cellId / rowCount) >> 0;
  6795. var row = this.cellId % rowCount;
  6796. x = this.cellWidth * row;
  6797. y = this.cellHeight * column;
  6798. width = this.cellWidth;
  6799. height = this.cellHeight;
  6800. }
  6801. this._prepareWorkingCanvasForOpaqueDetection();
  6802. this._applyStates(context);
  6803. if (this._loaded) {
  6804. switch (this._stretch) {
  6805. case Image.STRETCH_NONE:
  6806. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6807. break;
  6808. case Image.STRETCH_FILL:
  6809. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6810. break;
  6811. case Image.STRETCH_UNIFORM:
  6812. var hRatio = this._currentMeasure.width / width;
  6813. var vRatio = this._currentMeasure.height / height;
  6814. var ratio = Math.min(hRatio, vRatio);
  6815. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6816. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6817. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6818. break;
  6819. case Image.STRETCH_EXTEND:
  6820. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6821. break;
  6822. case Image.STRETCH_NINE_PATCH:
  6823. this._renderNinePatch(context);
  6824. break;
  6825. }
  6826. }
  6827. context.restore();
  6828. };
  6829. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6830. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6831. };
  6832. Image.prototype._renderNinePatch = function (context) {
  6833. var height = this._imageHeight;
  6834. var leftWidth = this._sliceLeft;
  6835. var topHeight = this._sliceTop;
  6836. var bottomHeight = this._imageHeight - this._sliceBottom;
  6837. var rightWidth = this._imageWidth - this._sliceRight;
  6838. var left = 0;
  6839. var top = 0;
  6840. if (this._populateNinePatchSlicesFromImage) {
  6841. left = 1;
  6842. top = 1;
  6843. height -= 2;
  6844. leftWidth -= 1;
  6845. topHeight -= 1;
  6846. bottomHeight -= 1;
  6847. rightWidth -= 1;
  6848. }
  6849. var centerWidth = this._sliceRight - this._sliceLeft;
  6850. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft;
  6851. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6852. // Corners
  6853. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6854. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6855. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6856. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6857. // Center
  6858. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight);
  6859. // Borders
  6860. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6861. 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);
  6862. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6863. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6864. };
  6865. Image.prototype.dispose = function () {
  6866. _super.prototype.dispose.call(this);
  6867. this.onImageLoadedObservable.clear();
  6868. this.onSVGAttributesComputedObservable.clear();
  6869. };
  6870. // Static
  6871. /** STRETCH_NONE */
  6872. Image.STRETCH_NONE = 0;
  6873. /** STRETCH_FILL */
  6874. Image.STRETCH_FILL = 1;
  6875. /** STRETCH_UNIFORM */
  6876. Image.STRETCH_UNIFORM = 2;
  6877. /** STRETCH_EXTEND */
  6878. Image.STRETCH_EXTEND = 3;
  6879. /** NINE_PATCH */
  6880. Image.STRETCH_NINE_PATCH = 4;
  6881. return Image;
  6882. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6883. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  6884. /***/ }),
  6885. /***/ "./2D/controls/index.ts":
  6886. /*!******************************!*\
  6887. !*** ./2D/controls/index.ts ***!
  6888. \******************************/
  6889. /*! 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 */
  6890. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6891. "use strict";
  6892. __webpack_require__.r(__webpack_exports__);
  6893. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6895. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6897. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6899. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6901. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6903. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6905. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6907. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6909. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6911. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6913. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6915. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6917. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6919. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6921. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6927. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6929. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6932. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6935. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6937. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6939. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6941. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6943. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6945. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6947. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  6948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__["ImageScrollBar"]; });
  6949. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_25__["name"]; });
  6951. /***/ }),
  6952. /***/ "./2D/controls/inputPassword.ts":
  6953. /*!**************************************!*\
  6954. !*** ./2D/controls/inputPassword.ts ***!
  6955. \**************************************/
  6956. /*! exports provided: InputPassword */
  6957. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6958. "use strict";
  6959. __webpack_require__.r(__webpack_exports__);
  6960. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6961. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6962. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6963. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  6964. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  6965. /**
  6966. * Class used to create a password control
  6967. */
  6968. var InputPassword = /** @class */ (function (_super) {
  6969. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  6970. function InputPassword() {
  6971. return _super !== null && _super.apply(this, arguments) || this;
  6972. }
  6973. InputPassword.prototype._beforeRenderText = function (text) {
  6974. var txt = "";
  6975. for (var i = 0; i < text.length; i++) {
  6976. txt += "\u2022";
  6977. }
  6978. return txt;
  6979. };
  6980. return InputPassword;
  6981. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6982. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  6983. /***/ }),
  6984. /***/ "./2D/controls/inputText.ts":
  6985. /*!**********************************!*\
  6986. !*** ./2D/controls/inputText.ts ***!
  6987. \**********************************/
  6988. /*! exports provided: InputText */
  6989. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6990. "use strict";
  6991. __webpack_require__.r(__webpack_exports__);
  6992. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6993. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6994. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6995. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6996. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6997. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6998. /**
  6999. * Class used to create input text control
  7000. */
  7001. var InputText = /** @class */ (function (_super) {
  7002. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7003. /**
  7004. * Creates a new InputText
  7005. * @param name defines the control name
  7006. * @param text defines the text of the control
  7007. */
  7008. function InputText(name, text) {
  7009. if (text === void 0) { text = ""; }
  7010. var _this = _super.call(this, name) || this;
  7011. _this.name = name;
  7012. _this._text = "";
  7013. _this._placeholderText = "";
  7014. _this._background = "#222222";
  7015. _this._focusedBackground = "#000000";
  7016. _this._focusedColor = "white";
  7017. _this._placeholderColor = "gray";
  7018. _this._thickness = 1;
  7019. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7020. _this._autoStretchWidth = true;
  7021. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7022. _this._isFocused = false;
  7023. _this._blinkIsEven = false;
  7024. _this._cursorOffset = 0;
  7025. _this._deadKey = false;
  7026. _this._addKey = true;
  7027. _this._currentKey = "";
  7028. _this._isTextHighlightOn = false;
  7029. _this._textHighlightColor = "#d5e0ff";
  7030. _this._highligherOpacity = 0.4;
  7031. _this._highlightedText = "";
  7032. _this._startHighlightIndex = 0;
  7033. _this._endHighlightIndex = 0;
  7034. _this._cursorIndex = -1;
  7035. _this._onFocusSelectAll = false;
  7036. _this._isPointerDown = false;
  7037. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7038. _this.promptMessage = "Please enter text:";
  7039. /** Force disable prompt on mobile device */
  7040. _this.disableMobilePrompt = false;
  7041. /** Observable raised when the text changes */
  7042. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7043. /** Observable raised just before an entered character is to be added */
  7044. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7045. /** Observable raised when the control gets the focus */
  7046. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7047. /** Observable raised when the control loses the focus */
  7048. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7049. /**Observable raised when the text is highlighted */
  7050. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7051. /**Observable raised when copy event is triggered */
  7052. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7053. /** Observable raised when cut event is triggered */
  7054. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7055. /** Observable raised when paste event is triggered */
  7056. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7057. /** Observable raised when a key event was processed */
  7058. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7059. _this.text = text;
  7060. _this.isPointerBlocker = true;
  7061. return _this;
  7062. }
  7063. Object.defineProperty(InputText.prototype, "maxWidth", {
  7064. /** Gets or sets the maximum width allowed by the control */
  7065. get: function () {
  7066. return this._maxWidth.toString(this._host);
  7067. },
  7068. set: function (value) {
  7069. if (this._maxWidth.toString(this._host) === value) {
  7070. return;
  7071. }
  7072. if (this._maxWidth.fromString(value)) {
  7073. this._markAsDirty();
  7074. }
  7075. },
  7076. enumerable: true,
  7077. configurable: true
  7078. });
  7079. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7080. /** Gets the maximum width allowed by the control in pixels */
  7081. get: function () {
  7082. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7083. },
  7084. enumerable: true,
  7085. configurable: true
  7086. });
  7087. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7088. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7089. get: function () {
  7090. return this._highligherOpacity;
  7091. },
  7092. set: function (value) {
  7093. if (this._highligherOpacity === value) {
  7094. return;
  7095. }
  7096. this._highligherOpacity = value;
  7097. this._markAsDirty();
  7098. },
  7099. enumerable: true,
  7100. configurable: true
  7101. });
  7102. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7103. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7104. get: function () {
  7105. return this._onFocusSelectAll;
  7106. },
  7107. set: function (value) {
  7108. if (this._onFocusSelectAll === value) {
  7109. return;
  7110. }
  7111. this._onFocusSelectAll = value;
  7112. this._markAsDirty();
  7113. },
  7114. enumerable: true,
  7115. configurable: true
  7116. });
  7117. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7118. /** Gets or sets the text hightlight color */
  7119. get: function () {
  7120. return this._textHighlightColor;
  7121. },
  7122. set: function (value) {
  7123. if (this._textHighlightColor === value) {
  7124. return;
  7125. }
  7126. this._textHighlightColor = value;
  7127. this._markAsDirty();
  7128. },
  7129. enumerable: true,
  7130. configurable: true
  7131. });
  7132. Object.defineProperty(InputText.prototype, "margin", {
  7133. /** Gets or sets control margin */
  7134. get: function () {
  7135. return this._margin.toString(this._host);
  7136. },
  7137. set: function (value) {
  7138. if (this._margin.toString(this._host) === value) {
  7139. return;
  7140. }
  7141. if (this._margin.fromString(value)) {
  7142. this._markAsDirty();
  7143. }
  7144. },
  7145. enumerable: true,
  7146. configurable: true
  7147. });
  7148. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7149. /** Gets control margin in pixels */
  7150. get: function () {
  7151. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7152. },
  7153. enumerable: true,
  7154. configurable: true
  7155. });
  7156. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7157. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7158. get: function () {
  7159. return this._autoStretchWidth;
  7160. },
  7161. set: function (value) {
  7162. if (this._autoStretchWidth === value) {
  7163. return;
  7164. }
  7165. this._autoStretchWidth = value;
  7166. this._markAsDirty();
  7167. },
  7168. enumerable: true,
  7169. configurable: true
  7170. });
  7171. Object.defineProperty(InputText.prototype, "thickness", {
  7172. /** Gets or sets border thickness */
  7173. get: function () {
  7174. return this._thickness;
  7175. },
  7176. set: function (value) {
  7177. if (this._thickness === value) {
  7178. return;
  7179. }
  7180. this._thickness = value;
  7181. this._markAsDirty();
  7182. },
  7183. enumerable: true,
  7184. configurable: true
  7185. });
  7186. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7187. /** Gets or sets the background color when focused */
  7188. get: function () {
  7189. return this._focusedBackground;
  7190. },
  7191. set: function (value) {
  7192. if (this._focusedBackground === value) {
  7193. return;
  7194. }
  7195. this._focusedBackground = value;
  7196. this._markAsDirty();
  7197. },
  7198. enumerable: true,
  7199. configurable: true
  7200. });
  7201. Object.defineProperty(InputText.prototype, "focusedColor", {
  7202. /** Gets or sets the background color when focused */
  7203. get: function () {
  7204. return this._focusedColor;
  7205. },
  7206. set: function (value) {
  7207. if (this._focusedColor === value) {
  7208. return;
  7209. }
  7210. this._focusedColor = value;
  7211. this._markAsDirty();
  7212. },
  7213. enumerable: true,
  7214. configurable: true
  7215. });
  7216. Object.defineProperty(InputText.prototype, "background", {
  7217. /** Gets or sets the background color */
  7218. get: function () {
  7219. return this._background;
  7220. },
  7221. set: function (value) {
  7222. if (this._background === value) {
  7223. return;
  7224. }
  7225. this._background = value;
  7226. this._markAsDirty();
  7227. },
  7228. enumerable: true,
  7229. configurable: true
  7230. });
  7231. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7232. /** Gets or sets the placeholder color */
  7233. get: function () {
  7234. return this._placeholderColor;
  7235. },
  7236. set: function (value) {
  7237. if (this._placeholderColor === value) {
  7238. return;
  7239. }
  7240. this._placeholderColor = value;
  7241. this._markAsDirty();
  7242. },
  7243. enumerable: true,
  7244. configurable: true
  7245. });
  7246. Object.defineProperty(InputText.prototype, "placeholderText", {
  7247. /** Gets or sets the text displayed when the control is empty */
  7248. get: function () {
  7249. return this._placeholderText;
  7250. },
  7251. set: function (value) {
  7252. if (this._placeholderText === value) {
  7253. return;
  7254. }
  7255. this._placeholderText = value;
  7256. this._markAsDirty();
  7257. },
  7258. enumerable: true,
  7259. configurable: true
  7260. });
  7261. Object.defineProperty(InputText.prototype, "deadKey", {
  7262. /** Gets or sets the dead key flag */
  7263. get: function () {
  7264. return this._deadKey;
  7265. },
  7266. set: function (flag) {
  7267. this._deadKey = flag;
  7268. },
  7269. enumerable: true,
  7270. configurable: true
  7271. });
  7272. Object.defineProperty(InputText.prototype, "highlightedText", {
  7273. /** Gets or sets the highlight text */
  7274. get: function () {
  7275. return this._highlightedText;
  7276. },
  7277. set: function (text) {
  7278. if (this._highlightedText === text) {
  7279. return;
  7280. }
  7281. this._highlightedText = text;
  7282. this._markAsDirty();
  7283. },
  7284. enumerable: true,
  7285. configurable: true
  7286. });
  7287. Object.defineProperty(InputText.prototype, "addKey", {
  7288. /** Gets or sets if the current key should be added */
  7289. get: function () {
  7290. return this._addKey;
  7291. },
  7292. set: function (flag) {
  7293. this._addKey = flag;
  7294. },
  7295. enumerable: true,
  7296. configurable: true
  7297. });
  7298. Object.defineProperty(InputText.prototype, "currentKey", {
  7299. /** Gets or sets the value of the current key being entered */
  7300. get: function () {
  7301. return this._currentKey;
  7302. },
  7303. set: function (key) {
  7304. this._currentKey = key;
  7305. },
  7306. enumerable: true,
  7307. configurable: true
  7308. });
  7309. Object.defineProperty(InputText.prototype, "text", {
  7310. /** Gets or sets the text displayed in the control */
  7311. get: function () {
  7312. return this._text;
  7313. },
  7314. set: function (value) {
  7315. var valueAsString = value.toString(); // Forcing convertion
  7316. if (this._text === valueAsString) {
  7317. return;
  7318. }
  7319. this._text = valueAsString;
  7320. this._markAsDirty();
  7321. this.onTextChangedObservable.notifyObservers(this);
  7322. },
  7323. enumerable: true,
  7324. configurable: true
  7325. });
  7326. Object.defineProperty(InputText.prototype, "width", {
  7327. /** Gets or sets control width */
  7328. get: function () {
  7329. return this._width.toString(this._host);
  7330. },
  7331. set: function (value) {
  7332. if (this._width.toString(this._host) === value) {
  7333. return;
  7334. }
  7335. if (this._width.fromString(value)) {
  7336. this._markAsDirty();
  7337. }
  7338. this.autoStretchWidth = false;
  7339. },
  7340. enumerable: true,
  7341. configurable: true
  7342. });
  7343. /** @hidden */
  7344. InputText.prototype.onBlur = function () {
  7345. this._isFocused = false;
  7346. this._scrollLeft = null;
  7347. this._cursorOffset = 0;
  7348. clearTimeout(this._blinkTimeout);
  7349. this._markAsDirty();
  7350. this.onBlurObservable.notifyObservers(this);
  7351. this._host.unRegisterClipboardEvents();
  7352. if (this._onClipboardObserver) {
  7353. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7354. }
  7355. var scene = this._host.getScene();
  7356. if (this._onPointerDblTapObserver && scene) {
  7357. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7358. }
  7359. };
  7360. /** @hidden */
  7361. InputText.prototype.onFocus = function () {
  7362. var _this = this;
  7363. if (!this._isEnabled) {
  7364. return;
  7365. }
  7366. this._scrollLeft = null;
  7367. this._isFocused = true;
  7368. this._blinkIsEven = false;
  7369. this._cursorOffset = 0;
  7370. this._markAsDirty();
  7371. this.onFocusObservable.notifyObservers(this);
  7372. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7373. var value = prompt(this.promptMessage);
  7374. if (value !== null) {
  7375. this.text = value;
  7376. }
  7377. this._host.focusedControl = null;
  7378. return;
  7379. }
  7380. this._host.registerClipboardEvents();
  7381. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7382. // process clipboard event, can be configured.
  7383. switch (clipboardInfo.type) {
  7384. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7385. _this._onCopyText(clipboardInfo.event);
  7386. _this.onTextCopyObservable.notifyObservers(_this);
  7387. break;
  7388. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7389. _this._onCutText(clipboardInfo.event);
  7390. _this.onTextCutObservable.notifyObservers(_this);
  7391. break;
  7392. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7393. _this._onPasteText(clipboardInfo.event);
  7394. _this.onTextPasteObservable.notifyObservers(_this);
  7395. break;
  7396. default: return;
  7397. }
  7398. });
  7399. var scene = this._host.getScene();
  7400. if (scene) {
  7401. //register the pointer double tap event
  7402. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7403. if (!_this._isFocused) {
  7404. return;
  7405. }
  7406. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7407. _this._processDblClick(pointerInfo);
  7408. }
  7409. });
  7410. }
  7411. if (this._onFocusSelectAll) {
  7412. this._selectAllText();
  7413. }
  7414. };
  7415. InputText.prototype._getTypeName = function () {
  7416. return "InputText";
  7417. };
  7418. /**
  7419. * Function called to get the list of controls that should not steal the focus from this control
  7420. * @returns an array of controls
  7421. */
  7422. InputText.prototype.keepsFocusWith = function () {
  7423. if (!this._connectedVirtualKeyboard) {
  7424. return null;
  7425. }
  7426. return [this._connectedVirtualKeyboard];
  7427. };
  7428. /** @hidden */
  7429. InputText.prototype.processKey = function (keyCode, key, evt) {
  7430. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7431. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7432. return;
  7433. }
  7434. //select all
  7435. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7436. this._selectAllText();
  7437. evt.preventDefault();
  7438. return;
  7439. }
  7440. // Specific cases
  7441. switch (keyCode) {
  7442. case 32: //SPACE
  7443. key = " "; //ie11 key for space is "Spacebar"
  7444. break;
  7445. case 191: //SLASH
  7446. if (evt) {
  7447. evt.preventDefault();
  7448. }
  7449. break;
  7450. case 8: // BACKSPACE
  7451. if (this._text && this._text.length > 0) {
  7452. //delete the highlighted text
  7453. if (this._isTextHighlightOn) {
  7454. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7455. this._isTextHighlightOn = false;
  7456. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7457. this._blinkIsEven = false;
  7458. if (evt) {
  7459. evt.preventDefault();
  7460. }
  7461. return;
  7462. }
  7463. //delete single character
  7464. if (this._cursorOffset === 0) {
  7465. this.text = this._text.substr(0, this._text.length - 1);
  7466. }
  7467. else {
  7468. var deletePosition = this._text.length - this._cursorOffset;
  7469. if (deletePosition > 0) {
  7470. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7471. }
  7472. }
  7473. }
  7474. if (evt) {
  7475. evt.preventDefault();
  7476. }
  7477. return;
  7478. case 46: // DELETE
  7479. if (this._isTextHighlightOn) {
  7480. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7481. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7482. while (decrementor > 0 && this._cursorOffset > 0) {
  7483. this._cursorOffset--;
  7484. }
  7485. this._isTextHighlightOn = false;
  7486. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7487. if (evt) {
  7488. evt.preventDefault();
  7489. }
  7490. return;
  7491. }
  7492. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7493. var deletePosition = this._text.length - this._cursorOffset;
  7494. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7495. this._cursorOffset--;
  7496. }
  7497. if (evt) {
  7498. evt.preventDefault();
  7499. }
  7500. return;
  7501. case 13: // RETURN
  7502. this._host.focusedControl = null;
  7503. this._isTextHighlightOn = false;
  7504. return;
  7505. case 35: // END
  7506. this._cursorOffset = 0;
  7507. this._blinkIsEven = false;
  7508. this._isTextHighlightOn = false;
  7509. this._markAsDirty();
  7510. return;
  7511. case 36: // HOME
  7512. this._cursorOffset = this._text.length;
  7513. this._blinkIsEven = false;
  7514. this._isTextHighlightOn = false;
  7515. this._markAsDirty();
  7516. return;
  7517. case 37: // LEFT
  7518. this._cursorOffset++;
  7519. if (this._cursorOffset > this._text.length) {
  7520. this._cursorOffset = this._text.length;
  7521. }
  7522. if (evt && evt.shiftKey) {
  7523. // update the cursor
  7524. this._blinkIsEven = false;
  7525. // shift + ctrl/cmd + <-
  7526. if (evt.ctrlKey || evt.metaKey) {
  7527. if (!this._isTextHighlightOn) {
  7528. if (this._text.length === this._cursorOffset) {
  7529. return;
  7530. }
  7531. else {
  7532. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7533. }
  7534. }
  7535. this._startHighlightIndex = 0;
  7536. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7537. this._cursorOffset = this._text.length;
  7538. this._isTextHighlightOn = true;
  7539. this._markAsDirty();
  7540. return;
  7541. }
  7542. //store the starting point
  7543. if (!this._isTextHighlightOn) {
  7544. this._isTextHighlightOn = true;
  7545. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7546. }
  7547. //if text is already highlighted
  7548. else if (this._cursorIndex === -1) {
  7549. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7550. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7551. }
  7552. //set the highlight indexes
  7553. if (this._cursorIndex < this._cursorOffset) {
  7554. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7555. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7556. }
  7557. else if (this._cursorIndex > this._cursorOffset) {
  7558. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7559. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7560. }
  7561. else {
  7562. this._isTextHighlightOn = false;
  7563. }
  7564. this._markAsDirty();
  7565. return;
  7566. }
  7567. if (this._isTextHighlightOn) {
  7568. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7569. this._isTextHighlightOn = false;
  7570. }
  7571. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7572. this._cursorOffset = this.text.length;
  7573. evt.preventDefault();
  7574. }
  7575. this._blinkIsEven = false;
  7576. this._isTextHighlightOn = false;
  7577. this._cursorIndex = -1;
  7578. this._markAsDirty();
  7579. return;
  7580. case 39: // RIGHT
  7581. this._cursorOffset--;
  7582. if (this._cursorOffset < 0) {
  7583. this._cursorOffset = 0;
  7584. }
  7585. if (evt && evt.shiftKey) {
  7586. //update the cursor
  7587. this._blinkIsEven = false;
  7588. //shift + ctrl/cmd + ->
  7589. if (evt.ctrlKey || evt.metaKey) {
  7590. if (!this._isTextHighlightOn) {
  7591. if (this._cursorOffset === 0) {
  7592. return;
  7593. }
  7594. else {
  7595. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7596. }
  7597. }
  7598. this._endHighlightIndex = this._text.length;
  7599. this._isTextHighlightOn = true;
  7600. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7601. this._cursorOffset = 0;
  7602. this._markAsDirty();
  7603. return;
  7604. }
  7605. if (!this._isTextHighlightOn) {
  7606. this._isTextHighlightOn = true;
  7607. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7608. }
  7609. //if text is already highlighted
  7610. else if (this._cursorIndex === -1) {
  7611. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7612. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7613. }
  7614. //set the highlight indexes
  7615. if (this._cursorIndex < this._cursorOffset) {
  7616. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7617. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7618. }
  7619. else if (this._cursorIndex > this._cursorOffset) {
  7620. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7621. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7622. }
  7623. else {
  7624. this._isTextHighlightOn = false;
  7625. }
  7626. this._markAsDirty();
  7627. return;
  7628. }
  7629. if (this._isTextHighlightOn) {
  7630. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7631. this._isTextHighlightOn = false;
  7632. }
  7633. //ctr + ->
  7634. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7635. this._cursorOffset = 0;
  7636. evt.preventDefault();
  7637. }
  7638. this._blinkIsEven = false;
  7639. this._isTextHighlightOn = false;
  7640. this._cursorIndex = -1;
  7641. this._markAsDirty();
  7642. return;
  7643. case 222: // Dead
  7644. if (evt) {
  7645. evt.preventDefault();
  7646. }
  7647. this._cursorIndex = -1;
  7648. this.deadKey = true;
  7649. break;
  7650. }
  7651. // Printable characters
  7652. if (key &&
  7653. ((keyCode === -1) || // Direct access
  7654. (keyCode === 32) || // Space
  7655. (keyCode > 47 && keyCode < 64) || // Numbers
  7656. (keyCode > 64 && keyCode < 91) || // Letters
  7657. (keyCode > 159 && keyCode < 193) || // Special characters
  7658. (keyCode > 218 && keyCode < 223) || // Special characters
  7659. (keyCode > 95 && keyCode < 112))) { // Numpad
  7660. this._currentKey = key;
  7661. this.onBeforeKeyAddObservable.notifyObservers(this);
  7662. key = this._currentKey;
  7663. if (this._addKey) {
  7664. if (this._isTextHighlightOn) {
  7665. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7666. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7667. this._isTextHighlightOn = false;
  7668. this._blinkIsEven = false;
  7669. this._markAsDirty();
  7670. }
  7671. else if (this._cursorOffset === 0) {
  7672. this.text += key;
  7673. }
  7674. else {
  7675. var insertPosition = this._text.length - this._cursorOffset;
  7676. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7677. }
  7678. }
  7679. }
  7680. };
  7681. /** @hidden */
  7682. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7683. //update the cursor
  7684. this._blinkIsEven = false;
  7685. if (this._cursorIndex === -1) {
  7686. this._cursorIndex = offset;
  7687. }
  7688. else {
  7689. if (this._cursorIndex < this._cursorOffset) {
  7690. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7691. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7692. }
  7693. else if (this._cursorIndex > this._cursorOffset) {
  7694. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7695. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7696. }
  7697. else {
  7698. this._isTextHighlightOn = false;
  7699. this._markAsDirty();
  7700. return;
  7701. }
  7702. }
  7703. this._isTextHighlightOn = true;
  7704. this._markAsDirty();
  7705. };
  7706. /** @hidden */
  7707. InputText.prototype._processDblClick = function (evt) {
  7708. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7709. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7710. this._endHighlightIndex = this._startHighlightIndex;
  7711. var rWord = /\w+/g, moveLeft, moveRight;
  7712. do {
  7713. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7714. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7715. } while (moveLeft || moveRight);
  7716. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7717. this.onTextHighlightObservable.notifyObservers(this);
  7718. this._isTextHighlightOn = true;
  7719. this._clickedCoordinate = null;
  7720. this._blinkIsEven = true;
  7721. this._cursorIndex = -1;
  7722. this._markAsDirty();
  7723. };
  7724. /** @hidden */
  7725. InputText.prototype._selectAllText = function () {
  7726. this._blinkIsEven = true;
  7727. this._isTextHighlightOn = true;
  7728. this._startHighlightIndex = 0;
  7729. this._endHighlightIndex = this._text.length;
  7730. this._cursorOffset = this._text.length;
  7731. this._cursorIndex = -1;
  7732. this._markAsDirty();
  7733. };
  7734. /**
  7735. * Handles the keyboard event
  7736. * @param evt Defines the KeyboardEvent
  7737. */
  7738. InputText.prototype.processKeyboard = function (evt) {
  7739. // process pressed key
  7740. this.processKey(evt.keyCode, evt.key, evt);
  7741. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7742. };
  7743. /** @hidden */
  7744. InputText.prototype._onCopyText = function (ev) {
  7745. this._isTextHighlightOn = false;
  7746. //when write permission to clipbaord data is denied
  7747. try {
  7748. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7749. }
  7750. catch (_a) { } //pass
  7751. this._host.clipboardData = this._highlightedText;
  7752. };
  7753. /** @hidden */
  7754. InputText.prototype._onCutText = function (ev) {
  7755. if (!this._highlightedText) {
  7756. return;
  7757. }
  7758. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7759. this._isTextHighlightOn = false;
  7760. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7761. //when write permission to clipbaord data is denied
  7762. try {
  7763. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7764. }
  7765. catch (_a) { } //pass
  7766. this._host.clipboardData = this._highlightedText;
  7767. this._highlightedText = "";
  7768. };
  7769. /** @hidden */
  7770. InputText.prototype._onPasteText = function (ev) {
  7771. var data = "";
  7772. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7773. data = ev.clipboardData.getData("text/plain");
  7774. }
  7775. else {
  7776. //get the cached data; returns blank string by default
  7777. data = this._host.clipboardData;
  7778. }
  7779. var insertPosition = this._text.length - this._cursorOffset;
  7780. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7781. };
  7782. InputText.prototype._draw = function (context, invalidatedRectangle) {
  7783. var _this = this;
  7784. context.save();
  7785. this._applyStates(context);
  7786. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7787. context.shadowColor = this.shadowColor;
  7788. context.shadowBlur = this.shadowBlur;
  7789. context.shadowOffsetX = this.shadowOffsetX;
  7790. context.shadowOffsetY = this.shadowOffsetY;
  7791. }
  7792. // Background
  7793. if (this._isFocused) {
  7794. if (this._focusedBackground) {
  7795. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7796. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7797. }
  7798. }
  7799. else if (this._background) {
  7800. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7801. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7802. }
  7803. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7804. context.shadowBlur = 0;
  7805. context.shadowOffsetX = 0;
  7806. context.shadowOffsetY = 0;
  7807. }
  7808. if (!this._fontOffset) {
  7809. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7810. }
  7811. // Text
  7812. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7813. if (this.color) {
  7814. context.fillStyle = this.color;
  7815. }
  7816. var text = this._beforeRenderText(this._text);
  7817. if (!this._isFocused && !this._text && this._placeholderText) {
  7818. text = this._placeholderText;
  7819. if (this._placeholderColor) {
  7820. context.fillStyle = this._placeholderColor;
  7821. }
  7822. }
  7823. this._textWidth = context.measureText(text).width;
  7824. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7825. if (this._autoStretchWidth) {
  7826. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7827. }
  7828. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7829. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7830. context.save();
  7831. context.beginPath();
  7832. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7833. context.clip();
  7834. if (this._isFocused && this._textWidth > availableWidth) {
  7835. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7836. if (!this._scrollLeft) {
  7837. this._scrollLeft = textLeft;
  7838. }
  7839. }
  7840. else {
  7841. this._scrollLeft = clipTextLeft;
  7842. }
  7843. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7844. // Cursor
  7845. if (this._isFocused) {
  7846. // Need to move cursor
  7847. if (this._clickedCoordinate) {
  7848. var rightPosition = this._scrollLeft + this._textWidth;
  7849. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7850. var currentSize = 0;
  7851. this._cursorOffset = 0;
  7852. var previousDist = 0;
  7853. do {
  7854. if (this._cursorOffset) {
  7855. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7856. }
  7857. this._cursorOffset++;
  7858. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7859. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7860. // Find closest move
  7861. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7862. this._cursorOffset--;
  7863. }
  7864. this._blinkIsEven = false;
  7865. this._clickedCoordinate = null;
  7866. }
  7867. // Render cursor
  7868. if (!this._blinkIsEven) {
  7869. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7870. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7871. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7872. if (cursorLeft < clipTextLeft) {
  7873. this._scrollLeft += (clipTextLeft - cursorLeft);
  7874. cursorLeft = clipTextLeft;
  7875. this._markAsDirty();
  7876. }
  7877. else if (cursorLeft > clipTextLeft + availableWidth) {
  7878. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7879. cursorLeft = clipTextLeft + availableWidth;
  7880. this._markAsDirty();
  7881. }
  7882. if (!this._isTextHighlightOn) {
  7883. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7884. }
  7885. }
  7886. clearTimeout(this._blinkTimeout);
  7887. this._blinkTimeout = setTimeout(function () {
  7888. _this._blinkIsEven = !_this._blinkIsEven;
  7889. _this._markAsDirty();
  7890. }, 500);
  7891. //show the highlighted text
  7892. if (this._isTextHighlightOn) {
  7893. clearTimeout(this._blinkTimeout);
  7894. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7895. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7896. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7897. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7898. if (highlightCursorLeft < clipTextLeft) {
  7899. width = width - (clipTextLeft - highlightCursorLeft);
  7900. if (!width) {
  7901. // when using left arrow on text.length > availableWidth;
  7902. // assigns the width of the first letter after clipTextLeft
  7903. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7904. }
  7905. highlightCursorLeft = clipTextLeft;
  7906. }
  7907. //for transparancy
  7908. context.globalAlpha = this._highligherOpacity;
  7909. context.fillStyle = this._textHighlightColor;
  7910. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7911. context.globalAlpha = 1.0;
  7912. }
  7913. }
  7914. context.restore();
  7915. // Border
  7916. if (this._thickness) {
  7917. if (this._isFocused) {
  7918. if (this.focusedColor) {
  7919. context.strokeStyle = this.focusedColor;
  7920. }
  7921. }
  7922. else {
  7923. if (this.color) {
  7924. context.strokeStyle = this.color;
  7925. }
  7926. }
  7927. context.lineWidth = this._thickness;
  7928. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7929. }
  7930. context.restore();
  7931. };
  7932. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7933. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7934. return false;
  7935. }
  7936. this._clickedCoordinate = coordinates.x;
  7937. this._isTextHighlightOn = false;
  7938. this._highlightedText = "";
  7939. this._cursorIndex = -1;
  7940. this._isPointerDown = true;
  7941. this._host._capturingControl[pointerId] = this;
  7942. if (this._host.focusedControl === this) {
  7943. // Move cursor
  7944. clearTimeout(this._blinkTimeout);
  7945. this._markAsDirty();
  7946. return true;
  7947. }
  7948. if (!this._isEnabled) {
  7949. return false;
  7950. }
  7951. this._host.focusedControl = this;
  7952. return true;
  7953. };
  7954. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7955. if (this._host.focusedControl === this && this._isPointerDown) {
  7956. this._clickedCoordinate = coordinates.x;
  7957. this._markAsDirty();
  7958. this._updateValueFromCursorIndex(this._cursorOffset);
  7959. }
  7960. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7961. };
  7962. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7963. this._isPointerDown = false;
  7964. delete this._host._capturingControl[pointerId];
  7965. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7966. };
  7967. InputText.prototype._beforeRenderText = function (text) {
  7968. return text;
  7969. };
  7970. InputText.prototype.dispose = function () {
  7971. _super.prototype.dispose.call(this);
  7972. this.onBlurObservable.clear();
  7973. this.onFocusObservable.clear();
  7974. this.onTextChangedObservable.clear();
  7975. this.onTextCopyObservable.clear();
  7976. this.onTextCutObservable.clear();
  7977. this.onTextPasteObservable.clear();
  7978. this.onTextHighlightObservable.clear();
  7979. this.onKeyboardEventProcessedObservable.clear();
  7980. };
  7981. return InputText;
  7982. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7983. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  7984. /***/ }),
  7985. /***/ "./2D/controls/line.ts":
  7986. /*!*****************************!*\
  7987. !*** ./2D/controls/line.ts ***!
  7988. \*****************************/
  7989. /*! exports provided: Line */
  7990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7991. "use strict";
  7992. __webpack_require__.r(__webpack_exports__);
  7993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7994. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7995. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  7996. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7997. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7998. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7999. /** Class used to render 2D lines */
  8000. var Line = /** @class */ (function (_super) {
  8001. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8002. /**
  8003. * Creates a new Line
  8004. * @param name defines the control name
  8005. */
  8006. function Line(name) {
  8007. var _this = _super.call(this, name) || this;
  8008. _this.name = name;
  8009. _this._lineWidth = 1;
  8010. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8011. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8012. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8013. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8014. _this._dash = new Array();
  8015. _this._automaticSize = true;
  8016. _this.isHitTestVisible = false;
  8017. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8018. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8019. return _this;
  8020. }
  8021. Object.defineProperty(Line.prototype, "dash", {
  8022. /** Gets or sets the dash pattern */
  8023. get: function () {
  8024. return this._dash;
  8025. },
  8026. set: function (value) {
  8027. if (this._dash === value) {
  8028. return;
  8029. }
  8030. this._dash = value;
  8031. this._markAsDirty();
  8032. },
  8033. enumerable: true,
  8034. configurable: true
  8035. });
  8036. Object.defineProperty(Line.prototype, "connectedControl", {
  8037. /** Gets or sets the control connected with the line end */
  8038. get: function () {
  8039. return this._connectedControl;
  8040. },
  8041. set: function (value) {
  8042. var _this = this;
  8043. if (this._connectedControl === value) {
  8044. return;
  8045. }
  8046. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8047. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8048. this._connectedControlDirtyObserver = null;
  8049. }
  8050. if (value) {
  8051. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8052. }
  8053. this._connectedControl = value;
  8054. this._markAsDirty();
  8055. },
  8056. enumerable: true,
  8057. configurable: true
  8058. });
  8059. Object.defineProperty(Line.prototype, "x1", {
  8060. /** Gets or sets start coordinates on X axis */
  8061. get: function () {
  8062. return this._x1.toString(this._host);
  8063. },
  8064. set: function (value) {
  8065. if (this._x1.toString(this._host) === value) {
  8066. return;
  8067. }
  8068. if (this._x1.fromString(value)) {
  8069. this._markAsDirty();
  8070. }
  8071. },
  8072. enumerable: true,
  8073. configurable: true
  8074. });
  8075. Object.defineProperty(Line.prototype, "y1", {
  8076. /** Gets or sets start coordinates on Y axis */
  8077. get: function () {
  8078. return this._y1.toString(this._host);
  8079. },
  8080. set: function (value) {
  8081. if (this._y1.toString(this._host) === value) {
  8082. return;
  8083. }
  8084. if (this._y1.fromString(value)) {
  8085. this._markAsDirty();
  8086. }
  8087. },
  8088. enumerable: true,
  8089. configurable: true
  8090. });
  8091. Object.defineProperty(Line.prototype, "x2", {
  8092. /** Gets or sets end coordinates on X axis */
  8093. get: function () {
  8094. return this._x2.toString(this._host);
  8095. },
  8096. set: function (value) {
  8097. if (this._x2.toString(this._host) === value) {
  8098. return;
  8099. }
  8100. if (this._x2.fromString(value)) {
  8101. this._markAsDirty();
  8102. }
  8103. },
  8104. enumerable: true,
  8105. configurable: true
  8106. });
  8107. Object.defineProperty(Line.prototype, "y2", {
  8108. /** Gets or sets end coordinates on Y axis */
  8109. get: function () {
  8110. return this._y2.toString(this._host);
  8111. },
  8112. set: function (value) {
  8113. if (this._y2.toString(this._host) === value) {
  8114. return;
  8115. }
  8116. if (this._y2.fromString(value)) {
  8117. this._markAsDirty();
  8118. }
  8119. },
  8120. enumerable: true,
  8121. configurable: true
  8122. });
  8123. Object.defineProperty(Line.prototype, "lineWidth", {
  8124. /** Gets or sets line width */
  8125. get: function () {
  8126. return this._lineWidth;
  8127. },
  8128. set: function (value) {
  8129. if (this._lineWidth === value) {
  8130. return;
  8131. }
  8132. this._lineWidth = value;
  8133. this._markAsDirty();
  8134. },
  8135. enumerable: true,
  8136. configurable: true
  8137. });
  8138. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8139. /** Gets or sets horizontal alignment */
  8140. set: function (value) {
  8141. return;
  8142. },
  8143. enumerable: true,
  8144. configurable: true
  8145. });
  8146. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8147. /** Gets or sets vertical alignment */
  8148. set: function (value) {
  8149. return;
  8150. },
  8151. enumerable: true,
  8152. configurable: true
  8153. });
  8154. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8155. get: function () {
  8156. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8157. },
  8158. enumerable: true,
  8159. configurable: true
  8160. });
  8161. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8162. get: function () {
  8163. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8164. },
  8165. enumerable: true,
  8166. configurable: true
  8167. });
  8168. Line.prototype._getTypeName = function () {
  8169. return "Line";
  8170. };
  8171. Line.prototype._draw = function (context) {
  8172. context.save();
  8173. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8174. context.shadowColor = this.shadowColor;
  8175. context.shadowBlur = this.shadowBlur;
  8176. context.shadowOffsetX = this.shadowOffsetX;
  8177. context.shadowOffsetY = this.shadowOffsetY;
  8178. }
  8179. this._applyStates(context);
  8180. context.strokeStyle = this.color;
  8181. context.lineWidth = this._lineWidth;
  8182. context.setLineDash(this._dash);
  8183. context.beginPath();
  8184. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8185. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8186. context.stroke();
  8187. context.restore();
  8188. };
  8189. Line.prototype._measure = function () {
  8190. // Width / Height
  8191. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8192. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8193. };
  8194. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8195. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8196. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8197. };
  8198. /**
  8199. * Move one end of the line given 3D cartesian coordinates.
  8200. * @param position Targeted world position
  8201. * @param scene Scene
  8202. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8203. */
  8204. Line.prototype.moveToVector3 = function (position, scene, end) {
  8205. if (end === void 0) { end = false; }
  8206. if (!this._host || this.parent !== this._host._rootContainer) {
  8207. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8208. return;
  8209. }
  8210. var globalViewport = this._host._getGlobalViewport(scene);
  8211. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8212. this._moveToProjectedPosition(projectedPosition, end);
  8213. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8214. this.notRenderable = true;
  8215. return;
  8216. }
  8217. this.notRenderable = false;
  8218. };
  8219. /**
  8220. * Move one end of the line to a position in screen absolute space.
  8221. * @param projectedPosition Position in screen absolute space (X, Y)
  8222. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8223. */
  8224. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8225. if (end === void 0) { end = false; }
  8226. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8227. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8228. if (end) {
  8229. this.x2 = x;
  8230. this.y2 = y;
  8231. this._x2.ignoreAdaptiveScaling = true;
  8232. this._y2.ignoreAdaptiveScaling = true;
  8233. }
  8234. else {
  8235. this.x1 = x;
  8236. this.y1 = y;
  8237. this._x1.ignoreAdaptiveScaling = true;
  8238. this._y1.ignoreAdaptiveScaling = true;
  8239. }
  8240. };
  8241. return Line;
  8242. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8243. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8244. /***/ }),
  8245. /***/ "./2D/controls/multiLine.ts":
  8246. /*!**********************************!*\
  8247. !*** ./2D/controls/multiLine.ts ***!
  8248. \**********************************/
  8249. /*! exports provided: MultiLine */
  8250. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8251. "use strict";
  8252. __webpack_require__.r(__webpack_exports__);
  8253. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8254. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8255. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/perfCounter");
  8256. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8257. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8258. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8259. /**
  8260. * Class used to create multi line control
  8261. */
  8262. var MultiLine = /** @class */ (function (_super) {
  8263. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8264. /**
  8265. * Creates a new MultiLine
  8266. * @param name defines the control name
  8267. */
  8268. function MultiLine(name) {
  8269. var _this = _super.call(this, name) || this;
  8270. _this.name = name;
  8271. _this._lineWidth = 1;
  8272. /** Function called when a point is updated */
  8273. _this.onPointUpdate = function () {
  8274. _this._markAsDirty();
  8275. };
  8276. _this._automaticSize = true;
  8277. _this.isHitTestVisible = false;
  8278. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8279. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8280. _this._dash = [];
  8281. _this._points = [];
  8282. return _this;
  8283. }
  8284. Object.defineProperty(MultiLine.prototype, "dash", {
  8285. /** Gets or sets dash pattern */
  8286. get: function () {
  8287. return this._dash;
  8288. },
  8289. set: function (value) {
  8290. if (this._dash === value) {
  8291. return;
  8292. }
  8293. this._dash = value;
  8294. this._markAsDirty();
  8295. },
  8296. enumerable: true,
  8297. configurable: true
  8298. });
  8299. /**
  8300. * Gets point stored at specified index
  8301. * @param index defines the index to look for
  8302. * @returns the requested point if found
  8303. */
  8304. MultiLine.prototype.getAt = function (index) {
  8305. if (!this._points[index]) {
  8306. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8307. }
  8308. return this._points[index];
  8309. };
  8310. /**
  8311. * Adds new points to the point collection
  8312. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8313. * @returns the list of created MultiLinePoint
  8314. */
  8315. MultiLine.prototype.add = function () {
  8316. var _this = this;
  8317. var items = [];
  8318. for (var _i = 0; _i < arguments.length; _i++) {
  8319. items[_i] = arguments[_i];
  8320. }
  8321. return items.map(function (item) { return _this.push(item); });
  8322. };
  8323. /**
  8324. * Adds a new point to the point collection
  8325. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8326. * @returns the created MultiLinePoint
  8327. */
  8328. MultiLine.prototype.push = function (item) {
  8329. var point = this.getAt(this._points.length);
  8330. if (item == null) {
  8331. return point;
  8332. }
  8333. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8334. point.mesh = item;
  8335. }
  8336. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8337. point.control = item;
  8338. }
  8339. else if (item.x != null && item.y != null) {
  8340. point.x = item.x;
  8341. point.y = item.y;
  8342. }
  8343. return point;
  8344. };
  8345. /**
  8346. * Remove a specific value or point from the active point collection
  8347. * @param value defines the value or point to remove
  8348. */
  8349. MultiLine.prototype.remove = function (value) {
  8350. var index;
  8351. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8352. index = this._points.indexOf(value);
  8353. if (index === -1) {
  8354. return;
  8355. }
  8356. }
  8357. else {
  8358. index = value;
  8359. }
  8360. var point = this._points[index];
  8361. if (!point) {
  8362. return;
  8363. }
  8364. point.dispose();
  8365. this._points.splice(index, 1);
  8366. };
  8367. /**
  8368. * Resets this object to initial state (no point)
  8369. */
  8370. MultiLine.prototype.reset = function () {
  8371. while (this._points.length > 0) {
  8372. this.remove(this._points.length - 1);
  8373. }
  8374. };
  8375. /**
  8376. * Resets all links
  8377. */
  8378. MultiLine.prototype.resetLinks = function () {
  8379. this._points.forEach(function (point) {
  8380. if (point != null) {
  8381. point.resetLinks();
  8382. }
  8383. });
  8384. };
  8385. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8386. /** Gets or sets line width */
  8387. get: function () {
  8388. return this._lineWidth;
  8389. },
  8390. set: function (value) {
  8391. if (this._lineWidth === value) {
  8392. return;
  8393. }
  8394. this._lineWidth = value;
  8395. this._markAsDirty();
  8396. },
  8397. enumerable: true,
  8398. configurable: true
  8399. });
  8400. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8401. set: function (value) {
  8402. return;
  8403. },
  8404. enumerable: true,
  8405. configurable: true
  8406. });
  8407. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8408. set: function (value) {
  8409. return;
  8410. },
  8411. enumerable: true,
  8412. configurable: true
  8413. });
  8414. MultiLine.prototype._getTypeName = function () {
  8415. return "MultiLine";
  8416. };
  8417. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8418. context.save();
  8419. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8420. context.shadowColor = this.shadowColor;
  8421. context.shadowBlur = this.shadowBlur;
  8422. context.shadowOffsetX = this.shadowOffsetX;
  8423. context.shadowOffsetY = this.shadowOffsetY;
  8424. }
  8425. this._applyStates(context);
  8426. context.strokeStyle = this.color;
  8427. context.lineWidth = this._lineWidth;
  8428. context.setLineDash(this._dash);
  8429. context.beginPath();
  8430. var first = true; //first index is not necessarily 0
  8431. this._points.forEach(function (point) {
  8432. if (!point) {
  8433. return;
  8434. }
  8435. if (first) {
  8436. context.moveTo(point._point.x, point._point.y);
  8437. first = false;
  8438. }
  8439. else {
  8440. context.lineTo(point._point.x, point._point.y);
  8441. }
  8442. });
  8443. context.stroke();
  8444. context.restore();
  8445. };
  8446. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8447. var _this = this;
  8448. this._minX = null;
  8449. this._minY = null;
  8450. this._maxX = null;
  8451. this._maxY = null;
  8452. this._points.forEach(function (point, index) {
  8453. if (!point) {
  8454. return;
  8455. }
  8456. point.translate();
  8457. if (_this._minX == null || point._point.x < _this._minX) {
  8458. _this._minX = point._point.x;
  8459. }
  8460. if (_this._minY == null || point._point.y < _this._minY) {
  8461. _this._minY = point._point.y;
  8462. }
  8463. if (_this._maxX == null || point._point.x > _this._maxX) {
  8464. _this._maxX = point._point.x;
  8465. }
  8466. if (_this._maxY == null || point._point.y > _this._maxY) {
  8467. _this._maxY = point._point.y;
  8468. }
  8469. });
  8470. if (this._minX == null) {
  8471. this._minX = 0;
  8472. }
  8473. if (this._minY == null) {
  8474. this._minY = 0;
  8475. }
  8476. if (this._maxX == null) {
  8477. this._maxX = 0;
  8478. }
  8479. if (this._maxY == null) {
  8480. this._maxY = 0;
  8481. }
  8482. };
  8483. MultiLine.prototype._measure = function () {
  8484. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8485. return;
  8486. }
  8487. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8488. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8489. };
  8490. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8491. if (this._minX == null || this._minY == null) {
  8492. return;
  8493. }
  8494. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8495. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8496. };
  8497. MultiLine.prototype.dispose = function () {
  8498. this.reset();
  8499. _super.prototype.dispose.call(this);
  8500. };
  8501. return MultiLine;
  8502. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8503. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8504. /***/ }),
  8505. /***/ "./2D/controls/radioButton.ts":
  8506. /*!************************************!*\
  8507. !*** ./2D/controls/radioButton.ts ***!
  8508. \************************************/
  8509. /*! exports provided: RadioButton */
  8510. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8511. "use strict";
  8512. __webpack_require__.r(__webpack_exports__);
  8513. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8514. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8515. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  8516. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8517. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8518. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8519. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8520. /**
  8521. * Class used to create radio button controls
  8522. */
  8523. var RadioButton = /** @class */ (function (_super) {
  8524. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8525. /**
  8526. * Creates a new RadioButton
  8527. * @param name defines the control name
  8528. */
  8529. function RadioButton(name) {
  8530. var _this = _super.call(this, name) || this;
  8531. _this.name = name;
  8532. _this._isChecked = false;
  8533. _this._background = "black";
  8534. _this._checkSizeRatio = 0.8;
  8535. _this._thickness = 1;
  8536. /** Gets or sets group name */
  8537. _this.group = "";
  8538. /** Observable raised when isChecked is changed */
  8539. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8540. _this.isPointerBlocker = true;
  8541. return _this;
  8542. }
  8543. Object.defineProperty(RadioButton.prototype, "thickness", {
  8544. /** Gets or sets border thickness */
  8545. get: function () {
  8546. return this._thickness;
  8547. },
  8548. set: function (value) {
  8549. if (this._thickness === value) {
  8550. return;
  8551. }
  8552. this._thickness = value;
  8553. this._markAsDirty();
  8554. },
  8555. enumerable: true,
  8556. configurable: true
  8557. });
  8558. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8559. /** Gets or sets a value indicating the ratio between overall size and check size */
  8560. get: function () {
  8561. return this._checkSizeRatio;
  8562. },
  8563. set: function (value) {
  8564. value = Math.max(Math.min(1, value), 0);
  8565. if (this._checkSizeRatio === value) {
  8566. return;
  8567. }
  8568. this._checkSizeRatio = value;
  8569. this._markAsDirty();
  8570. },
  8571. enumerable: true,
  8572. configurable: true
  8573. });
  8574. Object.defineProperty(RadioButton.prototype, "background", {
  8575. /** Gets or sets background color */
  8576. get: function () {
  8577. return this._background;
  8578. },
  8579. set: function (value) {
  8580. if (this._background === value) {
  8581. return;
  8582. }
  8583. this._background = value;
  8584. this._markAsDirty();
  8585. },
  8586. enumerable: true,
  8587. configurable: true
  8588. });
  8589. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8590. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8591. get: function () {
  8592. return this._isChecked;
  8593. },
  8594. set: function (value) {
  8595. var _this = this;
  8596. if (this._isChecked === value) {
  8597. return;
  8598. }
  8599. this._isChecked = value;
  8600. this._markAsDirty();
  8601. this.onIsCheckedChangedObservable.notifyObservers(value);
  8602. if (this._isChecked && this._host) {
  8603. // Update all controls from same group
  8604. this._host.executeOnAllControls(function (control) {
  8605. if (control === _this) {
  8606. return;
  8607. }
  8608. if (control.group === undefined) {
  8609. return;
  8610. }
  8611. var childRadio = control;
  8612. if (childRadio.group === _this.group) {
  8613. childRadio.isChecked = false;
  8614. }
  8615. });
  8616. }
  8617. },
  8618. enumerable: true,
  8619. configurable: true
  8620. });
  8621. RadioButton.prototype._getTypeName = function () {
  8622. return "RadioButton";
  8623. };
  8624. RadioButton.prototype._draw = function (context) {
  8625. context.save();
  8626. this._applyStates(context);
  8627. var actualWidth = this._currentMeasure.width - this._thickness;
  8628. var actualHeight = this._currentMeasure.height - this._thickness;
  8629. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8630. context.shadowColor = this.shadowColor;
  8631. context.shadowBlur = this.shadowBlur;
  8632. context.shadowOffsetX = this.shadowOffsetX;
  8633. context.shadowOffsetY = this.shadowOffsetY;
  8634. }
  8635. // Outer
  8636. _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);
  8637. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8638. context.fill();
  8639. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8640. context.shadowBlur = 0;
  8641. context.shadowOffsetX = 0;
  8642. context.shadowOffsetY = 0;
  8643. }
  8644. context.strokeStyle = this.color;
  8645. context.lineWidth = this._thickness;
  8646. context.stroke();
  8647. // Inner
  8648. if (this._isChecked) {
  8649. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8650. var offsetWidth = actualWidth * this._checkSizeRatio;
  8651. var offseHeight = actualHeight * this._checkSizeRatio;
  8652. _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);
  8653. context.fill();
  8654. }
  8655. context.restore();
  8656. };
  8657. // Events
  8658. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8659. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8660. return false;
  8661. }
  8662. if (!this.isChecked) {
  8663. this.isChecked = true;
  8664. }
  8665. return true;
  8666. };
  8667. /**
  8668. * Utility function to easily create a radio button with a header
  8669. * @param title defines the label to use for the header
  8670. * @param group defines the group to use for the radio button
  8671. * @param isChecked defines the initial state of the radio button
  8672. * @param onValueChanged defines the callback to call when value changes
  8673. * @returns a StackPanel containing the radio button and a textBlock
  8674. */
  8675. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8676. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8677. panel.isVertical = false;
  8678. panel.height = "30px";
  8679. var radio = new RadioButton();
  8680. radio.width = "20px";
  8681. radio.height = "20px";
  8682. radio.isChecked = isChecked;
  8683. radio.color = "green";
  8684. radio.group = group;
  8685. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8686. panel.addControl(radio);
  8687. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8688. header.text = title;
  8689. header.width = "180px";
  8690. header.paddingLeft = "5px";
  8691. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8692. header.color = "white";
  8693. panel.addControl(header);
  8694. return panel;
  8695. };
  8696. return RadioButton;
  8697. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8698. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8699. /***/ }),
  8700. /***/ "./2D/controls/rectangle.ts":
  8701. /*!**********************************!*\
  8702. !*** ./2D/controls/rectangle.ts ***!
  8703. \**********************************/
  8704. /*! exports provided: Rectangle */
  8705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8706. "use strict";
  8707. __webpack_require__.r(__webpack_exports__);
  8708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8709. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8710. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8711. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  8712. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8713. /** Class used to create rectangle container */
  8714. var Rectangle = /** @class */ (function (_super) {
  8715. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8716. /**
  8717. * Creates a new Rectangle
  8718. * @param name defines the control name
  8719. */
  8720. function Rectangle(name) {
  8721. var _this = _super.call(this, name) || this;
  8722. _this.name = name;
  8723. _this._thickness = 1;
  8724. _this._cornerRadius = 0;
  8725. return _this;
  8726. }
  8727. Object.defineProperty(Rectangle.prototype, "thickness", {
  8728. /** Gets or sets border thickness */
  8729. get: function () {
  8730. return this._thickness;
  8731. },
  8732. set: function (value) {
  8733. if (this._thickness === value) {
  8734. return;
  8735. }
  8736. this._thickness = value;
  8737. this._markAsDirty();
  8738. },
  8739. enumerable: true,
  8740. configurable: true
  8741. });
  8742. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8743. /** Gets or sets the corner radius angle */
  8744. get: function () {
  8745. return this._cornerRadius;
  8746. },
  8747. set: function (value) {
  8748. if (value < 0) {
  8749. value = 0;
  8750. }
  8751. if (this._cornerRadius === value) {
  8752. return;
  8753. }
  8754. this._cornerRadius = value;
  8755. this._markAsDirty();
  8756. },
  8757. enumerable: true,
  8758. configurable: true
  8759. });
  8760. Rectangle.prototype._getTypeName = function () {
  8761. return "Rectangle";
  8762. };
  8763. Rectangle.prototype._localDraw = function (context) {
  8764. context.save();
  8765. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8766. context.shadowColor = this.shadowColor;
  8767. context.shadowBlur = this.shadowBlur;
  8768. context.shadowOffsetX = this.shadowOffsetX;
  8769. context.shadowOffsetY = this.shadowOffsetY;
  8770. }
  8771. if (this._background) {
  8772. context.fillStyle = this._background;
  8773. if (this._cornerRadius) {
  8774. this._drawRoundedRect(context, this._thickness / 2);
  8775. context.fill();
  8776. }
  8777. else {
  8778. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8779. }
  8780. }
  8781. if (this._thickness) {
  8782. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8783. context.shadowBlur = 0;
  8784. context.shadowOffsetX = 0;
  8785. context.shadowOffsetY = 0;
  8786. }
  8787. if (this.color) {
  8788. context.strokeStyle = this.color;
  8789. }
  8790. context.lineWidth = this._thickness;
  8791. if (this._cornerRadius) {
  8792. this._drawRoundedRect(context, this._thickness / 2);
  8793. context.stroke();
  8794. }
  8795. else {
  8796. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8797. }
  8798. }
  8799. context.restore();
  8800. };
  8801. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8802. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8803. this._measureForChildren.width -= 2 * this._thickness;
  8804. this._measureForChildren.height -= 2 * this._thickness;
  8805. this._measureForChildren.left += this._thickness;
  8806. this._measureForChildren.top += this._thickness;
  8807. };
  8808. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8809. if (offset === void 0) { offset = 0; }
  8810. var x = this._currentMeasure.left + offset;
  8811. var y = this._currentMeasure.top + offset;
  8812. var width = this._currentMeasure.width - offset * 2;
  8813. var height = this._currentMeasure.height - offset * 2;
  8814. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8815. context.beginPath();
  8816. context.moveTo(x + radius, y);
  8817. context.lineTo(x + width - radius, y);
  8818. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8819. context.lineTo(x + width, y + height - radius);
  8820. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8821. context.lineTo(x + radius, y + height);
  8822. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8823. context.lineTo(x, y + radius);
  8824. context.quadraticCurveTo(x, y, x + radius, y);
  8825. context.closePath();
  8826. };
  8827. Rectangle.prototype._clipForChildren = function (context) {
  8828. if (this._cornerRadius) {
  8829. this._drawRoundedRect(context, this._thickness);
  8830. context.clip();
  8831. }
  8832. };
  8833. return Rectangle;
  8834. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8835. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  8836. /***/ }),
  8837. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8838. /*!***************************************************!*\
  8839. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8840. \***************************************************/
  8841. /*! exports provided: ScrollViewer */
  8842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8843. "use strict";
  8844. __webpack_require__.r(__webpack_exports__);
  8845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8846. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8847. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/perfCounter");
  8848. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8849. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8850. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8851. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8852. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8853. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8854. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  8855. /**
  8856. * Class used to hold a viewer window and sliders in a grid
  8857. */
  8858. var ScrollViewer = /** @class */ (function (_super) {
  8859. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  8860. /**
  8861. * Creates a new ScrollViewer
  8862. * @param name of ScrollViewer
  8863. */
  8864. function ScrollViewer(name, isImageBased) {
  8865. var _this = _super.call(this, name) || this;
  8866. _this._barSize = 20;
  8867. _this._pointerIsOver = false;
  8868. _this._wheelPrecision = 0.05;
  8869. _this._thumbLength = 0.5;
  8870. _this._thumbHeight = 1;
  8871. _this._barImageHeight = 1;
  8872. _this._forceHorizontalBar = false;
  8873. _this._forceVerticalBar = false;
  8874. _this._useImageBar = isImageBased ? isImageBased : false;
  8875. _this.onDirtyObservable.add(function () {
  8876. _this._horizontalBarSpace.color = _this.color;
  8877. _this._verticalBarSpace.color = _this.color;
  8878. _this._dragSpace.color = _this.color;
  8879. });
  8880. _this.onPointerEnterObservable.add(function () {
  8881. _this._pointerIsOver = true;
  8882. });
  8883. _this.onPointerOutObservable.add(function () {
  8884. _this._pointerIsOver = false;
  8885. });
  8886. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8887. if (_this._useImageBar) {
  8888. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__["ImageScrollBar"]();
  8889. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__["ImageScrollBar"]();
  8890. }
  8891. else {
  8892. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8893. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8894. }
  8895. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]("scrollViewer_window");
  8896. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8897. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8898. _this._grid.addColumnDefinition(1);
  8899. _this._grid.addColumnDefinition(0, true);
  8900. _this._grid.addRowDefinition(1);
  8901. _this._grid.addRowDefinition(0, true);
  8902. _super.prototype.addControl.call(_this, _this._grid);
  8903. _this._grid.addControl(_this._window, 0, 0);
  8904. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8905. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8906. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8907. _this._verticalBarSpace.thickness = 1;
  8908. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8909. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  8910. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8911. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8912. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8913. _this._horizontalBarSpace.thickness = 1;
  8914. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8915. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  8916. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8917. _this._dragSpace.thickness = 1;
  8918. _this._grid.addControl(_this._dragSpace, 1, 1);
  8919. // Colors
  8920. if (!_this._useImageBar) {
  8921. _this.barColor = "grey";
  8922. _this.barBackground = "transparent";
  8923. }
  8924. return _this;
  8925. }
  8926. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8927. /**
  8928. * Gets the horizontal scrollbar
  8929. */
  8930. get: function () {
  8931. return this._horizontalBar;
  8932. },
  8933. enumerable: true,
  8934. configurable: true
  8935. });
  8936. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8937. /**
  8938. * Gets the vertical scrollbar
  8939. */
  8940. get: function () {
  8941. return this._verticalBar;
  8942. },
  8943. enumerable: true,
  8944. configurable: true
  8945. });
  8946. /**
  8947. * Adds a new control to the current container
  8948. * @param control defines the control to add
  8949. * @returns the current container
  8950. */
  8951. ScrollViewer.prototype.addControl = function (control) {
  8952. if (!control) {
  8953. return this;
  8954. }
  8955. this._window.addControl(control);
  8956. return this;
  8957. };
  8958. /**
  8959. * Removes a control from the current container
  8960. * @param control defines the control to remove
  8961. * @returns the current container
  8962. */
  8963. ScrollViewer.prototype.removeControl = function (control) {
  8964. this._window.removeControl(control);
  8965. return this;
  8966. };
  8967. Object.defineProperty(ScrollViewer.prototype, "children", {
  8968. /** Gets the list of children */
  8969. get: function () {
  8970. return this._window.children;
  8971. },
  8972. enumerable: true,
  8973. configurable: true
  8974. });
  8975. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8976. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8977. var child = _a[_i];
  8978. child._markMatrixAsDirty();
  8979. }
  8980. };
  8981. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  8982. /**
  8983. * Freezes or unfreezes the controls in the window.
  8984. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  8985. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  8986. */
  8987. get: function () {
  8988. return this._window.freezeControls;
  8989. },
  8990. set: function (value) {
  8991. this._window.freezeControls = value;
  8992. },
  8993. enumerable: true,
  8994. configurable: true
  8995. });
  8996. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  8997. /** Gets the bucket width */
  8998. get: function () {
  8999. return this._window.bucketWidth;
  9000. },
  9001. enumerable: true,
  9002. configurable: true
  9003. });
  9004. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9005. /** Gets the bucket height */
  9006. get: function () {
  9007. return this._window.bucketHeight;
  9008. },
  9009. enumerable: true,
  9010. configurable: true
  9011. });
  9012. /**
  9013. * Sets the bucket sizes.
  9014. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9015. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9016. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9017. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9018. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9019. * used), that's why it is not enabled by default.
  9020. * @param width width of the bucket
  9021. * @param height height of the bucket
  9022. */
  9023. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9024. this._window.setBucketSizes(width, height);
  9025. };
  9026. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9027. /**
  9028. * Forces the horizontal scroll bar to be displayed
  9029. */
  9030. get: function () {
  9031. return this._forceHorizontalBar;
  9032. },
  9033. set: function (value) {
  9034. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9035. this._horizontalBar.isVisible = value;
  9036. this._forceHorizontalBar = value;
  9037. },
  9038. enumerable: true,
  9039. configurable: true
  9040. });
  9041. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9042. /**
  9043. * Forces the vertical scroll bar to be displayed
  9044. */
  9045. get: function () {
  9046. return this._forceVerticalBar;
  9047. },
  9048. set: function (value) {
  9049. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9050. this._verticalBar.isVisible = value;
  9051. this._forceVerticalBar = value;
  9052. },
  9053. enumerable: true,
  9054. configurable: true
  9055. });
  9056. /** Reset the scroll viewer window to initial size */
  9057. ScrollViewer.prototype.resetWindow = function () {
  9058. this._window.width = "100%";
  9059. this._window.height = "100%";
  9060. };
  9061. ScrollViewer.prototype._getTypeName = function () {
  9062. return "ScrollViewer";
  9063. };
  9064. ScrollViewer.prototype._buildClientSizes = function () {
  9065. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize : 0) - 2 * this.thickness;
  9066. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize : 0) - 2 * this.thickness;
  9067. this._clientWidth = this._window.parentClientWidth;
  9068. this._clientHeight = this._window.parentClientHeight;
  9069. };
  9070. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  9071. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9072. this._buildClientSizes();
  9073. };
  9074. ScrollViewer.prototype._postMeasure = function () {
  9075. _super.prototype._postMeasure.call(this);
  9076. this._updateScroller();
  9077. };
  9078. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  9079. /**
  9080. * Gets or sets the mouse wheel precision
  9081. * from 0 to 1 with a default value of 0.05
  9082. * */
  9083. get: function () {
  9084. return this._wheelPrecision;
  9085. },
  9086. set: function (value) {
  9087. if (this._wheelPrecision === value) {
  9088. return;
  9089. }
  9090. if (value < 0) {
  9091. value = 0;
  9092. }
  9093. if (value > 1) {
  9094. value = 1;
  9095. }
  9096. this._wheelPrecision = value;
  9097. },
  9098. enumerable: true,
  9099. configurable: true
  9100. });
  9101. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  9102. /** Gets or sets the scroll bar container background color */
  9103. get: function () {
  9104. return this._horizontalBarSpace.background;
  9105. },
  9106. set: function (color) {
  9107. if (this._horizontalBarSpace.background === color) {
  9108. return;
  9109. }
  9110. this._horizontalBarSpace.background = color;
  9111. this._verticalBarSpace.background = color;
  9112. },
  9113. enumerable: true,
  9114. configurable: true
  9115. });
  9116. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9117. /** Gets or sets the bar color */
  9118. get: function () {
  9119. return this._barColor;
  9120. },
  9121. set: function (color) {
  9122. if (this._barColor === color) {
  9123. return;
  9124. }
  9125. this._barColor = color;
  9126. this._horizontalBar.color = color;
  9127. this._verticalBar.color = color;
  9128. },
  9129. enumerable: true,
  9130. configurable: true
  9131. });
  9132. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9133. /** Gets or sets the bar image */
  9134. get: function () {
  9135. return this._barImage;
  9136. },
  9137. set: function (value) {
  9138. if (this._barImage === value) {
  9139. return;
  9140. }
  9141. this._barImage = value;
  9142. var hb = this._horizontalBar;
  9143. var vb = this._verticalBar;
  9144. hb.thumbImage = value;
  9145. vb.thumbImage = value;
  9146. },
  9147. enumerable: true,
  9148. configurable: true
  9149. });
  9150. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9151. /** Gets or sets the size of the bar */
  9152. get: function () {
  9153. return this._barSize;
  9154. },
  9155. set: function (value) {
  9156. if (this._barSize === value) {
  9157. return;
  9158. }
  9159. this._barSize = value;
  9160. this._markAsDirty();
  9161. if (this._horizontalBar.isVisible) {
  9162. this._grid.setRowDefinition(1, this._barSize, true);
  9163. }
  9164. if (this._verticalBar.isVisible) {
  9165. this._grid.setColumnDefinition(1, this._barSize, true);
  9166. }
  9167. },
  9168. enumerable: true,
  9169. configurable: true
  9170. });
  9171. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9172. /** Gets or sets the length of the thumb */
  9173. get: function () {
  9174. return this._thumbLength;
  9175. },
  9176. set: function (value) {
  9177. if (this._thumbLength === value) {
  9178. return;
  9179. }
  9180. if (value <= 0) {
  9181. value = 0.1;
  9182. }
  9183. if (value > 1) {
  9184. value = 1;
  9185. }
  9186. this._thumbLength = value;
  9187. var hb = this._horizontalBar;
  9188. var vb = this._verticalBar;
  9189. hb.thumbLength = value;
  9190. vb.thumbLength = value;
  9191. this._markAsDirty();
  9192. },
  9193. enumerable: true,
  9194. configurable: true
  9195. });
  9196. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9197. /** Gets or sets the height of the thumb */
  9198. get: function () {
  9199. return this._thumbHeight;
  9200. },
  9201. set: function (value) {
  9202. if (this._thumbHeight === value) {
  9203. return;
  9204. }
  9205. if (value <= 0) {
  9206. value = 0.1;
  9207. }
  9208. if (value > 1) {
  9209. value = 1;
  9210. }
  9211. this._thumbHeight = value;
  9212. var hb = this._horizontalBar;
  9213. var vb = this._verticalBar;
  9214. hb.thumbHeight = value;
  9215. vb.thumbHeight = value;
  9216. this._markAsDirty();
  9217. },
  9218. enumerable: true,
  9219. configurable: true
  9220. });
  9221. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9222. /** Gets or sets the height of the bar image */
  9223. get: function () {
  9224. return this._barImageHeight;
  9225. },
  9226. set: function (value) {
  9227. if (this._barImageHeight === value) {
  9228. return;
  9229. }
  9230. if (value <= 0) {
  9231. value = 0.1;
  9232. }
  9233. if (value > 1) {
  9234. value = 1;
  9235. }
  9236. this._barImageHeight = value;
  9237. var hb = this._horizontalBar;
  9238. var vb = this._verticalBar;
  9239. hb.barImageHeight = value;
  9240. vb.barImageHeight = value;
  9241. this._markAsDirty();
  9242. },
  9243. enumerable: true,
  9244. configurable: true
  9245. });
  9246. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9247. /** Gets or sets the bar background */
  9248. get: function () {
  9249. return this._barBackground;
  9250. },
  9251. set: function (color) {
  9252. if (this._barBackground === color) {
  9253. return;
  9254. }
  9255. this._barBackground = color;
  9256. var hb = this._horizontalBar;
  9257. var vb = this._verticalBar;
  9258. hb.background = color;
  9259. vb.background = color;
  9260. this._dragSpace.background = color;
  9261. },
  9262. enumerable: true,
  9263. configurable: true
  9264. });
  9265. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9266. /** Gets or sets the bar background image */
  9267. get: function () {
  9268. return this._barBackgroundImage;
  9269. },
  9270. set: function (value) {
  9271. if (this._barBackgroundImage === value) {
  9272. }
  9273. this._barBackgroundImage = value;
  9274. var hb = this._horizontalBar;
  9275. var vb = this._verticalBar;
  9276. hb.backgroundImage = value;
  9277. vb.backgroundImage = value;
  9278. },
  9279. enumerable: true,
  9280. configurable: true
  9281. });
  9282. ScrollViewer.prototype._setWindowPosition = function () {
  9283. var windowContentsWidth = this._window._currentMeasure.width;
  9284. var windowContentsHeight = this._window._currentMeasure.height;
  9285. var _endLeft = this._clientWidth - windowContentsWidth;
  9286. var _endTop = this._clientHeight - windowContentsHeight;
  9287. var newLeft = this._horizontalBar.value * _endLeft + "px";
  9288. var newTop = this._verticalBar.value * _endTop + "px";
  9289. if (newLeft !== this._window.left) {
  9290. this._window.left = newLeft;
  9291. if (!this.freezeControls) {
  9292. this._rebuildLayout = true;
  9293. }
  9294. }
  9295. if (newTop !== this._window.top) {
  9296. this._window.top = newTop;
  9297. if (!this.freezeControls) {
  9298. this._rebuildLayout = true;
  9299. }
  9300. }
  9301. };
  9302. /** @hidden */
  9303. ScrollViewer.prototype._updateScroller = function () {
  9304. var windowContentsWidth = this._window._currentMeasure.width;
  9305. var windowContentsHeight = this._window._currentMeasure.height;
  9306. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  9307. this._grid.setRowDefinition(1, 0, true);
  9308. this._horizontalBar.isVisible = false;
  9309. this._horizontalBar.value = 0;
  9310. this._rebuildLayout = true;
  9311. }
  9312. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  9313. this._grid.setRowDefinition(1, this._barSize, true);
  9314. this._horizontalBar.isVisible = true;
  9315. this._rebuildLayout = true;
  9316. }
  9317. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  9318. this._grid.setColumnDefinition(1, 0, true);
  9319. this._verticalBar.isVisible = false;
  9320. this._verticalBar.value = 0;
  9321. this._rebuildLayout = true;
  9322. }
  9323. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  9324. this._grid.setColumnDefinition(1, this._barSize, true);
  9325. this._verticalBar.isVisible = true;
  9326. this._rebuildLayout = true;
  9327. }
  9328. this._buildClientSizes();
  9329. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * this._clientWidth + "px";
  9330. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * this._clientHeight + "px";
  9331. };
  9332. ScrollViewer.prototype._link = function (host) {
  9333. _super.prototype._link.call(this, host);
  9334. this._attachWheel();
  9335. };
  9336. /** @hidden */
  9337. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9338. var _this = this;
  9339. barControl.paddingLeft = 0;
  9340. barControl.width = "100%";
  9341. barControl.height = "100%";
  9342. barControl.barOffset = 0;
  9343. barControl.value = 0;
  9344. barControl.maximum = 1;
  9345. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9346. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9347. barControl.isVertical = isVertical;
  9348. barControl.rotation = rotation;
  9349. barControl.isVisible = false;
  9350. barContainer.addControl(barControl);
  9351. barControl.onValueChangedObservable.add(function (value) {
  9352. _this._setWindowPosition();
  9353. });
  9354. };
  9355. /** @hidden */
  9356. ScrollViewer.prototype._attachWheel = function () {
  9357. var _this = this;
  9358. if (!this._host || this._onPointerObserver) {
  9359. return;
  9360. }
  9361. var scene = this._host.getScene();
  9362. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  9363. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  9364. return;
  9365. }
  9366. if (_this._verticalBar.isVisible == true) {
  9367. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  9368. _this._verticalBar.value -= _this._wheelPrecision;
  9369. }
  9370. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9371. _this._verticalBar.value += _this._wheelPrecision;
  9372. }
  9373. }
  9374. if (_this._horizontalBar.isVisible == true) {
  9375. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9376. _this._horizontalBar.value += _this._wheelPrecision;
  9377. }
  9378. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  9379. _this._horizontalBar.value -= _this._wheelPrecision;
  9380. }
  9381. }
  9382. });
  9383. };
  9384. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9385. if (!this.isHighlighted) {
  9386. return;
  9387. }
  9388. _super.prototype._renderHighlightSpecific.call(this, context);
  9389. this._grid._renderHighlightSpecific(context);
  9390. context.restore();
  9391. };
  9392. /** Releases associated resources */
  9393. ScrollViewer.prototype.dispose = function () {
  9394. var scene = this._host.getScene();
  9395. if (scene && this._onPointerObserver) {
  9396. scene.onPointerObservable.remove(this._onPointerObserver);
  9397. this._onPointerObserver = null;
  9398. }
  9399. _super.prototype.dispose.call(this);
  9400. };
  9401. return ScrollViewer;
  9402. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  9403. babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9404. /***/ }),
  9405. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9406. /*!*********************************************************!*\
  9407. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9408. \*********************************************************/
  9409. /*! exports provided: _ScrollViewerWindow */
  9410. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9411. "use strict";
  9412. __webpack_require__.r(__webpack_exports__);
  9413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9414. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9415. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9416. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9417. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9418. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9419. /**
  9420. * Class used to hold a the container for ScrollViewer
  9421. * @hidden
  9422. */
  9423. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9424. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9425. /**
  9426. * Creates a new ScrollViewerWindow
  9427. * @param name of ScrollViewerWindow
  9428. */
  9429. function _ScrollViewerWindow(name) {
  9430. var _this = _super.call(this, name) || this;
  9431. _this._freezeControls = false;
  9432. _this._bucketWidth = 0;
  9433. _this._bucketHeight = 0;
  9434. _this._buckets = {};
  9435. return _this;
  9436. }
  9437. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  9438. get: function () {
  9439. return this._freezeControls;
  9440. },
  9441. set: function (value) {
  9442. if (this._freezeControls === value) {
  9443. return;
  9444. }
  9445. // trigger a full normal layout calculation to be sure all children have their measures up to date
  9446. this._freezeControls = false;
  9447. var textureSize = this.host.getSize();
  9448. var renderWidth = textureSize.width;
  9449. var renderHeight = textureSize.height;
  9450. var context = this.host.getContext();
  9451. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  9452. this.host._numLayoutCalls = 0;
  9453. this.host._rootContainer._layout(measure, context);
  9454. // in freeze mode, prepare children measures accordingly
  9455. if (value) {
  9456. this._updateMeasures();
  9457. if (this._useBuckets()) {
  9458. this._makeBuckets();
  9459. }
  9460. }
  9461. this._freezeControls = value;
  9462. this.host.markAsDirty(); // redraw with the (new) current settings
  9463. },
  9464. enumerable: true,
  9465. configurable: true
  9466. });
  9467. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  9468. get: function () {
  9469. return this._bucketWidth;
  9470. },
  9471. enumerable: true,
  9472. configurable: true
  9473. });
  9474. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  9475. get: function () {
  9476. return this._bucketHeight;
  9477. },
  9478. enumerable: true,
  9479. configurable: true
  9480. });
  9481. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  9482. this._bucketWidth = width;
  9483. this._bucketHeight = height;
  9484. if (this._useBuckets()) {
  9485. if (this._freezeControls) {
  9486. this._makeBuckets();
  9487. }
  9488. }
  9489. else {
  9490. this._buckets = {};
  9491. }
  9492. };
  9493. _ScrollViewerWindow.prototype._useBuckets = function () {
  9494. return this._bucketWidth > 0 && this._bucketHeight > 0;
  9495. };
  9496. _ScrollViewerWindow.prototype._makeBuckets = function () {
  9497. this._buckets = {};
  9498. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  9499. this._dispatchInBuckets(this._children);
  9500. };
  9501. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  9502. for (var i = 0; i < children.length; ++i) {
  9503. var child = children[i];
  9504. 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);
  9505. while (bStartY <= bEndY) {
  9506. for (var x = bStartX; x <= bEndX; ++x) {
  9507. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9508. if (!lstc) {
  9509. lstc = [];
  9510. this._buckets[bucket] = lstc;
  9511. }
  9512. lstc.push(child);
  9513. }
  9514. bStartY++;
  9515. }
  9516. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9517. this._dispatchInBuckets(child._children);
  9518. }
  9519. }
  9520. };
  9521. // reset left and top measures for the window and all its children
  9522. _ScrollViewerWindow.prototype._updateMeasures = function () {
  9523. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9524. this._measureForChildren.left -= left;
  9525. this._measureForChildren.top -= top;
  9526. this._currentMeasure.left -= left;
  9527. this._currentMeasure.top -= top;
  9528. this._updateChildrenMeasures(this._children, left, top);
  9529. };
  9530. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  9531. for (var i = 0; i < children.length; ++i) {
  9532. var child = children[i];
  9533. child._currentMeasure.left -= left;
  9534. child._currentMeasure.top -= top;
  9535. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  9536. child._customData._origTop = child._currentMeasure.top;
  9537. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9538. this._updateChildrenMeasures(child._children, left, top);
  9539. }
  9540. }
  9541. };
  9542. _ScrollViewerWindow.prototype._getTypeName = function () {
  9543. return "ScrollViewerWindow";
  9544. };
  9545. /** @hidden */
  9546. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9547. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9548. this._parentMeasure = parentMeasure;
  9549. this._measureForChildren.left = this._currentMeasure.left;
  9550. this._measureForChildren.top = this._currentMeasure.top;
  9551. this._measureForChildren.width = parentMeasure.width;
  9552. this._measureForChildren.height = parentMeasure.height;
  9553. };
  9554. /** @hidden */
  9555. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  9556. if (this._freezeControls) {
  9557. this.invalidateRect(); // will trigger a redraw of the window
  9558. return false;
  9559. }
  9560. return _super.prototype._layout.call(this, parentMeasure, context);
  9561. };
  9562. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  9563. for (var i = 0; i < children.length; ++i) {
  9564. var child = children[i];
  9565. child._currentMeasure.left = child._customData._origLeft + left;
  9566. child._currentMeasure.top = child._customData._origTop + top;
  9567. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9568. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9569. this._scrollChildren(child._children, left, top);
  9570. }
  9571. }
  9572. };
  9573. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  9574. 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);
  9575. while (bStartY <= bEndY) {
  9576. for (var x = bStartX; x <= bEndX; ++x) {
  9577. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9578. if (lstc) {
  9579. for (var i = 0; i < lstc.length; ++i) {
  9580. var child = lstc[i];
  9581. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  9582. child._currentMeasure.top = child._customData._origTop + scrollTop;
  9583. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9584. }
  9585. }
  9586. }
  9587. bStartY++;
  9588. }
  9589. };
  9590. /** @hidden */
  9591. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  9592. if (!this._freezeControls) {
  9593. _super.prototype._draw.call(this, context, invalidatedRectangle);
  9594. return;
  9595. }
  9596. this._localDraw(context);
  9597. if (this.clipChildren) {
  9598. this._clipForChildren(context);
  9599. }
  9600. var left = this.leftInPixels, top = this.topInPixels;
  9601. if (this._useBuckets()) {
  9602. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  9603. this._scrollChildrenWithBuckets(left, top, left, top);
  9604. }
  9605. else {
  9606. this._scrollChildren(this._children, left, top);
  9607. }
  9608. this._oldLeft = left;
  9609. this._oldTop = top;
  9610. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9611. var child = _a[_i];
  9612. if (!child._intersectsRect(this._parentMeasure)) {
  9613. continue;
  9614. }
  9615. child._render(context, this._parentMeasure);
  9616. }
  9617. };
  9618. _ScrollViewerWindow.prototype._postMeasure = function () {
  9619. if (this._freezeControls) {
  9620. _super.prototype._postMeasure.call(this);
  9621. return;
  9622. }
  9623. var maxWidth = this.parentClientWidth;
  9624. var maxHeight = this.parentClientHeight;
  9625. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9626. var child = _a[_i];
  9627. if (!child.isVisible || child.notRenderable) {
  9628. continue;
  9629. }
  9630. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9631. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9632. }
  9633. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9634. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9635. }
  9636. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9637. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9638. }
  9639. if (this._currentMeasure.width !== maxWidth) {
  9640. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9641. this._currentMeasure.width = maxWidth;
  9642. this._rebuildLayout = true;
  9643. this._isDirty = true;
  9644. }
  9645. if (this._currentMeasure.height !== maxHeight) {
  9646. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9647. this._currentMeasure.height = maxHeight;
  9648. this._rebuildLayout = true;
  9649. this._isDirty = true;
  9650. }
  9651. _super.prototype._postMeasure.call(this);
  9652. };
  9653. return _ScrollViewerWindow;
  9654. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  9655. /***/ }),
  9656. /***/ "./2D/controls/selector.ts":
  9657. /*!*********************************!*\
  9658. !*** ./2D/controls/selector.ts ***!
  9659. \*********************************/
  9660. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9661. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9662. "use strict";
  9663. __webpack_require__.r(__webpack_exports__);
  9664. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9665. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9666. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9669. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9670. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9671. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9672. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9673. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9674. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9675. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9676. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9677. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9678. /** Class used to create a RadioGroup
  9679. * which contains groups of radio buttons
  9680. */
  9681. var SelectorGroup = /** @class */ (function () {
  9682. /**
  9683. * Creates a new SelectorGroup
  9684. * @param name of group, used as a group heading
  9685. */
  9686. function SelectorGroup(
  9687. /** name of SelectorGroup */
  9688. name) {
  9689. this.name = name;
  9690. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9691. this._selectors = new Array();
  9692. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9693. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9694. this._groupHeader = this._addGroupHeader(name);
  9695. }
  9696. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9697. /** Gets the groupPanel of the SelectorGroup */
  9698. get: function () {
  9699. return this._groupPanel;
  9700. },
  9701. enumerable: true,
  9702. configurable: true
  9703. });
  9704. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9705. /** Gets the selectors array */
  9706. get: function () {
  9707. return this._selectors;
  9708. },
  9709. enumerable: true,
  9710. configurable: true
  9711. });
  9712. Object.defineProperty(SelectorGroup.prototype, "header", {
  9713. /** Gets and sets the group header */
  9714. get: function () {
  9715. return this._groupHeader.text;
  9716. },
  9717. set: function (label) {
  9718. if (this._groupHeader.text === "label") {
  9719. return;
  9720. }
  9721. this._groupHeader.text = label;
  9722. },
  9723. enumerable: true,
  9724. configurable: true
  9725. });
  9726. /** @hidden */
  9727. SelectorGroup.prototype._addGroupHeader = function (text) {
  9728. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9729. groupHeading.width = 0.9;
  9730. groupHeading.height = "30px";
  9731. groupHeading.textWrapping = true;
  9732. groupHeading.color = "black";
  9733. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9734. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9735. groupHeading.left = "2px";
  9736. this._groupPanel.addControl(groupHeading);
  9737. return groupHeading;
  9738. };
  9739. /** @hidden*/
  9740. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9741. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9742. return;
  9743. }
  9744. return this._selectors[selectorNb];
  9745. };
  9746. /** Removes the selector at the given position
  9747. * @param selectorNb the position of the selector within the group
  9748. */
  9749. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9750. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9751. return;
  9752. }
  9753. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9754. this._selectors.splice(selectorNb, 1);
  9755. };
  9756. return SelectorGroup;
  9757. }());
  9758. /** Class used to create a CheckboxGroup
  9759. * which contains groups of checkbox buttons
  9760. */
  9761. var CheckboxGroup = /** @class */ (function (_super) {
  9762. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  9763. function CheckboxGroup() {
  9764. return _super !== null && _super.apply(this, arguments) || this;
  9765. }
  9766. /** Adds a checkbox as a control
  9767. * @param text is the label for the selector
  9768. * @param func is the function called when the Selector is checked
  9769. * @param checked is true when Selector is checked
  9770. */
  9771. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9772. if (func === void 0) { func = function (s) { }; }
  9773. if (checked === void 0) { checked = false; }
  9774. var checked = checked || false;
  9775. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9776. button.width = "20px";
  9777. button.height = "20px";
  9778. button.color = "#364249";
  9779. button.background = "#CCCCCC";
  9780. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9781. button.onIsCheckedChangedObservable.add(function (state) {
  9782. func(state);
  9783. });
  9784. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9785. _selector.height = "30px";
  9786. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9787. _selector.left = "4px";
  9788. this.groupPanel.addControl(_selector);
  9789. this.selectors.push(_selector);
  9790. button.isChecked = checked;
  9791. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9792. button.color = this.groupPanel.parent.parent.buttonColor;
  9793. button.background = this.groupPanel.parent.parent.buttonBackground;
  9794. }
  9795. };
  9796. /** @hidden */
  9797. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9798. this.selectors[selectorNb].children[1].text = label;
  9799. };
  9800. /** @hidden */
  9801. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9802. this.selectors[selectorNb].children[1].color = color;
  9803. };
  9804. /** @hidden */
  9805. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9806. this.selectors[selectorNb].children[0].color = color;
  9807. };
  9808. /** @hidden */
  9809. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9810. this.selectors[selectorNb].children[0].background = color;
  9811. };
  9812. return CheckboxGroup;
  9813. }(SelectorGroup));
  9814. /** Class used to create a RadioGroup
  9815. * which contains groups of radio buttons
  9816. */
  9817. var RadioGroup = /** @class */ (function (_super) {
  9818. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  9819. function RadioGroup() {
  9820. var _this = _super !== null && _super.apply(this, arguments) || this;
  9821. _this._selectNb = 0;
  9822. return _this;
  9823. }
  9824. /** Adds a radio button as a control
  9825. * @param label is the label for the selector
  9826. * @param func is the function called when the Selector is checked
  9827. * @param checked is true when Selector is checked
  9828. */
  9829. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9830. if (func === void 0) { func = function (n) { }; }
  9831. if (checked === void 0) { checked = false; }
  9832. var nb = this._selectNb++;
  9833. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9834. button.name = label;
  9835. button.width = "20px";
  9836. button.height = "20px";
  9837. button.color = "#364249";
  9838. button.background = "#CCCCCC";
  9839. button.group = this.name;
  9840. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9841. button.onIsCheckedChangedObservable.add(function (state) {
  9842. if (state) {
  9843. func(nb);
  9844. }
  9845. });
  9846. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9847. _selector.height = "30px";
  9848. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9849. _selector.left = "4px";
  9850. this.groupPanel.addControl(_selector);
  9851. this.selectors.push(_selector);
  9852. button.isChecked = checked;
  9853. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9854. button.color = this.groupPanel.parent.parent.buttonColor;
  9855. button.background = this.groupPanel.parent.parent.buttonBackground;
  9856. }
  9857. };
  9858. /** @hidden */
  9859. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9860. this.selectors[selectorNb].children[1].text = label;
  9861. };
  9862. /** @hidden */
  9863. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9864. this.selectors[selectorNb].children[1].color = color;
  9865. };
  9866. /** @hidden */
  9867. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9868. this.selectors[selectorNb].children[0].color = color;
  9869. };
  9870. /** @hidden */
  9871. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9872. this.selectors[selectorNb].children[0].background = color;
  9873. };
  9874. return RadioGroup;
  9875. }(SelectorGroup));
  9876. /** Class used to create a SliderGroup
  9877. * which contains groups of slider buttons
  9878. */
  9879. var SliderGroup = /** @class */ (function (_super) {
  9880. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  9881. function SliderGroup() {
  9882. return _super !== null && _super.apply(this, arguments) || this;
  9883. }
  9884. /**
  9885. * Adds a slider to the SelectorGroup
  9886. * @param label is the label for the SliderBar
  9887. * @param func is the function called when the Slider moves
  9888. * @param unit is a string describing the units used, eg degrees or metres
  9889. * @param min is the minimum value for the Slider
  9890. * @param max is the maximum value for the Slider
  9891. * @param value is the start value for the Slider between min and max
  9892. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9893. */
  9894. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9895. if (func === void 0) { func = function (v) { }; }
  9896. if (unit === void 0) { unit = "Units"; }
  9897. if (min === void 0) { min = 0; }
  9898. if (max === void 0) { max = 0; }
  9899. if (value === void 0) { value = 0; }
  9900. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9901. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9902. button.name = unit;
  9903. button.value = value;
  9904. button.minimum = min;
  9905. button.maximum = max;
  9906. button.width = 0.9;
  9907. button.height = "20px";
  9908. button.color = "#364249";
  9909. button.background = "#CCCCCC";
  9910. button.borderColor = "black";
  9911. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9912. button.left = "4px";
  9913. button.paddingBottom = "4px";
  9914. button.onValueChangedObservable.add(function (value) {
  9915. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9916. func(value);
  9917. });
  9918. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9919. _selector.height = "60px";
  9920. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9921. _selector.left = "4px";
  9922. _selector.children[0].name = label;
  9923. this.groupPanel.addControl(_selector);
  9924. this.selectors.push(_selector);
  9925. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9926. button.color = this.groupPanel.parent.parent.buttonColor;
  9927. button.background = this.groupPanel.parent.parent.buttonBackground;
  9928. }
  9929. };
  9930. /** @hidden */
  9931. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9932. this.selectors[selectorNb].children[0].name = label;
  9933. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9934. };
  9935. /** @hidden */
  9936. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9937. this.selectors[selectorNb].children[0].color = color;
  9938. };
  9939. /** @hidden */
  9940. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9941. this.selectors[selectorNb].children[1].color = color;
  9942. };
  9943. /** @hidden */
  9944. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9945. this.selectors[selectorNb].children[1].background = color;
  9946. };
  9947. return SliderGroup;
  9948. }(SelectorGroup));
  9949. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9950. * @see http://doc.babylonjs.com/how_to/selector
  9951. */
  9952. var SelectionPanel = /** @class */ (function (_super) {
  9953. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  9954. /**
  9955. * Creates a new SelectionPanel
  9956. * @param name of SelectionPanel
  9957. * @param groups is an array of SelectionGroups
  9958. */
  9959. function SelectionPanel(
  9960. /** name of SelectionPanel */
  9961. name,
  9962. /** an array of SelectionGroups */
  9963. groups) {
  9964. if (groups === void 0) { groups = []; }
  9965. var _this = _super.call(this, name) || this;
  9966. _this.name = name;
  9967. _this.groups = groups;
  9968. _this._buttonColor = "#364249";
  9969. _this._buttonBackground = "#CCCCCC";
  9970. _this._headerColor = "black";
  9971. _this._barColor = "white";
  9972. _this._barHeight = "2px";
  9973. _this._spacerHeight = "20px";
  9974. _this._bars = new Array();
  9975. _this._groups = groups;
  9976. _this.thickness = 2;
  9977. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9978. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9979. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9980. _this._panel.top = 5;
  9981. _this._panel.left = 5;
  9982. _this._panel.width = 0.95;
  9983. if (groups.length > 0) {
  9984. for (var i = 0; i < groups.length - 1; i++) {
  9985. _this._panel.addControl(groups[i].groupPanel);
  9986. _this._addSpacer();
  9987. }
  9988. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9989. }
  9990. _this.addControl(_this._panel);
  9991. return _this;
  9992. }
  9993. SelectionPanel.prototype._getTypeName = function () {
  9994. return "SelectionPanel";
  9995. };
  9996. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9997. /** Gets or sets the headerColor */
  9998. get: function () {
  9999. return this._headerColor;
  10000. },
  10001. set: function (color) {
  10002. if (this._headerColor === color) {
  10003. return;
  10004. }
  10005. this._headerColor = color;
  10006. this._setHeaderColor();
  10007. },
  10008. enumerable: true,
  10009. configurable: true
  10010. });
  10011. SelectionPanel.prototype._setHeaderColor = function () {
  10012. for (var i = 0; i < this._groups.length; i++) {
  10013. this._groups[i].groupPanel.children[0].color = this._headerColor;
  10014. }
  10015. };
  10016. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  10017. /** Gets or sets the button color */
  10018. get: function () {
  10019. return this._buttonColor;
  10020. },
  10021. set: function (color) {
  10022. if (this._buttonColor === color) {
  10023. return;
  10024. }
  10025. this._buttonColor = color;
  10026. this._setbuttonColor();
  10027. },
  10028. enumerable: true,
  10029. configurable: true
  10030. });
  10031. SelectionPanel.prototype._setbuttonColor = function () {
  10032. for (var i = 0; i < this._groups.length; i++) {
  10033. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10034. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  10035. }
  10036. }
  10037. };
  10038. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  10039. /** Gets or sets the label color */
  10040. get: function () {
  10041. return this._labelColor;
  10042. },
  10043. set: function (color) {
  10044. if (this._labelColor === color) {
  10045. return;
  10046. }
  10047. this._labelColor = color;
  10048. this._setLabelColor();
  10049. },
  10050. enumerable: true,
  10051. configurable: true
  10052. });
  10053. SelectionPanel.prototype._setLabelColor = function () {
  10054. for (var i = 0; i < this._groups.length; i++) {
  10055. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10056. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  10057. }
  10058. }
  10059. };
  10060. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  10061. /** Gets or sets the button background */
  10062. get: function () {
  10063. return this._buttonBackground;
  10064. },
  10065. set: function (color) {
  10066. if (this._buttonBackground === color) {
  10067. return;
  10068. }
  10069. this._buttonBackground = color;
  10070. this._setButtonBackground();
  10071. },
  10072. enumerable: true,
  10073. configurable: true
  10074. });
  10075. SelectionPanel.prototype._setButtonBackground = function () {
  10076. for (var i = 0; i < this._groups.length; i++) {
  10077. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10078. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  10079. }
  10080. }
  10081. };
  10082. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  10083. /** Gets or sets the color of separator bar */
  10084. get: function () {
  10085. return this._barColor;
  10086. },
  10087. set: function (color) {
  10088. if (this._barColor === color) {
  10089. return;
  10090. }
  10091. this._barColor = color;
  10092. this._setBarColor();
  10093. },
  10094. enumerable: true,
  10095. configurable: true
  10096. });
  10097. SelectionPanel.prototype._setBarColor = function () {
  10098. for (var i = 0; i < this._bars.length; i++) {
  10099. this._bars[i].children[0].background = this._barColor;
  10100. }
  10101. };
  10102. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  10103. /** Gets or sets the height of separator bar */
  10104. get: function () {
  10105. return this._barHeight;
  10106. },
  10107. set: function (value) {
  10108. if (this._barHeight === value) {
  10109. return;
  10110. }
  10111. this._barHeight = value;
  10112. this._setBarHeight();
  10113. },
  10114. enumerable: true,
  10115. configurable: true
  10116. });
  10117. SelectionPanel.prototype._setBarHeight = function () {
  10118. for (var i = 0; i < this._bars.length; i++) {
  10119. this._bars[i].children[0].height = this._barHeight;
  10120. }
  10121. };
  10122. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  10123. /** Gets or sets the height of spacers*/
  10124. get: function () {
  10125. return this._spacerHeight;
  10126. },
  10127. set: function (value) {
  10128. if (this._spacerHeight === value) {
  10129. return;
  10130. }
  10131. this._spacerHeight = value;
  10132. this._setSpacerHeight();
  10133. },
  10134. enumerable: true,
  10135. configurable: true
  10136. });
  10137. SelectionPanel.prototype._setSpacerHeight = function () {
  10138. for (var i = 0; i < this._bars.length; i++) {
  10139. this._bars[i].height = this._spacerHeight;
  10140. }
  10141. };
  10142. /** Adds a bar between groups */
  10143. SelectionPanel.prototype._addSpacer = function () {
  10144. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  10145. separator.width = 1;
  10146. separator.height = this._spacerHeight;
  10147. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10148. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  10149. bar.width = 1;
  10150. bar.height = this._barHeight;
  10151. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10152. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10153. bar.background = this._barColor;
  10154. bar.color = "transparent";
  10155. separator.addControl(bar);
  10156. this._panel.addControl(separator);
  10157. this._bars.push(separator);
  10158. };
  10159. /** Add a group to the selection panel
  10160. * @param group is the selector group to add
  10161. */
  10162. SelectionPanel.prototype.addGroup = function (group) {
  10163. if (this._groups.length > 0) {
  10164. this._addSpacer();
  10165. }
  10166. this._panel.addControl(group.groupPanel);
  10167. this._groups.push(group);
  10168. group.groupPanel.children[0].color = this._headerColor;
  10169. for (var j = 0; j < group.selectors.length; j++) {
  10170. group._setSelectorButtonColor(j, this._buttonColor);
  10171. group._setSelectorButtonBackground(j, this._buttonBackground);
  10172. }
  10173. };
  10174. /** Remove the group from the given position
  10175. * @param groupNb is the position of the group in the list
  10176. */
  10177. SelectionPanel.prototype.removeGroup = function (groupNb) {
  10178. if (groupNb < 0 || groupNb >= this._groups.length) {
  10179. return;
  10180. }
  10181. var group = this._groups[groupNb];
  10182. this._panel.removeControl(group.groupPanel);
  10183. this._groups.splice(groupNb, 1);
  10184. if (groupNb < this._bars.length) {
  10185. this._panel.removeControl(this._bars[groupNb]);
  10186. this._bars.splice(groupNb, 1);
  10187. }
  10188. };
  10189. /** Change a group header label
  10190. * @param label is the new group header label
  10191. * @param groupNb is the number of the group to relabel
  10192. * */
  10193. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  10194. if (groupNb < 0 || groupNb >= this._groups.length) {
  10195. return;
  10196. }
  10197. var group = this._groups[groupNb];
  10198. group.groupPanel.children[0].text = label;
  10199. };
  10200. /** Change selector label to the one given
  10201. * @param label is the new selector label
  10202. * @param groupNb is the number of the groupcontaining the selector
  10203. * @param selectorNb is the number of the selector within a group to relabel
  10204. * */
  10205. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  10206. if (groupNb < 0 || groupNb >= this._groups.length) {
  10207. return;
  10208. }
  10209. var group = this._groups[groupNb];
  10210. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10211. return;
  10212. }
  10213. group._setSelectorLabel(selectorNb, label);
  10214. };
  10215. /** For a given group position remove the selector at the given position
  10216. * @param groupNb is the number of the group to remove the selector from
  10217. * @param selectorNb is the number of the selector within the group
  10218. */
  10219. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  10220. if (groupNb < 0 || groupNb >= this._groups.length) {
  10221. return;
  10222. }
  10223. var group = this._groups[groupNb];
  10224. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10225. return;
  10226. }
  10227. group.removeSelector(selectorNb);
  10228. };
  10229. /** For a given group position of correct type add a checkbox button
  10230. * @param groupNb is the number of the group to remove the selector from
  10231. * @param label is the label for the selector
  10232. * @param func is the function called when the Selector is checked
  10233. * @param checked is true when Selector is checked
  10234. */
  10235. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  10236. if (func === void 0) { func = function () { }; }
  10237. if (checked === void 0) { checked = false; }
  10238. if (groupNb < 0 || groupNb >= this._groups.length) {
  10239. return;
  10240. }
  10241. var group = this._groups[groupNb];
  10242. group.addCheckbox(label, func, checked);
  10243. };
  10244. /** For a given group position of correct type add a radio button
  10245. * @param groupNb is the number of the group to remove the selector from
  10246. * @param label is the label for the selector
  10247. * @param func is the function called when the Selector is checked
  10248. * @param checked is true when Selector is checked
  10249. */
  10250. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  10251. if (func === void 0) { func = function () { }; }
  10252. if (checked === void 0) { checked = false; }
  10253. if (groupNb < 0 || groupNb >= this._groups.length) {
  10254. return;
  10255. }
  10256. var group = this._groups[groupNb];
  10257. group.addRadio(label, func, checked);
  10258. };
  10259. /**
  10260. * For a given slider group add a slider
  10261. * @param groupNb is the number of the group to add the slider to
  10262. * @param label is the label for the Slider
  10263. * @param func is the function called when the Slider moves
  10264. * @param unit is a string describing the units used, eg degrees or metres
  10265. * @param min is the minimum value for the Slider
  10266. * @param max is the maximum value for the Slider
  10267. * @param value is the start value for the Slider between min and max
  10268. * @param onVal is the function used to format the value displayed, eg radians to degrees
  10269. */
  10270. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  10271. if (func === void 0) { func = function () { }; }
  10272. if (unit === void 0) { unit = "Units"; }
  10273. if (min === void 0) { min = 0; }
  10274. if (max === void 0) { max = 0; }
  10275. if (value === void 0) { value = 0; }
  10276. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  10277. if (groupNb < 0 || groupNb >= this._groups.length) {
  10278. return;
  10279. }
  10280. var group = this._groups[groupNb];
  10281. group.addSlider(label, func, unit, min, max, value, onVal);
  10282. };
  10283. return SelectionPanel;
  10284. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10285. /***/ }),
  10286. /***/ "./2D/controls/sliders/baseSlider.ts":
  10287. /*!*******************************************!*\
  10288. !*** ./2D/controls/sliders/baseSlider.ts ***!
  10289. \*******************************************/
  10290. /*! exports provided: BaseSlider */
  10291. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10292. "use strict";
  10293. __webpack_require__.r(__webpack_exports__);
  10294. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  10295. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10296. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  10297. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10298. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10299. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10300. /**
  10301. * Class used to create slider controls
  10302. */
  10303. var BaseSlider = /** @class */ (function (_super) {
  10304. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  10305. /**
  10306. * Creates a new BaseSlider
  10307. * @param name defines the control name
  10308. */
  10309. function BaseSlider(name) {
  10310. var _this = _super.call(this, name) || this;
  10311. _this.name = name;
  10312. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10313. _this._minimum = 0;
  10314. _this._maximum = 100;
  10315. _this._value = 50;
  10316. _this._isVertical = false;
  10317. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10318. _this._isThumbClamped = false;
  10319. _this._displayThumb = true;
  10320. _this._step = 0;
  10321. _this._lastPointerDownID = -1;
  10322. // Shared rendering info
  10323. _this._effectiveBarOffset = 0;
  10324. /** Observable raised when the sldier value changes */
  10325. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10326. // Events
  10327. _this._pointerIsDown = false;
  10328. _this.isPointerBlocker = true;
  10329. return _this;
  10330. }
  10331. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10332. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10333. get: function () {
  10334. return this._displayThumb;
  10335. },
  10336. set: function (value) {
  10337. if (this._displayThumb === value) {
  10338. return;
  10339. }
  10340. this._displayThumb = value;
  10341. this._markAsDirty();
  10342. },
  10343. enumerable: true,
  10344. configurable: true
  10345. });
  10346. Object.defineProperty(BaseSlider.prototype, "step", {
  10347. /** Gets or sets a step to apply to values (0 by default) */
  10348. get: function () {
  10349. return this._step;
  10350. },
  10351. set: function (value) {
  10352. if (this._step === value) {
  10353. return;
  10354. }
  10355. this._step = value;
  10356. this._markAsDirty();
  10357. },
  10358. enumerable: true,
  10359. configurable: true
  10360. });
  10361. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10362. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10363. get: function () {
  10364. return this._barOffset.toString(this._host);
  10365. },
  10366. set: function (value) {
  10367. if (this._barOffset.toString(this._host) === value) {
  10368. return;
  10369. }
  10370. if (this._barOffset.fromString(value)) {
  10371. this._markAsDirty();
  10372. }
  10373. },
  10374. enumerable: true,
  10375. configurable: true
  10376. });
  10377. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10378. /** Gets main bar offset in pixels*/
  10379. get: function () {
  10380. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10381. },
  10382. enumerable: true,
  10383. configurable: true
  10384. });
  10385. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10386. /** Gets or sets thumb width */
  10387. get: function () {
  10388. return this._thumbWidth.toString(this._host);
  10389. },
  10390. set: function (value) {
  10391. if (this._thumbWidth.toString(this._host) === value) {
  10392. return;
  10393. }
  10394. if (this._thumbWidth.fromString(value)) {
  10395. this._markAsDirty();
  10396. }
  10397. },
  10398. enumerable: true,
  10399. configurable: true
  10400. });
  10401. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10402. /** Gets thumb width in pixels */
  10403. get: function () {
  10404. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10405. },
  10406. enumerable: true,
  10407. configurable: true
  10408. });
  10409. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10410. /** Gets or sets minimum value */
  10411. get: function () {
  10412. return this._minimum;
  10413. },
  10414. set: function (value) {
  10415. if (this._minimum === value) {
  10416. return;
  10417. }
  10418. this._minimum = value;
  10419. this._markAsDirty();
  10420. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10421. },
  10422. enumerable: true,
  10423. configurable: true
  10424. });
  10425. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10426. /** Gets or sets maximum value */
  10427. get: function () {
  10428. return this._maximum;
  10429. },
  10430. set: function (value) {
  10431. if (this._maximum === value) {
  10432. return;
  10433. }
  10434. this._maximum = value;
  10435. this._markAsDirty();
  10436. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10437. },
  10438. enumerable: true,
  10439. configurable: true
  10440. });
  10441. Object.defineProperty(BaseSlider.prototype, "value", {
  10442. /** Gets or sets current value */
  10443. get: function () {
  10444. return this._value;
  10445. },
  10446. set: function (value) {
  10447. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10448. if (this._value === value) {
  10449. return;
  10450. }
  10451. this._value = value;
  10452. this._markAsDirty();
  10453. this.onValueChangedObservable.notifyObservers(this._value);
  10454. },
  10455. enumerable: true,
  10456. configurable: true
  10457. });
  10458. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10459. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10460. get: function () {
  10461. return this._isVertical;
  10462. },
  10463. set: function (value) {
  10464. if (this._isVertical === value) {
  10465. return;
  10466. }
  10467. this._isVertical = value;
  10468. this._markAsDirty();
  10469. },
  10470. enumerable: true,
  10471. configurable: true
  10472. });
  10473. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10474. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10475. get: function () {
  10476. return this._isThumbClamped;
  10477. },
  10478. set: function (value) {
  10479. if (this._isThumbClamped === value) {
  10480. return;
  10481. }
  10482. this._isThumbClamped = value;
  10483. this._markAsDirty();
  10484. },
  10485. enumerable: true,
  10486. configurable: true
  10487. });
  10488. BaseSlider.prototype._getTypeName = function () {
  10489. return "BaseSlider";
  10490. };
  10491. BaseSlider.prototype._getThumbPosition = function () {
  10492. if (this.isVertical) {
  10493. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10494. }
  10495. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10496. };
  10497. BaseSlider.prototype._getThumbThickness = function (type) {
  10498. var thumbThickness = 0;
  10499. switch (type) {
  10500. case "circle":
  10501. if (this._thumbWidth.isPixel) {
  10502. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10503. }
  10504. else {
  10505. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10506. }
  10507. break;
  10508. case "rectangle":
  10509. if (this._thumbWidth.isPixel) {
  10510. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10511. }
  10512. else {
  10513. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10514. }
  10515. }
  10516. return thumbThickness;
  10517. };
  10518. BaseSlider.prototype._prepareRenderingData = function (type) {
  10519. // Main bar
  10520. this._effectiveBarOffset = 0;
  10521. this._renderLeft = this._currentMeasure.left;
  10522. this._renderTop = this._currentMeasure.top;
  10523. this._renderWidth = this._currentMeasure.width;
  10524. this._renderHeight = this._currentMeasure.height;
  10525. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10526. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10527. this._effectiveThumbThickness = this._getThumbThickness(type);
  10528. if (this.displayThumb) {
  10529. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10530. }
  10531. //throw error when height is less than width for vertical slider
  10532. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10533. console.error("Height should be greater than width");
  10534. return;
  10535. }
  10536. if (this._barOffset.isPixel) {
  10537. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10538. }
  10539. else {
  10540. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10541. }
  10542. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10543. if (this.isVertical) {
  10544. this._renderLeft += this._effectiveBarOffset;
  10545. if (!this.isThumbClamped && this.displayThumb) {
  10546. this._renderTop += (this._effectiveThumbThickness / 2);
  10547. }
  10548. this._renderHeight = this._backgroundBoxLength;
  10549. this._renderWidth = this._backgroundBoxThickness;
  10550. }
  10551. else {
  10552. this._renderTop += this._effectiveBarOffset;
  10553. if (!this.isThumbClamped && this.displayThumb) {
  10554. this._renderLeft += (this._effectiveThumbThickness / 2);
  10555. }
  10556. this._renderHeight = this._backgroundBoxThickness;
  10557. this._renderWidth = this._backgroundBoxLength;
  10558. }
  10559. };
  10560. /** @hidden */
  10561. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10562. if (this.rotation != 0) {
  10563. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10564. x = this._transformedPosition.x;
  10565. y = this._transformedPosition.y;
  10566. }
  10567. var value;
  10568. if (this._isVertical) {
  10569. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10570. }
  10571. else {
  10572. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10573. }
  10574. var mult = (1 / this._step) | 0;
  10575. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10576. };
  10577. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10578. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10579. return false;
  10580. }
  10581. this._pointerIsDown = true;
  10582. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10583. this._host._capturingControl[pointerId] = this;
  10584. this._lastPointerDownID = pointerId;
  10585. return true;
  10586. };
  10587. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10588. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10589. if (pointerId != this._lastPointerDownID) {
  10590. return;
  10591. }
  10592. if (this._pointerIsDown) {
  10593. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10594. }
  10595. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10596. };
  10597. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10598. this._pointerIsDown = false;
  10599. delete this._host._capturingControl[pointerId];
  10600. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10601. };
  10602. return BaseSlider;
  10603. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10604. /***/ }),
  10605. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10606. /*!*************************************************!*\
  10607. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10608. \*************************************************/
  10609. /*! exports provided: ImageBasedSlider */
  10610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10611. "use strict";
  10612. __webpack_require__.r(__webpack_exports__);
  10613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10614. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10615. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10616. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10617. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  10618. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10619. /**
  10620. * Class used to create slider controls based on images
  10621. */
  10622. var ImageBasedSlider = /** @class */ (function (_super) {
  10623. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  10624. /**
  10625. * Creates a new ImageBasedSlider
  10626. * @param name defines the control name
  10627. */
  10628. function ImageBasedSlider(name) {
  10629. var _this = _super.call(this, name) || this;
  10630. _this.name = name;
  10631. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10632. return _this;
  10633. }
  10634. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10635. get: function () {
  10636. return this._displayThumb && this.thumbImage != null;
  10637. },
  10638. set: function (value) {
  10639. if (this._displayThumb === value) {
  10640. return;
  10641. }
  10642. this._displayThumb = value;
  10643. this._markAsDirty();
  10644. },
  10645. enumerable: true,
  10646. configurable: true
  10647. });
  10648. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10649. /**
  10650. * Gets or sets the image used to render the background
  10651. */
  10652. get: function () {
  10653. return this._backgroundImage;
  10654. },
  10655. set: function (value) {
  10656. var _this = this;
  10657. if (this._backgroundImage === value) {
  10658. return;
  10659. }
  10660. this._backgroundImage = value;
  10661. if (value && !value.isLoaded) {
  10662. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10663. }
  10664. this._markAsDirty();
  10665. },
  10666. enumerable: true,
  10667. configurable: true
  10668. });
  10669. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10670. /**
  10671. * Gets or sets the image used to render the value bar
  10672. */
  10673. get: function () {
  10674. return this._valueBarImage;
  10675. },
  10676. set: function (value) {
  10677. var _this = this;
  10678. if (this._valueBarImage === value) {
  10679. return;
  10680. }
  10681. this._valueBarImage = value;
  10682. if (value && !value.isLoaded) {
  10683. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10684. }
  10685. this._markAsDirty();
  10686. },
  10687. enumerable: true,
  10688. configurable: true
  10689. });
  10690. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10691. /**
  10692. * Gets or sets the image used to render the thumb
  10693. */
  10694. get: function () {
  10695. return this._thumbImage;
  10696. },
  10697. set: function (value) {
  10698. var _this = this;
  10699. if (this._thumbImage === value) {
  10700. return;
  10701. }
  10702. this._thumbImage = value;
  10703. if (value && !value.isLoaded) {
  10704. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10705. }
  10706. this._markAsDirty();
  10707. },
  10708. enumerable: true,
  10709. configurable: true
  10710. });
  10711. ImageBasedSlider.prototype._getTypeName = function () {
  10712. return "ImageBasedSlider";
  10713. };
  10714. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  10715. context.save();
  10716. this._applyStates(context);
  10717. this._prepareRenderingData("rectangle");
  10718. var thumbPosition = this._getThumbPosition();
  10719. var left = this._renderLeft;
  10720. var top = this._renderTop;
  10721. var width = this._renderWidth;
  10722. var height = this._renderHeight;
  10723. // Background
  10724. if (this._backgroundImage) {
  10725. this._tempMeasure.copyFromFloats(left, top, width, height);
  10726. if (this.isThumbClamped && this.displayThumb) {
  10727. if (this.isVertical) {
  10728. this._tempMeasure.height += this._effectiveThumbThickness;
  10729. }
  10730. else {
  10731. this._tempMeasure.width += this._effectiveThumbThickness;
  10732. }
  10733. }
  10734. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10735. this._backgroundImage._draw(context);
  10736. }
  10737. // Bar
  10738. if (this._valueBarImage) {
  10739. if (this.isVertical) {
  10740. if (this.isThumbClamped && this.displayThumb) {
  10741. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10742. }
  10743. else {
  10744. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10745. }
  10746. }
  10747. else {
  10748. if (this.isThumbClamped && this.displayThumb) {
  10749. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10750. }
  10751. else {
  10752. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10753. }
  10754. }
  10755. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10756. this._valueBarImage._draw(context);
  10757. }
  10758. // Thumb
  10759. if (this.displayThumb) {
  10760. if (this.isVertical) {
  10761. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10762. }
  10763. else {
  10764. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10765. }
  10766. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10767. this._thumbImage._draw(context);
  10768. }
  10769. context.restore();
  10770. };
  10771. return ImageBasedSlider;
  10772. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10773. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  10774. /***/ }),
  10775. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  10776. /*!***********************************************!*\
  10777. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  10778. \***********************************************/
  10779. /*! exports provided: ImageScrollBar */
  10780. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10781. "use strict";
  10782. __webpack_require__.r(__webpack_exports__);
  10783. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  10784. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10785. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10786. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10787. /**
  10788. * Class used to create slider controls
  10789. */
  10790. var ImageScrollBar = /** @class */ (function (_super) {
  10791. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  10792. /**
  10793. * Creates a new ImageScrollBar
  10794. * @param name defines the control name
  10795. */
  10796. function ImageScrollBar(name) {
  10797. var _this = _super.call(this, name) || this;
  10798. _this.name = name;
  10799. _this._thumbLength = 0.5;
  10800. _this._thumbHeight = 1;
  10801. _this._barImageHeight = 1;
  10802. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10803. return _this;
  10804. }
  10805. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  10806. /**
  10807. * Gets or sets the image used to render the background for horizontal bar
  10808. */
  10809. get: function () {
  10810. return this._backgroundBaseImage;
  10811. },
  10812. set: function (value) {
  10813. var _this = this;
  10814. if (this._backgroundBaseImage === value) {
  10815. return;
  10816. }
  10817. this._backgroundBaseImage = value;
  10818. if (this.isVertical) {
  10819. if (value && !value.isLoaded) {
  10820. value.onImageLoadedObservable.addOnce(function () {
  10821. var rotatedValue = value._rotate90(1);
  10822. _this._backgroundImage = rotatedValue;
  10823. if (!rotatedValue.isLoaded) {
  10824. rotatedValue.onImageLoadedObservable.addOnce(function () {
  10825. _this._markAsDirty();
  10826. });
  10827. }
  10828. _this._markAsDirty();
  10829. });
  10830. }
  10831. this._backgroundImage = value._rotate90(1);
  10832. this._markAsDirty();
  10833. }
  10834. else {
  10835. this._backgroundImage = value;
  10836. if (value && !value.isLoaded) {
  10837. value.onImageLoadedObservable.addOnce(function () {
  10838. _this._markAsDirty();
  10839. });
  10840. }
  10841. this._markAsDirty();
  10842. }
  10843. },
  10844. enumerable: true,
  10845. configurable: true
  10846. });
  10847. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  10848. /**
  10849. * Gets or sets the image used to render the thumb
  10850. */
  10851. get: function () {
  10852. return this._thumbBaseImage;
  10853. },
  10854. set: function (value) {
  10855. var _this = this;
  10856. if (this._thumbBaseImage === value) {
  10857. return;
  10858. }
  10859. this._thumbBaseImage = value;
  10860. if (this.isVertical) {
  10861. if (value && !value.isLoaded) {
  10862. value.onImageLoadedObservable.addOnce(function () {
  10863. var rotatedValue = value._rotate90(-1);
  10864. _this._thumbImage = rotatedValue;
  10865. if (!rotatedValue.isLoaded) {
  10866. rotatedValue.onImageLoadedObservable.addOnce(function () {
  10867. _this._markAsDirty();
  10868. });
  10869. }
  10870. _this._markAsDirty();
  10871. });
  10872. }
  10873. this._thumbImage = value._rotate90(-1);
  10874. this._markAsDirty();
  10875. }
  10876. else {
  10877. this._thumbImage = value;
  10878. if (value && !value.isLoaded) {
  10879. value.onImageLoadedObservable.addOnce(function () {
  10880. _this._markAsDirty();
  10881. });
  10882. }
  10883. this._markAsDirty();
  10884. }
  10885. },
  10886. enumerable: true,
  10887. configurable: true
  10888. });
  10889. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  10890. /**
  10891. * Gets or sets the length of the thumb
  10892. */
  10893. get: function () {
  10894. return this._thumbLength;
  10895. },
  10896. set: function (value) {
  10897. if (this._thumbLength === value) {
  10898. return;
  10899. }
  10900. this._thumbLength = value;
  10901. this._markAsDirty();
  10902. },
  10903. enumerable: true,
  10904. configurable: true
  10905. });
  10906. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  10907. /**
  10908. * Gets or sets the height of the thumb
  10909. */
  10910. get: function () {
  10911. return this._thumbHeight;
  10912. },
  10913. set: function (value) {
  10914. if (this._thumbLength === value) {
  10915. return;
  10916. }
  10917. this._thumbHeight = value;
  10918. this._markAsDirty();
  10919. },
  10920. enumerable: true,
  10921. configurable: true
  10922. });
  10923. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  10924. /**
  10925. * Gets or sets the height of the bar image
  10926. */
  10927. get: function () {
  10928. return this._barImageHeight;
  10929. },
  10930. set: function (value) {
  10931. if (this._barImageHeight === value) {
  10932. return;
  10933. }
  10934. this._barImageHeight = value;
  10935. this._markAsDirty();
  10936. },
  10937. enumerable: true,
  10938. configurable: true
  10939. });
  10940. ImageScrollBar.prototype._getTypeName = function () {
  10941. return "ImageScrollBar";
  10942. };
  10943. ImageScrollBar.prototype._getThumbThickness = function () {
  10944. var thumbThickness = 0;
  10945. if (this._thumbWidth.isPixel) {
  10946. thumbThickness = this._thumbWidth.getValue(this._host);
  10947. }
  10948. else {
  10949. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10950. }
  10951. return thumbThickness;
  10952. };
  10953. ImageScrollBar.prototype._draw = function (context) {
  10954. context.save();
  10955. this._applyStates(context);
  10956. this._prepareRenderingData("rectangle");
  10957. var thumbPosition = this._getThumbPosition();
  10958. var left = this._renderLeft;
  10959. var top = this._renderTop;
  10960. var width = this._renderWidth;
  10961. var height = this._renderHeight;
  10962. // Background
  10963. if (this._backgroundImage) {
  10964. this._tempMeasure.copyFromFloats(left, top, width, height);
  10965. if (this.isVertical) {
  10966. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  10967. this._tempMeasure.height += this._effectiveThumbThickness;
  10968. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10969. }
  10970. else {
  10971. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  10972. this._tempMeasure.width += this._effectiveThumbThickness;
  10973. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10974. }
  10975. this._backgroundImage._draw(context);
  10976. }
  10977. // Thumb
  10978. if (this.isVertical) {
  10979. 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);
  10980. }
  10981. else {
  10982. 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);
  10983. }
  10984. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10985. this._thumbImage._draw(context);
  10986. context.restore();
  10987. };
  10988. /** @hidden */
  10989. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10990. if (this.rotation != 0) {
  10991. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10992. x = this._transformedPosition.x;
  10993. y = this._transformedPosition.y;
  10994. }
  10995. if (this._first) {
  10996. this._first = false;
  10997. this._originX = x;
  10998. this._originY = y;
  10999. // Check if move is required
  11000. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11001. if (this.isVertical) {
  11002. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11003. }
  11004. else {
  11005. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11006. }
  11007. }
  11008. }
  11009. // Delta mode
  11010. var delta = 0;
  11011. if (this.isVertical) {
  11012. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11013. }
  11014. else {
  11015. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11016. }
  11017. this.value += delta * (this.maximum - this.minimum);
  11018. this._originX = x;
  11019. this._originY = y;
  11020. };
  11021. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11022. this._first = true;
  11023. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11024. };
  11025. return ImageScrollBar;
  11026. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11027. /***/ }),
  11028. /***/ "./2D/controls/sliders/scrollBar.ts":
  11029. /*!******************************************!*\
  11030. !*** ./2D/controls/sliders/scrollBar.ts ***!
  11031. \******************************************/
  11032. /*! exports provided: ScrollBar */
  11033. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11034. "use strict";
  11035. __webpack_require__.r(__webpack_exports__);
  11036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  11037. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11038. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11039. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11040. /**
  11041. * Class used to create slider controls
  11042. */
  11043. var ScrollBar = /** @class */ (function (_super) {
  11044. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  11045. /**
  11046. * Creates a new Slider
  11047. * @param name defines the control name
  11048. */
  11049. function ScrollBar(name) {
  11050. var _this = _super.call(this, name) || this;
  11051. _this.name = name;
  11052. _this._background = "black";
  11053. _this._borderColor = "white";
  11054. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11055. return _this;
  11056. }
  11057. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  11058. /** Gets or sets border color */
  11059. get: function () {
  11060. return this._borderColor;
  11061. },
  11062. set: function (value) {
  11063. if (this._borderColor === value) {
  11064. return;
  11065. }
  11066. this._borderColor = value;
  11067. this._markAsDirty();
  11068. },
  11069. enumerable: true,
  11070. configurable: true
  11071. });
  11072. Object.defineProperty(ScrollBar.prototype, "background", {
  11073. /** Gets or sets background color */
  11074. get: function () {
  11075. return this._background;
  11076. },
  11077. set: function (value) {
  11078. if (this._background === value) {
  11079. return;
  11080. }
  11081. this._background = value;
  11082. this._markAsDirty();
  11083. },
  11084. enumerable: true,
  11085. configurable: true
  11086. });
  11087. ScrollBar.prototype._getTypeName = function () {
  11088. return "Scrollbar";
  11089. };
  11090. ScrollBar.prototype._getThumbThickness = function () {
  11091. var thumbThickness = 0;
  11092. if (this._thumbWidth.isPixel) {
  11093. thumbThickness = this._thumbWidth.getValue(this._host);
  11094. }
  11095. else {
  11096. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11097. }
  11098. return thumbThickness;
  11099. };
  11100. ScrollBar.prototype._draw = function (context) {
  11101. context.save();
  11102. this._applyStates(context);
  11103. this._prepareRenderingData("rectangle");
  11104. var left = this._renderLeft;
  11105. var thumbPosition = this._getThumbPosition();
  11106. context.fillStyle = this._background;
  11107. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  11108. // Value bar
  11109. context.fillStyle = this.color;
  11110. // Thumb
  11111. if (this.isVertical) {
  11112. this._tempMeasure.left = left - this._effectiveBarOffset;
  11113. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  11114. this._tempMeasure.width = this._currentMeasure.width;
  11115. this._tempMeasure.height = this._effectiveThumbThickness;
  11116. }
  11117. else {
  11118. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  11119. this._tempMeasure.top = this._currentMeasure.top;
  11120. this._tempMeasure.width = this._effectiveThumbThickness;
  11121. this._tempMeasure.height = this._currentMeasure.height;
  11122. }
  11123. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  11124. context.restore();
  11125. };
  11126. /** @hidden */
  11127. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11128. if (this.rotation != 0) {
  11129. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11130. x = this._transformedPosition.x;
  11131. y = this._transformedPosition.y;
  11132. }
  11133. if (this._first) {
  11134. this._first = false;
  11135. this._originX = x;
  11136. this._originY = y;
  11137. // Check if move is required
  11138. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11139. if (this.isVertical) {
  11140. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11141. }
  11142. else {
  11143. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11144. }
  11145. }
  11146. }
  11147. // Delta mode
  11148. var delta = 0;
  11149. if (this.isVertical) {
  11150. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11151. }
  11152. else {
  11153. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11154. }
  11155. this.value += delta * (this.maximum - this.minimum);
  11156. this._originX = x;
  11157. this._originY = y;
  11158. };
  11159. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11160. this._first = true;
  11161. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11162. };
  11163. return ScrollBar;
  11164. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11165. /***/ }),
  11166. /***/ "./2D/controls/sliders/slider.ts":
  11167. /*!***************************************!*\
  11168. !*** ./2D/controls/sliders/slider.ts ***!
  11169. \***************************************/
  11170. /*! exports provided: Slider */
  11171. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11172. "use strict";
  11173. __webpack_require__.r(__webpack_exports__);
  11174. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  11175. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11176. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11177. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  11178. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  11179. /**
  11180. * Class used to create slider controls
  11181. */
  11182. var Slider = /** @class */ (function (_super) {
  11183. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  11184. /**
  11185. * Creates a new Slider
  11186. * @param name defines the control name
  11187. */
  11188. function Slider(name) {
  11189. var _this = _super.call(this, name) || this;
  11190. _this.name = name;
  11191. _this._background = "black";
  11192. _this._borderColor = "white";
  11193. _this._isThumbCircle = false;
  11194. _this._displayValueBar = true;
  11195. return _this;
  11196. }
  11197. Object.defineProperty(Slider.prototype, "displayValueBar", {
  11198. /** Gets or sets a boolean indicating if the value bar must be rendered */
  11199. get: function () {
  11200. return this._displayValueBar;
  11201. },
  11202. set: function (value) {
  11203. if (this._displayValueBar === value) {
  11204. return;
  11205. }
  11206. this._displayValueBar = value;
  11207. this._markAsDirty();
  11208. },
  11209. enumerable: true,
  11210. configurable: true
  11211. });
  11212. Object.defineProperty(Slider.prototype, "borderColor", {
  11213. /** Gets or sets border color */
  11214. get: function () {
  11215. return this._borderColor;
  11216. },
  11217. set: function (value) {
  11218. if (this._borderColor === value) {
  11219. return;
  11220. }
  11221. this._borderColor = value;
  11222. this._markAsDirty();
  11223. },
  11224. enumerable: true,
  11225. configurable: true
  11226. });
  11227. Object.defineProperty(Slider.prototype, "background", {
  11228. /** Gets or sets background color */
  11229. get: function () {
  11230. return this._background;
  11231. },
  11232. set: function (value) {
  11233. if (this._background === value) {
  11234. return;
  11235. }
  11236. this._background = value;
  11237. this._markAsDirty();
  11238. },
  11239. enumerable: true,
  11240. configurable: true
  11241. });
  11242. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  11243. /** Gets or sets a boolean indicating if the thumb should be round or square */
  11244. get: function () {
  11245. return this._isThumbCircle;
  11246. },
  11247. set: function (value) {
  11248. if (this._isThumbCircle === value) {
  11249. return;
  11250. }
  11251. this._isThumbCircle = value;
  11252. this._markAsDirty();
  11253. },
  11254. enumerable: true,
  11255. configurable: true
  11256. });
  11257. Slider.prototype._getTypeName = function () {
  11258. return "Slider";
  11259. };
  11260. Slider.prototype._draw = function (context, invalidatedRectangle) {
  11261. context.save();
  11262. this._applyStates(context);
  11263. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  11264. var left = this._renderLeft;
  11265. var top = this._renderTop;
  11266. var width = this._renderWidth;
  11267. var height = this._renderHeight;
  11268. var radius = 0;
  11269. if (this.isThumbClamped && this.isThumbCircle) {
  11270. if (this.isVertical) {
  11271. top += (this._effectiveThumbThickness / 2);
  11272. }
  11273. else {
  11274. left += (this._effectiveThumbThickness / 2);
  11275. }
  11276. radius = this._backgroundBoxThickness / 2;
  11277. }
  11278. else {
  11279. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  11280. }
  11281. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11282. context.shadowColor = this.shadowColor;
  11283. context.shadowBlur = this.shadowBlur;
  11284. context.shadowOffsetX = this.shadowOffsetX;
  11285. context.shadowOffsetY = this.shadowOffsetY;
  11286. }
  11287. var thumbPosition = this._getThumbPosition();
  11288. context.fillStyle = this._background;
  11289. if (this.isVertical) {
  11290. if (this.isThumbClamped) {
  11291. if (this.isThumbCircle) {
  11292. context.beginPath();
  11293. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  11294. context.fill();
  11295. context.fillRect(left, top, width, height);
  11296. }
  11297. else {
  11298. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  11299. }
  11300. }
  11301. else {
  11302. context.fillRect(left, top, width, height);
  11303. }
  11304. }
  11305. else {
  11306. if (this.isThumbClamped) {
  11307. if (this.isThumbCircle) {
  11308. context.beginPath();
  11309. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11310. context.fill();
  11311. context.fillRect(left, top, width, height);
  11312. }
  11313. else {
  11314. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  11315. }
  11316. }
  11317. else {
  11318. context.fillRect(left, top, width, height);
  11319. }
  11320. }
  11321. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11322. context.shadowBlur = 0;
  11323. context.shadowOffsetX = 0;
  11324. context.shadowOffsetY = 0;
  11325. }
  11326. // Value bar
  11327. context.fillStyle = this.color;
  11328. if (this._displayValueBar) {
  11329. if (this.isVertical) {
  11330. if (this.isThumbClamped) {
  11331. if (this.isThumbCircle) {
  11332. context.beginPath();
  11333. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  11334. context.fill();
  11335. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11336. }
  11337. else {
  11338. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11339. }
  11340. }
  11341. else {
  11342. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11343. }
  11344. }
  11345. else {
  11346. if (this.isThumbClamped) {
  11347. if (this.isThumbCircle) {
  11348. context.beginPath();
  11349. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  11350. context.fill();
  11351. context.fillRect(left, top, thumbPosition, height);
  11352. }
  11353. else {
  11354. context.fillRect(left, top, thumbPosition, height);
  11355. }
  11356. }
  11357. else {
  11358. context.fillRect(left, top, thumbPosition, height);
  11359. }
  11360. }
  11361. }
  11362. // Thumb
  11363. if (this.displayThumb) {
  11364. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11365. context.shadowColor = this.shadowColor;
  11366. context.shadowBlur = this.shadowBlur;
  11367. context.shadowOffsetX = this.shadowOffsetX;
  11368. context.shadowOffsetY = this.shadowOffsetY;
  11369. }
  11370. if (this._isThumbCircle) {
  11371. context.beginPath();
  11372. if (this.isVertical) {
  11373. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11374. }
  11375. else {
  11376. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11377. }
  11378. context.fill();
  11379. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11380. context.shadowBlur = 0;
  11381. context.shadowOffsetX = 0;
  11382. context.shadowOffsetY = 0;
  11383. }
  11384. context.strokeStyle = this._borderColor;
  11385. context.stroke();
  11386. }
  11387. else {
  11388. if (this.isVertical) {
  11389. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11390. }
  11391. else {
  11392. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11393. }
  11394. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11395. context.shadowBlur = 0;
  11396. context.shadowOffsetX = 0;
  11397. context.shadowOffsetY = 0;
  11398. }
  11399. context.strokeStyle = this._borderColor;
  11400. if (this.isVertical) {
  11401. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11402. }
  11403. else {
  11404. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11405. }
  11406. }
  11407. }
  11408. context.restore();
  11409. };
  11410. return Slider;
  11411. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11412. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11413. /***/ }),
  11414. /***/ "./2D/controls/stackPanel.ts":
  11415. /*!***********************************!*\
  11416. !*** ./2D/controls/stackPanel.ts ***!
  11417. \***********************************/
  11418. /*! exports provided: StackPanel */
  11419. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11420. "use strict";
  11421. __webpack_require__.r(__webpack_exports__);
  11422. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11423. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11424. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  11425. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11426. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11427. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11428. /**
  11429. * Class used to create a 2D stack panel container
  11430. */
  11431. var StackPanel = /** @class */ (function (_super) {
  11432. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11433. /**
  11434. * Creates a new StackPanel
  11435. * @param name defines control name
  11436. */
  11437. function StackPanel(name) {
  11438. var _this = _super.call(this, name) || this;
  11439. _this.name = name;
  11440. _this._isVertical = true;
  11441. _this._manualWidth = false;
  11442. _this._manualHeight = false;
  11443. _this._doNotTrackManualChanges = false;
  11444. /**
  11445. * Gets or sets a boolean indicating that layou warnings should be ignored
  11446. */
  11447. _this.ignoreLayoutWarnings = false;
  11448. return _this;
  11449. }
  11450. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11451. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11452. get: function () {
  11453. return this._isVertical;
  11454. },
  11455. set: function (value) {
  11456. if (this._isVertical === value) {
  11457. return;
  11458. }
  11459. this._isVertical = value;
  11460. this._markAsDirty();
  11461. },
  11462. enumerable: true,
  11463. configurable: true
  11464. });
  11465. Object.defineProperty(StackPanel.prototype, "width", {
  11466. get: function () {
  11467. return this._width.toString(this._host);
  11468. },
  11469. /**
  11470. * Gets or sets panel width.
  11471. * This value should not be set when in horizontal mode as it will be computed automatically
  11472. */
  11473. set: function (value) {
  11474. if (!this._doNotTrackManualChanges) {
  11475. this._manualWidth = true;
  11476. }
  11477. if (this._width.toString(this._host) === value) {
  11478. return;
  11479. }
  11480. if (this._width.fromString(value)) {
  11481. this._markAsDirty();
  11482. }
  11483. },
  11484. enumerable: true,
  11485. configurable: true
  11486. });
  11487. Object.defineProperty(StackPanel.prototype, "height", {
  11488. get: function () {
  11489. return this._height.toString(this._host);
  11490. },
  11491. /**
  11492. * Gets or sets panel height.
  11493. * This value should not be set when in vertical mode as it will be computed automatically
  11494. */
  11495. set: function (value) {
  11496. if (!this._doNotTrackManualChanges) {
  11497. this._manualHeight = true;
  11498. }
  11499. if (this._height.toString(this._host) === value) {
  11500. return;
  11501. }
  11502. if (this._height.fromString(value)) {
  11503. this._markAsDirty();
  11504. }
  11505. },
  11506. enumerable: true,
  11507. configurable: true
  11508. });
  11509. StackPanel.prototype._getTypeName = function () {
  11510. return "StackPanel";
  11511. };
  11512. /** @hidden */
  11513. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11514. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11515. var child = _a[_i];
  11516. if (this._isVertical) {
  11517. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11518. }
  11519. else {
  11520. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11521. }
  11522. }
  11523. _super.prototype._preMeasure.call(this, parentMeasure, context);
  11524. };
  11525. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  11526. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  11527. this._measureForChildren.copyFrom(parentMeasure);
  11528. this._measureForChildren.left = this._currentMeasure.left;
  11529. this._measureForChildren.top = this._currentMeasure.top;
  11530. if (!this.isVertical || this._manualWidth) {
  11531. this._measureForChildren.width = this._currentMeasure.width;
  11532. }
  11533. if (this.isVertical || this._manualHeight) {
  11534. this._measureForChildren.height = this._currentMeasure.height;
  11535. }
  11536. };
  11537. StackPanel.prototype._postMeasure = function () {
  11538. var stackWidth = 0;
  11539. var stackHeight = 0;
  11540. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11541. var child = _a[_i];
  11542. if (!child.isVisible || child.notRenderable) {
  11543. continue;
  11544. }
  11545. if (this._isVertical) {
  11546. if (child.top !== stackHeight + "px") {
  11547. child.top = stackHeight + "px";
  11548. this._rebuildLayout = true;
  11549. child._top.ignoreAdaptiveScaling = true;
  11550. }
  11551. if (child._height.isPercentage && !child._automaticSize) {
  11552. if (!this.ignoreLayoutWarnings) {
  11553. 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");
  11554. }
  11555. }
  11556. else {
  11557. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  11558. }
  11559. }
  11560. else {
  11561. if (child.left !== stackWidth + "px") {
  11562. child.left = stackWidth + "px";
  11563. this._rebuildLayout = true;
  11564. child._left.ignoreAdaptiveScaling = true;
  11565. }
  11566. if (child._width.isPercentage && !child._automaticSize) {
  11567. if (!this.ignoreLayoutWarnings) {
  11568. 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");
  11569. }
  11570. }
  11571. else {
  11572. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  11573. }
  11574. }
  11575. }
  11576. this._doNotTrackManualChanges = true;
  11577. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  11578. // User can now define their own height and width for stack panel.
  11579. var panelWidthChanged = false;
  11580. var panelHeightChanged = false;
  11581. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  11582. var previousHeight = this.height;
  11583. this.height = stackHeight + "px";
  11584. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  11585. }
  11586. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  11587. var previousWidth = this.width;
  11588. this.width = stackWidth + "px";
  11589. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  11590. }
  11591. if (panelHeightChanged) {
  11592. this._height.ignoreAdaptiveScaling = true;
  11593. }
  11594. if (panelWidthChanged) {
  11595. this._width.ignoreAdaptiveScaling = true;
  11596. }
  11597. this._doNotTrackManualChanges = false;
  11598. if (panelWidthChanged || panelHeightChanged) {
  11599. this._rebuildLayout = true;
  11600. }
  11601. _super.prototype._postMeasure.call(this);
  11602. };
  11603. return StackPanel;
  11604. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  11605. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  11606. /***/ }),
  11607. /***/ "./2D/controls/statics.ts":
  11608. /*!********************************!*\
  11609. !*** ./2D/controls/statics.ts ***!
  11610. \********************************/
  11611. /*! exports provided: name */
  11612. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11613. "use strict";
  11614. __webpack_require__.r(__webpack_exports__);
  11615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  11616. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11617. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11618. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  11619. /**
  11620. * Forcing an export so that this code will execute
  11621. * @hidden
  11622. */
  11623. var name = "Statics";
  11624. /**
  11625. * Creates a stack panel that can be used to render headers
  11626. * @param control defines the control to associate with the header
  11627. * @param text defines the text of the header
  11628. * @param size defines the size of the header
  11629. * @param options defines options used to configure the header
  11630. * @returns a new StackPanel
  11631. */
  11632. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  11633. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  11634. var isHorizontal = options ? options.isHorizontal : true;
  11635. var controlFirst = options ? options.controlFirst : true;
  11636. panel.isVertical = !isHorizontal;
  11637. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  11638. header.text = text;
  11639. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11640. if (isHorizontal) {
  11641. header.width = size;
  11642. }
  11643. else {
  11644. header.height = size;
  11645. }
  11646. if (controlFirst) {
  11647. panel.addControl(control);
  11648. panel.addControl(header);
  11649. header.paddingLeft = "5px";
  11650. }
  11651. else {
  11652. panel.addControl(header);
  11653. panel.addControl(control);
  11654. header.paddingRight = "5px";
  11655. }
  11656. header.shadowBlur = control.shadowBlur;
  11657. header.shadowColor = control.shadowColor;
  11658. header.shadowOffsetX = control.shadowOffsetX;
  11659. header.shadowOffsetY = control.shadowOffsetY;
  11660. return panel;
  11661. };
  11662. /***/ }),
  11663. /***/ "./2D/controls/textBlock.ts":
  11664. /*!**********************************!*\
  11665. !*** ./2D/controls/textBlock.ts ***!
  11666. \**********************************/
  11667. /*! exports provided: TextWrapping, TextBlock */
  11668. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11669. "use strict";
  11670. __webpack_require__.r(__webpack_exports__);
  11671. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  11672. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  11673. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11674. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  11675. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11676. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  11677. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11678. /**
  11679. * Enum that determines the text-wrapping mode to use.
  11680. */
  11681. var TextWrapping;
  11682. (function (TextWrapping) {
  11683. /**
  11684. * Clip the text when it's larger than Control.width; this is the default mode.
  11685. */
  11686. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  11687. /**
  11688. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  11689. */
  11690. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  11691. /**
  11692. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  11693. */
  11694. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  11695. })(TextWrapping || (TextWrapping = {}));
  11696. /**
  11697. * Class used to create text block control
  11698. */
  11699. var TextBlock = /** @class */ (function (_super) {
  11700. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  11701. /**
  11702. * Creates a new TextBlock object
  11703. * @param name defines the name of the control
  11704. * @param text defines the text to display (emptry string by default)
  11705. */
  11706. function TextBlock(
  11707. /**
  11708. * Defines the name of the control
  11709. */
  11710. name, text) {
  11711. if (text === void 0) { text = ""; }
  11712. var _this = _super.call(this, name) || this;
  11713. _this.name = name;
  11714. _this._text = "";
  11715. _this._textWrapping = TextWrapping.Clip;
  11716. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  11717. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  11718. _this._resizeToFit = false;
  11719. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  11720. _this._outlineWidth = 0;
  11721. _this._outlineColor = "white";
  11722. /**
  11723. * An event triggered after the text is changed
  11724. */
  11725. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11726. /**
  11727. * An event triggered after the text was broken up into lines
  11728. */
  11729. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11730. _this.text = text;
  11731. return _this;
  11732. }
  11733. Object.defineProperty(TextBlock.prototype, "lines", {
  11734. /**
  11735. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  11736. */
  11737. get: function () {
  11738. return this._lines;
  11739. },
  11740. enumerable: true,
  11741. configurable: true
  11742. });
  11743. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  11744. /**
  11745. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11746. */
  11747. get: function () {
  11748. return this._resizeToFit;
  11749. },
  11750. /**
  11751. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11752. */
  11753. set: function (value) {
  11754. if (this._resizeToFit === value) {
  11755. return;
  11756. }
  11757. this._resizeToFit = value;
  11758. if (this._resizeToFit) {
  11759. this._width.ignoreAdaptiveScaling = true;
  11760. this._height.ignoreAdaptiveScaling = true;
  11761. }
  11762. this._markAsDirty();
  11763. },
  11764. enumerable: true,
  11765. configurable: true
  11766. });
  11767. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  11768. /**
  11769. * Gets or sets a boolean indicating if text must be wrapped
  11770. */
  11771. get: function () {
  11772. return this._textWrapping;
  11773. },
  11774. /**
  11775. * Gets or sets a boolean indicating if text must be wrapped
  11776. */
  11777. set: function (value) {
  11778. if (this._textWrapping === value) {
  11779. return;
  11780. }
  11781. this._textWrapping = +value;
  11782. this._markAsDirty();
  11783. },
  11784. enumerable: true,
  11785. configurable: true
  11786. });
  11787. Object.defineProperty(TextBlock.prototype, "text", {
  11788. /**
  11789. * Gets or sets text to display
  11790. */
  11791. get: function () {
  11792. return this._text;
  11793. },
  11794. /**
  11795. * Gets or sets text to display
  11796. */
  11797. set: function (value) {
  11798. if (this._text === value) {
  11799. return;
  11800. }
  11801. this._text = value;
  11802. this._markAsDirty();
  11803. this.onTextChangedObservable.notifyObservers(this);
  11804. },
  11805. enumerable: true,
  11806. configurable: true
  11807. });
  11808. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  11809. /**
  11810. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11811. */
  11812. get: function () {
  11813. return this._textHorizontalAlignment;
  11814. },
  11815. /**
  11816. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11817. */
  11818. set: function (value) {
  11819. if (this._textHorizontalAlignment === value) {
  11820. return;
  11821. }
  11822. this._textHorizontalAlignment = value;
  11823. this._markAsDirty();
  11824. },
  11825. enumerable: true,
  11826. configurable: true
  11827. });
  11828. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  11829. /**
  11830. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11831. */
  11832. get: function () {
  11833. return this._textVerticalAlignment;
  11834. },
  11835. /**
  11836. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11837. */
  11838. set: function (value) {
  11839. if (this._textVerticalAlignment === value) {
  11840. return;
  11841. }
  11842. this._textVerticalAlignment = value;
  11843. this._markAsDirty();
  11844. },
  11845. enumerable: true,
  11846. configurable: true
  11847. });
  11848. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  11849. /**
  11850. * Gets or sets line spacing value
  11851. */
  11852. get: function () {
  11853. return this._lineSpacing.toString(this._host);
  11854. },
  11855. /**
  11856. * Gets or sets line spacing value
  11857. */
  11858. set: function (value) {
  11859. if (this._lineSpacing.fromString(value)) {
  11860. this._markAsDirty();
  11861. }
  11862. },
  11863. enumerable: true,
  11864. configurable: true
  11865. });
  11866. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  11867. /**
  11868. * Gets or sets outlineWidth of the text to display
  11869. */
  11870. get: function () {
  11871. return this._outlineWidth;
  11872. },
  11873. /**
  11874. * Gets or sets outlineWidth of the text to display
  11875. */
  11876. set: function (value) {
  11877. if (this._outlineWidth === value) {
  11878. return;
  11879. }
  11880. this._outlineWidth = value;
  11881. this._markAsDirty();
  11882. },
  11883. enumerable: true,
  11884. configurable: true
  11885. });
  11886. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  11887. /**
  11888. * Gets or sets outlineColor of the text to display
  11889. */
  11890. get: function () {
  11891. return this._outlineColor;
  11892. },
  11893. /**
  11894. * Gets or sets outlineColor of the text to display
  11895. */
  11896. set: function (value) {
  11897. if (this._outlineColor === value) {
  11898. return;
  11899. }
  11900. this._outlineColor = value;
  11901. this._markAsDirty();
  11902. },
  11903. enumerable: true,
  11904. configurable: true
  11905. });
  11906. TextBlock.prototype._getTypeName = function () {
  11907. return "TextBlock";
  11908. };
  11909. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11910. if (!this._fontOffset) {
  11911. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11912. }
  11913. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11914. // Prepare lines
  11915. this._lines = this._breakLines(this._currentMeasure.width, context);
  11916. this.onLinesReadyObservable.notifyObservers(this);
  11917. var maxLineWidth = 0;
  11918. for (var i = 0; i < this._lines.length; i++) {
  11919. var line = this._lines[i];
  11920. if (line.width > maxLineWidth) {
  11921. maxLineWidth = line.width;
  11922. }
  11923. }
  11924. if (this._resizeToFit) {
  11925. if (this._textWrapping === TextWrapping.Clip) {
  11926. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11927. if (newWidth !== this._width.internalValue) {
  11928. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11929. this._rebuildLayout = true;
  11930. }
  11931. }
  11932. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11933. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11934. var lineSpacing = 0;
  11935. if (this._lineSpacing.isPixel) {
  11936. lineSpacing = this._lineSpacing.getValue(this._host);
  11937. }
  11938. else {
  11939. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11940. }
  11941. newHeight += (this._lines.length - 1) * lineSpacing;
  11942. }
  11943. if (newHeight !== this._height.internalValue) {
  11944. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11945. this._rebuildLayout = true;
  11946. }
  11947. }
  11948. };
  11949. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11950. var width = this._currentMeasure.width;
  11951. var x = 0;
  11952. switch (this._textHorizontalAlignment) {
  11953. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11954. x = 0;
  11955. break;
  11956. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11957. x = width - textWidth;
  11958. break;
  11959. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11960. x = (width - textWidth) / 2;
  11961. break;
  11962. }
  11963. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11964. context.shadowColor = this.shadowColor;
  11965. context.shadowBlur = this.shadowBlur;
  11966. context.shadowOffsetX = this.shadowOffsetX;
  11967. context.shadowOffsetY = this.shadowOffsetY;
  11968. }
  11969. if (this.outlineWidth) {
  11970. context.strokeText(text, this._currentMeasure.left + x, y);
  11971. }
  11972. context.fillText(text, this._currentMeasure.left + x, y);
  11973. };
  11974. /** @hidden */
  11975. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  11976. context.save();
  11977. this._applyStates(context);
  11978. // Render lines
  11979. this._renderLines(context);
  11980. context.restore();
  11981. };
  11982. TextBlock.prototype._applyStates = function (context) {
  11983. _super.prototype._applyStates.call(this, context);
  11984. if (this.outlineWidth) {
  11985. context.lineWidth = this.outlineWidth;
  11986. context.strokeStyle = this.outlineColor;
  11987. }
  11988. };
  11989. TextBlock.prototype._breakLines = function (refWidth, context) {
  11990. var lines = [];
  11991. var _lines = this.text.split("\n");
  11992. if (this._textWrapping === TextWrapping.Ellipsis) {
  11993. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11994. var _line = _lines_1[_i];
  11995. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11996. }
  11997. }
  11998. else if (this._textWrapping === TextWrapping.WordWrap) {
  11999. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  12000. var _line = _lines_2[_a];
  12001. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  12002. }
  12003. }
  12004. else {
  12005. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  12006. var _line = _lines_3[_b];
  12007. lines.push(this._parseLine(_line, context));
  12008. }
  12009. }
  12010. return lines;
  12011. };
  12012. TextBlock.prototype._parseLine = function (line, context) {
  12013. if (line === void 0) { line = ''; }
  12014. return { text: line, width: context.measureText(line).width };
  12015. };
  12016. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  12017. if (line === void 0) { line = ''; }
  12018. var lineWidth = context.measureText(line).width;
  12019. if (lineWidth > width) {
  12020. line += '…';
  12021. }
  12022. while (line.length > 2 && lineWidth > width) {
  12023. line = line.slice(0, -2) + '…';
  12024. lineWidth = context.measureText(line).width;
  12025. }
  12026. return { text: line, width: lineWidth };
  12027. };
  12028. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  12029. if (line === void 0) { line = ''; }
  12030. var lines = [];
  12031. var words = line.split(' ');
  12032. var lineWidth = 0;
  12033. for (var n = 0; n < words.length; n++) {
  12034. var testLine = n > 0 ? line + " " + words[n] : words[0];
  12035. var metrics = context.measureText(testLine);
  12036. var testWidth = metrics.width;
  12037. if (testWidth > width && n > 0) {
  12038. lines.push({ text: line, width: lineWidth });
  12039. line = words[n];
  12040. lineWidth = context.measureText(line).width;
  12041. }
  12042. else {
  12043. lineWidth = testWidth;
  12044. line = testLine;
  12045. }
  12046. }
  12047. lines.push({ text: line, width: lineWidth });
  12048. return lines;
  12049. };
  12050. TextBlock.prototype._renderLines = function (context) {
  12051. var height = this._currentMeasure.height;
  12052. var rootY = 0;
  12053. switch (this._textVerticalAlignment) {
  12054. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  12055. rootY = this._fontOffset.ascent;
  12056. break;
  12057. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  12058. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  12059. break;
  12060. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  12061. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  12062. break;
  12063. }
  12064. rootY += this._currentMeasure.top;
  12065. for (var i = 0; i < this._lines.length; i++) {
  12066. var line = this._lines[i];
  12067. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  12068. if (this._lineSpacing.isPixel) {
  12069. rootY += this._lineSpacing.getValue(this._host);
  12070. }
  12071. else {
  12072. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12073. }
  12074. }
  12075. this._drawText(line.text, line.width, rootY, context);
  12076. rootY += this._fontOffset.height;
  12077. }
  12078. };
  12079. /**
  12080. * Given a width constraint applied on the text block, find the expected height
  12081. * @returns expected height
  12082. */
  12083. TextBlock.prototype.computeExpectedHeight = function () {
  12084. if (this.text && this.widthInPixels) {
  12085. var context_1 = document.createElement('canvas').getContext('2d');
  12086. if (context_1) {
  12087. this._applyStates(context_1);
  12088. if (!this._fontOffset) {
  12089. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  12090. }
  12091. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  12092. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  12093. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12094. var lineSpacing = 0;
  12095. if (this._lineSpacing.isPixel) {
  12096. lineSpacing = this._lineSpacing.getValue(this._host);
  12097. }
  12098. else {
  12099. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12100. }
  12101. newHeight += (lines.length - 1) * lineSpacing;
  12102. }
  12103. return newHeight;
  12104. }
  12105. }
  12106. return 0;
  12107. };
  12108. TextBlock.prototype.dispose = function () {
  12109. _super.prototype.dispose.call(this);
  12110. this.onTextChangedObservable.clear();
  12111. };
  12112. return TextBlock;
  12113. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  12114. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  12115. /***/ }),
  12116. /***/ "./2D/controls/virtualKeyboard.ts":
  12117. /*!****************************************!*\
  12118. !*** ./2D/controls/virtualKeyboard.ts ***!
  12119. \****************************************/
  12120. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  12121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12122. "use strict";
  12123. __webpack_require__.r(__webpack_exports__);
  12124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  12125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  12126. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12127. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12128. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12129. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12130. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  12131. /**
  12132. * Class used to store key control properties
  12133. */
  12134. var KeyPropertySet = /** @class */ (function () {
  12135. function KeyPropertySet() {
  12136. }
  12137. return KeyPropertySet;
  12138. }());
  12139. /**
  12140. * Class used to create virtual keyboard
  12141. */
  12142. var VirtualKeyboard = /** @class */ (function (_super) {
  12143. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  12144. function VirtualKeyboard() {
  12145. var _this = _super !== null && _super.apply(this, arguments) || this;
  12146. /** Observable raised when a key is pressed */
  12147. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12148. /** Gets or sets default key button width */
  12149. _this.defaultButtonWidth = "40px";
  12150. /** Gets or sets default key button height */
  12151. _this.defaultButtonHeight = "40px";
  12152. /** Gets or sets default key button left padding */
  12153. _this.defaultButtonPaddingLeft = "2px";
  12154. /** Gets or sets default key button right padding */
  12155. _this.defaultButtonPaddingRight = "2px";
  12156. /** Gets or sets default key button top padding */
  12157. _this.defaultButtonPaddingTop = "2px";
  12158. /** Gets or sets default key button bottom padding */
  12159. _this.defaultButtonPaddingBottom = "2px";
  12160. /** Gets or sets default key button foreground color */
  12161. _this.defaultButtonColor = "#DDD";
  12162. /** Gets or sets default key button background color */
  12163. _this.defaultButtonBackground = "#070707";
  12164. /** Gets or sets shift button foreground color */
  12165. _this.shiftButtonColor = "#7799FF";
  12166. /** Gets or sets shift button thickness*/
  12167. _this.selectedShiftThickness = 1;
  12168. /** Gets shift key state */
  12169. _this.shiftState = 0;
  12170. _this._currentlyConnectedInputText = null;
  12171. _this._connectedInputTexts = [];
  12172. _this._onKeyPressObserver = null;
  12173. return _this;
  12174. }
  12175. VirtualKeyboard.prototype._getTypeName = function () {
  12176. return "VirtualKeyboard";
  12177. };
  12178. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  12179. var _this = this;
  12180. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  12181. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  12182. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  12183. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  12184. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  12185. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  12186. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  12187. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  12188. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  12189. button.thickness = 0;
  12190. button.isFocusInvisible = true;
  12191. button.shadowColor = this.shadowColor;
  12192. button.shadowBlur = this.shadowBlur;
  12193. button.shadowOffsetX = this.shadowOffsetX;
  12194. button.shadowOffsetY = this.shadowOffsetY;
  12195. button.onPointerUpObservable.add(function () {
  12196. _this.onKeyPressObservable.notifyObservers(key);
  12197. });
  12198. return button;
  12199. };
  12200. /**
  12201. * Adds a new row of keys
  12202. * @param keys defines the list of keys to add
  12203. * @param propertySets defines the associated property sets
  12204. */
  12205. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  12206. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  12207. panel.isVertical = false;
  12208. panel.isFocusInvisible = true;
  12209. var maxKey = null;
  12210. for (var i = 0; i < keys.length; i++) {
  12211. var properties = null;
  12212. if (propertySets && propertySets.length === keys.length) {
  12213. properties = propertySets[i];
  12214. }
  12215. var key = this._createKey(keys[i], properties);
  12216. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  12217. maxKey = key;
  12218. }
  12219. panel.addControl(key);
  12220. }
  12221. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  12222. this.addControl(panel);
  12223. };
  12224. /**
  12225. * Set the shift key to a specific state
  12226. * @param shiftState defines the new shift state
  12227. */
  12228. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  12229. if (!this.children) {
  12230. return;
  12231. }
  12232. for (var i = 0; i < this.children.length; i++) {
  12233. var row = this.children[i];
  12234. if (!row || !row.children) {
  12235. continue;
  12236. }
  12237. var rowContainer = row;
  12238. for (var j = 0; j < rowContainer.children.length; j++) {
  12239. var button = rowContainer.children[j];
  12240. if (!button || !button.children[0]) {
  12241. continue;
  12242. }
  12243. var button_tblock = button.children[0];
  12244. if (button_tblock.text === "\u21E7") {
  12245. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  12246. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  12247. }
  12248. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  12249. }
  12250. }
  12251. };
  12252. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  12253. /** Gets the input text control currently attached to the keyboard */
  12254. get: function () {
  12255. return this._currentlyConnectedInputText;
  12256. },
  12257. enumerable: true,
  12258. configurable: true
  12259. });
  12260. /**
  12261. * Connects the keyboard with an input text control
  12262. *
  12263. * @param input defines the target control
  12264. */
  12265. VirtualKeyboard.prototype.connect = function (input) {
  12266. var _this = this;
  12267. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  12268. if (inputTextAlreadyConnected) {
  12269. return;
  12270. }
  12271. if (this._onKeyPressObserver === null) {
  12272. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  12273. if (!_this._currentlyConnectedInputText) {
  12274. return;
  12275. }
  12276. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  12277. switch (key) {
  12278. case "\u21E7":
  12279. _this.shiftState++;
  12280. if (_this.shiftState > 2) {
  12281. _this.shiftState = 0;
  12282. }
  12283. _this.applyShiftState(_this.shiftState);
  12284. return;
  12285. case "\u2190":
  12286. _this._currentlyConnectedInputText.processKey(8);
  12287. return;
  12288. case "\u21B5":
  12289. _this._currentlyConnectedInputText.processKey(13);
  12290. return;
  12291. }
  12292. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  12293. if (_this.shiftState === 1) {
  12294. _this.shiftState = 0;
  12295. _this.applyShiftState(_this.shiftState);
  12296. }
  12297. });
  12298. }
  12299. this.isVisible = false;
  12300. this._currentlyConnectedInputText = input;
  12301. input._connectedVirtualKeyboard = this;
  12302. // Events hooking
  12303. var onFocusObserver = input.onFocusObservable.add(function () {
  12304. _this._currentlyConnectedInputText = input;
  12305. input._connectedVirtualKeyboard = _this;
  12306. _this.isVisible = true;
  12307. });
  12308. var onBlurObserver = input.onBlurObservable.add(function () {
  12309. input._connectedVirtualKeyboard = null;
  12310. _this._currentlyConnectedInputText = null;
  12311. _this.isVisible = false;
  12312. });
  12313. this._connectedInputTexts.push({
  12314. input: input,
  12315. onBlurObserver: onBlurObserver,
  12316. onFocusObserver: onFocusObserver
  12317. });
  12318. };
  12319. /**
  12320. * Disconnects the keyboard from connected InputText controls
  12321. *
  12322. * @param input optionally defines a target control, otherwise all are disconnected
  12323. */
  12324. VirtualKeyboard.prototype.disconnect = function (input) {
  12325. var _this = this;
  12326. if (input) {
  12327. // .find not available on IE
  12328. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  12329. if (filtered.length === 1) {
  12330. this._removeConnectedInputObservables(filtered[0]);
  12331. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  12332. if (this._currentlyConnectedInputText === input) {
  12333. this._currentlyConnectedInputText = null;
  12334. }
  12335. }
  12336. }
  12337. else {
  12338. this._connectedInputTexts.forEach(function (connectedInputText) {
  12339. _this._removeConnectedInputObservables(connectedInputText);
  12340. });
  12341. this._connectedInputTexts = [];
  12342. }
  12343. if (this._connectedInputTexts.length === 0) {
  12344. this._currentlyConnectedInputText = null;
  12345. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  12346. this._onKeyPressObserver = null;
  12347. }
  12348. };
  12349. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  12350. connectedInputText.input._connectedVirtualKeyboard = null;
  12351. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  12352. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  12353. };
  12354. /**
  12355. * Release all resources
  12356. */
  12357. VirtualKeyboard.prototype.dispose = function () {
  12358. _super.prototype.dispose.call(this);
  12359. this.disconnect();
  12360. };
  12361. // Statics
  12362. /**
  12363. * Creates a new keyboard using a default layout
  12364. *
  12365. * @param name defines control name
  12366. * @returns a new VirtualKeyboard
  12367. */
  12368. VirtualKeyboard.CreateDefaultLayout = function (name) {
  12369. var returnValue = new VirtualKeyboard(name);
  12370. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  12371. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  12372. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  12373. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  12374. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  12375. return returnValue;
  12376. };
  12377. return VirtualKeyboard;
  12378. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  12379. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  12380. /***/ }),
  12381. /***/ "./2D/index.ts":
  12382. /*!*********************!*\
  12383. !*** ./2D/index.ts ***!
  12384. \*********************/
  12385. /*! 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 */
  12386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12387. "use strict";
  12388. __webpack_require__.r(__webpack_exports__);
  12389. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  12390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  12391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  12392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  12393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  12394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  12395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  12396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  12397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  12398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  12399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  12400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  12401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  12402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  12403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  12404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  12405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  12406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  12407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  12408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  12409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  12410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  12411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  12412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  12413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  12414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  12415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  12416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  12417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  12418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  12419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  12420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  12421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  12422. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  12424. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  12425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  12426. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  12427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  12428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  12429. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  12430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  12431. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  12432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  12433. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  12434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  12435. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  12437. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  12438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  12439. /***/ }),
  12440. /***/ "./2D/math2D.ts":
  12441. /*!**********************!*\
  12442. !*** ./2D/math2D.ts ***!
  12443. \**********************/
  12444. /*! exports provided: Vector2WithInfo, Matrix2D */
  12445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12446. "use strict";
  12447. __webpack_require__.r(__webpack_exports__);
  12448. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  12449. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  12450. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12451. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12452. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12453. /**
  12454. * Class used to transport Vector2 information for pointer events
  12455. */
  12456. var Vector2WithInfo = /** @class */ (function (_super) {
  12457. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  12458. /**
  12459. * Creates a new Vector2WithInfo
  12460. * @param source defines the vector2 data to transport
  12461. * @param buttonIndex defines the current mouse button index
  12462. */
  12463. function Vector2WithInfo(source,
  12464. /** defines the current mouse button index */
  12465. buttonIndex) {
  12466. if (buttonIndex === void 0) { buttonIndex = 0; }
  12467. var _this = _super.call(this, source.x, source.y) || this;
  12468. _this.buttonIndex = buttonIndex;
  12469. return _this;
  12470. }
  12471. return Vector2WithInfo;
  12472. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  12473. /** Class used to provide 2D matrix features */
  12474. var Matrix2D = /** @class */ (function () {
  12475. /**
  12476. * Creates a new matrix
  12477. * @param m00 defines value for (0, 0)
  12478. * @param m01 defines value for (0, 1)
  12479. * @param m10 defines value for (1, 0)
  12480. * @param m11 defines value for (1, 1)
  12481. * @param m20 defines value for (2, 0)
  12482. * @param m21 defines value for (2, 1)
  12483. */
  12484. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  12485. /** Gets the internal array of 6 floats used to store matrix data */
  12486. this.m = new Float32Array(6);
  12487. this.fromValues(m00, m01, m10, m11, m20, m21);
  12488. }
  12489. /**
  12490. * Fills the matrix from direct values
  12491. * @param m00 defines value for (0, 0)
  12492. * @param m01 defines value for (0, 1)
  12493. * @param m10 defines value for (1, 0)
  12494. * @param m11 defines value for (1, 1)
  12495. * @param m20 defines value for (2, 0)
  12496. * @param m21 defines value for (2, 1)
  12497. * @returns the current modified matrix
  12498. */
  12499. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  12500. this.m[0] = m00;
  12501. this.m[1] = m01;
  12502. this.m[2] = m10;
  12503. this.m[3] = m11;
  12504. this.m[4] = m20;
  12505. this.m[5] = m21;
  12506. return this;
  12507. };
  12508. /**
  12509. * Gets matrix determinant
  12510. * @returns the determinant
  12511. */
  12512. Matrix2D.prototype.determinant = function () {
  12513. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  12514. };
  12515. /**
  12516. * Inverses the matrix and stores it in a target matrix
  12517. * @param result defines the target matrix
  12518. * @returns the current matrix
  12519. */
  12520. Matrix2D.prototype.invertToRef = function (result) {
  12521. var l0 = this.m[0];
  12522. var l1 = this.m[1];
  12523. var l2 = this.m[2];
  12524. var l3 = this.m[3];
  12525. var l4 = this.m[4];
  12526. var l5 = this.m[5];
  12527. var det = this.determinant();
  12528. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  12529. result.m[0] = 0;
  12530. result.m[1] = 0;
  12531. result.m[2] = 0;
  12532. result.m[3] = 0;
  12533. result.m[4] = 0;
  12534. result.m[5] = 0;
  12535. return this;
  12536. }
  12537. var detDiv = 1 / det;
  12538. var det4 = l2 * l5 - l3 * l4;
  12539. var det5 = l1 * l4 - l0 * l5;
  12540. result.m[0] = l3 * detDiv;
  12541. result.m[1] = -l1 * detDiv;
  12542. result.m[2] = -l2 * detDiv;
  12543. result.m[3] = l0 * detDiv;
  12544. result.m[4] = det4 * detDiv;
  12545. result.m[5] = det5 * detDiv;
  12546. return this;
  12547. };
  12548. /**
  12549. * Multiplies the current matrix with another one
  12550. * @param other defines the second operand
  12551. * @param result defines the target matrix
  12552. * @returns the current matrix
  12553. */
  12554. Matrix2D.prototype.multiplyToRef = function (other, result) {
  12555. var l0 = this.m[0];
  12556. var l1 = this.m[1];
  12557. var l2 = this.m[2];
  12558. var l3 = this.m[3];
  12559. var l4 = this.m[4];
  12560. var l5 = this.m[5];
  12561. var r0 = other.m[0];
  12562. var r1 = other.m[1];
  12563. var r2 = other.m[2];
  12564. var r3 = other.m[3];
  12565. var r4 = other.m[4];
  12566. var r5 = other.m[5];
  12567. result.m[0] = l0 * r0 + l1 * r2;
  12568. result.m[1] = l0 * r1 + l1 * r3;
  12569. result.m[2] = l2 * r0 + l3 * r2;
  12570. result.m[3] = l2 * r1 + l3 * r3;
  12571. result.m[4] = l4 * r0 + l5 * r2 + r4;
  12572. result.m[5] = l4 * r1 + l5 * r3 + r5;
  12573. return this;
  12574. };
  12575. /**
  12576. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  12577. * @param x defines the x coordinate to transform
  12578. * @param y defines the x coordinate to transform
  12579. * @param result defines the target vector2
  12580. * @returns the current matrix
  12581. */
  12582. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  12583. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  12584. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  12585. return this;
  12586. };
  12587. // Statics
  12588. /**
  12589. * Creates an identity matrix
  12590. * @returns a new matrix
  12591. */
  12592. Matrix2D.Identity = function () {
  12593. return new Matrix2D(1, 0, 0, 1, 0, 0);
  12594. };
  12595. /**
  12596. * Creates a translation matrix and stores it in a target matrix
  12597. * @param x defines the x coordinate of the translation
  12598. * @param y defines the y coordinate of the translation
  12599. * @param result defines the target matrix
  12600. */
  12601. Matrix2D.TranslationToRef = function (x, y, result) {
  12602. result.fromValues(1, 0, 0, 1, x, y);
  12603. };
  12604. /**
  12605. * Creates a scaling matrix and stores it in a target matrix
  12606. * @param x defines the x coordinate of the scaling
  12607. * @param y defines the y coordinate of the scaling
  12608. * @param result defines the target matrix
  12609. */
  12610. Matrix2D.ScalingToRef = function (x, y, result) {
  12611. result.fromValues(x, 0, 0, y, 0, 0);
  12612. };
  12613. /**
  12614. * Creates a rotation matrix and stores it in a target matrix
  12615. * @param angle defines the rotation angle
  12616. * @param result defines the target matrix
  12617. */
  12618. Matrix2D.RotationToRef = function (angle, result) {
  12619. var s = Math.sin(angle);
  12620. var c = Math.cos(angle);
  12621. result.fromValues(c, s, -s, c, 0, 0);
  12622. };
  12623. /**
  12624. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  12625. * @param tx defines the x coordinate of the translation
  12626. * @param ty defines the y coordinate of the translation
  12627. * @param angle defines the rotation angle
  12628. * @param scaleX defines the x coordinate of the scaling
  12629. * @param scaleY defines the y coordinate of the scaling
  12630. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  12631. * @param result defines the target matrix
  12632. */
  12633. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  12634. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  12635. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  12636. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  12637. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  12638. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  12639. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  12640. if (parentMatrix) {
  12641. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  12642. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  12643. }
  12644. else {
  12645. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  12646. }
  12647. };
  12648. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  12649. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  12650. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  12651. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  12652. Matrix2D._TempCompose0 = Matrix2D.Identity();
  12653. Matrix2D._TempCompose1 = Matrix2D.Identity();
  12654. Matrix2D._TempCompose2 = Matrix2D.Identity();
  12655. return Matrix2D;
  12656. }());
  12657. /***/ }),
  12658. /***/ "./2D/measure.ts":
  12659. /*!***********************!*\
  12660. !*** ./2D/measure.ts ***!
  12661. \***********************/
  12662. /*! exports provided: Measure */
  12663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12664. "use strict";
  12665. __webpack_require__.r(__webpack_exports__);
  12666. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  12667. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12668. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12669. var tmpRect = [
  12670. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12671. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12672. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12673. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12674. ];
  12675. var tmpRect2 = [
  12676. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12677. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12678. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12679. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12680. ];
  12681. var tmpV1 = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12682. var tmpV2 = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12683. /**
  12684. * Class used to store 2D control sizes
  12685. */
  12686. var Measure = /** @class */ (function () {
  12687. /**
  12688. * Creates a new measure
  12689. * @param left defines left coordinate
  12690. * @param top defines top coordinate
  12691. * @param width defines width dimension
  12692. * @param height defines height dimension
  12693. */
  12694. function Measure(
  12695. /** defines left coordinate */
  12696. left,
  12697. /** defines top coordinate */
  12698. top,
  12699. /** defines width dimension */
  12700. width,
  12701. /** defines height dimension */
  12702. height) {
  12703. this.left = left;
  12704. this.top = top;
  12705. this.width = width;
  12706. this.height = height;
  12707. }
  12708. /**
  12709. * Copy from another measure
  12710. * @param other defines the other measure to copy from
  12711. */
  12712. Measure.prototype.copyFrom = function (other) {
  12713. this.left = other.left;
  12714. this.top = other.top;
  12715. this.width = other.width;
  12716. this.height = other.height;
  12717. };
  12718. /**
  12719. * Copy from a group of 4 floats
  12720. * @param left defines left coordinate
  12721. * @param top defines top coordinate
  12722. * @param width defines width dimension
  12723. * @param height defines height dimension
  12724. */
  12725. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  12726. this.left = left;
  12727. this.top = top;
  12728. this.width = width;
  12729. this.height = height;
  12730. };
  12731. /**
  12732. * Computes the axis aligned bounding box measure for two given measures
  12733. * @param a Input measure
  12734. * @param b Input measure
  12735. * @param result the resulting bounding measure
  12736. */
  12737. Measure.CombineToRef = function (a, b, result) {
  12738. var left = Math.min(a.left, b.left);
  12739. var top = Math.min(a.top, b.top);
  12740. var right = Math.max(a.left + a.width, b.left + b.width);
  12741. var bottom = Math.max(a.top + a.height, b.top + b.height);
  12742. result.left = left;
  12743. result.top = top;
  12744. result.width = right - left;
  12745. result.height = bottom - top;
  12746. };
  12747. /**
  12748. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  12749. * @param transform the matrix to transform the measure before computing the AABB
  12750. * @param result the resulting AABB
  12751. */
  12752. Measure.prototype.transformToRef = function (transform, result) {
  12753. tmpRect[0].copyFromFloats(this.left, this.top);
  12754. tmpRect[1].copyFromFloats(this.left + this.width, this.top);
  12755. tmpRect[2].copyFromFloats(this.left + this.width, this.top + this.height);
  12756. tmpRect[3].copyFromFloats(this.left, this.top + this.height);
  12757. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  12758. tmpV2.copyFromFloats(0, 0);
  12759. for (var i = 0; i < 4; i++) {
  12760. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  12761. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  12762. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  12763. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  12764. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  12765. }
  12766. result.left = tmpV1.x;
  12767. result.top = tmpV1.y;
  12768. result.width = tmpV2.x - tmpV1.x;
  12769. result.height = tmpV2.y - tmpV1.y;
  12770. };
  12771. /**
  12772. * Check equality between this measure and another one
  12773. * @param other defines the other measures
  12774. * @returns true if both measures are equals
  12775. */
  12776. Measure.prototype.isEqualsTo = function (other) {
  12777. if (this.left !== other.left) {
  12778. return false;
  12779. }
  12780. if (this.top !== other.top) {
  12781. return false;
  12782. }
  12783. if (this.width !== other.width) {
  12784. return false;
  12785. }
  12786. if (this.height !== other.height) {
  12787. return false;
  12788. }
  12789. return true;
  12790. };
  12791. /**
  12792. * Creates an empty measure
  12793. * @returns a new measure
  12794. */
  12795. Measure.Empty = function () {
  12796. return new Measure(0, 0, 0, 0);
  12797. };
  12798. return Measure;
  12799. }());
  12800. /***/ }),
  12801. /***/ "./2D/multiLinePoint.ts":
  12802. /*!******************************!*\
  12803. !*** ./2D/multiLinePoint.ts ***!
  12804. \******************************/
  12805. /*! exports provided: MultiLinePoint */
  12806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12807. "use strict";
  12808. __webpack_require__.r(__webpack_exports__);
  12809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  12810. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12811. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12812. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12813. /**
  12814. * Class used to store a point for a MultiLine object.
  12815. * The point can be pure 2D coordinates, a mesh or a control
  12816. */
  12817. var MultiLinePoint = /** @class */ (function () {
  12818. /**
  12819. * Creates a new MultiLinePoint
  12820. * @param multiLine defines the source MultiLine object
  12821. */
  12822. function MultiLinePoint(multiLine) {
  12823. this._multiLine = multiLine;
  12824. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12825. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12826. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12827. }
  12828. Object.defineProperty(MultiLinePoint.prototype, "x", {
  12829. /** Gets or sets x coordinate */
  12830. get: function () {
  12831. return this._x.toString(this._multiLine._host);
  12832. },
  12833. set: function (value) {
  12834. if (this._x.toString(this._multiLine._host) === value) {
  12835. return;
  12836. }
  12837. if (this._x.fromString(value)) {
  12838. this._multiLine._markAsDirty();
  12839. }
  12840. },
  12841. enumerable: true,
  12842. configurable: true
  12843. });
  12844. Object.defineProperty(MultiLinePoint.prototype, "y", {
  12845. /** Gets or sets y coordinate */
  12846. get: function () {
  12847. return this._y.toString(this._multiLine._host);
  12848. },
  12849. set: function (value) {
  12850. if (this._y.toString(this._multiLine._host) === value) {
  12851. return;
  12852. }
  12853. if (this._y.fromString(value)) {
  12854. this._multiLine._markAsDirty();
  12855. }
  12856. },
  12857. enumerable: true,
  12858. configurable: true
  12859. });
  12860. Object.defineProperty(MultiLinePoint.prototype, "control", {
  12861. /** Gets or sets the control associated with this point */
  12862. get: function () {
  12863. return this._control;
  12864. },
  12865. set: function (value) {
  12866. if (this._control === value) {
  12867. return;
  12868. }
  12869. if (this._control && this._controlObserver) {
  12870. this._control.onDirtyObservable.remove(this._controlObserver);
  12871. this._controlObserver = null;
  12872. }
  12873. this._control = value;
  12874. if (this._control) {
  12875. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  12876. }
  12877. this._multiLine._markAsDirty();
  12878. },
  12879. enumerable: true,
  12880. configurable: true
  12881. });
  12882. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  12883. /** Gets or sets the mesh associated with this point */
  12884. get: function () {
  12885. return this._mesh;
  12886. },
  12887. set: function (value) {
  12888. if (this._mesh === value) {
  12889. return;
  12890. }
  12891. if (this._mesh && this._meshObserver) {
  12892. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  12893. }
  12894. this._mesh = value;
  12895. if (this._mesh) {
  12896. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  12897. }
  12898. this._multiLine._markAsDirty();
  12899. },
  12900. enumerable: true,
  12901. configurable: true
  12902. });
  12903. /** Resets links */
  12904. MultiLinePoint.prototype.resetLinks = function () {
  12905. this.control = null;
  12906. this.mesh = null;
  12907. };
  12908. /**
  12909. * Gets a translation vector
  12910. * @returns the translation vector
  12911. */
  12912. MultiLinePoint.prototype.translate = function () {
  12913. this._point = this._translatePoint();
  12914. return this._point;
  12915. };
  12916. MultiLinePoint.prototype._translatePoint = function () {
  12917. if (this._mesh != null) {
  12918. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  12919. }
  12920. else if (this._control != null) {
  12921. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  12922. }
  12923. else {
  12924. var host = this._multiLine._host;
  12925. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  12926. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  12927. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  12928. }
  12929. };
  12930. /** Release associated resources */
  12931. MultiLinePoint.prototype.dispose = function () {
  12932. this.resetLinks();
  12933. };
  12934. return MultiLinePoint;
  12935. }());
  12936. /***/ }),
  12937. /***/ "./2D/style.ts":
  12938. /*!*********************!*\
  12939. !*** ./2D/style.ts ***!
  12940. \*********************/
  12941. /*! exports provided: Style */
  12942. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12943. "use strict";
  12944. __webpack_require__.r(__webpack_exports__);
  12945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  12946. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12947. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12948. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12949. /**
  12950. * Define a style used by control to automatically setup properties based on a template.
  12951. * Only support font related properties so far
  12952. */
  12953. var Style = /** @class */ (function () {
  12954. /**
  12955. * Creates a new style object
  12956. * @param host defines the AdvancedDynamicTexture which hosts this style
  12957. */
  12958. function Style(host) {
  12959. this._fontFamily = "Arial";
  12960. this._fontStyle = "";
  12961. this._fontWeight = "";
  12962. /** @hidden */
  12963. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12964. /**
  12965. * Observable raised when the style values are changed
  12966. */
  12967. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12968. this._host = host;
  12969. }
  12970. Object.defineProperty(Style.prototype, "fontSize", {
  12971. /**
  12972. * Gets or sets the font size
  12973. */
  12974. get: function () {
  12975. return this._fontSize.toString(this._host);
  12976. },
  12977. set: function (value) {
  12978. if (this._fontSize.toString(this._host) === value) {
  12979. return;
  12980. }
  12981. if (this._fontSize.fromString(value)) {
  12982. this.onChangedObservable.notifyObservers(this);
  12983. }
  12984. },
  12985. enumerable: true,
  12986. configurable: true
  12987. });
  12988. Object.defineProperty(Style.prototype, "fontFamily", {
  12989. /**
  12990. * Gets or sets the font family
  12991. */
  12992. get: function () {
  12993. return this._fontFamily;
  12994. },
  12995. set: function (value) {
  12996. if (this._fontFamily === value) {
  12997. return;
  12998. }
  12999. this._fontFamily = value;
  13000. this.onChangedObservable.notifyObservers(this);
  13001. },
  13002. enumerable: true,
  13003. configurable: true
  13004. });
  13005. Object.defineProperty(Style.prototype, "fontStyle", {
  13006. /**
  13007. * Gets or sets the font style
  13008. */
  13009. get: function () {
  13010. return this._fontStyle;
  13011. },
  13012. set: function (value) {
  13013. if (this._fontStyle === value) {
  13014. return;
  13015. }
  13016. this._fontStyle = value;
  13017. this.onChangedObservable.notifyObservers(this);
  13018. },
  13019. enumerable: true,
  13020. configurable: true
  13021. });
  13022. Object.defineProperty(Style.prototype, "fontWeight", {
  13023. /** Gets or sets font weight */
  13024. get: function () {
  13025. return this._fontWeight;
  13026. },
  13027. set: function (value) {
  13028. if (this._fontWeight === value) {
  13029. return;
  13030. }
  13031. this._fontWeight = value;
  13032. this.onChangedObservable.notifyObservers(this);
  13033. },
  13034. enumerable: true,
  13035. configurable: true
  13036. });
  13037. /** Dispose all associated resources */
  13038. Style.prototype.dispose = function () {
  13039. this.onChangedObservable.clear();
  13040. };
  13041. return Style;
  13042. }());
  13043. /***/ }),
  13044. /***/ "./2D/valueAndUnit.ts":
  13045. /*!****************************!*\
  13046. !*** ./2D/valueAndUnit.ts ***!
  13047. \****************************/
  13048. /*! exports provided: ValueAndUnit */
  13049. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13050. "use strict";
  13051. __webpack_require__.r(__webpack_exports__);
  13052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  13053. /**
  13054. * Class used to specific a value and its associated unit
  13055. */
  13056. var ValueAndUnit = /** @class */ (function () {
  13057. /**
  13058. * Creates a new ValueAndUnit
  13059. * @param value defines the value to store
  13060. * @param unit defines the unit to store
  13061. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  13062. */
  13063. function ValueAndUnit(value,
  13064. /** defines the unit to store */
  13065. unit,
  13066. /** defines a boolean indicating if the value can be negative */
  13067. negativeValueAllowed) {
  13068. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13069. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  13070. this.unit = unit;
  13071. this.negativeValueAllowed = negativeValueAllowed;
  13072. this._value = 1;
  13073. /**
  13074. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  13075. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  13076. */
  13077. this.ignoreAdaptiveScaling = false;
  13078. this._value = value;
  13079. this._originalUnit = unit;
  13080. }
  13081. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  13082. /** Gets a boolean indicating if the value is a percentage */
  13083. get: function () {
  13084. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  13085. },
  13086. enumerable: true,
  13087. configurable: true
  13088. });
  13089. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  13090. /** Gets a boolean indicating if the value is store as pixel */
  13091. get: function () {
  13092. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  13093. },
  13094. enumerable: true,
  13095. configurable: true
  13096. });
  13097. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  13098. /** Gets direct internal value */
  13099. get: function () {
  13100. return this._value;
  13101. },
  13102. enumerable: true,
  13103. configurable: true
  13104. });
  13105. /**
  13106. * Gets value as pixel
  13107. * @param host defines the root host
  13108. * @param refValue defines the reference value for percentages
  13109. * @returns the value as pixel
  13110. */
  13111. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  13112. if (this.isPixel) {
  13113. return this.getValue(host);
  13114. }
  13115. return this.getValue(host) * refValue;
  13116. };
  13117. /**
  13118. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  13119. * @param value defines the value to store
  13120. * @param unit defines the unit to store
  13121. * @returns the current ValueAndUnit
  13122. */
  13123. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  13124. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13125. this._value = value;
  13126. this.unit = unit;
  13127. return this;
  13128. };
  13129. /**
  13130. * Gets the value accordingly to its unit
  13131. * @param host defines the root host
  13132. * @returns the value
  13133. */
  13134. ValueAndUnit.prototype.getValue = function (host) {
  13135. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  13136. var width = 0;
  13137. var height = 0;
  13138. if (host.idealWidth) {
  13139. width = (this._value * host.getSize().width) / host.idealWidth;
  13140. }
  13141. if (host.idealHeight) {
  13142. height = (this._value * host.getSize().height) / host.idealHeight;
  13143. }
  13144. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  13145. return window.innerWidth < window.innerHeight ? width : height;
  13146. }
  13147. if (host.idealWidth) { // horizontal
  13148. return width;
  13149. }
  13150. if (host.idealHeight) { // vertical
  13151. return height;
  13152. }
  13153. }
  13154. return this._value;
  13155. };
  13156. /**
  13157. * Gets a string representation of the value
  13158. * @param host defines the root host
  13159. * @param decimals defines an optional number of decimals to display
  13160. * @returns a string
  13161. */
  13162. ValueAndUnit.prototype.toString = function (host, decimals) {
  13163. switch (this.unit) {
  13164. case ValueAndUnit.UNITMODE_PERCENTAGE:
  13165. var percentage = this.getValue(host) * 100;
  13166. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  13167. case ValueAndUnit.UNITMODE_PIXEL:
  13168. var pixels = this.getValue(host);
  13169. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  13170. }
  13171. return this.unit.toString();
  13172. };
  13173. /**
  13174. * Store a value parsed from a string
  13175. * @param source defines the source string
  13176. * @returns true if the value was successfully parsed
  13177. */
  13178. ValueAndUnit.prototype.fromString = function (source) {
  13179. var match = ValueAndUnit._Regex.exec(source.toString());
  13180. if (!match || match.length === 0) {
  13181. return false;
  13182. }
  13183. var sourceValue = parseFloat(match[1]);
  13184. var sourceUnit = this._originalUnit;
  13185. if (!this.negativeValueAllowed) {
  13186. if (sourceValue < 0) {
  13187. sourceValue = 0;
  13188. }
  13189. }
  13190. if (match.length === 4) {
  13191. switch (match[3]) {
  13192. case "px":
  13193. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  13194. break;
  13195. case "%":
  13196. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  13197. sourceValue /= 100.0;
  13198. break;
  13199. }
  13200. }
  13201. if (sourceValue === this._value && sourceUnit === this.unit) {
  13202. return false;
  13203. }
  13204. this._value = sourceValue;
  13205. this.unit = sourceUnit;
  13206. return true;
  13207. };
  13208. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  13209. /** UNITMODE_PERCENTAGE */
  13210. get: function () {
  13211. return ValueAndUnit._UNITMODE_PERCENTAGE;
  13212. },
  13213. enumerable: true,
  13214. configurable: true
  13215. });
  13216. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  13217. /** UNITMODE_PIXEL */
  13218. get: function () {
  13219. return ValueAndUnit._UNITMODE_PIXEL;
  13220. },
  13221. enumerable: true,
  13222. configurable: true
  13223. });
  13224. // Static
  13225. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  13226. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  13227. ValueAndUnit._UNITMODE_PIXEL = 1;
  13228. return ValueAndUnit;
  13229. }());
  13230. /***/ }),
  13231. /***/ "./2D/xmlLoader.ts":
  13232. /*!*************************!*\
  13233. !*** ./2D/xmlLoader.ts ***!
  13234. \*************************/
  13235. /*! exports provided: XmlLoader */
  13236. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13237. "use strict";
  13238. __webpack_require__.r(__webpack_exports__);
  13239. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  13240. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  13241. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  13242. /**
  13243. * Class used to load GUI via XML.
  13244. */
  13245. var XmlLoader = /** @class */ (function () {
  13246. /**
  13247. * Create a new xml loader
  13248. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  13249. */
  13250. function XmlLoader(parentClass) {
  13251. if (parentClass === void 0) { parentClass = null; }
  13252. this._nodes = {};
  13253. this._nodeTypes = {
  13254. element: 1,
  13255. attribute: 2,
  13256. text: 3
  13257. };
  13258. this._isLoaded = false;
  13259. this._objectAttributes = {
  13260. "textHorizontalAlignment": 1,
  13261. "textVerticalAlignment": 2,
  13262. "horizontalAlignment": 3,
  13263. "verticalAlignment": 4,
  13264. "stretch": 5,
  13265. };
  13266. if (parentClass) {
  13267. this._parentClass = parentClass;
  13268. }
  13269. }
  13270. XmlLoader.prototype._getChainElement = function (attributeValue) {
  13271. var element = window;
  13272. if (this._parentClass) {
  13273. element = this._parentClass;
  13274. }
  13275. var value = attributeValue;
  13276. value = value.split(".");
  13277. for (var i = 0; i < value.length; i++) {
  13278. element = element[value[i]];
  13279. }
  13280. return element;
  13281. };
  13282. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  13283. var attribute = attributeName.split(".");
  13284. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  13285. return className[attribute[1]];
  13286. };
  13287. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  13288. if (linkParent === void 0) { linkParent = true; }
  13289. try {
  13290. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  13291. var guiNode = new className();
  13292. if (parent && linkParent) {
  13293. parent.addControl(guiNode);
  13294. }
  13295. for (var i = 0; i < node.attributes.length; i++) {
  13296. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  13297. continue;
  13298. }
  13299. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  13300. var element = this._getChainElement(node.attributes[i].value);
  13301. guiNode[node.attributes[i].name].add(element);
  13302. continue;
  13303. }
  13304. else if (node.attributes[i].name == "linkWithMesh") {
  13305. if (this._parentClass) {
  13306. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  13307. }
  13308. else {
  13309. guiNode.linkWithMesh(window[node.attributes[i].value]);
  13310. }
  13311. }
  13312. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  13313. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  13314. guiNode[node.attributes[i].name] = element;
  13315. }
  13316. else if (!this._objectAttributes[node.attributes[i].name]) {
  13317. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  13318. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  13319. }
  13320. else {
  13321. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  13322. }
  13323. }
  13324. else {
  13325. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  13326. }
  13327. }
  13328. if (!node.attributes.getNamedItem("id")) {
  13329. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  13330. return guiNode;
  13331. }
  13332. var id = node.attributes.getNamedItem("id").value;
  13333. if (id.startsWith("{{") && id.endsWith("}}")) {
  13334. id = this._getChainElement(id.substring(2, id.length - 2));
  13335. }
  13336. if (!this._nodes[id]) {
  13337. this._nodes[id] = guiNode;
  13338. }
  13339. else {
  13340. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  13341. }
  13342. return guiNode;
  13343. }
  13344. catch (e) {
  13345. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  13346. }
  13347. };
  13348. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  13349. var width;
  13350. var height;
  13351. var columns;
  13352. var rows = node.children;
  13353. var cells;
  13354. var isPixel = false;
  13355. var cellNode;
  13356. var rowNumber = -1;
  13357. var columnNumber = -1;
  13358. var totalColumnsNumber = 0;
  13359. for (var i = 0; i < rows.length; i++) {
  13360. if (rows[i].nodeType != this._nodeTypes.element) {
  13361. continue;
  13362. }
  13363. if (rows[i].nodeName != "Row") {
  13364. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  13365. }
  13366. rowNumber += 1;
  13367. columns = rows[i].children;
  13368. if (!rows[i].attributes.getNamedItem("height")) {
  13369. throw "XmlLoader Exception : Height must be defined for grid rows";
  13370. }
  13371. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  13372. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  13373. guiNode.addRowDefinition(height, isPixel);
  13374. for (var j = 0; j < columns.length; j++) {
  13375. if (columns[j].nodeType != this._nodeTypes.element) {
  13376. continue;
  13377. }
  13378. if (columns[j].nodeName != "Column") {
  13379. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  13380. }
  13381. columnNumber += 1;
  13382. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  13383. 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.";
  13384. }
  13385. if (rowNumber == 0) {
  13386. if (!columns[j].attributes.getNamedItem("width")) {
  13387. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  13388. }
  13389. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  13390. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  13391. guiNode.addColumnDefinition(width, isPixel);
  13392. }
  13393. cells = columns[j].children;
  13394. for (var k = 0; k < cells.length; k++) {
  13395. if (cells[k].nodeType != this._nodeTypes.element) {
  13396. continue;
  13397. }
  13398. cellNode = this._createGuiElement(cells[k], guiNode, false);
  13399. guiNode.addControl(cellNode, rowNumber, columnNumber);
  13400. if (cells[k].firstChild) {
  13401. this._parseXml(cells[k].firstChild, cellNode);
  13402. }
  13403. }
  13404. }
  13405. if (rowNumber == 0) {
  13406. totalColumnsNumber = columnNumber;
  13407. }
  13408. columnNumber = -1;
  13409. }
  13410. if (node.nextSibling) {
  13411. this._parseXml(node.nextSibling, parent);
  13412. }
  13413. };
  13414. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  13415. if (node.firstChild) {
  13416. this._parseXml(node.firstChild, guiNode);
  13417. }
  13418. if (node.nextSibling) {
  13419. this._parseXml(node.nextSibling, parent);
  13420. }
  13421. };
  13422. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  13423. if (this._parentClass) {
  13424. this._parentClass[variable] = source[iterator];
  13425. }
  13426. else {
  13427. window[variable] = source[iterator];
  13428. }
  13429. if (node.firstChild) {
  13430. this._parseXml(node.firstChild, guiNode, true);
  13431. }
  13432. };
  13433. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  13434. var dataSource = node.attributes.getNamedItem("dataSource").value;
  13435. if (!dataSource.includes(" in ")) {
  13436. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  13437. }
  13438. else {
  13439. var isArray = true;
  13440. var splittedSource = dataSource.split(" in ");
  13441. if (splittedSource.length < 2) {
  13442. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  13443. }
  13444. var source = splittedSource[1];
  13445. if (source.startsWith("{") && source.endsWith("}")) {
  13446. isArray = false;
  13447. }
  13448. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  13449. source = source.substring(1, source.length - 1);
  13450. }
  13451. if (this._parentClass) {
  13452. source = this._parentClass[source];
  13453. }
  13454. else {
  13455. source = window[source];
  13456. }
  13457. if (isArray) {
  13458. for (var i = 0; i < source.length; i++) {
  13459. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13460. }
  13461. }
  13462. else {
  13463. for (var i in source) {
  13464. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13465. }
  13466. }
  13467. if (node.nextSibling) {
  13468. this._parseXml(node.nextSibling, parent);
  13469. }
  13470. }
  13471. };
  13472. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  13473. if (generated === void 0) { generated = false; }
  13474. if (node.nodeType != this._nodeTypes.element) {
  13475. if (node.nextSibling) {
  13476. this._parseXml(node.nextSibling, parent, generated);
  13477. }
  13478. return;
  13479. }
  13480. if (generated) {
  13481. node.setAttribute("id", parent.id + (parent._children.length + 1));
  13482. }
  13483. var guiNode = this._createGuiElement(node, parent);
  13484. if (node.nodeName == "Grid") {
  13485. this._parseGrid(node, guiNode, parent);
  13486. }
  13487. else if (!node.attributes.getNamedItem("dataSource")) {
  13488. this._parseElement(node, guiNode, parent);
  13489. }
  13490. else {
  13491. this._parseElementsFromSource(node, guiNode, parent);
  13492. }
  13493. };
  13494. /**
  13495. * Gets if the loading has finished.
  13496. * @returns whether the loading has finished or not
  13497. */
  13498. XmlLoader.prototype.isLoaded = function () {
  13499. return this._isLoaded;
  13500. };
  13501. /**
  13502. * Gets a loaded node / control by id.
  13503. * @param id the Controls id set in the xml
  13504. * @returns element of type Control
  13505. */
  13506. XmlLoader.prototype.getNodeById = function (id) {
  13507. return this._nodes[id];
  13508. };
  13509. /**
  13510. * Gets all loaded nodes / controls
  13511. * @returns Array of controls
  13512. */
  13513. XmlLoader.prototype.getNodes = function () {
  13514. return this._nodes;
  13515. };
  13516. /**
  13517. * Initiates the xml layout loading
  13518. * @param xmlFile defines the xml layout to load
  13519. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  13520. * @param callback defines the callback called on layout load.
  13521. */
  13522. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  13523. var xhttp = new XMLHttpRequest();
  13524. xhttp.onreadystatechange = function () {
  13525. if (xhttp.readyState == 4 && xhttp.status == 200) {
  13526. if (!xhttp.responseXML) {
  13527. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  13528. }
  13529. var xmlDoc = xhttp.responseXML.documentElement;
  13530. this._parseXml(xmlDoc.firstChild, rootNode);
  13531. this._isLoaded = true;
  13532. if (callback) {
  13533. callback();
  13534. }
  13535. }
  13536. }.bind(this);
  13537. xhttp.open("GET", xmlFile, true);
  13538. xhttp.send();
  13539. };
  13540. return XmlLoader;
  13541. }());
  13542. /***/ }),
  13543. /***/ "./3D/controls/abstractButton3D.ts":
  13544. /*!*****************************************!*\
  13545. !*** ./3D/controls/abstractButton3D.ts ***!
  13546. \*****************************************/
  13547. /*! exports provided: AbstractButton3D */
  13548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13549. "use strict";
  13550. __webpack_require__.r(__webpack_exports__);
  13551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  13552. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13553. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  13554. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13555. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13556. /**
  13557. * Class used as a root to all buttons
  13558. */
  13559. var AbstractButton3D = /** @class */ (function (_super) {
  13560. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  13561. /**
  13562. * Creates a new button
  13563. * @param name defines the control name
  13564. */
  13565. function AbstractButton3D(name) {
  13566. return _super.call(this, name) || this;
  13567. }
  13568. AbstractButton3D.prototype._getTypeName = function () {
  13569. return "AbstractButton3D";
  13570. };
  13571. // Mesh association
  13572. AbstractButton3D.prototype._createNode = function (scene) {
  13573. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  13574. };
  13575. return AbstractButton3D;
  13576. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13577. /***/ }),
  13578. /***/ "./3D/controls/button3D.ts":
  13579. /*!*********************************!*\
  13580. !*** ./3D/controls/button3D.ts ***!
  13581. \*********************************/
  13582. /*! exports provided: Button3D */
  13583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13584. "use strict";
  13585. __webpack_require__.r(__webpack_exports__);
  13586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  13587. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13588. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  13589. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13590. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13591. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13592. /**
  13593. * Class used to create a button in 3D
  13594. */
  13595. var Button3D = /** @class */ (function (_super) {
  13596. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  13597. /**
  13598. * Creates a new button
  13599. * @param name defines the control name
  13600. */
  13601. function Button3D(name) {
  13602. var _this = _super.call(this, name) || this;
  13603. _this._contentResolution = 512;
  13604. _this._contentScaleRatio = 2;
  13605. // Default animations
  13606. _this.pointerEnterAnimation = function () {
  13607. if (!_this.mesh) {
  13608. return;
  13609. }
  13610. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  13611. };
  13612. _this.pointerOutAnimation = function () {
  13613. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13614. };
  13615. _this.pointerDownAnimation = function () {
  13616. if (!_this.mesh) {
  13617. return;
  13618. }
  13619. _this.mesh.scaling.scaleInPlace(0.95);
  13620. };
  13621. _this.pointerUpAnimation = function () {
  13622. if (!_this.mesh) {
  13623. return;
  13624. }
  13625. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13626. };
  13627. return _this;
  13628. }
  13629. Object.defineProperty(Button3D.prototype, "contentResolution", {
  13630. /**
  13631. * Gets or sets the texture resolution used to render content (512 by default)
  13632. */
  13633. get: function () {
  13634. return this._contentResolution;
  13635. },
  13636. set: function (value) {
  13637. if (this._contentResolution === value) {
  13638. return;
  13639. }
  13640. this._contentResolution = value;
  13641. this._resetContent();
  13642. },
  13643. enumerable: true,
  13644. configurable: true
  13645. });
  13646. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  13647. /**
  13648. * Gets or sets the texture scale ratio used to render content (2 by default)
  13649. */
  13650. get: function () {
  13651. return this._contentScaleRatio;
  13652. },
  13653. set: function (value) {
  13654. if (this._contentScaleRatio === value) {
  13655. return;
  13656. }
  13657. this._contentScaleRatio = value;
  13658. this._resetContent();
  13659. },
  13660. enumerable: true,
  13661. configurable: true
  13662. });
  13663. Button3D.prototype._disposeFacadeTexture = function () {
  13664. if (this._facadeTexture) {
  13665. this._facadeTexture.dispose();
  13666. this._facadeTexture = null;
  13667. }
  13668. };
  13669. Button3D.prototype._resetContent = function () {
  13670. this._disposeFacadeTexture();
  13671. this.content = this._content;
  13672. };
  13673. Object.defineProperty(Button3D.prototype, "content", {
  13674. /**
  13675. * Gets or sets the GUI 2D content used to display the button's facade
  13676. */
  13677. get: function () {
  13678. return this._content;
  13679. },
  13680. set: function (value) {
  13681. this._content = value;
  13682. if (!this._host || !this._host.utilityLayer) {
  13683. return;
  13684. }
  13685. if (!this._facadeTexture) {
  13686. 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);
  13687. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  13688. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  13689. this._facadeTexture.premulAlpha = true;
  13690. }
  13691. else {
  13692. this._facadeTexture.rootContainer.clearControls();
  13693. }
  13694. this._facadeTexture.addControl(value);
  13695. this._applyFacade(this._facadeTexture);
  13696. },
  13697. enumerable: true,
  13698. configurable: true
  13699. });
  13700. /**
  13701. * Apply the facade texture (created from the content property).
  13702. * This function can be overloaded by child classes
  13703. * @param facadeTexture defines the AdvancedDynamicTexture to use
  13704. */
  13705. Button3D.prototype._applyFacade = function (facadeTexture) {
  13706. this._currentMaterial.emissiveTexture = facadeTexture;
  13707. };
  13708. Button3D.prototype._getTypeName = function () {
  13709. return "Button3D";
  13710. };
  13711. // Mesh association
  13712. Button3D.prototype._createNode = function (scene) {
  13713. var faceUV = new Array(6);
  13714. for (var i = 0; i < 6; i++) {
  13715. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  13716. }
  13717. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  13718. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  13719. width: 1.0,
  13720. height: 1.0,
  13721. depth: 0.08,
  13722. faceUV: faceUV
  13723. }, scene);
  13724. return mesh;
  13725. };
  13726. Button3D.prototype._affectMaterial = function (mesh) {
  13727. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  13728. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13729. mesh.material = material;
  13730. this._currentMaterial = material;
  13731. this._resetContent();
  13732. };
  13733. /**
  13734. * Releases all associated resources
  13735. */
  13736. Button3D.prototype.dispose = function () {
  13737. _super.prototype.dispose.call(this);
  13738. this._disposeFacadeTexture();
  13739. if (this._currentMaterial) {
  13740. this._currentMaterial.dispose();
  13741. }
  13742. };
  13743. return Button3D;
  13744. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  13745. /***/ }),
  13746. /***/ "./3D/controls/container3D.ts":
  13747. /*!************************************!*\
  13748. !*** ./3D/controls/container3D.ts ***!
  13749. \************************************/
  13750. /*! exports provided: Container3D */
  13751. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13752. "use strict";
  13753. __webpack_require__.r(__webpack_exports__);
  13754. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  13755. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13756. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  13757. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13758. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13759. /**
  13760. * Class used to create containers for controls
  13761. */
  13762. var Container3D = /** @class */ (function (_super) {
  13763. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  13764. /**
  13765. * Creates a new container
  13766. * @param name defines the container name
  13767. */
  13768. function Container3D(name) {
  13769. var _this = _super.call(this, name) || this;
  13770. _this._blockLayout = false;
  13771. /**
  13772. * Gets the list of child controls
  13773. */
  13774. _this._children = new Array();
  13775. return _this;
  13776. }
  13777. Object.defineProperty(Container3D.prototype, "children", {
  13778. /**
  13779. * Gets the list of child controls
  13780. */
  13781. get: function () {
  13782. return this._children;
  13783. },
  13784. enumerable: true,
  13785. configurable: true
  13786. });
  13787. Object.defineProperty(Container3D.prototype, "blockLayout", {
  13788. /**
  13789. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  13790. * This is helpful to optimize layout operation when adding multiple children in a row
  13791. */
  13792. get: function () {
  13793. return this._blockLayout;
  13794. },
  13795. set: function (value) {
  13796. if (this._blockLayout === value) {
  13797. return;
  13798. }
  13799. this._blockLayout = value;
  13800. if (!this._blockLayout) {
  13801. this._arrangeChildren();
  13802. }
  13803. },
  13804. enumerable: true,
  13805. configurable: true
  13806. });
  13807. /**
  13808. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  13809. * @returns the current container
  13810. */
  13811. Container3D.prototype.updateLayout = function () {
  13812. this._arrangeChildren();
  13813. return this;
  13814. };
  13815. /**
  13816. * Gets a boolean indicating if the given control is in the children of this control
  13817. * @param control defines the control to check
  13818. * @returns true if the control is in the child list
  13819. */
  13820. Container3D.prototype.containsControl = function (control) {
  13821. return this._children.indexOf(control) !== -1;
  13822. };
  13823. /**
  13824. * Adds a control to the children of this control
  13825. * @param control defines the control to add
  13826. * @returns the current container
  13827. */
  13828. Container3D.prototype.addControl = function (control) {
  13829. var index = this._children.indexOf(control);
  13830. if (index !== -1) {
  13831. return this;
  13832. }
  13833. control.parent = this;
  13834. control._host = this._host;
  13835. this._children.push(control);
  13836. if (this._host.utilityLayer) {
  13837. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  13838. if (control.node) {
  13839. control.node.parent = this.node;
  13840. }
  13841. if (!this.blockLayout) {
  13842. this._arrangeChildren();
  13843. }
  13844. }
  13845. return this;
  13846. };
  13847. /**
  13848. * This function will be called everytime a new control is added
  13849. */
  13850. Container3D.prototype._arrangeChildren = function () {
  13851. };
  13852. Container3D.prototype._createNode = function (scene) {
  13853. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  13854. };
  13855. /**
  13856. * Removes a control from the children of this control
  13857. * @param control defines the control to remove
  13858. * @returns the current container
  13859. */
  13860. Container3D.prototype.removeControl = function (control) {
  13861. var index = this._children.indexOf(control);
  13862. if (index !== -1) {
  13863. this._children.splice(index, 1);
  13864. control.parent = null;
  13865. control._disposeNode();
  13866. }
  13867. return this;
  13868. };
  13869. Container3D.prototype._getTypeName = function () {
  13870. return "Container3D";
  13871. };
  13872. /**
  13873. * Releases all associated resources
  13874. */
  13875. Container3D.prototype.dispose = function () {
  13876. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13877. var control = _a[_i];
  13878. control.dispose();
  13879. }
  13880. this._children = [];
  13881. _super.prototype.dispose.call(this);
  13882. };
  13883. /** Control rotation will remain unchanged */
  13884. Container3D.UNSET_ORIENTATION = 0;
  13885. /** Control will rotate to make it look at sphere central axis */
  13886. Container3D.FACEORIGIN_ORIENTATION = 1;
  13887. /** Control will rotate to make it look back at sphere central axis */
  13888. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  13889. /** Control will rotate to look at z axis (0, 0, 1) */
  13890. Container3D.FACEFORWARD_ORIENTATION = 3;
  13891. /** Control will rotate to look at negative z axis (0, 0, -1) */
  13892. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  13893. return Container3D;
  13894. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13895. /***/ }),
  13896. /***/ "./3D/controls/control3D.ts":
  13897. /*!**********************************!*\
  13898. !*** ./3D/controls/control3D.ts ***!
  13899. \**********************************/
  13900. /*! exports provided: Control3D */
  13901. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13902. "use strict";
  13903. __webpack_require__.r(__webpack_exports__);
  13904. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  13905. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  13906. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13907. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  13908. /**
  13909. * Class used as base class for controls
  13910. */
  13911. var Control3D = /** @class */ (function () {
  13912. /**
  13913. * Creates a new control
  13914. * @param name defines the control name
  13915. */
  13916. function Control3D(
  13917. /** Defines the control name */
  13918. name) {
  13919. this.name = name;
  13920. this._downCount = 0;
  13921. this._enterCount = -1;
  13922. this._downPointerIds = {};
  13923. this._isVisible = true;
  13924. /**
  13925. * An event triggered when the pointer move over the control
  13926. */
  13927. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13928. /**
  13929. * An event triggered when the pointer move out of the control
  13930. */
  13931. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13932. /**
  13933. * An event triggered when the pointer taps the control
  13934. */
  13935. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13936. /**
  13937. * An event triggered when pointer is up
  13938. */
  13939. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13940. /**
  13941. * An event triggered when a control is clicked on (with a mouse)
  13942. */
  13943. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13944. /**
  13945. * An event triggered when pointer enters the control
  13946. */
  13947. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13948. // Behaviors
  13949. this._behaviors = new Array();
  13950. }
  13951. Object.defineProperty(Control3D.prototype, "position", {
  13952. /** Gets or sets the control position in world space */
  13953. get: function () {
  13954. if (!this._node) {
  13955. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  13956. }
  13957. return this._node.position;
  13958. },
  13959. set: function (value) {
  13960. if (!this._node) {
  13961. return;
  13962. }
  13963. this._node.position = value;
  13964. },
  13965. enumerable: true,
  13966. configurable: true
  13967. });
  13968. Object.defineProperty(Control3D.prototype, "scaling", {
  13969. /** Gets or sets the control scaling in world space */
  13970. get: function () {
  13971. if (!this._node) {
  13972. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  13973. }
  13974. return this._node.scaling;
  13975. },
  13976. set: function (value) {
  13977. if (!this._node) {
  13978. return;
  13979. }
  13980. this._node.scaling = value;
  13981. },
  13982. enumerable: true,
  13983. configurable: true
  13984. });
  13985. Object.defineProperty(Control3D.prototype, "behaviors", {
  13986. /**
  13987. * Gets the list of attached behaviors
  13988. * @see http://doc.babylonjs.com/features/behaviour
  13989. */
  13990. get: function () {
  13991. return this._behaviors;
  13992. },
  13993. enumerable: true,
  13994. configurable: true
  13995. });
  13996. /**
  13997. * Attach a behavior to the control
  13998. * @see http://doc.babylonjs.com/features/behaviour
  13999. * @param behavior defines the behavior to attach
  14000. * @returns the current control
  14001. */
  14002. Control3D.prototype.addBehavior = function (behavior) {
  14003. var _this = this;
  14004. var index = this._behaviors.indexOf(behavior);
  14005. if (index !== -1) {
  14006. return this;
  14007. }
  14008. behavior.init();
  14009. var scene = this._host.scene;
  14010. if (scene.isLoading) {
  14011. // We defer the attach when the scene will be loaded
  14012. scene.onDataLoadedObservable.addOnce(function () {
  14013. behavior.attach(_this);
  14014. });
  14015. }
  14016. else {
  14017. behavior.attach(this);
  14018. }
  14019. this._behaviors.push(behavior);
  14020. return this;
  14021. };
  14022. /**
  14023. * Remove an attached behavior
  14024. * @see http://doc.babylonjs.com/features/behaviour
  14025. * @param behavior defines the behavior to attach
  14026. * @returns the current control
  14027. */
  14028. Control3D.prototype.removeBehavior = function (behavior) {
  14029. var index = this._behaviors.indexOf(behavior);
  14030. if (index === -1) {
  14031. return this;
  14032. }
  14033. this._behaviors[index].detach();
  14034. this._behaviors.splice(index, 1);
  14035. return this;
  14036. };
  14037. /**
  14038. * Gets an attached behavior by name
  14039. * @param name defines the name of the behavior to look for
  14040. * @see http://doc.babylonjs.com/features/behaviour
  14041. * @returns null if behavior was not found else the requested behavior
  14042. */
  14043. Control3D.prototype.getBehaviorByName = function (name) {
  14044. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14045. var behavior = _a[_i];
  14046. if (behavior.name === name) {
  14047. return behavior;
  14048. }
  14049. }
  14050. return null;
  14051. };
  14052. Object.defineProperty(Control3D.prototype, "isVisible", {
  14053. /** Gets or sets a boolean indicating if the control is visible */
  14054. get: function () {
  14055. return this._isVisible;
  14056. },
  14057. set: function (value) {
  14058. if (this._isVisible === value) {
  14059. return;
  14060. }
  14061. this._isVisible = value;
  14062. var mesh = this.mesh;
  14063. if (mesh) {
  14064. mesh.setEnabled(value);
  14065. }
  14066. },
  14067. enumerable: true,
  14068. configurable: true
  14069. });
  14070. Object.defineProperty(Control3D.prototype, "typeName", {
  14071. /**
  14072. * Gets a string representing the class name
  14073. */
  14074. get: function () {
  14075. return this._getTypeName();
  14076. },
  14077. enumerable: true,
  14078. configurable: true
  14079. });
  14080. /**
  14081. * Get the current class name of the control.
  14082. * @returns current class name
  14083. */
  14084. Control3D.prototype.getClassName = function () {
  14085. return this._getTypeName();
  14086. };
  14087. Control3D.prototype._getTypeName = function () {
  14088. return "Control3D";
  14089. };
  14090. Object.defineProperty(Control3D.prototype, "node", {
  14091. /**
  14092. * Gets the transform node used by this control
  14093. */
  14094. get: function () {
  14095. return this._node;
  14096. },
  14097. enumerable: true,
  14098. configurable: true
  14099. });
  14100. Object.defineProperty(Control3D.prototype, "mesh", {
  14101. /**
  14102. * Gets the mesh used to render this control
  14103. */
  14104. get: function () {
  14105. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  14106. return this._node;
  14107. }
  14108. return null;
  14109. },
  14110. enumerable: true,
  14111. configurable: true
  14112. });
  14113. /**
  14114. * Link the control as child of the given node
  14115. * @param node defines the node to link to. Use null to unlink the control
  14116. * @returns the current control
  14117. */
  14118. Control3D.prototype.linkToTransformNode = function (node) {
  14119. if (this._node) {
  14120. this._node.parent = node;
  14121. }
  14122. return this;
  14123. };
  14124. /** @hidden **/
  14125. Control3D.prototype._prepareNode = function (scene) {
  14126. if (!this._node) {
  14127. this._node = this._createNode(scene);
  14128. if (!this.node) {
  14129. return;
  14130. }
  14131. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  14132. this._node.position = this.position;
  14133. this._node.scaling = this.scaling;
  14134. var mesh = this.mesh;
  14135. if (mesh) {
  14136. mesh.isPickable = true;
  14137. this._affectMaterial(mesh);
  14138. }
  14139. }
  14140. };
  14141. /**
  14142. * Node creation.
  14143. * Can be overriden by children
  14144. * @param scene defines the scene where the node must be attached
  14145. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  14146. */
  14147. Control3D.prototype._createNode = function (scene) {
  14148. // Do nothing by default
  14149. return null;
  14150. };
  14151. /**
  14152. * Affect a material to the given mesh
  14153. * @param mesh defines the mesh which will represent the control
  14154. */
  14155. Control3D.prototype._affectMaterial = function (mesh) {
  14156. mesh.material = null;
  14157. };
  14158. // Pointers
  14159. /** @hidden */
  14160. Control3D.prototype._onPointerMove = function (target, coordinates) {
  14161. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  14162. };
  14163. /** @hidden */
  14164. Control3D.prototype._onPointerEnter = function (target) {
  14165. if (this._enterCount > 0) {
  14166. return false;
  14167. }
  14168. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  14169. this._enterCount = 0;
  14170. }
  14171. this._enterCount++;
  14172. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  14173. if (this.pointerEnterAnimation) {
  14174. this.pointerEnterAnimation();
  14175. }
  14176. return true;
  14177. };
  14178. /** @hidden */
  14179. Control3D.prototype._onPointerOut = function (target) {
  14180. this._enterCount = 0;
  14181. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  14182. if (this.pointerOutAnimation) {
  14183. this.pointerOutAnimation();
  14184. }
  14185. };
  14186. /** @hidden */
  14187. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  14188. if (this._downCount !== 0) {
  14189. this._downCount++;
  14190. return false;
  14191. }
  14192. this._downCount++;
  14193. this._downPointerIds[pointerId] = true;
  14194. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14195. if (this.pointerDownAnimation) {
  14196. this.pointerDownAnimation();
  14197. }
  14198. return true;
  14199. };
  14200. /** @hidden */
  14201. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  14202. this._downCount--;
  14203. delete this._downPointerIds[pointerId];
  14204. if (this._downCount < 0) {
  14205. // Handle if forcePointerUp was called prior to this
  14206. this._downCount = 0;
  14207. return;
  14208. }
  14209. if (this._downCount == 0) {
  14210. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  14211. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14212. }
  14213. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14214. if (this.pointerUpAnimation) {
  14215. this.pointerUpAnimation();
  14216. }
  14217. }
  14218. };
  14219. /** @hidden */
  14220. Control3D.prototype.forcePointerUp = function (pointerId) {
  14221. if (pointerId === void 0) { pointerId = null; }
  14222. if (pointerId !== null) {
  14223. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  14224. }
  14225. else {
  14226. for (var key in this._downPointerIds) {
  14227. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  14228. }
  14229. if (this._downCount > 0) {
  14230. this._downCount = 1;
  14231. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  14232. }
  14233. }
  14234. };
  14235. /** @hidden */
  14236. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  14237. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14238. this._onPointerMove(this, pickedPoint);
  14239. var previousControlOver = this._host._lastControlOver[pointerId];
  14240. if (previousControlOver && previousControlOver !== this) {
  14241. previousControlOver._onPointerOut(this);
  14242. }
  14243. if (previousControlOver !== this) {
  14244. this._onPointerEnter(this);
  14245. }
  14246. this._host._lastControlOver[pointerId] = this;
  14247. return true;
  14248. }
  14249. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  14250. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  14251. this._host._lastControlDown[pointerId] = this;
  14252. this._host._lastPickedControl = this;
  14253. return true;
  14254. }
  14255. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14256. if (this._host._lastControlDown[pointerId]) {
  14257. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  14258. }
  14259. delete this._host._lastControlDown[pointerId];
  14260. return true;
  14261. }
  14262. return false;
  14263. };
  14264. /** @hidden */
  14265. Control3D.prototype._disposeNode = function () {
  14266. if (this._node) {
  14267. this._node.dispose();
  14268. this._node = null;
  14269. }
  14270. };
  14271. /**
  14272. * Releases all associated resources
  14273. */
  14274. Control3D.prototype.dispose = function () {
  14275. this.onPointerDownObservable.clear();
  14276. this.onPointerEnterObservable.clear();
  14277. this.onPointerMoveObservable.clear();
  14278. this.onPointerOutObservable.clear();
  14279. this.onPointerUpObservable.clear();
  14280. this.onPointerClickObservable.clear();
  14281. this._disposeNode();
  14282. // Behaviors
  14283. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14284. var behavior = _a[_i];
  14285. behavior.detach();
  14286. }
  14287. };
  14288. return Control3D;
  14289. }());
  14290. /***/ }),
  14291. /***/ "./3D/controls/cylinderPanel.ts":
  14292. /*!**************************************!*\
  14293. !*** ./3D/controls/cylinderPanel.ts ***!
  14294. \**************************************/
  14295. /*! exports provided: CylinderPanel */
  14296. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14297. "use strict";
  14298. __webpack_require__.r(__webpack_exports__);
  14299. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  14300. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14301. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  14302. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14303. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14304. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14305. /**
  14306. * Class used to create a container panel deployed on the surface of a cylinder
  14307. */
  14308. var CylinderPanel = /** @class */ (function (_super) {
  14309. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  14310. function CylinderPanel() {
  14311. var _this = _super !== null && _super.apply(this, arguments) || this;
  14312. _this._radius = 5.0;
  14313. return _this;
  14314. }
  14315. Object.defineProperty(CylinderPanel.prototype, "radius", {
  14316. /**
  14317. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  14318. */
  14319. get: function () {
  14320. return this._radius;
  14321. },
  14322. set: function (value) {
  14323. var _this = this;
  14324. if (this._radius === value) {
  14325. return;
  14326. }
  14327. this._radius = value;
  14328. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14329. _this._arrangeChildren();
  14330. });
  14331. },
  14332. enumerable: true,
  14333. configurable: true
  14334. });
  14335. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  14336. var mesh = control.mesh;
  14337. if (!mesh) {
  14338. return;
  14339. }
  14340. var newPos = this._cylindricalMapping(nodePosition);
  14341. control.position = newPos;
  14342. switch (this.orientation) {
  14343. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14344. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  14345. break;
  14346. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14347. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  14348. break;
  14349. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14350. break;
  14351. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14352. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14353. break;
  14354. }
  14355. };
  14356. CylinderPanel.prototype._cylindricalMapping = function (source) {
  14357. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  14358. var yAngle = (source.x / this._radius);
  14359. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14360. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14361. };
  14362. return CylinderPanel;
  14363. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14364. /***/ }),
  14365. /***/ "./3D/controls/holographicButton.ts":
  14366. /*!******************************************!*\
  14367. !*** ./3D/controls/holographicButton.ts ***!
  14368. \******************************************/
  14369. /*! exports provided: HolographicButton */
  14370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14371. "use strict";
  14372. __webpack_require__.r(__webpack_exports__);
  14373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  14374. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14375. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14376. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  14377. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  14378. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14379. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  14380. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  14381. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  14382. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14383. /**
  14384. * Class used to create a holographic button in 3D
  14385. */
  14386. var HolographicButton = /** @class */ (function (_super) {
  14387. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  14388. /**
  14389. * Creates a new button
  14390. * @param name defines the control name
  14391. */
  14392. function HolographicButton(name, shareMaterials) {
  14393. if (shareMaterials === void 0) { shareMaterials = true; }
  14394. var _this = _super.call(this, name) || this;
  14395. _this._shareMaterials = true;
  14396. _this._shareMaterials = shareMaterials;
  14397. // Default animations
  14398. _this.pointerEnterAnimation = function () {
  14399. if (!_this.mesh) {
  14400. return;
  14401. }
  14402. _this._frontPlate.setEnabled(true);
  14403. };
  14404. _this.pointerOutAnimation = function () {
  14405. if (!_this.mesh) {
  14406. return;
  14407. }
  14408. _this._frontPlate.setEnabled(false);
  14409. };
  14410. return _this;
  14411. }
  14412. HolographicButton.prototype._disposeTooltip = function () {
  14413. this._tooltipFade = null;
  14414. if (this._tooltipTextBlock) {
  14415. this._tooltipTextBlock.dispose();
  14416. }
  14417. if (this._tooltipTexture) {
  14418. this._tooltipTexture.dispose();
  14419. }
  14420. if (this._tooltipMesh) {
  14421. this._tooltipMesh.dispose();
  14422. }
  14423. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  14424. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  14425. };
  14426. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  14427. get: function () {
  14428. return this._backPlate.renderingGroupId;
  14429. },
  14430. /**
  14431. * Rendering ground id of all the mesh in the button
  14432. */
  14433. set: function (id) {
  14434. this._backPlate.renderingGroupId = id;
  14435. this._textPlate.renderingGroupId = id;
  14436. this._frontPlate.renderingGroupId = id;
  14437. if (this._tooltipMesh) {
  14438. this._tooltipMesh.renderingGroupId = id;
  14439. }
  14440. },
  14441. enumerable: true,
  14442. configurable: true
  14443. });
  14444. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  14445. get: function () {
  14446. if (this._tooltipTextBlock) {
  14447. return this._tooltipTextBlock.text;
  14448. }
  14449. return null;
  14450. },
  14451. /**
  14452. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  14453. */
  14454. set: function (text) {
  14455. var _this = this;
  14456. if (!text) {
  14457. this._disposeTooltip();
  14458. return;
  14459. }
  14460. if (!this._tooltipFade) {
  14461. // Create tooltip with mesh and text
  14462. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  14463. 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);
  14464. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  14465. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  14466. tooltipBackground.material = mat;
  14467. tooltipBackground.isPickable = false;
  14468. this._tooltipMesh.addChild(tooltipBackground);
  14469. tooltipBackground.position.z = 0.05;
  14470. this._tooltipMesh.scaling.y = 1 / 3;
  14471. this._tooltipMesh.position.y = 0.7;
  14472. this._tooltipMesh.position.z = -0.15;
  14473. this._tooltipMesh.isPickable = false;
  14474. this._tooltipMesh.parent = this._backPlate;
  14475. // Create text texture for the tooltip
  14476. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  14477. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14478. this._tooltipTextBlock.scaleY = 3;
  14479. this._tooltipTextBlock.color = "white";
  14480. this._tooltipTextBlock.fontSize = 130;
  14481. this._tooltipTexture.addControl(this._tooltipTextBlock);
  14482. // Add hover action to tooltip
  14483. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  14484. this._tooltipFade.delay = 500;
  14485. this._tooltipMesh.addBehavior(this._tooltipFade);
  14486. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  14487. if (_this._tooltipFade) {
  14488. _this._tooltipFade.fadeIn(true);
  14489. }
  14490. });
  14491. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  14492. if (_this._tooltipFade) {
  14493. _this._tooltipFade.fadeIn(false);
  14494. }
  14495. });
  14496. }
  14497. if (this._tooltipTextBlock) {
  14498. this._tooltipTextBlock.text = text;
  14499. }
  14500. },
  14501. enumerable: true,
  14502. configurable: true
  14503. });
  14504. Object.defineProperty(HolographicButton.prototype, "text", {
  14505. /**
  14506. * Gets or sets text for the button
  14507. */
  14508. get: function () {
  14509. return this._text;
  14510. },
  14511. set: function (value) {
  14512. if (this._text === value) {
  14513. return;
  14514. }
  14515. this._text = value;
  14516. this._rebuildContent();
  14517. },
  14518. enumerable: true,
  14519. configurable: true
  14520. });
  14521. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  14522. /**
  14523. * Gets or sets the image url for the button
  14524. */
  14525. get: function () {
  14526. return this._imageUrl;
  14527. },
  14528. set: function (value) {
  14529. if (this._imageUrl === value) {
  14530. return;
  14531. }
  14532. this._imageUrl = value;
  14533. this._rebuildContent();
  14534. },
  14535. enumerable: true,
  14536. configurable: true
  14537. });
  14538. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  14539. /**
  14540. * Gets the back material used by this button
  14541. */
  14542. get: function () {
  14543. return this._backMaterial;
  14544. },
  14545. enumerable: true,
  14546. configurable: true
  14547. });
  14548. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  14549. /**
  14550. * Gets the front material used by this button
  14551. */
  14552. get: function () {
  14553. return this._frontMaterial;
  14554. },
  14555. enumerable: true,
  14556. configurable: true
  14557. });
  14558. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  14559. /**
  14560. * Gets the plate material used by this button
  14561. */
  14562. get: function () {
  14563. return this._plateMaterial;
  14564. },
  14565. enumerable: true,
  14566. configurable: true
  14567. });
  14568. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  14569. /**
  14570. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  14571. */
  14572. get: function () {
  14573. return this._shareMaterials;
  14574. },
  14575. enumerable: true,
  14576. configurable: true
  14577. });
  14578. HolographicButton.prototype._getTypeName = function () {
  14579. return "HolographicButton";
  14580. };
  14581. HolographicButton.prototype._rebuildContent = function () {
  14582. this._disposeFacadeTexture();
  14583. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  14584. panel.isVertical = true;
  14585. if (this._imageUrl) {
  14586. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  14587. image.source = this._imageUrl;
  14588. image.paddingTop = "40px";
  14589. image.height = "180px";
  14590. image.width = "100px";
  14591. image.paddingBottom = "40px";
  14592. panel.addControl(image);
  14593. }
  14594. if (this._text) {
  14595. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14596. text.text = this._text;
  14597. text.color = "white";
  14598. text.height = "30px";
  14599. text.fontSize = 24;
  14600. panel.addControl(text);
  14601. }
  14602. if (this._frontPlate) {
  14603. this.content = panel;
  14604. }
  14605. };
  14606. // Mesh association
  14607. HolographicButton.prototype._createNode = function (scene) {
  14608. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  14609. width: 1.0,
  14610. height: 1.0,
  14611. depth: 0.08
  14612. }, scene);
  14613. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  14614. width: 1.0,
  14615. height: 1.0,
  14616. depth: 0.08
  14617. }, scene);
  14618. this._frontPlate.parent = this._backPlate;
  14619. this._frontPlate.position.z = -0.08;
  14620. this._frontPlate.isPickable = false;
  14621. this._frontPlate.setEnabled(false);
  14622. this._textPlate = _super.prototype._createNode.call(this, scene);
  14623. this._textPlate.parent = this._backPlate;
  14624. this._textPlate.position.z = -0.08;
  14625. this._textPlate.isPickable = false;
  14626. return this._backPlate;
  14627. };
  14628. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  14629. this._plateMaterial.emissiveTexture = facadeTexture;
  14630. this._plateMaterial.opacityTexture = facadeTexture;
  14631. };
  14632. HolographicButton.prototype._createBackMaterial = function (mesh) {
  14633. var _this = this;
  14634. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  14635. this._backMaterial.renderHoverLight = true;
  14636. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  14637. if (pickedPoint) {
  14638. _this._backMaterial.hoverPosition = pickedPoint;
  14639. _this._backMaterial.hoverColor.a = 1.0;
  14640. }
  14641. else {
  14642. _this._backMaterial.hoverColor.a = 0;
  14643. }
  14644. });
  14645. };
  14646. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  14647. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  14648. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  14649. this._frontMaterial.alpha = 0.5; // Additive
  14650. this._frontMaterial.renderBorders = true;
  14651. };
  14652. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  14653. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  14654. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  14655. };
  14656. HolographicButton.prototype._affectMaterial = function (mesh) {
  14657. // Back
  14658. if (this._shareMaterials) {
  14659. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  14660. this._createBackMaterial(mesh);
  14661. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  14662. }
  14663. else {
  14664. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  14665. }
  14666. // Front
  14667. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  14668. this._createFrontMaterial(mesh);
  14669. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  14670. }
  14671. else {
  14672. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  14673. }
  14674. }
  14675. else {
  14676. this._createBackMaterial(mesh);
  14677. this._createFrontMaterial(mesh);
  14678. }
  14679. this._createPlateMaterial(mesh);
  14680. this._backPlate.material = this._backMaterial;
  14681. this._frontPlate.material = this._frontMaterial;
  14682. this._textPlate.material = this._plateMaterial;
  14683. this._rebuildContent();
  14684. };
  14685. /**
  14686. * Releases all associated resources
  14687. */
  14688. HolographicButton.prototype.dispose = function () {
  14689. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  14690. this._disposeTooltip();
  14691. if (!this.shareMaterials) {
  14692. this._backMaterial.dispose();
  14693. this._frontMaterial.dispose();
  14694. this._plateMaterial.dispose();
  14695. if (this._pickedPointObserver) {
  14696. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  14697. this._pickedPointObserver = null;
  14698. }
  14699. }
  14700. };
  14701. return HolographicButton;
  14702. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14703. /***/ }),
  14704. /***/ "./3D/controls/index.ts":
  14705. /*!******************************!*\
  14706. !*** ./3D/controls/index.ts ***!
  14707. \******************************/
  14708. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  14709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14710. "use strict";
  14711. __webpack_require__.r(__webpack_exports__);
  14712. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  14713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14714. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14716. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  14718. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  14720. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  14721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  14722. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  14723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  14724. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  14725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  14726. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  14727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  14728. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  14729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  14730. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  14731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  14732. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  14733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  14734. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  14736. /***/ }),
  14737. /***/ "./3D/controls/meshButton3D.ts":
  14738. /*!*************************************!*\
  14739. !*** ./3D/controls/meshButton3D.ts ***!
  14740. \*************************************/
  14741. /*! exports provided: MeshButton3D */
  14742. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14743. "use strict";
  14744. __webpack_require__.r(__webpack_exports__);
  14745. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  14746. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14747. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14748. /**
  14749. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  14750. */
  14751. var MeshButton3D = /** @class */ (function (_super) {
  14752. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  14753. /**
  14754. * Creates a new 3D button based on a mesh
  14755. * @param mesh mesh to become a 3D button
  14756. * @param name defines the control name
  14757. */
  14758. function MeshButton3D(mesh, name) {
  14759. var _this = _super.call(this, name) || this;
  14760. _this._currentMesh = mesh;
  14761. /**
  14762. * Provides a default behavior on hover/out & up/down
  14763. * Override those function to create your own desired behavior specific to your mesh
  14764. */
  14765. _this.pointerEnterAnimation = function () {
  14766. if (!_this.mesh) {
  14767. return;
  14768. }
  14769. _this.mesh.scaling.scaleInPlace(1.1);
  14770. };
  14771. _this.pointerOutAnimation = function () {
  14772. if (!_this.mesh) {
  14773. return;
  14774. }
  14775. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  14776. };
  14777. _this.pointerDownAnimation = function () {
  14778. if (!_this.mesh) {
  14779. return;
  14780. }
  14781. _this.mesh.scaling.scaleInPlace(0.95);
  14782. };
  14783. _this.pointerUpAnimation = function () {
  14784. if (!_this.mesh) {
  14785. return;
  14786. }
  14787. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  14788. };
  14789. return _this;
  14790. }
  14791. MeshButton3D.prototype._getTypeName = function () {
  14792. return "MeshButton3D";
  14793. };
  14794. // Mesh association
  14795. MeshButton3D.prototype._createNode = function (scene) {
  14796. var _this = this;
  14797. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  14798. mesh.metadata = _this;
  14799. });
  14800. return this._currentMesh;
  14801. };
  14802. MeshButton3D.prototype._affectMaterial = function (mesh) {
  14803. };
  14804. return MeshButton3D;
  14805. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14806. /***/ }),
  14807. /***/ "./3D/controls/planePanel.ts":
  14808. /*!***********************************!*\
  14809. !*** ./3D/controls/planePanel.ts ***!
  14810. \***********************************/
  14811. /*! exports provided: PlanePanel */
  14812. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14813. "use strict";
  14814. __webpack_require__.r(__webpack_exports__);
  14815. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  14816. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14817. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  14818. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14819. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14820. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14821. /**
  14822. * Class used to create a container panel deployed on the surface of a plane
  14823. */
  14824. var PlanePanel = /** @class */ (function (_super) {
  14825. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  14826. function PlanePanel() {
  14827. return _super !== null && _super.apply(this, arguments) || this;
  14828. }
  14829. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  14830. var mesh = control.mesh;
  14831. if (!mesh) {
  14832. return;
  14833. }
  14834. control.position = nodePosition.clone();
  14835. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14836. target.copyFrom(nodePosition);
  14837. switch (this.orientation) {
  14838. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  14839. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  14840. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  14841. mesh.lookAt(target);
  14842. break;
  14843. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14844. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14845. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  14846. mesh.lookAt(target);
  14847. break;
  14848. }
  14849. };
  14850. return PlanePanel;
  14851. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  14852. /***/ }),
  14853. /***/ "./3D/controls/scatterPanel.ts":
  14854. /*!*************************************!*\
  14855. !*** ./3D/controls/scatterPanel.ts ***!
  14856. \*************************************/
  14857. /*! exports provided: ScatterPanel */
  14858. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14859. "use strict";
  14860. __webpack_require__.r(__webpack_exports__);
  14861. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  14862. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14863. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  14864. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14865. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14866. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14867. /**
  14868. * Class used to create a container panel where items get randomized planar mapping
  14869. */
  14870. var ScatterPanel = /** @class */ (function (_super) {
  14871. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  14872. function ScatterPanel() {
  14873. var _this = _super !== null && _super.apply(this, arguments) || this;
  14874. _this._iteration = 100.0;
  14875. return _this;
  14876. }
  14877. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  14878. /**
  14879. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  14880. */
  14881. get: function () {
  14882. return this._iteration;
  14883. },
  14884. set: function (value) {
  14885. var _this = this;
  14886. if (this._iteration === value) {
  14887. return;
  14888. }
  14889. this._iteration = value;
  14890. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14891. _this._arrangeChildren();
  14892. });
  14893. },
  14894. enumerable: true,
  14895. configurable: true
  14896. });
  14897. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  14898. var mesh = control.mesh;
  14899. var newPos = this._scatterMapping(nodePosition);
  14900. if (!mesh) {
  14901. return;
  14902. }
  14903. switch (this.orientation) {
  14904. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14905. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14906. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  14907. break;
  14908. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14909. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14910. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  14911. break;
  14912. }
  14913. control.position = newPos;
  14914. };
  14915. ScatterPanel.prototype._scatterMapping = function (source) {
  14916. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  14917. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  14918. return source;
  14919. };
  14920. ScatterPanel.prototype._finalProcessing = function () {
  14921. var meshes = [];
  14922. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14923. var child = _a[_i];
  14924. if (!child.mesh) {
  14925. continue;
  14926. }
  14927. meshes.push(child.mesh);
  14928. }
  14929. for (var count = 0; count < this._iteration; count++) {
  14930. meshes.sort(function (a, b) {
  14931. var distance1 = a.position.lengthSquared();
  14932. var distance2 = b.position.lengthSquared();
  14933. if (distance1 < distance2) {
  14934. return 1;
  14935. }
  14936. else if (distance1 > distance2) {
  14937. return -1;
  14938. }
  14939. return 0;
  14940. });
  14941. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  14942. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  14943. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  14944. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14945. for (var i = 0; i < meshes.length - 1; i++) {
  14946. for (var j = i + 1; j < meshes.length; j++) {
  14947. if (i != j) {
  14948. meshes[j].position.subtractToRef(meshes[i].position, difference);
  14949. // Ignore Z axis
  14950. difference2D.x = difference.x;
  14951. difference2D.y = difference.y;
  14952. var combinedRadius = cellSize;
  14953. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  14954. var minSeparation = Math.min(distance, radiusPaddingSquared);
  14955. distance -= minSeparation;
  14956. if (distance < (Math.pow(combinedRadius, 2.0))) {
  14957. difference2D.normalize();
  14958. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  14959. meshes[j].position.addInPlace(difference);
  14960. meshes[i].position.subtractInPlace(difference);
  14961. }
  14962. }
  14963. }
  14964. }
  14965. }
  14966. };
  14967. return ScatterPanel;
  14968. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14969. /***/ }),
  14970. /***/ "./3D/controls/spherePanel.ts":
  14971. /*!************************************!*\
  14972. !*** ./3D/controls/spherePanel.ts ***!
  14973. \************************************/
  14974. /*! exports provided: SpherePanel */
  14975. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14976. "use strict";
  14977. __webpack_require__.r(__webpack_exports__);
  14978. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  14979. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14980. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  14981. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14982. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14983. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14984. /**
  14985. * Class used to create a container panel deployed on the surface of a sphere
  14986. */
  14987. var SpherePanel = /** @class */ (function (_super) {
  14988. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  14989. function SpherePanel() {
  14990. var _this = _super !== null && _super.apply(this, arguments) || this;
  14991. _this._radius = 5.0;
  14992. return _this;
  14993. }
  14994. Object.defineProperty(SpherePanel.prototype, "radius", {
  14995. /**
  14996. * Gets or sets the radius of the sphere where to project controls (5 by default)
  14997. */
  14998. get: function () {
  14999. return this._radius;
  15000. },
  15001. set: function (value) {
  15002. var _this = this;
  15003. if (this._radius === value) {
  15004. return;
  15005. }
  15006. this._radius = value;
  15007. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15008. _this._arrangeChildren();
  15009. });
  15010. },
  15011. enumerable: true,
  15012. configurable: true
  15013. });
  15014. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  15015. var mesh = control.mesh;
  15016. if (!mesh) {
  15017. return;
  15018. }
  15019. var newPos = this._sphericalMapping(nodePosition);
  15020. control.position = newPos;
  15021. switch (this.orientation) {
  15022. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15023. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  15024. break;
  15025. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15026. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  15027. break;
  15028. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15029. break;
  15030. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15031. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  15032. break;
  15033. }
  15034. };
  15035. SpherePanel.prototype._sphericalMapping = function (source) {
  15036. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  15037. var xAngle = (source.y / this._radius);
  15038. var yAngle = -(source.x / this._radius);
  15039. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15040. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15041. };
  15042. return SpherePanel;
  15043. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15044. /***/ }),
  15045. /***/ "./3D/controls/stackPanel3D.ts":
  15046. /*!*************************************!*\
  15047. !*** ./3D/controls/stackPanel3D.ts ***!
  15048. \*************************************/
  15049. /*! exports provided: StackPanel3D */
  15050. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15051. "use strict";
  15052. __webpack_require__.r(__webpack_exports__);
  15053. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  15054. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15055. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15056. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15057. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15058. /**
  15059. * Class used to create a stack panel in 3D on XY plane
  15060. */
  15061. var StackPanel3D = /** @class */ (function (_super) {
  15062. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  15063. /**
  15064. * Creates new StackPanel
  15065. * @param isVertical
  15066. */
  15067. function StackPanel3D(isVertical) {
  15068. if (isVertical === void 0) { isVertical = false; }
  15069. var _this = _super.call(this) || this;
  15070. _this._isVertical = false;
  15071. /**
  15072. * Gets or sets the distance between elements
  15073. */
  15074. _this.margin = 0.1;
  15075. _this._isVertical = isVertical;
  15076. return _this;
  15077. }
  15078. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  15079. /**
  15080. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  15081. */
  15082. get: function () {
  15083. return this._isVertical;
  15084. },
  15085. set: function (value) {
  15086. var _this = this;
  15087. if (this._isVertical === value) {
  15088. return;
  15089. }
  15090. this._isVertical = value;
  15091. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15092. _this._arrangeChildren();
  15093. });
  15094. },
  15095. enumerable: true,
  15096. configurable: true
  15097. });
  15098. StackPanel3D.prototype._arrangeChildren = function () {
  15099. var width = 0;
  15100. var height = 0;
  15101. var controlCount = 0;
  15102. var extendSizes = [];
  15103. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15104. // Measure
  15105. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15106. var child = _a[_i];
  15107. if (!child.mesh) {
  15108. continue;
  15109. }
  15110. controlCount++;
  15111. child.mesh.computeWorldMatrix(true);
  15112. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15113. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  15114. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15115. extendSizes.push(extendSize);
  15116. if (this._isVertical) {
  15117. height += extendSize.y;
  15118. }
  15119. else {
  15120. width += extendSize.x;
  15121. }
  15122. }
  15123. if (this._isVertical) {
  15124. height += (controlCount - 1) * this.margin / 2;
  15125. }
  15126. else {
  15127. width += (controlCount - 1) * this.margin / 2;
  15128. }
  15129. // Arrange
  15130. var offset;
  15131. if (this._isVertical) {
  15132. offset = -height;
  15133. }
  15134. else {
  15135. offset = -width;
  15136. }
  15137. var index = 0;
  15138. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15139. var child = _c[_b];
  15140. if (!child.mesh) {
  15141. continue;
  15142. }
  15143. controlCount--;
  15144. var extendSize = extendSizes[index++];
  15145. if (this._isVertical) {
  15146. child.position.y = offset + extendSize.y;
  15147. child.position.x = 0;
  15148. offset += extendSize.y * 2;
  15149. }
  15150. else {
  15151. child.position.x = offset + extendSize.x;
  15152. child.position.y = 0;
  15153. offset += extendSize.x * 2;
  15154. }
  15155. offset += (controlCount > 0 ? this.margin : 0);
  15156. }
  15157. };
  15158. return StackPanel3D;
  15159. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15160. /***/ }),
  15161. /***/ "./3D/controls/volumeBasedPanel.ts":
  15162. /*!*****************************************!*\
  15163. !*** ./3D/controls/volumeBasedPanel.ts ***!
  15164. \*****************************************/
  15165. /*! exports provided: VolumeBasedPanel */
  15166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15167. "use strict";
  15168. __webpack_require__.r(__webpack_exports__);
  15169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  15170. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15171. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15172. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15173. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15174. /**
  15175. * Abstract class used to create a container panel deployed on the surface of a volume
  15176. */
  15177. var VolumeBasedPanel = /** @class */ (function (_super) {
  15178. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  15179. /**
  15180. * Creates new VolumeBasedPanel
  15181. */
  15182. function VolumeBasedPanel() {
  15183. var _this = _super.call(this) || this;
  15184. _this._columns = 10;
  15185. _this._rows = 0;
  15186. _this._rowThenColum = true;
  15187. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  15188. /**
  15189. * Gets or sets the distance between elements
  15190. */
  15191. _this.margin = 0;
  15192. return _this;
  15193. }
  15194. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  15195. /**
  15196. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  15197. * | Value | Type | Description |
  15198. * | ----- | ----------------------------------- | ----------- |
  15199. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  15200. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  15201. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  15202. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  15203. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  15204. */
  15205. get: function () {
  15206. return this._orientation;
  15207. },
  15208. set: function (value) {
  15209. var _this = this;
  15210. if (this._orientation === value) {
  15211. return;
  15212. }
  15213. this._orientation = value;
  15214. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15215. _this._arrangeChildren();
  15216. });
  15217. },
  15218. enumerable: true,
  15219. configurable: true
  15220. });
  15221. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  15222. /**
  15223. * Gets or sets the number of columns requested (10 by default).
  15224. * The panel will automatically compute the number of rows based on number of child controls.
  15225. */
  15226. get: function () {
  15227. return this._columns;
  15228. },
  15229. set: function (value) {
  15230. var _this = this;
  15231. if (this._columns === value) {
  15232. return;
  15233. }
  15234. this._columns = value;
  15235. this._rowThenColum = true;
  15236. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15237. _this._arrangeChildren();
  15238. });
  15239. },
  15240. enumerable: true,
  15241. configurable: true
  15242. });
  15243. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  15244. /**
  15245. * Gets or sets a the number of rows requested.
  15246. * The panel will automatically compute the number of columns based on number of child controls.
  15247. */
  15248. get: function () {
  15249. return this._rows;
  15250. },
  15251. set: function (value) {
  15252. var _this = this;
  15253. if (this._rows === value) {
  15254. return;
  15255. }
  15256. this._rows = value;
  15257. this._rowThenColum = false;
  15258. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15259. _this._arrangeChildren();
  15260. });
  15261. },
  15262. enumerable: true,
  15263. configurable: true
  15264. });
  15265. VolumeBasedPanel.prototype._arrangeChildren = function () {
  15266. this._cellWidth = 0;
  15267. this._cellHeight = 0;
  15268. var rows = 0;
  15269. var columns = 0;
  15270. var controlCount = 0;
  15271. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15272. // Measure
  15273. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15274. var child = _a[_i];
  15275. if (!child.mesh) {
  15276. continue;
  15277. }
  15278. controlCount++;
  15279. child.mesh.computeWorldMatrix(true);
  15280. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  15281. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  15282. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15283. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  15284. boundingBox.max.subtractToRef(boundingBox.min, diff);
  15285. diff.scaleInPlace(0.5);
  15286. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  15287. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  15288. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  15289. }
  15290. this._cellWidth += this.margin * 2;
  15291. this._cellHeight += this.margin * 2;
  15292. // Arrange
  15293. if (this._rowThenColum) {
  15294. columns = this._columns;
  15295. rows = Math.ceil(controlCount / this._columns);
  15296. }
  15297. else {
  15298. rows = this._rows;
  15299. columns = Math.ceil(controlCount / this._rows);
  15300. }
  15301. var startOffsetX = (columns * 0.5) * this._cellWidth;
  15302. var startOffsetY = (rows * 0.5) * this._cellHeight;
  15303. var nodeGrid = [];
  15304. var cellCounter = 0;
  15305. if (this._rowThenColum) {
  15306. for (var r = 0; r < rows; r++) {
  15307. for (var c = 0; c < columns; c++) {
  15308. 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));
  15309. cellCounter++;
  15310. if (cellCounter > controlCount) {
  15311. break;
  15312. }
  15313. }
  15314. }
  15315. }
  15316. else {
  15317. for (var c = 0; c < columns; c++) {
  15318. for (var r = 0; r < rows; r++) {
  15319. 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));
  15320. cellCounter++;
  15321. if (cellCounter > controlCount) {
  15322. break;
  15323. }
  15324. }
  15325. }
  15326. }
  15327. cellCounter = 0;
  15328. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15329. var child = _c[_b];
  15330. if (!child.mesh) {
  15331. continue;
  15332. }
  15333. this._mapGridNode(child, nodeGrid[cellCounter]);
  15334. cellCounter++;
  15335. }
  15336. this._finalProcessing();
  15337. };
  15338. /** Child classes can implement this function to provide additional processing */
  15339. VolumeBasedPanel.prototype._finalProcessing = function () {
  15340. };
  15341. return VolumeBasedPanel;
  15342. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15343. /***/ }),
  15344. /***/ "./3D/gui3DManager.ts":
  15345. /*!****************************!*\
  15346. !*** ./3D/gui3DManager.ts ***!
  15347. \****************************/
  15348. /*! exports provided: GUI3DManager */
  15349. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15350. "use strict";
  15351. __webpack_require__.r(__webpack_exports__);
  15352. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  15353. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  15354. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15355. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  15356. /**
  15357. * Class used to manage 3D user interface
  15358. * @see http://doc.babylonjs.com/how_to/gui3d
  15359. */
  15360. var GUI3DManager = /** @class */ (function () {
  15361. /**
  15362. * Creates a new GUI3DManager
  15363. * @param scene
  15364. */
  15365. function GUI3DManager(scene) {
  15366. var _this = this;
  15367. /** @hidden */
  15368. this._lastControlOver = {};
  15369. /** @hidden */
  15370. this._lastControlDown = {};
  15371. /**
  15372. * Observable raised when the point picked by the pointer events changed
  15373. */
  15374. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15375. // Shared resources
  15376. /** @hidden */
  15377. this._sharedMaterials = {};
  15378. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  15379. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  15380. _this._sceneDisposeObserver = null;
  15381. _this._utilityLayer = null;
  15382. _this.dispose();
  15383. });
  15384. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  15385. this._utilityLayer.onlyCheckPointerDownEvents = false;
  15386. this._utilityLayer.pickUtilitySceneFirst = false;
  15387. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  15388. return mesh && mesh.metadata && mesh.metadata._node;
  15389. };
  15390. // Root
  15391. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  15392. this._rootContainer._host = this;
  15393. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  15394. // Events
  15395. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  15396. _this._handlePointerOut(pointerId, true);
  15397. });
  15398. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  15399. _this._doPicking(pi);
  15400. });
  15401. // Scene
  15402. this._utilityLayer.utilityLayerScene.autoClear = false;
  15403. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  15404. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  15405. }
  15406. Object.defineProperty(GUI3DManager.prototype, "scene", {
  15407. /** Gets the hosting scene */
  15408. get: function () {
  15409. return this._scene;
  15410. },
  15411. enumerable: true,
  15412. configurable: true
  15413. });
  15414. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  15415. /** Gets associated utility layer */
  15416. get: function () {
  15417. return this._utilityLayer;
  15418. },
  15419. enumerable: true,
  15420. configurable: true
  15421. });
  15422. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  15423. var previousControlOver = this._lastControlOver[pointerId];
  15424. if (previousControlOver) {
  15425. previousControlOver._onPointerOut(previousControlOver);
  15426. delete this._lastControlOver[pointerId];
  15427. }
  15428. if (isPointerUp) {
  15429. if (this._lastControlDown[pointerId]) {
  15430. this._lastControlDown[pointerId].forcePointerUp();
  15431. delete this._lastControlDown[pointerId];
  15432. }
  15433. }
  15434. this.onPickedPointChangedObservable.notifyObservers(null);
  15435. };
  15436. GUI3DManager.prototype._doPicking = function (pi) {
  15437. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  15438. return false;
  15439. }
  15440. var pointerEvent = (pi.event);
  15441. var pointerId = pointerEvent.pointerId || 0;
  15442. var buttonIndex = pointerEvent.button;
  15443. var pickingInfo = pi.pickInfo;
  15444. if (!pickingInfo || !pickingInfo.hit) {
  15445. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  15446. return false;
  15447. }
  15448. var control = (pickingInfo.pickedMesh.metadata);
  15449. if (pickingInfo.pickedPoint) {
  15450. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  15451. }
  15452. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  15453. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15454. if (this._lastControlOver[pointerId]) {
  15455. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  15456. }
  15457. delete this._lastControlOver[pointerId];
  15458. }
  15459. }
  15460. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  15461. if (this._lastControlDown[pointerEvent.pointerId]) {
  15462. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  15463. delete this._lastControlDown[pointerEvent.pointerId];
  15464. }
  15465. if (pointerEvent.pointerType === "touch") {
  15466. this._handlePointerOut(pointerId, false);
  15467. }
  15468. }
  15469. return true;
  15470. };
  15471. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  15472. /**
  15473. * Gets the root container
  15474. */
  15475. get: function () {
  15476. return this._rootContainer;
  15477. },
  15478. enumerable: true,
  15479. configurable: true
  15480. });
  15481. /**
  15482. * Gets a boolean indicating if the given control is in the root child list
  15483. * @param control defines the control to check
  15484. * @returns true if the control is in the root child list
  15485. */
  15486. GUI3DManager.prototype.containsControl = function (control) {
  15487. return this._rootContainer.containsControl(control);
  15488. };
  15489. /**
  15490. * Adds a control to the root child list
  15491. * @param control defines the control to add
  15492. * @returns the current manager
  15493. */
  15494. GUI3DManager.prototype.addControl = function (control) {
  15495. this._rootContainer.addControl(control);
  15496. return this;
  15497. };
  15498. /**
  15499. * Removes a control from the root child list
  15500. * @param control defines the control to remove
  15501. * @returns the current container
  15502. */
  15503. GUI3DManager.prototype.removeControl = function (control) {
  15504. this._rootContainer.removeControl(control);
  15505. return this;
  15506. };
  15507. /**
  15508. * Releases all associated resources
  15509. */
  15510. GUI3DManager.prototype.dispose = function () {
  15511. this._rootContainer.dispose();
  15512. for (var materialName in this._sharedMaterials) {
  15513. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  15514. continue;
  15515. }
  15516. this._sharedMaterials[materialName].dispose();
  15517. }
  15518. this._sharedMaterials = {};
  15519. if (this._pointerOutObserver && this._utilityLayer) {
  15520. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  15521. this._pointerOutObserver = null;
  15522. }
  15523. this.onPickedPointChangedObservable.clear();
  15524. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  15525. if (utilityLayerScene) {
  15526. if (this._pointerObserver) {
  15527. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  15528. this._pointerObserver = null;
  15529. }
  15530. }
  15531. if (this._scene) {
  15532. if (this._sceneDisposeObserver) {
  15533. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  15534. this._sceneDisposeObserver = null;
  15535. }
  15536. }
  15537. if (this._utilityLayer) {
  15538. this._utilityLayer.dispose();
  15539. }
  15540. };
  15541. return GUI3DManager;
  15542. }());
  15543. /***/ }),
  15544. /***/ "./3D/index.ts":
  15545. /*!*********************!*\
  15546. !*** ./3D/index.ts ***!
  15547. \*********************/
  15548. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15549. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15550. "use strict";
  15551. __webpack_require__.r(__webpack_exports__);
  15552. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  15553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15565. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  15566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15568. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  15569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  15570. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  15571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  15572. /***/ }),
  15573. /***/ "./3D/materials/fluentMaterial.ts":
  15574. /*!****************************************!*\
  15575. !*** ./3D/materials/fluentMaterial.ts ***!
  15576. \****************************************/
  15577. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15579. "use strict";
  15580. __webpack_require__.r(__webpack_exports__);
  15581. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  15582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  15583. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15584. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  15585. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  15586. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  15587. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  15588. /** @hidden */
  15589. var FluentMaterialDefines = /** @class */ (function (_super) {
  15590. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  15591. function FluentMaterialDefines() {
  15592. var _this = _super.call(this) || this;
  15593. _this.INNERGLOW = false;
  15594. _this.BORDER = false;
  15595. _this.HOVERLIGHT = false;
  15596. _this.TEXTURE = false;
  15597. _this.rebuild();
  15598. return _this;
  15599. }
  15600. return FluentMaterialDefines;
  15601. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  15602. /**
  15603. * Class used to render controls with fluent desgin
  15604. */
  15605. var FluentMaterial = /** @class */ (function (_super) {
  15606. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  15607. /**
  15608. * Creates a new Fluent material
  15609. * @param name defines the name of the material
  15610. * @param scene defines the hosting scene
  15611. */
  15612. function FluentMaterial(name, scene) {
  15613. var _this = _super.call(this, name, scene) || this;
  15614. /**
  15615. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  15616. */
  15617. _this.innerGlowColorIntensity = 0.5;
  15618. /**
  15619. * Gets or sets the inner glow color (white by default)
  15620. */
  15621. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  15622. /**
  15623. * Gets or sets alpha value (default is 1.0)
  15624. */
  15625. _this.alpha = 1.0;
  15626. /**
  15627. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  15628. */
  15629. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  15630. /**
  15631. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  15632. */
  15633. _this.renderBorders = false;
  15634. /**
  15635. * Gets or sets border width (default is 0.5)
  15636. */
  15637. _this.borderWidth = 0.5;
  15638. /**
  15639. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  15640. */
  15641. _this.edgeSmoothingValue = 0.02;
  15642. /**
  15643. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  15644. */
  15645. _this.borderMinValue = 0.1;
  15646. /**
  15647. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  15648. */
  15649. _this.renderHoverLight = false;
  15650. /**
  15651. * Gets or sets the radius used to render the hover light (default is 1.0)
  15652. */
  15653. _this.hoverRadius = 1.0;
  15654. /**
  15655. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  15656. */
  15657. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  15658. /**
  15659. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  15660. */
  15661. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  15662. return _this;
  15663. }
  15664. FluentMaterial.prototype.needAlphaBlending = function () {
  15665. return this.alpha !== 1.0;
  15666. };
  15667. FluentMaterial.prototype.needAlphaTesting = function () {
  15668. return false;
  15669. };
  15670. FluentMaterial.prototype.getAlphaTestTexture = function () {
  15671. return null;
  15672. };
  15673. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  15674. if (this.isFrozen) {
  15675. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  15676. return true;
  15677. }
  15678. }
  15679. if (!subMesh._materialDefines) {
  15680. subMesh._materialDefines = new FluentMaterialDefines();
  15681. }
  15682. var scene = this.getScene();
  15683. var defines = subMesh._materialDefines;
  15684. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  15685. if (defines._renderId === scene.getRenderId()) {
  15686. return true;
  15687. }
  15688. }
  15689. if (defines._areTexturesDirty) {
  15690. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  15691. defines.BORDER = this.renderBorders;
  15692. defines.HOVERLIGHT = this.renderHoverLight;
  15693. if (this._albedoTexture) {
  15694. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  15695. return false;
  15696. }
  15697. else {
  15698. defines.TEXTURE = true;
  15699. }
  15700. }
  15701. else {
  15702. defines.TEXTURE = false;
  15703. }
  15704. }
  15705. var engine = scene.getEngine();
  15706. // Get correct effect
  15707. if (defines.isDirty) {
  15708. defines.markAsProcessed();
  15709. scene.resetCachedMaterial();
  15710. //Attributes
  15711. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  15712. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  15713. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  15714. var shaderName = "fluent";
  15715. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  15716. "hoverColor", "hoverPosition", "hoverRadius"
  15717. ];
  15718. var samplers = ["albedoSampler"];
  15719. var uniformBuffers = new Array();
  15720. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  15721. uniformsNames: uniforms,
  15722. uniformBuffersNames: uniformBuffers,
  15723. samplers: samplers,
  15724. defines: defines,
  15725. maxSimultaneousLights: 4
  15726. });
  15727. var join = defines.toString();
  15728. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  15729. attributes: attribs,
  15730. uniformsNames: uniforms,
  15731. uniformBuffersNames: uniformBuffers,
  15732. samplers: samplers,
  15733. defines: join,
  15734. fallbacks: null,
  15735. onCompiled: this.onCompiled,
  15736. onError: this.onError,
  15737. indexParameters: { maxSimultaneousLights: 4 }
  15738. }, engine));
  15739. }
  15740. if (!subMesh.effect || !subMesh.effect.isReady()) {
  15741. return false;
  15742. }
  15743. defines._renderId = scene.getRenderId();
  15744. subMesh.effect._wasPreviouslyReady = true;
  15745. return true;
  15746. };
  15747. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  15748. var scene = this.getScene();
  15749. var defines = subMesh._materialDefines;
  15750. if (!defines) {
  15751. return;
  15752. }
  15753. var effect = subMesh.effect;
  15754. if (!effect) {
  15755. return;
  15756. }
  15757. this._activeEffect = effect;
  15758. // Matrices
  15759. this.bindOnlyWorldMatrix(world);
  15760. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  15761. if (this._mustRebind(scene, effect)) {
  15762. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  15763. if (defines.INNERGLOW) {
  15764. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  15765. }
  15766. if (defines.BORDER) {
  15767. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  15768. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  15769. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  15770. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15771. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15772. }
  15773. if (defines.HOVERLIGHT) {
  15774. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  15775. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  15776. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  15777. }
  15778. if (defines.TEXTURE) {
  15779. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  15780. }
  15781. }
  15782. this._afterBind(mesh, this._activeEffect);
  15783. };
  15784. FluentMaterial.prototype.getActiveTextures = function () {
  15785. var activeTextures = _super.prototype.getActiveTextures.call(this);
  15786. return activeTextures;
  15787. };
  15788. FluentMaterial.prototype.hasTexture = function (texture) {
  15789. if (_super.prototype.hasTexture.call(this, texture)) {
  15790. return true;
  15791. }
  15792. return false;
  15793. };
  15794. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  15795. _super.prototype.dispose.call(this, forceDisposeEffect);
  15796. };
  15797. FluentMaterial.prototype.clone = function (name) {
  15798. var _this = this;
  15799. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  15800. };
  15801. FluentMaterial.prototype.serialize = function () {
  15802. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  15803. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  15804. return serializationObject;
  15805. };
  15806. FluentMaterial.prototype.getClassName = function () {
  15807. return "FluentMaterial";
  15808. };
  15809. // Statics
  15810. FluentMaterial.Parse = function (source, scene, rootUrl) {
  15811. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  15812. };
  15813. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15814. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15815. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15816. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  15817. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15818. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15819. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  15820. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15821. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15822. ], FluentMaterial.prototype, "alpha", void 0);
  15823. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15824. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15825. ], FluentMaterial.prototype, "albedoColor", void 0);
  15826. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15827. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15828. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15829. ], FluentMaterial.prototype, "renderBorders", void 0);
  15830. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15831. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15832. ], FluentMaterial.prototype, "borderWidth", void 0);
  15833. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15834. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15835. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  15836. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15837. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15838. ], FluentMaterial.prototype, "borderMinValue", void 0);
  15839. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15840. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15841. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15842. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  15843. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15844. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15845. ], FluentMaterial.prototype, "hoverRadius", void 0);
  15846. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15847. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  15848. ], FluentMaterial.prototype, "hoverColor", void 0);
  15849. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15850. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  15851. ], FluentMaterial.prototype, "hoverPosition", void 0);
  15852. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15853. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  15854. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  15855. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15856. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  15857. ], FluentMaterial.prototype, "albedoTexture", void 0);
  15858. return FluentMaterial;
  15859. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  15860. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  15861. /***/ }),
  15862. /***/ "./3D/materials/index.ts":
  15863. /*!*******************************!*\
  15864. !*** ./3D/materials/index.ts ***!
  15865. \*******************************/
  15866. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15867. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15868. "use strict";
  15869. __webpack_require__.r(__webpack_exports__);
  15870. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  15871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  15872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  15873. /***/ }),
  15874. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  15875. /*!*************************************************!*\
  15876. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  15877. \*************************************************/
  15878. /*! exports provided: fluentPixelShader */
  15879. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15880. "use strict";
  15881. __webpack_require__.r(__webpack_exports__);
  15882. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  15883. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  15884. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  15885. var name = 'fluentPixelShader';
  15886. 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}";
  15887. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  15888. /** @hidden */
  15889. var fluentPixelShader = { name: name, shader: shader };
  15890. /***/ }),
  15891. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  15892. /*!***********************************************!*\
  15893. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  15894. \***********************************************/
  15895. /*! exports provided: fluentVertexShader */
  15896. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15897. "use strict";
  15898. __webpack_require__.r(__webpack_exports__);
  15899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  15900. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  15901. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  15902. var name = 'fluentVertexShader';
  15903. 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";
  15904. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  15905. /** @hidden */
  15906. var fluentVertexShader = { name: name, shader: shader };
  15907. /***/ }),
  15908. /***/ "./3D/vector3WithInfo.ts":
  15909. /*!*******************************!*\
  15910. !*** ./3D/vector3WithInfo.ts ***!
  15911. \*******************************/
  15912. /*! exports provided: Vector3WithInfo */
  15913. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15914. "use strict";
  15915. __webpack_require__.r(__webpack_exports__);
  15916. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  15917. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15918. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  15919. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  15920. /**
  15921. * Class used to transport Vector3 information for pointer events
  15922. */
  15923. var Vector3WithInfo = /** @class */ (function (_super) {
  15924. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  15925. /**
  15926. * Creates a new Vector3WithInfo
  15927. * @param source defines the vector3 data to transport
  15928. * @param buttonIndex defines the current mouse button index
  15929. */
  15930. function Vector3WithInfo(source,
  15931. /** defines the current mouse button index */
  15932. buttonIndex) {
  15933. if (buttonIndex === void 0) { buttonIndex = 0; }
  15934. var _this = _super.call(this, source.x, source.y, source.z) || this;
  15935. _this.buttonIndex = buttonIndex;
  15936. return _this;
  15937. }
  15938. return Vector3WithInfo;
  15939. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  15940. /***/ }),
  15941. /***/ "./index.ts":
  15942. /*!******************!*\
  15943. !*** ./index.ts ***!
  15944. \******************/
  15945. /*! 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 */
  15946. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15947. "use strict";
  15948. __webpack_require__.r(__webpack_exports__);
  15949. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  15950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  15951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  15952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  15953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  15954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  15955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  15956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  15957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  15958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  15959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  15960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  15961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  15962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  15963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  15964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  15965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  15966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  15967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  15968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  15969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  15970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  15971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  15972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  15973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  15974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  15975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  15976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  15977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  15978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  15979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  15980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  15981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  15982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  15983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  15984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  15985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  15986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  15987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  15988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  15989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  15990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  15991. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  15992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  15993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  15994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  15995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  15996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  15997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  15998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  15999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  16000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  16001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  16002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  16003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  16004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  16005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  16006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16008. /***/ }),
  16009. /***/ "./legacy/legacy.ts":
  16010. /*!**************************!*\
  16011. !*** ./legacy/legacy.ts ***!
  16012. \**************************/
  16013. /*! 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 */
  16014. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16015. "use strict";
  16016. __webpack_require__.r(__webpack_exports__);
  16017. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  16018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  16028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  16029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16075. /**
  16076. * Legacy support, defining window.BABYLON.GUI (global variable).
  16077. *
  16078. * This is the entry point for the UMD module.
  16079. * The entry point for a future ESM package should be index.ts
  16080. */
  16081. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  16082. if (typeof globalObject !== "undefined") {
  16083. globalObject.BABYLON = globalObject.BABYLON || {};
  16084. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  16085. }
  16086. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  16087. /***/ }),
  16088. /***/ "babylonjs/Misc/perfCounter":
  16089. /*!****************************************************************************************************!*\
  16090. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  16091. \****************************************************************************************************/
  16092. /*! no static exports found */
  16093. /***/ (function(module, exports) {
  16094. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__;
  16095. /***/ })
  16096. /******/ });
  16097. });
  16098. //# sourceMappingURL=babylon.gui.js.map