babylon.gui.js 706 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187
  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. /**
  516. * Define type to string to ensure compatibility across browsers
  517. * Safari doesn't support DataTransfer constructor
  518. */
  519. _this._clipboardData = "";
  520. /**
  521. * Observable event triggered each time an clipboard event is received from the rendering canvas
  522. */
  523. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  524. /**
  525. * Observable event triggered each time a pointer down is intercepted by a control
  526. */
  527. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  528. /**
  529. * Observable event triggered before layout is evaluated
  530. */
  531. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  532. /**
  533. * Observable event triggered after the layout was evaluated
  534. */
  535. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  536. /**
  537. * Observable event triggered before the texture is rendered
  538. */
  539. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  540. /**
  541. * Observable event triggered after the texture was rendered
  542. */
  543. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  544. /**
  545. * Gets or sets a boolean defining if alpha is stored as premultiplied
  546. */
  547. _this.premulAlpha = false;
  548. _this._useInvalidateRectOptimization = true;
  549. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  550. _this._invalidatedRectangle = null;
  551. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  552. /** @hidden */
  553. _this.onClipboardCopy = function (rawEvt) {
  554. var evt = rawEvt;
  555. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  556. _this.onClipboardObservable.notifyObservers(ev);
  557. evt.preventDefault();
  558. };
  559. /** @hidden */
  560. _this.onClipboardCut = function (rawEvt) {
  561. var evt = rawEvt;
  562. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  563. _this.onClipboardObservable.notifyObservers(ev);
  564. evt.preventDefault();
  565. };
  566. /** @hidden */
  567. _this.onClipboardPaste = function (rawEvt) {
  568. var evt = rawEvt;
  569. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  570. _this.onClipboardObservable.notifyObservers(ev);
  571. evt.preventDefault();
  572. };
  573. scene = _this.getScene();
  574. if (!scene || !_this._texture) {
  575. return _this;
  576. }
  577. _this._rootElement = scene.getEngine().getInputElement();
  578. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  579. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  580. if (!_this._focusedControl) {
  581. return;
  582. }
  583. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  584. _this._focusedControl.processKeyboard(info.event);
  585. }
  586. info.skipOnPointerObservable = true;
  587. });
  588. _this._rootContainer._link(_this);
  589. _this.hasAlpha = true;
  590. if (!width || !height) {
  591. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  592. _this._onResize();
  593. }
  594. _this._texture.isReady = true;
  595. return _this;
  596. }
  597. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  598. /**
  599. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  600. * Useful when you want more antialiasing
  601. */
  602. get: function () {
  603. return this._renderScale;
  604. },
  605. set: function (value) {
  606. if (value === this._renderScale) {
  607. return;
  608. }
  609. this._renderScale = value;
  610. this._onResize();
  611. },
  612. enumerable: true,
  613. configurable: true
  614. });
  615. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  616. /** Gets or sets the background color */
  617. get: function () {
  618. return this._background;
  619. },
  620. set: function (value) {
  621. if (this._background === value) {
  622. return;
  623. }
  624. this._background = value;
  625. this.markAsDirty();
  626. },
  627. enumerable: true,
  628. configurable: true
  629. });
  630. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  631. /**
  632. * Gets or sets the ideal width used to design controls.
  633. * The GUI will then rescale everything accordingly
  634. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  635. */
  636. get: function () {
  637. return this._idealWidth;
  638. },
  639. set: function (value) {
  640. if (this._idealWidth === value) {
  641. return;
  642. }
  643. this._idealWidth = value;
  644. this.markAsDirty();
  645. this._rootContainer._markAllAsDirty();
  646. },
  647. enumerable: true,
  648. configurable: true
  649. });
  650. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  651. /**
  652. * Gets or sets the ideal height 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._idealHeight;
  658. },
  659. set: function (value) {
  660. if (this._idealHeight === value) {
  661. return;
  662. }
  663. this._idealHeight = value;
  664. this.markAsDirty();
  665. this._rootContainer._markAllAsDirty();
  666. },
  667. enumerable: true,
  668. configurable: true
  669. });
  670. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  671. /**
  672. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  673. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  674. */
  675. get: function () {
  676. return this._useSmallestIdeal;
  677. },
  678. set: function (value) {
  679. if (this._useSmallestIdeal === value) {
  680. return;
  681. }
  682. this._useSmallestIdeal = value;
  683. this.markAsDirty();
  684. this._rootContainer._markAllAsDirty();
  685. },
  686. enumerable: true,
  687. configurable: true
  688. });
  689. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  690. /**
  691. * Gets or sets a boolean indicating if adaptive scaling must be used
  692. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  693. */
  694. get: function () {
  695. return this._renderAtIdealSize;
  696. },
  697. set: function (value) {
  698. if (this._renderAtIdealSize === value) {
  699. return;
  700. }
  701. this._renderAtIdealSize = value;
  702. this._onResize();
  703. },
  704. enumerable: true,
  705. configurable: true
  706. });
  707. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  708. /**
  709. * Gets the underlying layer used to render the texture when in fullscreen mode
  710. */
  711. get: function () {
  712. return this._layerToDispose;
  713. },
  714. enumerable: true,
  715. configurable: true
  716. });
  717. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  718. /**
  719. * Gets the root container control
  720. */
  721. get: function () {
  722. return this._rootContainer;
  723. },
  724. enumerable: true,
  725. configurable: true
  726. });
  727. /**
  728. * Returns an array containing the root container.
  729. * This is mostly used to let the Inspector introspects the ADT
  730. * @returns an array containing the rootContainer
  731. */
  732. AdvancedDynamicTexture.prototype.getChildren = function () {
  733. return [this._rootContainer];
  734. };
  735. /**
  736. * Will return all controls that are inside this texture
  737. * @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
  738. * @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
  739. * @return all child controls
  740. */
  741. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  742. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  743. };
  744. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  745. /**
  746. * Gets or sets the current focused control
  747. */
  748. get: function () {
  749. return this._focusedControl;
  750. },
  751. set: function (control) {
  752. if (this._focusedControl == control) {
  753. return;
  754. }
  755. if (this._focusedControl) {
  756. this._focusedControl.onBlur();
  757. }
  758. if (control) {
  759. control.onFocus();
  760. }
  761. this._focusedControl = control;
  762. },
  763. enumerable: true,
  764. configurable: true
  765. });
  766. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  767. /**
  768. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  769. */
  770. get: function () {
  771. if (!this.layer) {
  772. return true;
  773. }
  774. return (!this.layer.isBackground);
  775. },
  776. set: function (value) {
  777. if (!this.layer) {
  778. return;
  779. }
  780. if (this.layer.isBackground === !value) {
  781. return;
  782. }
  783. this.layer.isBackground = !value;
  784. },
  785. enumerable: true,
  786. configurable: true
  787. });
  788. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  789. /**
  790. * Gets or set information about clipboardData
  791. */
  792. get: function () {
  793. return this._clipboardData;
  794. },
  795. set: function (value) {
  796. this._clipboardData = value;
  797. },
  798. enumerable: true,
  799. configurable: true
  800. });
  801. /**
  802. * Get the current class name of the texture useful for serialization or dynamic coding.
  803. * @returns "AdvancedDynamicTexture"
  804. */
  805. AdvancedDynamicTexture.prototype.getClassName = function () {
  806. return "AdvancedDynamicTexture";
  807. };
  808. /**
  809. * Function used to execute a function on all controls
  810. * @param func defines the function to execute
  811. * @param container defines the container where controls belong. If null the root container will be used
  812. */
  813. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  814. if (!container) {
  815. container = this._rootContainer;
  816. }
  817. func(container);
  818. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  819. var child = _a[_i];
  820. if (child.children) {
  821. this.executeOnAllControls(func, child);
  822. continue;
  823. }
  824. func(child);
  825. }
  826. };
  827. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  828. /**
  829. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  830. */
  831. get: function () {
  832. return this._useInvalidateRectOptimization;
  833. },
  834. set: function (value) {
  835. this._useInvalidateRectOptimization = value;
  836. },
  837. enumerable: true,
  838. configurable: true
  839. });
  840. /**
  841. * Invalidates a rectangle area on the gui texture
  842. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  843. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  844. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  845. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  846. */
  847. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  848. if (!this._useInvalidateRectOptimization) {
  849. return;
  850. }
  851. if (!this._invalidatedRectangle) {
  852. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  853. }
  854. else {
  855. // Compute intersection
  856. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  857. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  858. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  859. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  860. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  861. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  862. }
  863. };
  864. /**
  865. * Marks the texture as dirty forcing a complete update
  866. */
  867. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  868. this._isDirty = true;
  869. };
  870. /**
  871. * Helper function used to create a new style
  872. * @returns a new style
  873. * @see http://doc.babylonjs.com/how_to/gui#styles
  874. */
  875. AdvancedDynamicTexture.prototype.createStyle = function () {
  876. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  877. };
  878. /**
  879. * Adds a new control to the root container
  880. * @param control defines the control to add
  881. * @returns the current texture
  882. */
  883. AdvancedDynamicTexture.prototype.addControl = function (control) {
  884. this._rootContainer.addControl(control);
  885. return this;
  886. };
  887. /**
  888. * Removes a control from the root container
  889. * @param control defines the control to remove
  890. * @returns the current texture
  891. */
  892. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  893. this._rootContainer.removeControl(control);
  894. return this;
  895. };
  896. /**
  897. * Release all resources
  898. */
  899. AdvancedDynamicTexture.prototype.dispose = function () {
  900. var scene = this.getScene();
  901. if (!scene) {
  902. return;
  903. }
  904. this._rootElement = null;
  905. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  906. if (this._resizeObserver) {
  907. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  908. }
  909. if (this._pointerMoveObserver) {
  910. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  911. }
  912. if (this._pointerObserver) {
  913. scene.onPointerObservable.remove(this._pointerObserver);
  914. }
  915. if (this._preKeyboardObserver) {
  916. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  917. }
  918. if (this._canvasPointerOutObserver) {
  919. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  920. }
  921. if (this._layerToDispose) {
  922. this._layerToDispose.texture = null;
  923. this._layerToDispose.dispose();
  924. this._layerToDispose = null;
  925. }
  926. this._rootContainer.dispose();
  927. this.onClipboardObservable.clear();
  928. this.onControlPickedObservable.clear();
  929. this.onBeginRenderObservable.clear();
  930. this.onEndRenderObservable.clear();
  931. this.onBeginLayoutObservable.clear();
  932. this.onEndLayoutObservable.clear();
  933. _super.prototype.dispose.call(this);
  934. };
  935. AdvancedDynamicTexture.prototype._onResize = function () {
  936. var scene = this.getScene();
  937. if (!scene) {
  938. return;
  939. }
  940. // Check size
  941. var engine = scene.getEngine();
  942. var textureSize = this.getSize();
  943. var renderWidth = engine.getRenderWidth() * this._renderScale;
  944. var renderHeight = engine.getRenderHeight() * this._renderScale;
  945. if (this._renderAtIdealSize) {
  946. if (this._idealWidth) {
  947. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  948. renderWidth = this._idealWidth;
  949. }
  950. else if (this._idealHeight) {
  951. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  952. renderHeight = this._idealHeight;
  953. }
  954. }
  955. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  956. this.scaleTo(renderWidth, renderHeight);
  957. this.markAsDirty();
  958. if (this._idealWidth || this._idealHeight) {
  959. this._rootContainer._markAllAsDirty();
  960. }
  961. }
  962. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  963. };
  964. /** @hidden */
  965. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  966. var engine = scene.getEngine();
  967. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  968. };
  969. /**
  970. * Get screen coordinates for a vector3
  971. * @param position defines the position to project
  972. * @param worldMatrix defines the world matrix to use
  973. * @returns the projected position
  974. */
  975. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  976. var scene = this.getScene();
  977. if (!scene) {
  978. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  979. }
  980. var globalViewport = this._getGlobalViewport(scene);
  981. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  982. projectedPosition.scaleInPlace(this.renderScale);
  983. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  984. };
  985. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  986. if (this._layerToDispose) {
  987. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  988. return;
  989. }
  990. }
  991. if (this._isFullscreen && this._linkedControls.length) {
  992. var scene = this.getScene();
  993. if (!scene) {
  994. return;
  995. }
  996. var globalViewport = this._getGlobalViewport(scene);
  997. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  998. var control = _a[_i];
  999. if (!control.isVisible) {
  1000. continue;
  1001. }
  1002. var mesh = control._linkedMesh;
  1003. if (!mesh || mesh.isDisposed()) {
  1004. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1005. control.linkWithMesh(null);
  1006. });
  1007. continue;
  1008. }
  1009. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1010. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1011. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1012. control.notRenderable = true;
  1013. continue;
  1014. }
  1015. control.notRenderable = false;
  1016. // Account for RenderScale.
  1017. projectedPosition.scaleInPlace(this.renderScale);
  1018. control._moveToProjectedPosition(projectedPosition);
  1019. }
  1020. }
  1021. if (!this._isDirty && !this._rootContainer.isDirty) {
  1022. return;
  1023. }
  1024. this._isDirty = false;
  1025. this._render();
  1026. this.update(true, this.premulAlpha);
  1027. };
  1028. AdvancedDynamicTexture.prototype._render = function () {
  1029. var textureSize = this.getSize();
  1030. var renderWidth = textureSize.width;
  1031. var renderHeight = textureSize.height;
  1032. var context = this.getContext();
  1033. context.font = "18px Arial";
  1034. context.strokeStyle = "white";
  1035. // Layout
  1036. this.onBeginLayoutObservable.notifyObservers(this);
  1037. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1038. this._rootContainer._layout(measure, context);
  1039. this.onEndLayoutObservable.notifyObservers(this);
  1040. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1041. // Clear
  1042. if (this._invalidatedRectangle) {
  1043. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1044. }
  1045. else {
  1046. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1047. }
  1048. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1049. if (this._background) {
  1050. context.save();
  1051. context.fillStyle = this._background;
  1052. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1053. context.restore();
  1054. }
  1055. // Render
  1056. this.onBeginRenderObservable.notifyObservers(this);
  1057. this._rootContainer._render(context, this._invalidatedRectangle);
  1058. this.onEndRenderObservable.notifyObservers(this);
  1059. this._invalidatedRectangle = null;
  1060. };
  1061. /** @hidden */
  1062. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1063. if (this._rootElement) {
  1064. this._rootElement.style.cursor = cursor;
  1065. this._cursorChanged = true;
  1066. }
  1067. };
  1068. /** @hidden */
  1069. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1070. this._lastControlDown[pointerId] = control;
  1071. this.onControlPickedObservable.notifyObservers(control);
  1072. };
  1073. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1074. var scene = this.getScene();
  1075. if (!scene) {
  1076. return;
  1077. }
  1078. var engine = scene.getEngine();
  1079. var textureSize = this.getSize();
  1080. if (this._isFullscreen) {
  1081. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1082. var viewport = camera.viewport;
  1083. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1084. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1085. }
  1086. if (this._capturingControl[pointerId]) {
  1087. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1088. return;
  1089. }
  1090. this._cursorChanged = false;
  1091. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1092. this._changeCursor("");
  1093. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1094. if (this._lastControlOver[pointerId]) {
  1095. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1096. delete this._lastControlOver[pointerId];
  1097. }
  1098. }
  1099. }
  1100. if (!this._cursorChanged) {
  1101. this._changeCursor("");
  1102. }
  1103. this._manageFocus();
  1104. };
  1105. /** @hidden */
  1106. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1107. for (var pointerId in list) {
  1108. if (!list.hasOwnProperty(pointerId)) {
  1109. continue;
  1110. }
  1111. var lastControlOver = list[pointerId];
  1112. if (lastControlOver === control) {
  1113. delete list[pointerId];
  1114. }
  1115. }
  1116. };
  1117. /** @hidden */
  1118. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1119. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1120. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1121. };
  1122. /** Attach to all scene events required to support pointer events */
  1123. AdvancedDynamicTexture.prototype.attach = function () {
  1124. var _this = this;
  1125. var scene = this.getScene();
  1126. if (!scene) {
  1127. return;
  1128. }
  1129. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1130. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1131. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1132. return;
  1133. }
  1134. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1135. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1136. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1137. return;
  1138. }
  1139. if (!scene) {
  1140. return;
  1141. }
  1142. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1143. var engine = scene.getEngine();
  1144. if (!camera) {
  1145. tempViewport.x = 0;
  1146. tempViewport.y = 0;
  1147. tempViewport.width = engine.getRenderWidth();
  1148. tempViewport.height = engine.getRenderHeight();
  1149. }
  1150. else {
  1151. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1152. }
  1153. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1154. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1155. _this._shouldBlockPointer = false;
  1156. // Do picking modifies _shouldBlockPointer
  1157. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1158. // Avoid overwriting a true skipOnPointerObservable to false
  1159. if (_this._shouldBlockPointer) {
  1160. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1161. }
  1162. });
  1163. this._attachToOnPointerOut(scene);
  1164. };
  1165. /**
  1166. * Register the clipboard Events onto the canvas
  1167. */
  1168. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1169. self.addEventListener("copy", this.onClipboardCopy, false);
  1170. self.addEventListener("cut", this.onClipboardCut, false);
  1171. self.addEventListener("paste", this.onClipboardPaste, false);
  1172. };
  1173. /**
  1174. * Unregister the clipboard Events from the canvas
  1175. */
  1176. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1177. self.removeEventListener("copy", this.onClipboardCopy);
  1178. self.removeEventListener("cut", this.onClipboardCut);
  1179. self.removeEventListener("paste", this.onClipboardPaste);
  1180. };
  1181. /**
  1182. * Connect the texture to a hosting mesh to enable interactions
  1183. * @param mesh defines the mesh to attach to
  1184. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1185. */
  1186. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1187. var _this = this;
  1188. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1189. var scene = this.getScene();
  1190. if (!scene) {
  1191. return;
  1192. }
  1193. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1194. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1195. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1196. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1197. return;
  1198. }
  1199. var pointerId = pi.event.pointerId || 0;
  1200. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1201. var uv = pi.pickInfo.getTextureCoordinates();
  1202. if (uv) {
  1203. var size = _this.getSize();
  1204. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1205. }
  1206. }
  1207. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1208. if (_this._lastControlDown[pointerId]) {
  1209. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1210. }
  1211. delete _this._lastControlDown[pointerId];
  1212. if (_this.focusedControl) {
  1213. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1214. var canMoveFocus = true;
  1215. if (friendlyControls) {
  1216. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1217. var control = friendlyControls_1[_i];
  1218. // Same host, no need to keep the focus
  1219. if (_this === control._host) {
  1220. continue;
  1221. }
  1222. // Different hosts
  1223. var otherHost = control._host;
  1224. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1225. canMoveFocus = false;
  1226. break;
  1227. }
  1228. }
  1229. }
  1230. if (canMoveFocus) {
  1231. _this.focusedControl = null;
  1232. }
  1233. }
  1234. }
  1235. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1236. if (_this._lastControlOver[pointerId]) {
  1237. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1238. }
  1239. delete _this._lastControlOver[pointerId];
  1240. }
  1241. });
  1242. mesh.enablePointerMoveEvents = supportPointerMove;
  1243. this._attachToOnPointerOut(scene);
  1244. };
  1245. /**
  1246. * Move the focus to a specific control
  1247. * @param control defines the control which will receive the focus
  1248. */
  1249. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1250. this.focusedControl = control;
  1251. this._lastPickedControl = control;
  1252. this._blockNextFocusCheck = true;
  1253. };
  1254. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1255. if (this._blockNextFocusCheck) {
  1256. this._blockNextFocusCheck = false;
  1257. this._lastPickedControl = this._focusedControl;
  1258. return;
  1259. }
  1260. // Focus management
  1261. if (this._focusedControl) {
  1262. if (this._focusedControl !== this._lastPickedControl) {
  1263. if (this._lastPickedControl.isFocusInvisible) {
  1264. return;
  1265. }
  1266. this.focusedControl = null;
  1267. }
  1268. }
  1269. };
  1270. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1271. var _this = this;
  1272. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1273. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1274. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1275. }
  1276. delete _this._lastControlOver[pointerEvent.pointerId];
  1277. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1278. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1279. delete _this._lastControlDown[pointerEvent.pointerId];
  1280. }
  1281. });
  1282. };
  1283. // Statics
  1284. /**
  1285. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1286. * @param mesh defines the mesh which will receive the texture
  1287. * @param width defines the texture width (1024 by default)
  1288. * @param height defines the texture height (1024 by default)
  1289. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1290. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1291. * @returns a new AdvancedDynamicTexture
  1292. */
  1293. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1294. if (width === void 0) { width = 1024; }
  1295. if (height === void 0) { height = 1024; }
  1296. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1297. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1298. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1299. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1300. material.backFaceCulling = false;
  1301. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1302. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1303. if (onlyAlphaTesting) {
  1304. material.diffuseTexture = result;
  1305. material.emissiveTexture = result;
  1306. result.hasAlpha = true;
  1307. }
  1308. else {
  1309. material.emissiveTexture = result;
  1310. material.opacityTexture = result;
  1311. }
  1312. mesh.material = material;
  1313. result.attachToMesh(mesh, supportPointerMove);
  1314. return result;
  1315. };
  1316. /**
  1317. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1318. * In this mode the texture will rely on a layer for its rendering.
  1319. * This allows it to be treated like any other layer.
  1320. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1321. * LayerMask is set through advancedTexture.layer.layerMask
  1322. * @param name defines name for the texture
  1323. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1324. * @param scene defines the hsoting scene
  1325. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1326. * @returns a new AdvancedDynamicTexture
  1327. */
  1328. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1329. if (foreground === void 0) { foreground = true; }
  1330. if (scene === void 0) { scene = null; }
  1331. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1332. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1333. // Display
  1334. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1335. layer.texture = result;
  1336. result._layerToDispose = layer;
  1337. result._isFullscreen = true;
  1338. // Attach
  1339. result.attach();
  1340. return result;
  1341. };
  1342. return AdvancedDynamicTexture;
  1343. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1344. /***/ }),
  1345. /***/ "./2D/controls/button.ts":
  1346. /*!*******************************!*\
  1347. !*** ./2D/controls/button.ts ***!
  1348. \*******************************/
  1349. /*! exports provided: Button */
  1350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1351. "use strict";
  1352. __webpack_require__.r(__webpack_exports__);
  1353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1354. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1355. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1356. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1357. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1358. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1359. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  1360. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1361. /**
  1362. * Class used to create 2D buttons
  1363. */
  1364. var Button = /** @class */ (function (_super) {
  1365. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1366. /**
  1367. * Creates a new Button
  1368. * @param name defines the name of the button
  1369. */
  1370. function Button(name) {
  1371. var _this = _super.call(this, name) || this;
  1372. _this.name = name;
  1373. /**
  1374. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1375. */
  1376. _this.delegatePickingToChildren = false;
  1377. _this.thickness = 1;
  1378. _this.isPointerBlocker = true;
  1379. var alphaStore = null;
  1380. _this.pointerEnterAnimation = function () {
  1381. alphaStore = _this.alpha;
  1382. _this.alpha -= 0.1;
  1383. };
  1384. _this.pointerOutAnimation = function () {
  1385. if (alphaStore !== null) {
  1386. _this.alpha = alphaStore;
  1387. }
  1388. };
  1389. _this.pointerDownAnimation = function () {
  1390. _this.scaleX -= 0.05;
  1391. _this.scaleY -= 0.05;
  1392. };
  1393. _this.pointerUpAnimation = function () {
  1394. _this.scaleX += 0.05;
  1395. _this.scaleY += 0.05;
  1396. };
  1397. return _this;
  1398. }
  1399. Object.defineProperty(Button.prototype, "image", {
  1400. /**
  1401. * Returns the image part of the button (if any)
  1402. */
  1403. get: function () {
  1404. return this._image;
  1405. },
  1406. enumerable: true,
  1407. configurable: true
  1408. });
  1409. Object.defineProperty(Button.prototype, "textBlock", {
  1410. /**
  1411. * Returns the image part of the button (if any)
  1412. */
  1413. get: function () {
  1414. return this._textBlock;
  1415. },
  1416. enumerable: true,
  1417. configurable: true
  1418. });
  1419. Button.prototype._getTypeName = function () {
  1420. return "Button";
  1421. };
  1422. // While being a container, the button behaves like a control.
  1423. /** @hidden */
  1424. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1425. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1426. return false;
  1427. }
  1428. if (!_super.prototype.contains.call(this, x, y)) {
  1429. return false;
  1430. }
  1431. if (this.delegatePickingToChildren) {
  1432. var contains = false;
  1433. for (var index = this._children.length - 1; index >= 0; index--) {
  1434. var child = this._children[index];
  1435. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1436. contains = true;
  1437. break;
  1438. }
  1439. }
  1440. if (!contains) {
  1441. return false;
  1442. }
  1443. }
  1444. this._processObservables(type, x, y, pointerId, buttonIndex);
  1445. return true;
  1446. };
  1447. /** @hidden */
  1448. Button.prototype._onPointerEnter = function (target) {
  1449. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1450. return false;
  1451. }
  1452. if (this.pointerEnterAnimation) {
  1453. this.pointerEnterAnimation();
  1454. }
  1455. return true;
  1456. };
  1457. /** @hidden */
  1458. Button.prototype._onPointerOut = function (target, force) {
  1459. if (force === void 0) { force = false; }
  1460. if (this.pointerOutAnimation) {
  1461. this.pointerOutAnimation();
  1462. }
  1463. _super.prototype._onPointerOut.call(this, target, force);
  1464. };
  1465. /** @hidden */
  1466. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1467. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1468. return false;
  1469. }
  1470. if (this.pointerDownAnimation) {
  1471. this.pointerDownAnimation();
  1472. }
  1473. return true;
  1474. };
  1475. /** @hidden */
  1476. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1477. if (this.pointerUpAnimation) {
  1478. this.pointerUpAnimation();
  1479. }
  1480. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1481. };
  1482. // Statics
  1483. /**
  1484. * Creates a new button made with an image and a text
  1485. * @param name defines the name of the button
  1486. * @param text defines the text of the button
  1487. * @param imageUrl defines the url of the image
  1488. * @returns a new Button
  1489. */
  1490. Button.CreateImageButton = function (name, text, imageUrl) {
  1491. var result = new Button(name);
  1492. // Adding text
  1493. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1494. textBlock.textWrapping = true;
  1495. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1496. textBlock.paddingLeft = "20%";
  1497. result.addControl(textBlock);
  1498. // Adding image
  1499. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1500. iconImage.width = "20%";
  1501. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1502. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1503. result.addControl(iconImage);
  1504. // Store
  1505. result._image = iconImage;
  1506. result._textBlock = textBlock;
  1507. return result;
  1508. };
  1509. /**
  1510. * Creates a new button made with an image
  1511. * @param name defines the name of the button
  1512. * @param imageUrl defines the url of the image
  1513. * @returns a new Button
  1514. */
  1515. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1516. var result = new Button(name);
  1517. // Adding image
  1518. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1519. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1520. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1521. result.addControl(iconImage);
  1522. // Store
  1523. result._image = iconImage;
  1524. return result;
  1525. };
  1526. /**
  1527. * Creates a new button made with a text
  1528. * @param name defines the name of the button
  1529. * @param text defines the text of the button
  1530. * @returns a new Button
  1531. */
  1532. Button.CreateSimpleButton = function (name, text) {
  1533. var result = new Button(name);
  1534. // Adding text
  1535. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1536. textBlock.textWrapping = true;
  1537. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1538. result.addControl(textBlock);
  1539. // Store
  1540. result._textBlock = textBlock;
  1541. return result;
  1542. };
  1543. /**
  1544. * Creates a new button made with an image and a centered text
  1545. * @param name defines the name of the button
  1546. * @param text defines the text of the button
  1547. * @param imageUrl defines the url of the image
  1548. * @returns a new Button
  1549. */
  1550. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1551. var result = new Button(name);
  1552. // Adding image
  1553. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1554. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1555. result.addControl(iconImage);
  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._image = iconImage;
  1563. result._textBlock = textBlock;
  1564. return result;
  1565. };
  1566. return Button;
  1567. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1568. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1569. /***/ }),
  1570. /***/ "./2D/controls/checkbox.ts":
  1571. /*!*********************************!*\
  1572. !*** ./2D/controls/checkbox.ts ***!
  1573. \*********************************/
  1574. /*! exports provided: Checkbox */
  1575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1576. "use strict";
  1577. __webpack_require__.r(__webpack_exports__);
  1578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1579. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1580. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1581. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1582. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1583. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1584. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1585. /**
  1586. * Class used to represent a 2D checkbox
  1587. */
  1588. var Checkbox = /** @class */ (function (_super) {
  1589. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1590. /**
  1591. * Creates a new CheckBox
  1592. * @param name defines the control name
  1593. */
  1594. function Checkbox(name) {
  1595. var _this = _super.call(this, name) || this;
  1596. _this.name = name;
  1597. _this._isChecked = false;
  1598. _this._background = "black";
  1599. _this._checkSizeRatio = 0.8;
  1600. _this._thickness = 1;
  1601. /**
  1602. * Observable raised when isChecked property changes
  1603. */
  1604. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1605. _this.isPointerBlocker = true;
  1606. return _this;
  1607. }
  1608. Object.defineProperty(Checkbox.prototype, "thickness", {
  1609. /** Gets or sets border thickness */
  1610. get: function () {
  1611. return this._thickness;
  1612. },
  1613. set: function (value) {
  1614. if (this._thickness === value) {
  1615. return;
  1616. }
  1617. this._thickness = value;
  1618. this._markAsDirty();
  1619. },
  1620. enumerable: true,
  1621. configurable: true
  1622. });
  1623. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1624. /** Gets or sets a value indicating the ratio between overall size and check size */
  1625. get: function () {
  1626. return this._checkSizeRatio;
  1627. },
  1628. set: function (value) {
  1629. value = Math.max(Math.min(1, value), 0);
  1630. if (this._checkSizeRatio === value) {
  1631. return;
  1632. }
  1633. this._checkSizeRatio = value;
  1634. this._markAsDirty();
  1635. },
  1636. enumerable: true,
  1637. configurable: true
  1638. });
  1639. Object.defineProperty(Checkbox.prototype, "background", {
  1640. /** Gets or sets background color */
  1641. get: function () {
  1642. return this._background;
  1643. },
  1644. set: function (value) {
  1645. if (this._background === value) {
  1646. return;
  1647. }
  1648. this._background = value;
  1649. this._markAsDirty();
  1650. },
  1651. enumerable: true,
  1652. configurable: true
  1653. });
  1654. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1655. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1656. get: function () {
  1657. return this._isChecked;
  1658. },
  1659. set: function (value) {
  1660. if (this._isChecked === value) {
  1661. return;
  1662. }
  1663. this._isChecked = value;
  1664. this._markAsDirty();
  1665. this.onIsCheckedChangedObservable.notifyObservers(value);
  1666. },
  1667. enumerable: true,
  1668. configurable: true
  1669. });
  1670. Checkbox.prototype._getTypeName = function () {
  1671. return "Checkbox";
  1672. };
  1673. /** @hidden */
  1674. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1675. context.save();
  1676. this._applyStates(context);
  1677. var actualWidth = this._currentMeasure.width - this._thickness;
  1678. var actualHeight = this._currentMeasure.height - this._thickness;
  1679. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1680. context.shadowColor = this.shadowColor;
  1681. context.shadowBlur = this.shadowBlur;
  1682. context.shadowOffsetX = this.shadowOffsetX;
  1683. context.shadowOffsetY = this.shadowOffsetY;
  1684. }
  1685. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1686. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1687. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1688. context.shadowBlur = 0;
  1689. context.shadowOffsetX = 0;
  1690. context.shadowOffsetY = 0;
  1691. }
  1692. if (this._isChecked) {
  1693. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1694. var offsetWidth = actualWidth * this._checkSizeRatio;
  1695. var offseHeight = actualHeight * this._checkSizeRatio;
  1696. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1697. }
  1698. context.strokeStyle = this.color;
  1699. context.lineWidth = this._thickness;
  1700. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1701. context.restore();
  1702. };
  1703. // Events
  1704. /** @hidden */
  1705. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1706. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1707. return false;
  1708. }
  1709. this.isChecked = !this.isChecked;
  1710. return true;
  1711. };
  1712. /**
  1713. * Utility function to easily create a checkbox with a header
  1714. * @param title defines the label to use for the header
  1715. * @param onValueChanged defines the callback to call when value changes
  1716. * @returns a StackPanel containing the checkbox and a textBlock
  1717. */
  1718. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1719. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1720. panel.isVertical = false;
  1721. panel.height = "30px";
  1722. var checkbox = new Checkbox();
  1723. checkbox.width = "20px";
  1724. checkbox.height = "20px";
  1725. checkbox.isChecked = true;
  1726. checkbox.color = "green";
  1727. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1728. panel.addControl(checkbox);
  1729. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1730. header.text = title;
  1731. header.width = "180px";
  1732. header.paddingLeft = "5px";
  1733. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1734. header.color = "white";
  1735. panel.addControl(header);
  1736. return panel;
  1737. };
  1738. return Checkbox;
  1739. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1740. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1741. /***/ }),
  1742. /***/ "./2D/controls/colorpicker.ts":
  1743. /*!************************************!*\
  1744. !*** ./2D/controls/colorpicker.ts ***!
  1745. \************************************/
  1746. /*! exports provided: ColorPicker */
  1747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1748. "use strict";
  1749. __webpack_require__.r(__webpack_exports__);
  1750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1751. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1752. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1753. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1754. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1755. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1756. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1757. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1758. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1759. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1760. /** Class used to create color pickers */
  1761. var ColorPicker = /** @class */ (function (_super) {
  1762. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1763. /**
  1764. * Creates a new ColorPicker
  1765. * @param name defines the control name
  1766. */
  1767. function ColorPicker(name) {
  1768. var _this = _super.call(this, name) || this;
  1769. _this.name = name;
  1770. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1771. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1772. _this._pointerStartedOnSquare = false;
  1773. _this._pointerStartedOnWheel = false;
  1774. _this._squareLeft = 0;
  1775. _this._squareTop = 0;
  1776. _this._squareSize = 0;
  1777. _this._h = 360;
  1778. _this._s = 1;
  1779. _this._v = 1;
  1780. _this._lastPointerDownID = -1;
  1781. /**
  1782. * Observable raised when the value changes
  1783. */
  1784. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1785. // Events
  1786. _this._pointerIsDown = false;
  1787. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1788. _this.size = "200px";
  1789. _this.isPointerBlocker = true;
  1790. return _this;
  1791. }
  1792. Object.defineProperty(ColorPicker.prototype, "value", {
  1793. /** Gets or sets the color of the color picker */
  1794. get: function () {
  1795. return this._value;
  1796. },
  1797. set: function (value) {
  1798. if (this._value.equals(value)) {
  1799. return;
  1800. }
  1801. this._value.copyFrom(value);
  1802. this._value.toHSVToRef(this._tmpColor);
  1803. this._h = this._tmpColor.r;
  1804. this._s = Math.max(this._tmpColor.g, 0.00001);
  1805. this._v = Math.max(this._tmpColor.b, 0.00001);
  1806. this._markAsDirty();
  1807. if (this._value.r <= ColorPicker._Epsilon) {
  1808. this._value.r = 0;
  1809. }
  1810. if (this._value.g <= ColorPicker._Epsilon) {
  1811. this._value.g = 0;
  1812. }
  1813. if (this._value.b <= ColorPicker._Epsilon) {
  1814. this._value.b = 0;
  1815. }
  1816. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1817. this._value.r = 1.0;
  1818. }
  1819. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1820. this._value.g = 1.0;
  1821. }
  1822. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1823. this._value.b = 1.0;
  1824. }
  1825. this.onValueChangedObservable.notifyObservers(this._value);
  1826. },
  1827. enumerable: true,
  1828. configurable: true
  1829. });
  1830. Object.defineProperty(ColorPicker.prototype, "width", {
  1831. /**
  1832. * Gets or sets control width
  1833. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1834. */
  1835. get: function () {
  1836. return this._width.toString(this._host);
  1837. },
  1838. set: function (value) {
  1839. if (this._width.toString(this._host) === value) {
  1840. return;
  1841. }
  1842. if (this._width.fromString(value)) {
  1843. this._height.fromString(value);
  1844. this._markAsDirty();
  1845. }
  1846. },
  1847. enumerable: true,
  1848. configurable: true
  1849. });
  1850. Object.defineProperty(ColorPicker.prototype, "height", {
  1851. /**
  1852. * Gets or sets control height
  1853. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1854. */
  1855. get: function () {
  1856. return this._height.toString(this._host);
  1857. },
  1858. /** Gets or sets control height */
  1859. set: function (value) {
  1860. if (this._height.toString(this._host) === value) {
  1861. return;
  1862. }
  1863. if (this._height.fromString(value)) {
  1864. this._width.fromString(value);
  1865. this._markAsDirty();
  1866. }
  1867. },
  1868. enumerable: true,
  1869. configurable: true
  1870. });
  1871. Object.defineProperty(ColorPicker.prototype, "size", {
  1872. /** Gets or sets control size */
  1873. get: function () {
  1874. return this.width;
  1875. },
  1876. set: function (value) {
  1877. this.width = value;
  1878. },
  1879. enumerable: true,
  1880. configurable: true
  1881. });
  1882. ColorPicker.prototype._getTypeName = function () {
  1883. return "ColorPicker";
  1884. };
  1885. /** @hidden */
  1886. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1887. if (parentMeasure.width < parentMeasure.height) {
  1888. this._currentMeasure.height = parentMeasure.width;
  1889. }
  1890. else {
  1891. this._currentMeasure.width = parentMeasure.height;
  1892. }
  1893. };
  1894. ColorPicker.prototype._updateSquareProps = function () {
  1895. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1896. var wheelThickness = radius * .2;
  1897. var innerDiameter = (radius - wheelThickness) * 2;
  1898. var squareSize = innerDiameter / (Math.sqrt(2));
  1899. var offset = radius - squareSize * .5;
  1900. this._squareLeft = this._currentMeasure.left + offset;
  1901. this._squareTop = this._currentMeasure.top + offset;
  1902. this._squareSize = squareSize;
  1903. };
  1904. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1905. var lgh = context.createLinearGradient(left, top, width + left, top);
  1906. lgh.addColorStop(0, '#fff');
  1907. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1908. context.fillStyle = lgh;
  1909. context.fillRect(left, top, width, height);
  1910. var lgv = context.createLinearGradient(left, top, left, height + top);
  1911. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1912. lgv.addColorStop(1, '#000');
  1913. context.fillStyle = lgv;
  1914. context.fillRect(left, top, width, height);
  1915. };
  1916. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1917. context.beginPath();
  1918. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1919. context.lineWidth = 3;
  1920. context.strokeStyle = '#333333';
  1921. context.stroke();
  1922. context.beginPath();
  1923. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1924. context.lineWidth = 3;
  1925. context.strokeStyle = '#ffffff';
  1926. context.stroke();
  1927. };
  1928. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1929. var canvas = document.createElement("canvas");
  1930. canvas.width = radius * 2;
  1931. canvas.height = radius * 2;
  1932. var context = canvas.getContext("2d");
  1933. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1934. var data = image.data;
  1935. var color = this._tmpColor;
  1936. var maxDistSq = radius * radius;
  1937. var innerRadius = radius - thickness;
  1938. var minDistSq = innerRadius * innerRadius;
  1939. for (var x = -radius; x < radius; x++) {
  1940. for (var y = -radius; y < radius; y++) {
  1941. var distSq = x * x + y * y;
  1942. if (distSq > maxDistSq || distSq < minDistSq) {
  1943. continue;
  1944. }
  1945. var dist = Math.sqrt(distSq);
  1946. var ang = Math.atan2(y, x);
  1947. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1948. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1949. data[index] = color.r * 255;
  1950. data[index + 1] = color.g * 255;
  1951. data[index + 2] = color.b * 255;
  1952. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1953. //apply less alpha to bigger color pickers
  1954. var alphaAmount = .2;
  1955. var maxAlpha = .2;
  1956. var minAlpha = .04;
  1957. var lowerRadius = 50;
  1958. var upperRadius = 150;
  1959. if (radius < lowerRadius) {
  1960. alphaAmount = maxAlpha;
  1961. }
  1962. else if (radius > upperRadius) {
  1963. alphaAmount = minAlpha;
  1964. }
  1965. else {
  1966. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1967. }
  1968. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1969. if (alphaRatio < alphaAmount) {
  1970. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1971. }
  1972. else if (alphaRatio > 1 - alphaAmount) {
  1973. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1974. }
  1975. else {
  1976. data[index + 3] = 255;
  1977. }
  1978. }
  1979. }
  1980. context.putImageData(image, 0, 0);
  1981. return canvas;
  1982. };
  1983. /** @hidden */
  1984. ColorPicker.prototype._draw = function (context) {
  1985. context.save();
  1986. this._applyStates(context);
  1987. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1988. var wheelThickness = radius * .2;
  1989. var left = this._currentMeasure.left;
  1990. var top = this._currentMeasure.top;
  1991. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  1992. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  1993. }
  1994. this._updateSquareProps();
  1995. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1996. context.shadowColor = this.shadowColor;
  1997. context.shadowBlur = this.shadowBlur;
  1998. context.shadowOffsetX = this.shadowOffsetX;
  1999. context.shadowOffsetY = this.shadowOffsetY;
  2000. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2001. }
  2002. context.drawImage(this._colorWheelCanvas, left, top);
  2003. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2004. context.shadowBlur = 0;
  2005. context.shadowOffsetX = 0;
  2006. context.shadowOffsetY = 0;
  2007. }
  2008. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2009. var cx = this._squareLeft + this._squareSize * this._s;
  2010. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2011. this._drawCircle(cx, cy, radius * .04, context);
  2012. var dist = radius - wheelThickness * .5;
  2013. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2014. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2015. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2016. context.restore();
  2017. };
  2018. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2019. if (this._pointerStartedOnWheel) {
  2020. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2021. var centerX = radius + this._currentMeasure.left;
  2022. var centerY = radius + this._currentMeasure.top;
  2023. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2024. }
  2025. else if (this._pointerStartedOnSquare) {
  2026. this._updateSquareProps();
  2027. this._s = (x - this._squareLeft) / this._squareSize;
  2028. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2029. this._s = Math.min(this._s, 1);
  2030. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2031. this._v = Math.min(this._v, 1);
  2032. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2033. }
  2034. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2035. this.value = this._tmpColor;
  2036. };
  2037. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2038. this._updateSquareProps();
  2039. var left = this._squareLeft;
  2040. var top = this._squareTop;
  2041. var size = this._squareSize;
  2042. if (x >= left && x <= left + size &&
  2043. y >= top && y <= top + size) {
  2044. return true;
  2045. }
  2046. return false;
  2047. };
  2048. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2049. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2050. var centerX = radius + this._currentMeasure.left;
  2051. var centerY = radius + this._currentMeasure.top;
  2052. var wheelThickness = radius * .2;
  2053. var innerRadius = radius - wheelThickness;
  2054. var radiusSq = radius * radius;
  2055. var innerRadiusSq = innerRadius * innerRadius;
  2056. var dx = x - centerX;
  2057. var dy = y - centerY;
  2058. var distSq = dx * dx + dy * dy;
  2059. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2060. return true;
  2061. }
  2062. return false;
  2063. };
  2064. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2065. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2066. return false;
  2067. }
  2068. this._pointerIsDown = true;
  2069. this._pointerStartedOnSquare = false;
  2070. this._pointerStartedOnWheel = false;
  2071. // Invert transform
  2072. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2073. var x = this._transformedPosition.x;
  2074. var y = this._transformedPosition.y;
  2075. if (this._isPointOnSquare(x, y)) {
  2076. this._pointerStartedOnSquare = true;
  2077. }
  2078. else if (this._isPointOnWheel(x, y)) {
  2079. this._pointerStartedOnWheel = true;
  2080. }
  2081. this._updateValueFromPointer(x, y);
  2082. this._host._capturingControl[pointerId] = this;
  2083. this._lastPointerDownID = pointerId;
  2084. return true;
  2085. };
  2086. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2087. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2088. if (pointerId != this._lastPointerDownID) {
  2089. return;
  2090. }
  2091. // Invert transform
  2092. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2093. var x = this._transformedPosition.x;
  2094. var y = this._transformedPosition.y;
  2095. if (this._pointerIsDown) {
  2096. this._updateValueFromPointer(x, y);
  2097. }
  2098. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2099. };
  2100. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2101. this._pointerIsDown = false;
  2102. delete this._host._capturingControl[pointerId];
  2103. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2104. };
  2105. /**
  2106. * This function expands the color picker by creating a color picker dialog with manual
  2107. * color value input and the ability to save colors into an array to be used later in
  2108. * subsequent launches of the dialogue.
  2109. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2110. * @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.
  2111. * @returns picked color as a hex string and the saved colors array as hex strings.
  2112. */
  2113. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2114. return new Promise(function (resolve, reject) {
  2115. // Default options
  2116. options.pickerWidth = options.pickerWidth || "640px";
  2117. options.pickerHeight = options.pickerHeight || "400px";
  2118. options.headerHeight = options.headerHeight || "35px";
  2119. options.lastColor = options.lastColor || "#000000";
  2120. options.swatchLimit = options.swatchLimit || 20;
  2121. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2122. // Window size settings
  2123. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2124. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2125. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2126. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2127. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2128. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2129. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2130. // Button Colors
  2131. var buttonColor = "#c0c0c0";
  2132. var buttonBackgroundColor = "#535353";
  2133. var buttonBackgroundHoverColor = "#414141";
  2134. var buttonBackgroundClickColor = "515151";
  2135. var buttonDisabledColor = "#555555";
  2136. var buttonDisabledBackgroundColor = "#454545";
  2137. var currentSwatchesOutlineColor = "#404040";
  2138. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2139. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2140. var iconColorDark = "#aaaaaa";
  2141. var iconColorLight = "#ffffff";
  2142. var closeIconColor;
  2143. // Button settings
  2144. var buttonFontSize;
  2145. var butEdit;
  2146. var buttonWidth;
  2147. var buttonHeight;
  2148. // Input Text Colors
  2149. var inputFieldLabels = ["R", "G", "B"];
  2150. var inputTextBackgroundColor = "#454545";
  2151. var inputTextColor = "#f0f0f0";
  2152. // This is the current color as set by either the picker or by entering a value
  2153. var currentColor;
  2154. // This int is used for naming swatches and serves as the index for calling them from the list
  2155. var swatchNumber;
  2156. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2157. var swatchDrawer;
  2158. var editSwatchMode = false;
  2159. // Color InputText fields that will be updated upon value change
  2160. var picker;
  2161. var rValInt;
  2162. var gValInt;
  2163. var bValInt;
  2164. var rValDec;
  2165. var gValDec;
  2166. var bValDec;
  2167. var hexVal;
  2168. var newSwatch;
  2169. var lastVal;
  2170. var activeField;
  2171. /**
  2172. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2173. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2174. * are will receive no update. This is to prevent the input from the user being overwritten.
  2175. */
  2176. function updateValues(value, inputField) {
  2177. activeField = inputField;
  2178. var pickedColor = value.toHexString();
  2179. newSwatch.background = pickedColor;
  2180. if (rValInt.name != activeField) {
  2181. rValInt.text = Math.floor(value.r * 255).toString();
  2182. }
  2183. if (gValInt.name != activeField) {
  2184. gValInt.text = Math.floor(value.g * 255).toString();
  2185. }
  2186. if (bValInt.name != activeField) {
  2187. bValInt.text = Math.floor(value.b * 255).toString();
  2188. }
  2189. if (rValDec.name != activeField) {
  2190. rValDec.text = value.r.toString();
  2191. }
  2192. if (gValDec.name != activeField) {
  2193. gValDec.text = value.g.toString();
  2194. }
  2195. if (bValDec.name != activeField) {
  2196. bValDec.text = value.b.toString();
  2197. }
  2198. if (hexVal.name != activeField) {
  2199. var minusPound = pickedColor.split("#");
  2200. hexVal.text = minusPound[1];
  2201. }
  2202. if (picker.name != activeField) {
  2203. picker.value = value;
  2204. }
  2205. }
  2206. // 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.
  2207. function updateInt(field, channel) {
  2208. var newValue = field.text;
  2209. var checkVal = /[^0-9]/g.test(newValue);
  2210. if (checkVal) {
  2211. field.text = lastVal;
  2212. return;
  2213. }
  2214. else {
  2215. if (newValue != "") {
  2216. if (Math.floor(parseInt(newValue)) < 0) {
  2217. newValue = "0";
  2218. }
  2219. else if (Math.floor(parseInt(newValue)) > 255) {
  2220. newValue = "255";
  2221. }
  2222. else if (isNaN(parseInt(newValue))) {
  2223. newValue = "0";
  2224. }
  2225. }
  2226. if (activeField == field.name) {
  2227. lastVal = newValue;
  2228. }
  2229. }
  2230. if (newValue != "") {
  2231. newValue = parseInt(newValue).toString();
  2232. field.text = newValue;
  2233. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2234. if (activeField == field.name) {
  2235. if (channel == "r") {
  2236. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2237. }
  2238. else if (channel == "g") {
  2239. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2240. }
  2241. else {
  2242. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2243. }
  2244. }
  2245. }
  2246. }
  2247. // 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.
  2248. function updateFloat(field, channel) {
  2249. var newValue = field.text;
  2250. var checkVal = /[^0-9\.]/g.test(newValue);
  2251. if (checkVal) {
  2252. field.text = lastVal;
  2253. return;
  2254. }
  2255. else {
  2256. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2257. if (parseFloat(newValue) < 0.0) {
  2258. newValue = "0.0";
  2259. }
  2260. else if (parseFloat(newValue) > 1.0) {
  2261. newValue = "1.0";
  2262. }
  2263. else if (isNaN(parseFloat(newValue))) {
  2264. newValue = "0.0";
  2265. }
  2266. }
  2267. if (activeField == field.name) {
  2268. lastVal = newValue;
  2269. }
  2270. }
  2271. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2272. newValue = parseFloat(newValue).toString();
  2273. field.text = newValue;
  2274. }
  2275. else {
  2276. newValue = "0.0";
  2277. }
  2278. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2279. if (activeField == field.name) {
  2280. if (channel == "r") {
  2281. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2282. }
  2283. else if (channel == "g") {
  2284. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2285. }
  2286. else {
  2287. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2288. }
  2289. }
  2290. }
  2291. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2292. function deleteSwatch(index) {
  2293. if (options.savedColors) {
  2294. options.savedColors.splice(index, 1);
  2295. }
  2296. if (options.savedColors && options.savedColors.length == 0) {
  2297. setEditButtonVisibility(false);
  2298. editSwatchMode = false;
  2299. }
  2300. }
  2301. // Creates and styles an individual swatch when updateSwatches is called.
  2302. function createSwatch() {
  2303. if (options.savedColors && options.savedColors[swatchNumber]) {
  2304. if (editSwatchMode) {
  2305. var icon = "b";
  2306. }
  2307. else {
  2308. var icon = "";
  2309. }
  2310. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2311. swatch.fontFamily = "BabylonJSglyphs";
  2312. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2313. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2314. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2315. if (swatchLuminence > luminanceLimit) {
  2316. swatch.color = iconColorDark;
  2317. }
  2318. else {
  2319. swatch.color = iconColorLight;
  2320. }
  2321. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2322. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2323. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2324. swatch.background = options.savedColors[swatchNumber];
  2325. swatch.thickness = 2;
  2326. var metadata_1 = swatchNumber;
  2327. swatch.pointerDownAnimation = function () {
  2328. swatch.thickness = 4;
  2329. };
  2330. swatch.pointerUpAnimation = function () {
  2331. swatch.thickness = 3;
  2332. };
  2333. swatch.pointerEnterAnimation = function () {
  2334. swatch.thickness = 3;
  2335. };
  2336. swatch.pointerOutAnimation = function () {
  2337. swatch.thickness = 2;
  2338. };
  2339. swatch.onPointerClickObservable.add(function () {
  2340. if (!editSwatchMode) {
  2341. if (options.savedColors) {
  2342. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2343. }
  2344. }
  2345. else {
  2346. deleteSwatch(metadata_1);
  2347. updateSwatches("", butSave);
  2348. }
  2349. });
  2350. return swatch;
  2351. }
  2352. else {
  2353. return null;
  2354. }
  2355. }
  2356. // Mode switch to render button text and close symbols on swatch controls
  2357. function editSwatches(mode) {
  2358. if (mode !== undefined) {
  2359. editSwatchMode = mode;
  2360. }
  2361. if (editSwatchMode) {
  2362. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2363. var thisButton = swatchDrawer.children[i];
  2364. thisButton.textBlock.text = "b";
  2365. }
  2366. if (butEdit !== undefined) {
  2367. butEdit.textBlock.text = "Done";
  2368. }
  2369. }
  2370. else {
  2371. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2372. var thisButton = swatchDrawer.children[i];
  2373. thisButton.textBlock.text = "";
  2374. }
  2375. if (butEdit !== undefined) {
  2376. butEdit.textBlock.text = "Edit";
  2377. }
  2378. }
  2379. }
  2380. /**
  2381. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2382. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2383. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2384. * saved colors there are and how many can be stored per row.
  2385. */
  2386. function updateSwatches(color, button) {
  2387. if (options.savedColors) {
  2388. if (color != "") {
  2389. options.savedColors.push(color);
  2390. }
  2391. swatchNumber = 0;
  2392. swatchDrawer.clearControls();
  2393. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2394. if (rowCount == 0) {
  2395. var gutterCount = 0;
  2396. }
  2397. else {
  2398. var gutterCount = rowCount + 1;
  2399. }
  2400. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2401. var currentRows = swatchDrawer.rowCount;
  2402. for (var i = 0; i < currentRows; i++) {
  2403. swatchDrawer.removeRowDefinition(0);
  2404. }
  2405. for (var i = 0; i < rowCount + gutterCount; i++) {
  2406. if (i % 2) {
  2407. swatchDrawer.addRowDefinition(swatchSize, true);
  2408. }
  2409. else {
  2410. swatchDrawer.addRowDefinition(gutterSize, true);
  2411. }
  2412. }
  2413. }
  2414. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2415. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2416. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2417. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2418. var totalButtonsThisRow = options.numSwatchesPerLine;
  2419. }
  2420. else {
  2421. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2422. }
  2423. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2424. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2425. if (x > options.numSwatchesPerLine) {
  2426. continue;
  2427. }
  2428. var swatch = createSwatch();
  2429. if (swatch != null) {
  2430. swatchDrawer.addControl(swatch, y, w);
  2431. w += 2;
  2432. swatchNumber++;
  2433. }
  2434. else {
  2435. continue;
  2436. }
  2437. }
  2438. }
  2439. if (options.savedColors.length >= options.swatchLimit) {
  2440. disableButton(button, true);
  2441. }
  2442. else {
  2443. disableButton(button, false);
  2444. }
  2445. }
  2446. }
  2447. // Shows or hides edit swatches button depending on if there are saved swatches
  2448. function setEditButtonVisibility(enableButton) {
  2449. if (enableButton) {
  2450. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2451. butEdit.width = buttonWidth;
  2452. butEdit.height = buttonHeight;
  2453. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2454. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2455. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2456. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2457. butEdit.thickness = 2;
  2458. butEdit.color = buttonColor;
  2459. butEdit.fontSize = buttonFontSize;
  2460. butEdit.background = buttonBackgroundColor;
  2461. butEdit.onPointerEnterObservable.add(function () {
  2462. butEdit.background = buttonBackgroundHoverColor;
  2463. });
  2464. butEdit.onPointerOutObservable.add(function () {
  2465. butEdit.background = buttonBackgroundColor;
  2466. });
  2467. butEdit.pointerDownAnimation = function () {
  2468. butEdit.background = buttonBackgroundClickColor;
  2469. };
  2470. butEdit.pointerUpAnimation = function () {
  2471. butEdit.background = buttonBackgroundHoverColor;
  2472. };
  2473. butEdit.onPointerClickObservable.add(function () {
  2474. if (editSwatchMode) {
  2475. editSwatchMode = false;
  2476. }
  2477. else {
  2478. editSwatchMode = true;
  2479. }
  2480. editSwatches();
  2481. });
  2482. pickerGrid.addControl(butEdit, 1, 0);
  2483. }
  2484. else {
  2485. pickerGrid.removeControl(butEdit);
  2486. }
  2487. }
  2488. // Called when the user hits the limit of saved colors in the drawer.
  2489. function disableButton(button, disabled) {
  2490. if (disabled) {
  2491. button.color = buttonDisabledColor;
  2492. button.background = buttonDisabledBackgroundColor;
  2493. }
  2494. else {
  2495. button.color = buttonColor;
  2496. button.background = buttonBackgroundColor;
  2497. }
  2498. }
  2499. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2500. function closePicker(color) {
  2501. if (options.savedColors && options.savedColors.length > 0) {
  2502. resolve({
  2503. savedColors: options.savedColors,
  2504. pickedColor: color
  2505. });
  2506. }
  2507. else {
  2508. resolve({
  2509. pickedColor: color
  2510. });
  2511. }
  2512. advancedTexture.removeControl(dialogContainer);
  2513. }
  2514. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2515. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2516. dialogContainer.name = "Dialog Container";
  2517. dialogContainer.width = options.pickerWidth;
  2518. if (options.savedColors) {
  2519. dialogContainer.height = containerSize;
  2520. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2521. dialogContainer.addRowDefinition(topRow, false);
  2522. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2523. }
  2524. else {
  2525. dialogContainer.height = options.pickerHeight;
  2526. dialogContainer.addRowDefinition(1.0, false);
  2527. }
  2528. advancedTexture.addControl(dialogContainer);
  2529. // Swatch drawer which contains all saved color buttons
  2530. if (options.savedColors) {
  2531. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2532. swatchDrawer.name = "Swatch Drawer";
  2533. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2534. swatchDrawer.background = buttonBackgroundColor;
  2535. swatchDrawer.width = options.pickerWidth;
  2536. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2537. if (initialRows == 0) {
  2538. var gutterCount = 0;
  2539. }
  2540. else {
  2541. var gutterCount = initialRows + 1;
  2542. }
  2543. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2544. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2545. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2546. if (i % 2 != 0) {
  2547. swatchDrawer.addRowDefinition(swatchSize, true);
  2548. }
  2549. else {
  2550. swatchDrawer.addRowDefinition(gutterSize, true);
  2551. }
  2552. }
  2553. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2554. if (i % 2 != 0) {
  2555. swatchDrawer.addColumnDefinition(swatchSize, true);
  2556. }
  2557. else {
  2558. swatchDrawer.addColumnDefinition(gutterSize, true);
  2559. }
  2560. }
  2561. dialogContainer.addControl(swatchDrawer, 1, 0);
  2562. }
  2563. // Picker container
  2564. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2565. pickerPanel.name = "Picker Panel";
  2566. pickerPanel.height = options.pickerHeight;
  2567. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2568. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2569. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2570. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2571. dialogContainer.addControl(pickerPanel, 0, 0);
  2572. // Picker container header
  2573. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2574. header.name = "Dialogue Header Bar";
  2575. header.background = "#cccccc";
  2576. header.thickness = 0;
  2577. pickerPanel.addControl(header, 0, 0);
  2578. // Header close button
  2579. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2580. closeButton.fontFamily = "BabylonJSglyphs";
  2581. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2582. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2583. closeButton.color = closeIconColor.toHexString();
  2584. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2585. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2586. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2587. closeButton.height = closeButton.width = options.headerHeight;
  2588. closeButton.background = header.background;
  2589. closeButton.thickness = 0;
  2590. closeButton.pointerDownAnimation = function () {
  2591. };
  2592. closeButton.pointerUpAnimation = function () {
  2593. closeButton.background = header.background;
  2594. };
  2595. closeButton.pointerEnterAnimation = function () {
  2596. closeButton.color = header.background;
  2597. closeButton.background = "red";
  2598. };
  2599. closeButton.pointerOutAnimation = function () {
  2600. closeButton.color = closeIconColor.toHexString();
  2601. closeButton.background = header.background;
  2602. };
  2603. closeButton.onPointerClickObservable.add(function () {
  2604. closePicker(currentSwatch.background);
  2605. });
  2606. pickerPanel.addControl(closeButton, 0, 0);
  2607. // Dialog container body
  2608. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2609. dialogBody.name = "Dialogue Body";
  2610. dialogBody.background = buttonBackgroundColor;
  2611. var dialogBodyCols = [0.4375, 0.5625];
  2612. dialogBody.addRowDefinition(1.0, false);
  2613. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2614. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2615. pickerPanel.addControl(dialogBody, 1, 0);
  2616. // Picker grid
  2617. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2618. pickerGrid.name = "Picker Grid";
  2619. pickerGrid.addRowDefinition(0.85, false);
  2620. pickerGrid.addRowDefinition(0.15, false);
  2621. dialogBody.addControl(pickerGrid, 0, 0);
  2622. // Picker control
  2623. picker = new ColorPicker();
  2624. picker.name = "GUI Color Picker";
  2625. if (options.pickerHeight < options.pickerWidth) {
  2626. picker.width = 0.89;
  2627. }
  2628. else {
  2629. picker.height = 0.89;
  2630. }
  2631. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2632. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2633. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2634. picker.onPointerDownObservable.add(function () {
  2635. activeField = picker.name;
  2636. lastVal = "";
  2637. editSwatches(false);
  2638. });
  2639. picker.onValueChangedObservable.add(function (value) {
  2640. if (activeField == picker.name) {
  2641. updateValues(value, picker.name);
  2642. }
  2643. });
  2644. pickerGrid.addControl(picker, 0, 0);
  2645. // Picker body right quarant
  2646. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2647. pickerBodyRight.name = "Dialogue Right Half";
  2648. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2649. var pickerBodyRightRows = [0.514, 0.486];
  2650. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2651. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2652. dialogBody.addControl(pickerBodyRight, 1, 1);
  2653. // Picker container swatches and buttons
  2654. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2655. pickerSwatchesButtons.name = "Swatches and Buttons";
  2656. var pickerButtonsCol = [0.417, 0.583];
  2657. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2658. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2659. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2660. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2661. // Picker Swatches quadrant
  2662. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2663. pickerSwatches.name = "New and Current Swatches";
  2664. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2665. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2666. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2667. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2668. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2669. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2670. // Active swatches
  2671. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2672. activeSwatches.name = "Active Swatches";
  2673. activeSwatches.width = 0.67;
  2674. activeSwatches.addRowDefinition(0.5, false);
  2675. activeSwatches.addRowDefinition(0.5, false);
  2676. pickerSwatches.addControl(activeSwatches, 2, 0);
  2677. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2678. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2679. if (options.pickerWidth > options.pickerHeight) {
  2680. var labelTextSize = labelHeight;
  2681. }
  2682. else {
  2683. var labelTextSize = labelWidth;
  2684. }
  2685. // New color swatch and previous color button
  2686. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2687. newText.text = "new";
  2688. newText.name = "New Color Label";
  2689. newText.color = buttonColor;
  2690. newText.fontSize = labelTextSize;
  2691. pickerSwatches.addControl(newText, 1, 0);
  2692. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2693. newSwatch.name = "New Color Swatch";
  2694. newSwatch.background = options.lastColor;
  2695. newSwatch.thickness = 0;
  2696. activeSwatches.addControl(newSwatch, 0, 0);
  2697. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2698. currentSwatch.background = options.lastColor;
  2699. currentSwatch.thickness = 0;
  2700. currentSwatch.onPointerClickObservable.add(function () {
  2701. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2702. updateValues(revertColor, currentSwatch.name);
  2703. editSwatches(false);
  2704. });
  2705. currentSwatch.pointerDownAnimation = function () { };
  2706. currentSwatch.pointerUpAnimation = function () { };
  2707. currentSwatch.pointerEnterAnimation = function () { };
  2708. currentSwatch.pointerOutAnimation = function () { };
  2709. activeSwatches.addControl(currentSwatch, 1, 0);
  2710. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2711. swatchOutline.name = "Swatch Outline";
  2712. swatchOutline.width = 0.67;
  2713. swatchOutline.thickness = 2;
  2714. swatchOutline.color = currentSwatchesOutlineColor;
  2715. swatchOutline.isHitTestVisible = false;
  2716. pickerSwatches.addControl(swatchOutline, 2, 0);
  2717. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2718. currentText.name = "Current Color Label";
  2719. currentText.text = "current";
  2720. currentText.color = buttonColor;
  2721. currentText.fontSize = labelTextSize;
  2722. pickerSwatches.addControl(currentText, 3, 0);
  2723. // Buttons grid
  2724. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2725. buttonGrid.name = "Button Grid";
  2726. buttonGrid.height = 0.8;
  2727. var buttonGridRows = 1 / 3;
  2728. buttonGrid.addRowDefinition(buttonGridRows, false);
  2729. buttonGrid.addRowDefinition(buttonGridRows, false);
  2730. buttonGrid.addRowDefinition(buttonGridRows, false);
  2731. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2732. // Determine pixel width and height for all buttons from overall panel dimensions
  2733. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2734. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2735. // Determine button type size
  2736. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2737. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2738. }
  2739. else {
  2740. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2741. }
  2742. // Panel Buttons
  2743. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2744. butOK.width = buttonWidth;
  2745. butOK.height = buttonHeight;
  2746. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2747. butOK.thickness = 2;
  2748. butOK.color = buttonColor;
  2749. butOK.fontSize = buttonFontSize;
  2750. butOK.background = buttonBackgroundColor;
  2751. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2752. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2753. butOK.pointerDownAnimation = function () {
  2754. butOK.background = buttonBackgroundClickColor;
  2755. };
  2756. butOK.pointerUpAnimation = function () {
  2757. butOK.background = buttonBackgroundHoverColor;
  2758. };
  2759. butOK.onPointerClickObservable.add(function () {
  2760. editSwatches(false);
  2761. closePicker(newSwatch.background);
  2762. });
  2763. buttonGrid.addControl(butOK, 0, 0);
  2764. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2765. butCancel.width = buttonWidth;
  2766. butCancel.height = buttonHeight;
  2767. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2768. butCancel.thickness = 2;
  2769. butCancel.color = buttonColor;
  2770. butCancel.fontSize = buttonFontSize;
  2771. butCancel.background = buttonBackgroundColor;
  2772. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2773. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2774. butCancel.pointerDownAnimation = function () {
  2775. butCancel.background = buttonBackgroundClickColor;
  2776. };
  2777. butCancel.pointerUpAnimation = function () {
  2778. butCancel.background = buttonBackgroundHoverColor;
  2779. };
  2780. butCancel.onPointerClickObservable.add(function () {
  2781. editSwatches(false);
  2782. closePicker(currentSwatch.background);
  2783. });
  2784. buttonGrid.addControl(butCancel, 1, 0);
  2785. if (options.savedColors) {
  2786. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2787. butSave.width = buttonWidth;
  2788. butSave.height = buttonHeight;
  2789. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2790. butSave.thickness = 2;
  2791. butSave.fontSize = buttonFontSize;
  2792. if (options.savedColors.length < options.swatchLimit) {
  2793. butSave.color = buttonColor;
  2794. butSave.background = buttonBackgroundColor;
  2795. }
  2796. else {
  2797. disableButton(butSave, true);
  2798. }
  2799. butSave.onPointerEnterObservable.add(function () {
  2800. if (options.savedColors) {
  2801. if (options.savedColors.length < options.swatchLimit) {
  2802. butSave.background = buttonBackgroundHoverColor;
  2803. }
  2804. }
  2805. });
  2806. butSave.onPointerOutObservable.add(function () {
  2807. if (options.savedColors) {
  2808. if (options.savedColors.length < options.swatchLimit) {
  2809. butSave.background = buttonBackgroundColor;
  2810. }
  2811. }
  2812. });
  2813. butSave.pointerDownAnimation = function () {
  2814. if (options.savedColors) {
  2815. if (options.savedColors.length < options.swatchLimit) {
  2816. butSave.background = buttonBackgroundClickColor;
  2817. }
  2818. }
  2819. };
  2820. butSave.pointerUpAnimation = function () {
  2821. if (options.savedColors) {
  2822. if (options.savedColors.length < options.swatchLimit) {
  2823. butSave.background = buttonBackgroundHoverColor;
  2824. }
  2825. }
  2826. };
  2827. butSave.onPointerClickObservable.add(function () {
  2828. if (options.savedColors) {
  2829. if (options.savedColors.length == 0) {
  2830. setEditButtonVisibility(true);
  2831. }
  2832. if (options.savedColors.length < options.swatchLimit) {
  2833. updateSwatches(newSwatch.background, butSave);
  2834. }
  2835. editSwatches(false);
  2836. }
  2837. });
  2838. if (options.savedColors.length > 0) {
  2839. setEditButtonVisibility(true);
  2840. }
  2841. buttonGrid.addControl(butSave, 2, 0);
  2842. }
  2843. // Picker color values input
  2844. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2845. pickerColorValues.name = "Dialog Lower Right";
  2846. pickerColorValues.addRowDefinition(0.02, false);
  2847. pickerColorValues.addRowDefinition(0.63, false);
  2848. pickerColorValues.addRowDefinition(0.21, false);
  2849. pickerColorValues.addRowDefinition(0.14, false);
  2850. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2851. // RGB values text boxes
  2852. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2853. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2854. rgbValuesQuadrant.name = "RGB Values";
  2855. rgbValuesQuadrant.width = 0.82;
  2856. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2857. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2858. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2859. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2860. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2861. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2862. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2863. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2864. for (var i = 0; i < inputFieldLabels.length; i++) {
  2865. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2866. labelText.text = inputFieldLabels[i];
  2867. labelText.color = buttonColor;
  2868. labelText.fontSize = buttonFontSize;
  2869. rgbValuesQuadrant.addControl(labelText, i, 0);
  2870. }
  2871. // Input fields for RGB values
  2872. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2873. rValInt.width = 0.83;
  2874. rValInt.height = 0.72;
  2875. rValInt.name = "rIntField";
  2876. rValInt.fontSize = buttonFontSize;
  2877. rValInt.text = (currentColor.r * 255).toString();
  2878. rValInt.color = inputTextColor;
  2879. rValInt.background = inputTextBackgroundColor;
  2880. rValInt.onFocusObservable.add(function () {
  2881. activeField = rValInt.name;
  2882. lastVal = rValInt.text;
  2883. editSwatches(false);
  2884. });
  2885. rValInt.onBlurObservable.add(function () {
  2886. if (rValInt.text == "") {
  2887. rValInt.text = "0";
  2888. }
  2889. updateInt(rValInt, "r");
  2890. if (activeField == rValInt.name) {
  2891. activeField = "";
  2892. }
  2893. });
  2894. rValInt.onTextChangedObservable.add(function () {
  2895. if (activeField == rValInt.name) {
  2896. updateInt(rValInt, "r");
  2897. }
  2898. });
  2899. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2900. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2901. gValInt.width = 0.83;
  2902. gValInt.height = 0.72;
  2903. gValInt.name = "gIntField";
  2904. gValInt.fontSize = buttonFontSize;
  2905. gValInt.text = (currentColor.g * 255).toString();
  2906. gValInt.color = inputTextColor;
  2907. gValInt.background = inputTextBackgroundColor;
  2908. gValInt.onFocusObservable.add(function () {
  2909. activeField = gValInt.name;
  2910. lastVal = gValInt.text;
  2911. editSwatches(false);
  2912. });
  2913. gValInt.onBlurObservable.add(function () {
  2914. if (gValInt.text == "") {
  2915. gValInt.text = "0";
  2916. }
  2917. updateInt(gValInt, "g");
  2918. if (activeField == gValInt.name) {
  2919. activeField = "";
  2920. }
  2921. });
  2922. gValInt.onTextChangedObservable.add(function () {
  2923. if (activeField == gValInt.name) {
  2924. updateInt(gValInt, "g");
  2925. }
  2926. });
  2927. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2928. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2929. bValInt.width = 0.83;
  2930. bValInt.height = 0.72;
  2931. bValInt.name = "bIntField";
  2932. bValInt.fontSize = buttonFontSize;
  2933. bValInt.text = (currentColor.b * 255).toString();
  2934. bValInt.color = inputTextColor;
  2935. bValInt.background = inputTextBackgroundColor;
  2936. bValInt.onFocusObservable.add(function () {
  2937. activeField = bValInt.name;
  2938. lastVal = bValInt.text;
  2939. editSwatches(false);
  2940. });
  2941. bValInt.onBlurObservable.add(function () {
  2942. if (bValInt.text == "") {
  2943. bValInt.text = "0";
  2944. }
  2945. updateInt(bValInt, "b");
  2946. if (activeField == bValInt.name) {
  2947. activeField = "";
  2948. }
  2949. });
  2950. bValInt.onTextChangedObservable.add(function () {
  2951. if (activeField == bValInt.name) {
  2952. updateInt(bValInt, "b");
  2953. }
  2954. });
  2955. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2956. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2957. rValDec.width = 0.95;
  2958. rValDec.height = 0.72;
  2959. rValDec.name = "rDecField";
  2960. rValDec.fontSize = buttonFontSize;
  2961. rValDec.text = currentColor.r.toString();
  2962. rValDec.color = inputTextColor;
  2963. rValDec.background = inputTextBackgroundColor;
  2964. rValDec.onFocusObservable.add(function () {
  2965. activeField = rValDec.name;
  2966. lastVal = rValDec.text;
  2967. editSwatches(false);
  2968. });
  2969. rValDec.onBlurObservable.add(function () {
  2970. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2971. rValDec.text = "0";
  2972. updateFloat(rValDec, "r");
  2973. }
  2974. if (activeField == rValDec.name) {
  2975. activeField = "";
  2976. }
  2977. });
  2978. rValDec.onTextChangedObservable.add(function () {
  2979. if (activeField == rValDec.name) {
  2980. updateFloat(rValDec, "r");
  2981. }
  2982. });
  2983. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  2984. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2985. gValDec.width = 0.95;
  2986. gValDec.height = 0.72;
  2987. gValDec.name = "gDecField";
  2988. gValDec.fontSize = buttonFontSize;
  2989. gValDec.text = currentColor.g.toString();
  2990. gValDec.color = inputTextColor;
  2991. gValDec.background = inputTextBackgroundColor;
  2992. gValDec.onFocusObservable.add(function () {
  2993. activeField = gValDec.name;
  2994. lastVal = gValDec.text;
  2995. editSwatches(false);
  2996. });
  2997. gValDec.onBlurObservable.add(function () {
  2998. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  2999. gValDec.text = "0";
  3000. updateFloat(gValDec, "g");
  3001. }
  3002. if (activeField == gValDec.name) {
  3003. activeField = "";
  3004. }
  3005. });
  3006. gValDec.onTextChangedObservable.add(function () {
  3007. if (activeField == gValDec.name) {
  3008. updateFloat(gValDec, "g");
  3009. }
  3010. });
  3011. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3012. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3013. bValDec.width = 0.95;
  3014. bValDec.height = 0.72;
  3015. bValDec.name = "bDecField";
  3016. bValDec.fontSize = buttonFontSize;
  3017. bValDec.text = currentColor.b.toString();
  3018. bValDec.color = inputTextColor;
  3019. bValDec.background = inputTextBackgroundColor;
  3020. bValDec.onFocusObservable.add(function () {
  3021. activeField = bValDec.name;
  3022. lastVal = bValDec.text;
  3023. editSwatches(false);
  3024. });
  3025. bValDec.onBlurObservable.add(function () {
  3026. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3027. bValDec.text = "0";
  3028. updateFloat(bValDec, "b");
  3029. }
  3030. if (activeField == bValDec.name) {
  3031. activeField = "";
  3032. }
  3033. });
  3034. bValDec.onTextChangedObservable.add(function () {
  3035. if (activeField == bValDec.name) {
  3036. updateFloat(bValDec, "b");
  3037. }
  3038. });
  3039. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3040. // Hex value input
  3041. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3042. hexValueQuadrant.name = "Hex Value";
  3043. hexValueQuadrant.width = 0.82;
  3044. hexValueQuadrant.addRowDefinition(1.0, false);
  3045. hexValueQuadrant.addColumnDefinition(0.1, false);
  3046. hexValueQuadrant.addColumnDefinition(0.9, false);
  3047. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3048. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3049. labelText.text = "#";
  3050. labelText.color = buttonColor;
  3051. labelText.fontSize = buttonFontSize;
  3052. hexValueQuadrant.addControl(labelText, 0, 0);
  3053. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3054. hexVal.width = 0.96;
  3055. hexVal.height = 0.72;
  3056. hexVal.name = "hexField";
  3057. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3058. hexVal.fontSize = buttonFontSize;
  3059. var minusPound = options.lastColor.split("#");
  3060. hexVal.text = minusPound[1];
  3061. hexVal.color = inputTextColor;
  3062. hexVal.background = inputTextBackgroundColor;
  3063. hexVal.onFocusObservable.add(function () {
  3064. activeField = hexVal.name;
  3065. lastVal = hexVal.text;
  3066. editSwatches(false);
  3067. });
  3068. hexVal.onBlurObservable.add(function () {
  3069. if (hexVal.text.length == 3) {
  3070. var val = hexVal.text.split("");
  3071. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3072. }
  3073. if (hexVal.text == "") {
  3074. hexVal.text = "000000";
  3075. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3076. }
  3077. if (activeField == hexVal.name) {
  3078. activeField = "";
  3079. }
  3080. });
  3081. hexVal.onTextChangedObservable.add(function () {
  3082. var newHexValue = hexVal.text;
  3083. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3084. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3085. hexVal.text = lastVal;
  3086. }
  3087. else {
  3088. if (hexVal.text.length < 6) {
  3089. var leadingZero = 6 - hexVal.text.length;
  3090. for (var i = 0; i < leadingZero; i++) {
  3091. newHexValue = "0" + newHexValue;
  3092. }
  3093. }
  3094. if (hexVal.text.length == 3) {
  3095. var val = hexVal.text.split("");
  3096. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3097. }
  3098. newHexValue = "#" + newHexValue;
  3099. if (activeField == hexVal.name) {
  3100. lastVal = hexVal.text;
  3101. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3102. }
  3103. }
  3104. });
  3105. hexValueQuadrant.addControl(hexVal, 0, 1);
  3106. if (options.savedColors && options.savedColors.length > 0) {
  3107. updateSwatches("", butSave);
  3108. }
  3109. });
  3110. };
  3111. ColorPicker._Epsilon = 0.000001;
  3112. return ColorPicker;
  3113. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3114. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3115. /***/ }),
  3116. /***/ "./2D/controls/container.ts":
  3117. /*!**********************************!*\
  3118. !*** ./2D/controls/container.ts ***!
  3119. \**********************************/
  3120. /*! exports provided: Container */
  3121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3122. "use strict";
  3123. __webpack_require__.r(__webpack_exports__);
  3124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3125. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3126. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/perfCounter");
  3127. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3128. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3129. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3130. /**
  3131. * Root class for 2D containers
  3132. * @see http://doc.babylonjs.com/how_to/gui#containers
  3133. */
  3134. var Container = /** @class */ (function (_super) {
  3135. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3136. /**
  3137. * Creates a new Container
  3138. * @param name defines the name of the container
  3139. */
  3140. function Container(name) {
  3141. var _this = _super.call(this, name) || this;
  3142. _this.name = name;
  3143. /** @hidden */
  3144. _this._children = new Array();
  3145. /** @hidden */
  3146. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3147. /** @hidden */
  3148. _this._background = "";
  3149. /** @hidden */
  3150. _this._adaptWidthToChildren = false;
  3151. /** @hidden */
  3152. _this._adaptHeightToChildren = false;
  3153. /**
  3154. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3155. */
  3156. _this.logLayoutCycleErrors = false;
  3157. /**
  3158. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3159. */
  3160. _this.maxLayoutCycle = 3;
  3161. return _this;
  3162. }
  3163. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3164. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3165. get: function () {
  3166. return this._adaptHeightToChildren;
  3167. },
  3168. set: function (value) {
  3169. if (this._adaptHeightToChildren === value) {
  3170. return;
  3171. }
  3172. this._adaptHeightToChildren = value;
  3173. if (value) {
  3174. this.height = "100%";
  3175. }
  3176. this._markAsDirty();
  3177. },
  3178. enumerable: true,
  3179. configurable: true
  3180. });
  3181. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3182. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3183. get: function () {
  3184. return this._adaptWidthToChildren;
  3185. },
  3186. set: function (value) {
  3187. if (this._adaptWidthToChildren === value) {
  3188. return;
  3189. }
  3190. this._adaptWidthToChildren = value;
  3191. if (value) {
  3192. this.width = "100%";
  3193. }
  3194. this._markAsDirty();
  3195. },
  3196. enumerable: true,
  3197. configurable: true
  3198. });
  3199. Object.defineProperty(Container.prototype, "background", {
  3200. /** Gets or sets background color */
  3201. get: function () {
  3202. return this._background;
  3203. },
  3204. set: function (value) {
  3205. if (this._background === value) {
  3206. return;
  3207. }
  3208. this._background = value;
  3209. this._markAsDirty();
  3210. },
  3211. enumerable: true,
  3212. configurable: true
  3213. });
  3214. Object.defineProperty(Container.prototype, "children", {
  3215. /** Gets the list of children */
  3216. get: function () {
  3217. return this._children;
  3218. },
  3219. enumerable: true,
  3220. configurable: true
  3221. });
  3222. Container.prototype._getTypeName = function () {
  3223. return "Container";
  3224. };
  3225. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3226. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3227. var child = _a[_i];
  3228. child._markMatrixAsDirty();
  3229. }
  3230. };
  3231. /**
  3232. * Gets a child using its name
  3233. * @param name defines the child name to look for
  3234. * @returns the child control if found
  3235. */
  3236. Container.prototype.getChildByName = function (name) {
  3237. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3238. var child = _a[_i];
  3239. if (child.name === name) {
  3240. return child;
  3241. }
  3242. }
  3243. return null;
  3244. };
  3245. /**
  3246. * Gets a child using its type and its name
  3247. * @param name defines the child name to look for
  3248. * @param type defines the child type to look for
  3249. * @returns the child control if found
  3250. */
  3251. Container.prototype.getChildByType = function (name, type) {
  3252. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3253. var child = _a[_i];
  3254. if (child.typeName === type) {
  3255. return child;
  3256. }
  3257. }
  3258. return null;
  3259. };
  3260. /**
  3261. * Search for a specific control in children
  3262. * @param control defines the control to look for
  3263. * @returns true if the control is in child list
  3264. */
  3265. Container.prototype.containsControl = function (control) {
  3266. return this.children.indexOf(control) !== -1;
  3267. };
  3268. /**
  3269. * Adds a new control to the current container
  3270. * @param control defines the control to add
  3271. * @returns the current container
  3272. */
  3273. Container.prototype.addControl = function (control) {
  3274. if (!control) {
  3275. return this;
  3276. }
  3277. var index = this._children.indexOf(control);
  3278. if (index !== -1) {
  3279. return this;
  3280. }
  3281. control._link(this._host);
  3282. control._markAllAsDirty();
  3283. this._reOrderControl(control);
  3284. this._markAsDirty();
  3285. return this;
  3286. };
  3287. /**
  3288. * Removes all controls from the current container
  3289. * @returns the current container
  3290. */
  3291. Container.prototype.clearControls = function () {
  3292. var children = this.children.slice();
  3293. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3294. var child = children_1[_i];
  3295. this.removeControl(child);
  3296. }
  3297. return this;
  3298. };
  3299. /**
  3300. * Removes a control from the current container
  3301. * @param control defines the control to remove
  3302. * @returns the current container
  3303. */
  3304. Container.prototype.removeControl = function (control) {
  3305. var index = this._children.indexOf(control);
  3306. if (index !== -1) {
  3307. this._children.splice(index, 1);
  3308. control.parent = null;
  3309. }
  3310. control.linkWithMesh(null);
  3311. if (this._host) {
  3312. this._host._cleanControlAfterRemoval(control);
  3313. }
  3314. this._markAsDirty();
  3315. return this;
  3316. };
  3317. /** @hidden */
  3318. Container.prototype._reOrderControl = function (control) {
  3319. this.removeControl(control);
  3320. var wasAdded = false;
  3321. for (var index = 0; index < this._children.length; index++) {
  3322. if (this._children[index].zIndex > control.zIndex) {
  3323. this._children.splice(index, 0, control);
  3324. wasAdded = true;
  3325. break;
  3326. }
  3327. }
  3328. if (!wasAdded) {
  3329. this._children.push(control);
  3330. }
  3331. control.parent = this;
  3332. this._markAsDirty();
  3333. };
  3334. /** @hidden */
  3335. Container.prototype._offsetLeft = function (offset) {
  3336. _super.prototype._offsetLeft.call(this, offset);
  3337. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3338. var child = _a[_i];
  3339. child._offsetLeft(offset);
  3340. }
  3341. };
  3342. /** @hidden */
  3343. Container.prototype._offsetTop = function (offset) {
  3344. _super.prototype._offsetTop.call(this, offset);
  3345. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3346. var child = _a[_i];
  3347. child._offsetTop(offset);
  3348. }
  3349. };
  3350. /** @hidden */
  3351. Container.prototype._markAllAsDirty = function () {
  3352. _super.prototype._markAllAsDirty.call(this);
  3353. for (var index = 0; index < this._children.length; index++) {
  3354. this._children[index]._markAllAsDirty();
  3355. }
  3356. };
  3357. /** @hidden */
  3358. Container.prototype._localDraw = function (context) {
  3359. if (this._background) {
  3360. context.save();
  3361. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3362. context.shadowColor = this.shadowColor;
  3363. context.shadowBlur = this.shadowBlur;
  3364. context.shadowOffsetX = this.shadowOffsetX;
  3365. context.shadowOffsetY = this.shadowOffsetY;
  3366. }
  3367. context.fillStyle = this._background;
  3368. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3369. context.restore();
  3370. }
  3371. };
  3372. /** @hidden */
  3373. Container.prototype._link = function (host) {
  3374. _super.prototype._link.call(this, host);
  3375. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3376. var child = _a[_i];
  3377. child._link(host);
  3378. }
  3379. };
  3380. /** @hidden */
  3381. Container.prototype._beforeLayout = function () {
  3382. // Do nothing
  3383. };
  3384. /** @hidden */
  3385. Container.prototype._processMeasures = function (parentMeasure, context) {
  3386. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3387. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3388. this._evaluateClippingState(parentMeasure);
  3389. }
  3390. };
  3391. /** @hidden */
  3392. Container.prototype._layout = function (parentMeasure, context) {
  3393. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3394. return false;
  3395. }
  3396. if (this._isDirty) {
  3397. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3398. }
  3399. var rebuildCount = 0;
  3400. context.save();
  3401. this._applyStates(context);
  3402. this._beforeLayout();
  3403. do {
  3404. var computedWidth = -1;
  3405. var computedHeight = -1;
  3406. this._rebuildLayout = false;
  3407. this._processMeasures(parentMeasure, context);
  3408. if (!this._isClipped) {
  3409. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3410. var child = _a[_i];
  3411. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3412. if (child._layout(this._measureForChildren, context)) {
  3413. if (this.adaptWidthToChildren && child._width.isPixel) {
  3414. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3415. }
  3416. if (this.adaptHeightToChildren && child._height.isPixel) {
  3417. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3418. }
  3419. }
  3420. }
  3421. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3422. if (this.width !== computedWidth + "px") {
  3423. this.width = computedWidth + "px";
  3424. this._rebuildLayout = true;
  3425. }
  3426. }
  3427. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3428. if (this.height !== computedHeight + "px") {
  3429. this.height = computedHeight + "px";
  3430. this._rebuildLayout = true;
  3431. }
  3432. }
  3433. this._postMeasure();
  3434. }
  3435. rebuildCount++;
  3436. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3437. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3438. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3439. }
  3440. context.restore();
  3441. if (this._isDirty) {
  3442. this.invalidateRect();
  3443. this._isDirty = false;
  3444. }
  3445. return true;
  3446. };
  3447. Container.prototype._postMeasure = function () {
  3448. // Do nothing by default
  3449. };
  3450. /** @hidden */
  3451. Container.prototype._draw = function (context, invalidatedRectangle) {
  3452. this._localDraw(context);
  3453. if (this.clipChildren) {
  3454. this._clipForChildren(context);
  3455. }
  3456. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3457. var child = _a[_i];
  3458. // Only redraw parts of the screen that are invalidated
  3459. if (invalidatedRectangle) {
  3460. if (!child._intersectsRect(invalidatedRectangle)) {
  3461. continue;
  3462. }
  3463. }
  3464. child._render(context, invalidatedRectangle);
  3465. }
  3466. };
  3467. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3468. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3469. if (!this.children) {
  3470. return;
  3471. }
  3472. for (var index = 0; index < this.children.length; index++) {
  3473. var item = this.children[index];
  3474. if (!predicate || predicate(item)) {
  3475. results.push(item);
  3476. }
  3477. if (!directDescendantsOnly) {
  3478. item.getDescendantsToRef(results, false, predicate);
  3479. }
  3480. }
  3481. };
  3482. /** @hidden */
  3483. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3484. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3485. return false;
  3486. }
  3487. if (!_super.prototype.contains.call(this, x, y)) {
  3488. return false;
  3489. }
  3490. // Checking backwards to pick closest first
  3491. for (var index = this._children.length - 1; index >= 0; index--) {
  3492. var child = this._children[index];
  3493. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3494. if (child.hoverCursor) {
  3495. this._host._changeCursor(child.hoverCursor);
  3496. }
  3497. return true;
  3498. }
  3499. }
  3500. if (!this.isHitTestVisible) {
  3501. return false;
  3502. }
  3503. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3504. };
  3505. /** @hidden */
  3506. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3507. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3508. this._measureForChildren.copyFrom(this._currentMeasure);
  3509. };
  3510. /** Releases associated resources */
  3511. Container.prototype.dispose = function () {
  3512. _super.prototype.dispose.call(this);
  3513. for (var index = this.children.length - 1; index >= 0; index--) {
  3514. this.children[index].dispose();
  3515. }
  3516. };
  3517. return Container;
  3518. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3519. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3520. /***/ }),
  3521. /***/ "./2D/controls/control.ts":
  3522. /*!********************************!*\
  3523. !*** ./2D/controls/control.ts ***!
  3524. \********************************/
  3525. /*! exports provided: Control */
  3526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3527. "use strict";
  3528. __webpack_require__.r(__webpack_exports__);
  3529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3530. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  3531. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3532. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3533. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3534. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3535. /**
  3536. * Root class used for all 2D controls
  3537. * @see http://doc.babylonjs.com/how_to/gui#controls
  3538. */
  3539. var Control = /** @class */ (function () {
  3540. // Functions
  3541. /**
  3542. * Creates a new control
  3543. * @param name defines the name of the control
  3544. */
  3545. function Control(
  3546. /** defines the name of the control */
  3547. name) {
  3548. this.name = name;
  3549. this._alpha = 1;
  3550. this._alphaSet = false;
  3551. this._zIndex = 0;
  3552. /** @hidden */
  3553. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3554. this._fontFamily = "Arial";
  3555. this._fontStyle = "";
  3556. this._fontWeight = "";
  3557. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3558. /** @hidden */
  3559. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3560. /** @hidden */
  3561. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3562. this._color = "";
  3563. this._style = null;
  3564. /** @hidden */
  3565. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3566. /** @hidden */
  3567. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3568. /** @hidden */
  3569. this._isDirty = true;
  3570. /** @hidden */
  3571. this._wasDirty = false;
  3572. /** @hidden */
  3573. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3574. /** @hidden */
  3575. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3576. /** @hidden */
  3577. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3578. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3579. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3580. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3581. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3582. /** @hidden */
  3583. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3584. /** @hidden */
  3585. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3586. this._scaleX = 1.0;
  3587. this._scaleY = 1.0;
  3588. this._rotation = 0;
  3589. this._transformCenterX = 0.5;
  3590. this._transformCenterY = 0.5;
  3591. /** @hidden */
  3592. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3593. /** @hidden */
  3594. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3595. /** @hidden */
  3596. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3597. this._isMatrixDirty = true;
  3598. this._isVisible = true;
  3599. this._isHighlighted = false;
  3600. this._fontSet = false;
  3601. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3602. this._downCount = 0;
  3603. this._enterCount = -1;
  3604. this._doNotRender = false;
  3605. this._downPointerIds = {};
  3606. this._isEnabled = true;
  3607. this._disabledColor = "#9a9a9a";
  3608. /** @hidden */
  3609. this._rebuildLayout = false;
  3610. /** @hidden */
  3611. this._isClipped = false;
  3612. /**
  3613. * Gets or sets an object used to store user defined information for the node
  3614. */
  3615. this.metadata = null;
  3616. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3617. this.isHitTestVisible = true;
  3618. /** Gets or sets a boolean indicating if the control can block pointer events */
  3619. this.isPointerBlocker = false;
  3620. /** Gets or sets a boolean indicating if the control can be focusable */
  3621. this.isFocusInvisible = false;
  3622. /**
  3623. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3624. * 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
  3625. */
  3626. this.clipChildren = true;
  3627. /**
  3628. * Gets or sets a boolean indicating that control content must be clipped
  3629. * 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
  3630. */
  3631. this.clipContent = true;
  3632. /**
  3633. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3634. */
  3635. this.useBitmapCache = false;
  3636. this._shadowOffsetX = 0;
  3637. this._shadowOffsetY = 0;
  3638. this._shadowBlur = 0;
  3639. this._shadowColor = 'black';
  3640. /** Gets or sets the cursor to use when the control is hovered */
  3641. this.hoverCursor = "";
  3642. /** @hidden */
  3643. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3644. /** @hidden */
  3645. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3646. /**
  3647. * An event triggered when the pointer move over the control.
  3648. */
  3649. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3650. /**
  3651. * An event triggered when the pointer move out of the control.
  3652. */
  3653. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3654. /**
  3655. * An event triggered when the pointer taps the control
  3656. */
  3657. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3658. /**
  3659. * An event triggered when pointer up
  3660. */
  3661. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3662. /**
  3663. * An event triggered when a control is clicked on
  3664. */
  3665. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3666. /**
  3667. * An event triggered when pointer enters the control
  3668. */
  3669. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3670. /**
  3671. * An event triggered when the control is marked as dirty
  3672. */
  3673. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3674. /**
  3675. * An event triggered before drawing the control
  3676. */
  3677. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3678. /**
  3679. * An event triggered after the control was drawn
  3680. */
  3681. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3682. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3683. }
  3684. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3685. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3686. get: function () {
  3687. return this._shadowOffsetX;
  3688. },
  3689. set: function (value) {
  3690. if (this._shadowOffsetX === value) {
  3691. return;
  3692. }
  3693. this._shadowOffsetX = value;
  3694. this._markAsDirty();
  3695. },
  3696. enumerable: true,
  3697. configurable: true
  3698. });
  3699. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3700. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3701. get: function () {
  3702. return this._shadowOffsetY;
  3703. },
  3704. set: function (value) {
  3705. if (this._shadowOffsetY === value) {
  3706. return;
  3707. }
  3708. this._shadowOffsetY = value;
  3709. this._markAsDirty();
  3710. },
  3711. enumerable: true,
  3712. configurable: true
  3713. });
  3714. Object.defineProperty(Control.prototype, "shadowBlur", {
  3715. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3716. get: function () {
  3717. return this._shadowBlur;
  3718. },
  3719. set: function (value) {
  3720. if (this._shadowBlur === value) {
  3721. return;
  3722. }
  3723. this._shadowBlur = value;
  3724. this._markAsDirty();
  3725. },
  3726. enumerable: true,
  3727. configurable: true
  3728. });
  3729. Object.defineProperty(Control.prototype, "shadowColor", {
  3730. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3731. get: function () {
  3732. return this._shadowColor;
  3733. },
  3734. set: function (value) {
  3735. if (this._shadowColor === value) {
  3736. return;
  3737. }
  3738. this._shadowColor = value;
  3739. this._markAsDirty();
  3740. },
  3741. enumerable: true,
  3742. configurable: true
  3743. });
  3744. Object.defineProperty(Control.prototype, "typeName", {
  3745. // Properties
  3746. /** Gets the control type name */
  3747. get: function () {
  3748. return this._getTypeName();
  3749. },
  3750. enumerable: true,
  3751. configurable: true
  3752. });
  3753. /**
  3754. * Get the current class name of the control.
  3755. * @returns current class name
  3756. */
  3757. Control.prototype.getClassName = function () {
  3758. return this._getTypeName();
  3759. };
  3760. Object.defineProperty(Control.prototype, "host", {
  3761. /**
  3762. * Get the hosting AdvancedDynamicTexture
  3763. */
  3764. get: function () {
  3765. return this._host;
  3766. },
  3767. enumerable: true,
  3768. configurable: true
  3769. });
  3770. Object.defineProperty(Control.prototype, "fontOffset", {
  3771. /** Gets or set information about font offsets (used to render and align text) */
  3772. get: function () {
  3773. return this._fontOffset;
  3774. },
  3775. set: function (offset) {
  3776. this._fontOffset = offset;
  3777. },
  3778. enumerable: true,
  3779. configurable: true
  3780. });
  3781. Object.defineProperty(Control.prototype, "alpha", {
  3782. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3783. get: function () {
  3784. return this._alpha;
  3785. },
  3786. set: function (value) {
  3787. if (this._alpha === value) {
  3788. return;
  3789. }
  3790. this._alphaSet = true;
  3791. this._alpha = value;
  3792. this._markAsDirty();
  3793. },
  3794. enumerable: true,
  3795. configurable: true
  3796. });
  3797. Object.defineProperty(Control.prototype, "isHighlighted", {
  3798. /**
  3799. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3800. */
  3801. get: function () {
  3802. return this._isHighlighted;
  3803. },
  3804. set: function (value) {
  3805. if (this._isHighlighted === value) {
  3806. return;
  3807. }
  3808. this._isHighlighted = value;
  3809. this._markAsDirty();
  3810. },
  3811. enumerable: true,
  3812. configurable: true
  3813. });
  3814. Object.defineProperty(Control.prototype, "scaleX", {
  3815. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3816. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3817. */
  3818. get: function () {
  3819. return this._scaleX;
  3820. },
  3821. set: function (value) {
  3822. if (this._scaleX === value) {
  3823. return;
  3824. }
  3825. this._scaleX = value;
  3826. this._markAsDirty();
  3827. this._markMatrixAsDirty();
  3828. },
  3829. enumerable: true,
  3830. configurable: true
  3831. });
  3832. Object.defineProperty(Control.prototype, "scaleY", {
  3833. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3834. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3835. */
  3836. get: function () {
  3837. return this._scaleY;
  3838. },
  3839. set: function (value) {
  3840. if (this._scaleY === value) {
  3841. return;
  3842. }
  3843. this._scaleY = value;
  3844. this._markAsDirty();
  3845. this._markMatrixAsDirty();
  3846. },
  3847. enumerable: true,
  3848. configurable: true
  3849. });
  3850. Object.defineProperty(Control.prototype, "rotation", {
  3851. /** Gets or sets the rotation angle (0 by default)
  3852. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3853. */
  3854. get: function () {
  3855. return this._rotation;
  3856. },
  3857. set: function (value) {
  3858. if (this._rotation === value) {
  3859. return;
  3860. }
  3861. this._rotation = value;
  3862. this._markAsDirty();
  3863. this._markMatrixAsDirty();
  3864. },
  3865. enumerable: true,
  3866. configurable: true
  3867. });
  3868. Object.defineProperty(Control.prototype, "transformCenterY", {
  3869. /** Gets or sets the transformation center on Y axis (0 by default)
  3870. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3871. */
  3872. get: function () {
  3873. return this._transformCenterY;
  3874. },
  3875. set: function (value) {
  3876. if (this._transformCenterY === value) {
  3877. return;
  3878. }
  3879. this._transformCenterY = value;
  3880. this._markAsDirty();
  3881. this._markMatrixAsDirty();
  3882. },
  3883. enumerable: true,
  3884. configurable: true
  3885. });
  3886. Object.defineProperty(Control.prototype, "transformCenterX", {
  3887. /** Gets or sets the transformation center on X axis (0 by default)
  3888. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3889. */
  3890. get: function () {
  3891. return this._transformCenterX;
  3892. },
  3893. set: function (value) {
  3894. if (this._transformCenterX === value) {
  3895. return;
  3896. }
  3897. this._transformCenterX = value;
  3898. this._markAsDirty();
  3899. this._markMatrixAsDirty();
  3900. },
  3901. enumerable: true,
  3902. configurable: true
  3903. });
  3904. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3905. /**
  3906. * Gets or sets the horizontal alignment
  3907. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3908. */
  3909. get: function () {
  3910. return this._horizontalAlignment;
  3911. },
  3912. set: function (value) {
  3913. if (this._horizontalAlignment === value) {
  3914. return;
  3915. }
  3916. this._horizontalAlignment = value;
  3917. this._markAsDirty();
  3918. },
  3919. enumerable: true,
  3920. configurable: true
  3921. });
  3922. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3923. /**
  3924. * Gets or sets the vertical alignment
  3925. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3926. */
  3927. get: function () {
  3928. return this._verticalAlignment;
  3929. },
  3930. set: function (value) {
  3931. if (this._verticalAlignment === value) {
  3932. return;
  3933. }
  3934. this._verticalAlignment = value;
  3935. this._markAsDirty();
  3936. },
  3937. enumerable: true,
  3938. configurable: true
  3939. });
  3940. Object.defineProperty(Control.prototype, "width", {
  3941. /**
  3942. * Gets or sets control width
  3943. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3944. */
  3945. get: function () {
  3946. return this._width.toString(this._host);
  3947. },
  3948. set: function (value) {
  3949. if (this._width.toString(this._host) === value) {
  3950. return;
  3951. }
  3952. if (this._width.fromString(value)) {
  3953. this._markAsDirty();
  3954. }
  3955. },
  3956. enumerable: true,
  3957. configurable: true
  3958. });
  3959. Object.defineProperty(Control.prototype, "widthInPixels", {
  3960. /**
  3961. * Gets or sets the control width in pixel
  3962. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3963. */
  3964. get: function () {
  3965. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3966. },
  3967. set: function (value) {
  3968. if (isNaN(value)) {
  3969. return;
  3970. }
  3971. this.width = value + "px";
  3972. },
  3973. enumerable: true,
  3974. configurable: true
  3975. });
  3976. Object.defineProperty(Control.prototype, "height", {
  3977. /**
  3978. * Gets or sets control height
  3979. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3980. */
  3981. get: function () {
  3982. return this._height.toString(this._host);
  3983. },
  3984. set: function (value) {
  3985. if (this._height.toString(this._host) === value) {
  3986. return;
  3987. }
  3988. if (this._height.fromString(value)) {
  3989. this._markAsDirty();
  3990. }
  3991. },
  3992. enumerable: true,
  3993. configurable: true
  3994. });
  3995. Object.defineProperty(Control.prototype, "heightInPixels", {
  3996. /**
  3997. * Gets or sets control height in pixel
  3998. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3999. */
  4000. get: function () {
  4001. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4002. },
  4003. set: function (value) {
  4004. if (isNaN(value)) {
  4005. return;
  4006. }
  4007. this.height = value + "px";
  4008. },
  4009. enumerable: true,
  4010. configurable: true
  4011. });
  4012. Object.defineProperty(Control.prototype, "fontFamily", {
  4013. /** Gets or set font family */
  4014. get: function () {
  4015. if (!this._fontSet) {
  4016. return "";
  4017. }
  4018. return this._fontFamily;
  4019. },
  4020. set: function (value) {
  4021. if (this._fontFamily === value) {
  4022. return;
  4023. }
  4024. this._fontFamily = value;
  4025. this._resetFontCache();
  4026. },
  4027. enumerable: true,
  4028. configurable: true
  4029. });
  4030. Object.defineProperty(Control.prototype, "fontStyle", {
  4031. /** Gets or sets font style */
  4032. get: function () {
  4033. return this._fontStyle;
  4034. },
  4035. set: function (value) {
  4036. if (this._fontStyle === value) {
  4037. return;
  4038. }
  4039. this._fontStyle = value;
  4040. this._resetFontCache();
  4041. },
  4042. enumerable: true,
  4043. configurable: true
  4044. });
  4045. Object.defineProperty(Control.prototype, "fontWeight", {
  4046. /** Gets or sets font weight */
  4047. get: function () {
  4048. return this._fontWeight;
  4049. },
  4050. set: function (value) {
  4051. if (this._fontWeight === value) {
  4052. return;
  4053. }
  4054. this._fontWeight = value;
  4055. this._resetFontCache();
  4056. },
  4057. enumerable: true,
  4058. configurable: true
  4059. });
  4060. Object.defineProperty(Control.prototype, "style", {
  4061. /**
  4062. * Gets or sets style
  4063. * @see http://doc.babylonjs.com/how_to/gui#styles
  4064. */
  4065. get: function () {
  4066. return this._style;
  4067. },
  4068. set: function (value) {
  4069. var _this = this;
  4070. if (this._style) {
  4071. this._style.onChangedObservable.remove(this._styleObserver);
  4072. this._styleObserver = null;
  4073. }
  4074. this._style = value;
  4075. if (this._style) {
  4076. this._styleObserver = this._style.onChangedObservable.add(function () {
  4077. _this._markAsDirty();
  4078. _this._resetFontCache();
  4079. });
  4080. }
  4081. this._markAsDirty();
  4082. this._resetFontCache();
  4083. },
  4084. enumerable: true,
  4085. configurable: true
  4086. });
  4087. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4088. /** @hidden */
  4089. get: function () {
  4090. return this._fontSize.isPercentage;
  4091. },
  4092. enumerable: true,
  4093. configurable: true
  4094. });
  4095. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4096. /** Gets or sets font size in pixels */
  4097. get: function () {
  4098. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4099. if (fontSizeToUse.isPixel) {
  4100. return fontSizeToUse.getValue(this._host);
  4101. }
  4102. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4103. },
  4104. set: function (value) {
  4105. if (isNaN(value)) {
  4106. return;
  4107. }
  4108. this.fontSize = value + "px";
  4109. },
  4110. enumerable: true,
  4111. configurable: true
  4112. });
  4113. Object.defineProperty(Control.prototype, "fontSize", {
  4114. /** Gets or sets font size */
  4115. get: function () {
  4116. return this._fontSize.toString(this._host);
  4117. },
  4118. set: function (value) {
  4119. if (this._fontSize.toString(this._host) === value) {
  4120. return;
  4121. }
  4122. if (this._fontSize.fromString(value)) {
  4123. this._markAsDirty();
  4124. this._resetFontCache();
  4125. }
  4126. },
  4127. enumerable: true,
  4128. configurable: true
  4129. });
  4130. Object.defineProperty(Control.prototype, "color", {
  4131. /** Gets or sets foreground color */
  4132. get: function () {
  4133. return this._color;
  4134. },
  4135. set: function (value) {
  4136. if (this._color === value) {
  4137. return;
  4138. }
  4139. this._color = value;
  4140. this._markAsDirty();
  4141. },
  4142. enumerable: true,
  4143. configurable: true
  4144. });
  4145. Object.defineProperty(Control.prototype, "zIndex", {
  4146. /** Gets or sets z index which is used to reorder controls on the z axis */
  4147. get: function () {
  4148. return this._zIndex;
  4149. },
  4150. set: function (value) {
  4151. if (this.zIndex === value) {
  4152. return;
  4153. }
  4154. this._zIndex = value;
  4155. if (this.parent) {
  4156. this.parent._reOrderControl(this);
  4157. }
  4158. },
  4159. enumerable: true,
  4160. configurable: true
  4161. });
  4162. Object.defineProperty(Control.prototype, "notRenderable", {
  4163. /** Gets or sets a boolean indicating if the control can be rendered */
  4164. get: function () {
  4165. return this._doNotRender;
  4166. },
  4167. set: function (value) {
  4168. if (this._doNotRender === value) {
  4169. return;
  4170. }
  4171. this._doNotRender = value;
  4172. this._markAsDirty();
  4173. },
  4174. enumerable: true,
  4175. configurable: true
  4176. });
  4177. Object.defineProperty(Control.prototype, "isVisible", {
  4178. /** Gets or sets a boolean indicating if the control is visible */
  4179. get: function () {
  4180. return this._isVisible;
  4181. },
  4182. set: function (value) {
  4183. if (this._isVisible === value) {
  4184. return;
  4185. }
  4186. this._isVisible = value;
  4187. this._markAsDirty(true);
  4188. },
  4189. enumerable: true,
  4190. configurable: true
  4191. });
  4192. Object.defineProperty(Control.prototype, "isDirty", {
  4193. /** Gets a boolean indicating that the control needs to update its rendering */
  4194. get: function () {
  4195. return this._isDirty;
  4196. },
  4197. enumerable: true,
  4198. configurable: true
  4199. });
  4200. Object.defineProperty(Control.prototype, "linkedMesh", {
  4201. /**
  4202. * Gets the current linked mesh (or null if none)
  4203. */
  4204. get: function () {
  4205. return this._linkedMesh;
  4206. },
  4207. enumerable: true,
  4208. configurable: true
  4209. });
  4210. Object.defineProperty(Control.prototype, "paddingLeft", {
  4211. /**
  4212. * Gets or sets a value indicating the padding to use on the left of the control
  4213. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4214. */
  4215. get: function () {
  4216. return this._paddingLeft.toString(this._host);
  4217. },
  4218. set: function (value) {
  4219. if (this._paddingLeft.fromString(value)) {
  4220. this._markAsDirty();
  4221. }
  4222. },
  4223. enumerable: true,
  4224. configurable: true
  4225. });
  4226. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4227. /**
  4228. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4229. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4230. */
  4231. get: function () {
  4232. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4233. },
  4234. set: function (value) {
  4235. if (isNaN(value)) {
  4236. return;
  4237. }
  4238. this.paddingLeft = value + "px";
  4239. },
  4240. enumerable: true,
  4241. configurable: true
  4242. });
  4243. Object.defineProperty(Control.prototype, "paddingRight", {
  4244. /**
  4245. * Gets or sets a value indicating the padding to use on the right of the control
  4246. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4247. */
  4248. get: function () {
  4249. return this._paddingRight.toString(this._host);
  4250. },
  4251. set: function (value) {
  4252. if (this._paddingRight.fromString(value)) {
  4253. this._markAsDirty();
  4254. }
  4255. },
  4256. enumerable: true,
  4257. configurable: true
  4258. });
  4259. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4260. /**
  4261. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4262. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4263. */
  4264. get: function () {
  4265. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4266. },
  4267. set: function (value) {
  4268. if (isNaN(value)) {
  4269. return;
  4270. }
  4271. this.paddingRight = value + "px";
  4272. },
  4273. enumerable: true,
  4274. configurable: true
  4275. });
  4276. Object.defineProperty(Control.prototype, "paddingTop", {
  4277. /**
  4278. * Gets or sets a value indicating the padding to use on the top of the control
  4279. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4280. */
  4281. get: function () {
  4282. return this._paddingTop.toString(this._host);
  4283. },
  4284. set: function (value) {
  4285. if (this._paddingTop.fromString(value)) {
  4286. this._markAsDirty();
  4287. }
  4288. },
  4289. enumerable: true,
  4290. configurable: true
  4291. });
  4292. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4293. /**
  4294. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4295. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4296. */
  4297. get: function () {
  4298. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4299. },
  4300. set: function (value) {
  4301. if (isNaN(value)) {
  4302. return;
  4303. }
  4304. this.paddingTop = value + "px";
  4305. },
  4306. enumerable: true,
  4307. configurable: true
  4308. });
  4309. Object.defineProperty(Control.prototype, "paddingBottom", {
  4310. /**
  4311. * Gets or sets a value indicating the padding to use on the bottom of the control
  4312. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4313. */
  4314. get: function () {
  4315. return this._paddingBottom.toString(this._host);
  4316. },
  4317. set: function (value) {
  4318. if (this._paddingBottom.fromString(value)) {
  4319. this._markAsDirty();
  4320. }
  4321. },
  4322. enumerable: true,
  4323. configurable: true
  4324. });
  4325. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4326. /**
  4327. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4328. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4329. */
  4330. get: function () {
  4331. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4332. },
  4333. set: function (value) {
  4334. if (isNaN(value)) {
  4335. return;
  4336. }
  4337. this.paddingBottom = value + "px";
  4338. },
  4339. enumerable: true,
  4340. configurable: true
  4341. });
  4342. Object.defineProperty(Control.prototype, "left", {
  4343. /**
  4344. * Gets or sets a value indicating the left coordinate of the control
  4345. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4346. */
  4347. get: function () {
  4348. return this._left.toString(this._host);
  4349. },
  4350. set: function (value) {
  4351. if (this._left.fromString(value)) {
  4352. this._markAsDirty();
  4353. }
  4354. },
  4355. enumerable: true,
  4356. configurable: true
  4357. });
  4358. Object.defineProperty(Control.prototype, "leftInPixels", {
  4359. /**
  4360. * Gets or sets a value indicating the left coordinate in pixels of the control
  4361. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4362. */
  4363. get: function () {
  4364. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4365. },
  4366. set: function (value) {
  4367. if (isNaN(value)) {
  4368. return;
  4369. }
  4370. this.left = value + "px";
  4371. },
  4372. enumerable: true,
  4373. configurable: true
  4374. });
  4375. Object.defineProperty(Control.prototype, "top", {
  4376. /**
  4377. * Gets or sets a value indicating the top coordinate of the control
  4378. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4379. */
  4380. get: function () {
  4381. return this._top.toString(this._host);
  4382. },
  4383. set: function (value) {
  4384. if (this._top.fromString(value)) {
  4385. this._markAsDirty();
  4386. }
  4387. },
  4388. enumerable: true,
  4389. configurable: true
  4390. });
  4391. Object.defineProperty(Control.prototype, "topInPixels", {
  4392. /**
  4393. * Gets or sets a value indicating the top coordinate in pixels of the control
  4394. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4395. */
  4396. get: function () {
  4397. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4398. },
  4399. set: function (value) {
  4400. if (isNaN(value)) {
  4401. return;
  4402. }
  4403. this.top = value + "px";
  4404. },
  4405. enumerable: true,
  4406. configurable: true
  4407. });
  4408. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4409. /**
  4410. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4411. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4412. */
  4413. get: function () {
  4414. return this._linkOffsetX.toString(this._host);
  4415. },
  4416. set: function (value) {
  4417. if (this._linkOffsetX.fromString(value)) {
  4418. this._markAsDirty();
  4419. }
  4420. },
  4421. enumerable: true,
  4422. configurable: true
  4423. });
  4424. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4425. /**
  4426. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4427. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4428. */
  4429. get: function () {
  4430. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4431. },
  4432. set: function (value) {
  4433. if (isNaN(value)) {
  4434. return;
  4435. }
  4436. this.linkOffsetX = value + "px";
  4437. },
  4438. enumerable: true,
  4439. configurable: true
  4440. });
  4441. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4442. /**
  4443. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4444. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4445. */
  4446. get: function () {
  4447. return this._linkOffsetY.toString(this._host);
  4448. },
  4449. set: function (value) {
  4450. if (this._linkOffsetY.fromString(value)) {
  4451. this._markAsDirty();
  4452. }
  4453. },
  4454. enumerable: true,
  4455. configurable: true
  4456. });
  4457. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4458. /**
  4459. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4460. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4461. */
  4462. get: function () {
  4463. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4464. },
  4465. set: function (value) {
  4466. if (isNaN(value)) {
  4467. return;
  4468. }
  4469. this.linkOffsetY = value + "px";
  4470. },
  4471. enumerable: true,
  4472. configurable: true
  4473. });
  4474. Object.defineProperty(Control.prototype, "centerX", {
  4475. /** Gets the center coordinate on X axis */
  4476. get: function () {
  4477. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4478. },
  4479. enumerable: true,
  4480. configurable: true
  4481. });
  4482. Object.defineProperty(Control.prototype, "centerY", {
  4483. /** Gets the center coordinate on Y axis */
  4484. get: function () {
  4485. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4486. },
  4487. enumerable: true,
  4488. configurable: true
  4489. });
  4490. Object.defineProperty(Control.prototype, "isEnabled", {
  4491. /** Gets or sets if control is Enabled*/
  4492. get: function () {
  4493. return this._isEnabled;
  4494. },
  4495. set: function (value) {
  4496. if (this._isEnabled === value) {
  4497. return;
  4498. }
  4499. this._isEnabled = value;
  4500. this._markAsDirty();
  4501. },
  4502. enumerable: true,
  4503. configurable: true
  4504. });
  4505. Object.defineProperty(Control.prototype, "disabledColor", {
  4506. /** Gets or sets background color of control if it's disabled*/
  4507. get: function () {
  4508. return this._disabledColor;
  4509. },
  4510. set: function (value) {
  4511. if (this._disabledColor === value) {
  4512. return;
  4513. }
  4514. this._disabledColor = value;
  4515. this._markAsDirty();
  4516. },
  4517. enumerable: true,
  4518. configurable: true
  4519. });
  4520. /** @hidden */
  4521. Control.prototype._getTypeName = function () {
  4522. return "Control";
  4523. };
  4524. /**
  4525. * Gets the first ascendant in the hierarchy of the given type
  4526. * @param className defines the required type
  4527. * @returns the ascendant or null if not found
  4528. */
  4529. Control.prototype.getAscendantOfClass = function (className) {
  4530. if (!this.parent) {
  4531. return null;
  4532. }
  4533. if (this.parent.getClassName() === className) {
  4534. return this.parent;
  4535. }
  4536. return this.parent.getAscendantOfClass(className);
  4537. };
  4538. /** @hidden */
  4539. Control.prototype._resetFontCache = function () {
  4540. this._fontSet = true;
  4541. this._markAsDirty();
  4542. };
  4543. /**
  4544. * Determines if a container is an ascendant of the current control
  4545. * @param container defines the container to look for
  4546. * @returns true if the container is one of the ascendant of the control
  4547. */
  4548. Control.prototype.isAscendant = function (container) {
  4549. if (!this.parent) {
  4550. return false;
  4551. }
  4552. if (this.parent === container) {
  4553. return true;
  4554. }
  4555. return this.parent.isAscendant(container);
  4556. };
  4557. /**
  4558. * Gets coordinates in local control space
  4559. * @param globalCoordinates defines the coordinates to transform
  4560. * @returns the new coordinates in local space
  4561. */
  4562. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4563. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4564. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4565. return result;
  4566. };
  4567. /**
  4568. * Gets coordinates in local control space
  4569. * @param globalCoordinates defines the coordinates to transform
  4570. * @param result defines the target vector2 where to store the result
  4571. * @returns the current control
  4572. */
  4573. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4574. result.x = globalCoordinates.x - this._currentMeasure.left;
  4575. result.y = globalCoordinates.y - this._currentMeasure.top;
  4576. return this;
  4577. };
  4578. /**
  4579. * Gets coordinates in parent local control space
  4580. * @param globalCoordinates defines the coordinates to transform
  4581. * @returns the new coordinates in parent local space
  4582. */
  4583. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4584. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4585. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4586. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4587. return result;
  4588. };
  4589. /**
  4590. * Move the current control to a vector3 position projected onto the screen.
  4591. * @param position defines the target position
  4592. * @param scene defines the hosting scene
  4593. */
  4594. Control.prototype.moveToVector3 = function (position, scene) {
  4595. if (!this._host || this.parent !== this._host._rootContainer) {
  4596. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4597. return;
  4598. }
  4599. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4600. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4601. var globalViewport = this._host._getGlobalViewport(scene);
  4602. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4603. this._moveToProjectedPosition(projectedPosition);
  4604. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4605. this.notRenderable = true;
  4606. return;
  4607. }
  4608. this.notRenderable = false;
  4609. };
  4610. /**
  4611. * Will store all controls that have this control as ascendant in a given array
  4612. * @param results defines the array where to store the descendants
  4613. * @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
  4614. * @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
  4615. */
  4616. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4617. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4618. // Do nothing by default
  4619. };
  4620. /**
  4621. * Will return all controls that have this control as ascendant
  4622. * @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
  4623. * @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
  4624. * @return all child controls
  4625. */
  4626. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4627. var results = new Array();
  4628. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4629. return results;
  4630. };
  4631. /**
  4632. * Link current control with a target mesh
  4633. * @param mesh defines the mesh to link with
  4634. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4635. */
  4636. Control.prototype.linkWithMesh = function (mesh) {
  4637. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4638. if (mesh) {
  4639. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4640. }
  4641. return;
  4642. }
  4643. var index = this._host._linkedControls.indexOf(this);
  4644. if (index !== -1) {
  4645. this._linkedMesh = mesh;
  4646. if (!mesh) {
  4647. this._host._linkedControls.splice(index, 1);
  4648. }
  4649. return;
  4650. }
  4651. else if (!mesh) {
  4652. return;
  4653. }
  4654. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4655. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4656. this._linkedMesh = mesh;
  4657. this._host._linkedControls.push(this);
  4658. };
  4659. /** @hidden */
  4660. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4661. var oldLeft = this._left.getValue(this._host);
  4662. var oldTop = this._top.getValue(this._host);
  4663. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4664. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4665. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4666. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4667. newLeft = oldLeft;
  4668. }
  4669. if (Math.abs(newTop - oldTop) < 0.5) {
  4670. newTop = oldTop;
  4671. }
  4672. }
  4673. this.left = newLeft + "px";
  4674. this.top = newTop + "px";
  4675. this._left.ignoreAdaptiveScaling = true;
  4676. this._top.ignoreAdaptiveScaling = true;
  4677. this._markAsDirty();
  4678. };
  4679. /** @hidden */
  4680. Control.prototype._offsetLeft = function (offset) {
  4681. this._isDirty = true;
  4682. this._currentMeasure.left += offset;
  4683. };
  4684. /** @hidden */
  4685. Control.prototype._offsetTop = function (offset) {
  4686. this._isDirty = true;
  4687. this._currentMeasure.top += offset;
  4688. };
  4689. /** @hidden */
  4690. Control.prototype._markMatrixAsDirty = function () {
  4691. this._isMatrixDirty = true;
  4692. this._flagDescendantsAsMatrixDirty();
  4693. };
  4694. /** @hidden */
  4695. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4696. // No child
  4697. };
  4698. /** @hidden */
  4699. Control.prototype._intersectsRect = function (rect) {
  4700. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4701. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4702. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4703. return false;
  4704. }
  4705. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4706. return false;
  4707. }
  4708. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4709. return false;
  4710. }
  4711. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4712. return false;
  4713. }
  4714. return true;
  4715. };
  4716. /** @hidden */
  4717. Control.prototype.invalidateRect = function () {
  4718. this._transform();
  4719. if (this.host && this.host.useInvalidateRectOptimization) {
  4720. // Rotate by transform to get the measure transformed to global space
  4721. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4722. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4723. // the previous measure is used to properly clear a control that is scaled down
  4724. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4725. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4726. // Expand rect based on shadows
  4727. var shadowOffsetX = this.shadowOffsetX;
  4728. var shadowOffsetY = this.shadowOffsetY;
  4729. var shadowBlur = this.shadowBlur;
  4730. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4731. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4732. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4733. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4734. 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));
  4735. }
  4736. else {
  4737. 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));
  4738. }
  4739. }
  4740. };
  4741. /** @hidden */
  4742. Control.prototype._markAsDirty = function (force) {
  4743. if (force === void 0) { force = false; }
  4744. if (!this._isVisible && !force) {
  4745. return;
  4746. }
  4747. this._isDirty = true;
  4748. // Redraw only this rectangle
  4749. if (this._host) {
  4750. this._host.markAsDirty();
  4751. }
  4752. };
  4753. /** @hidden */
  4754. Control.prototype._markAllAsDirty = function () {
  4755. this._markAsDirty();
  4756. if (this._font) {
  4757. this._prepareFont();
  4758. }
  4759. };
  4760. /** @hidden */
  4761. Control.prototype._link = function (host) {
  4762. this._host = host;
  4763. if (this._host) {
  4764. this.uniqueId = this._host.getScene().getUniqueId();
  4765. }
  4766. };
  4767. /** @hidden */
  4768. Control.prototype._transform = function (context) {
  4769. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4770. return;
  4771. }
  4772. // postTranslate
  4773. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4774. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4775. if (context) {
  4776. context.translate(offsetX, offsetY);
  4777. // rotate
  4778. context.rotate(this._rotation);
  4779. // scale
  4780. context.scale(this._scaleX, this._scaleY);
  4781. // preTranslate
  4782. context.translate(-offsetX, -offsetY);
  4783. }
  4784. // Need to update matrices?
  4785. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4786. this._cachedOffsetX = offsetX;
  4787. this._cachedOffsetY = offsetY;
  4788. this._isMatrixDirty = false;
  4789. this._flagDescendantsAsMatrixDirty();
  4790. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4791. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4792. }
  4793. };
  4794. /** @hidden */
  4795. Control.prototype._renderHighlight = function (context) {
  4796. if (!this.isHighlighted) {
  4797. return;
  4798. }
  4799. context.save();
  4800. context.strokeStyle = "#4affff";
  4801. context.lineWidth = 2;
  4802. this._renderHighlightSpecific(context);
  4803. context.restore();
  4804. };
  4805. /** @hidden */
  4806. Control.prototype._renderHighlightSpecific = function (context) {
  4807. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4808. };
  4809. /** @hidden */
  4810. Control.prototype._applyStates = function (context) {
  4811. if (this._isFontSizeInPercentage) {
  4812. this._fontSet = true;
  4813. }
  4814. if (this._fontSet) {
  4815. this._prepareFont();
  4816. this._fontSet = false;
  4817. }
  4818. if (this._font) {
  4819. context.font = this._font;
  4820. }
  4821. if (this._color) {
  4822. context.fillStyle = this._color;
  4823. }
  4824. if (Control.AllowAlphaInheritance) {
  4825. context.globalAlpha *= this._alpha;
  4826. }
  4827. else if (this._alphaSet) {
  4828. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4829. }
  4830. };
  4831. /** @hidden */
  4832. Control.prototype._layout = function (parentMeasure, context) {
  4833. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4834. return false;
  4835. }
  4836. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4837. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4838. context.save();
  4839. this._applyStates(context);
  4840. var rebuildCount = 0;
  4841. do {
  4842. this._rebuildLayout = false;
  4843. this._processMeasures(parentMeasure, context);
  4844. rebuildCount++;
  4845. } while (this._rebuildLayout && rebuildCount < 3);
  4846. if (rebuildCount >= 3) {
  4847. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4848. }
  4849. context.restore();
  4850. this.invalidateRect();
  4851. this._evaluateClippingState(parentMeasure);
  4852. }
  4853. this._wasDirty = this._isDirty;
  4854. this._isDirty = false;
  4855. return true;
  4856. };
  4857. /** @hidden */
  4858. Control.prototype._processMeasures = function (parentMeasure, context) {
  4859. this._currentMeasure.copyFrom(parentMeasure);
  4860. // Let children take some pre-measurement actions
  4861. this._preMeasure(parentMeasure, context);
  4862. this._measure();
  4863. this._computeAlignment(parentMeasure, context);
  4864. // Convert to int values
  4865. this._currentMeasure.left = this._currentMeasure.left | 0;
  4866. this._currentMeasure.top = this._currentMeasure.top | 0;
  4867. this._currentMeasure.width = this._currentMeasure.width | 0;
  4868. this._currentMeasure.height = this._currentMeasure.height | 0;
  4869. // Let children add more features
  4870. this._additionalProcessing(parentMeasure, context);
  4871. this._cachedParentMeasure.copyFrom(parentMeasure);
  4872. if (this.onDirtyObservable.hasObservers()) {
  4873. this.onDirtyObservable.notifyObservers(this);
  4874. }
  4875. };
  4876. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4877. if (this.parent && this.parent.clipChildren) {
  4878. // Early clip
  4879. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4880. this._isClipped = true;
  4881. return;
  4882. }
  4883. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4884. this._isClipped = true;
  4885. return;
  4886. }
  4887. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4888. this._isClipped = true;
  4889. return;
  4890. }
  4891. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4892. this._isClipped = true;
  4893. return;
  4894. }
  4895. }
  4896. this._isClipped = false;
  4897. };
  4898. /** @hidden */
  4899. Control.prototype._measure = function () {
  4900. // Width / Height
  4901. if (this._width.isPixel) {
  4902. this._currentMeasure.width = this._width.getValue(this._host);
  4903. }
  4904. else {
  4905. this._currentMeasure.width *= this._width.getValue(this._host);
  4906. }
  4907. if (this._height.isPixel) {
  4908. this._currentMeasure.height = this._height.getValue(this._host);
  4909. }
  4910. else {
  4911. this._currentMeasure.height *= this._height.getValue(this._host);
  4912. }
  4913. };
  4914. /** @hidden */
  4915. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4916. var width = this._currentMeasure.width;
  4917. var height = this._currentMeasure.height;
  4918. var parentWidth = parentMeasure.width;
  4919. var parentHeight = parentMeasure.height;
  4920. // Left / top
  4921. var x = 0;
  4922. var y = 0;
  4923. switch (this.horizontalAlignment) {
  4924. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4925. x = 0;
  4926. break;
  4927. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4928. x = parentWidth - width;
  4929. break;
  4930. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4931. x = (parentWidth - width) / 2;
  4932. break;
  4933. }
  4934. switch (this.verticalAlignment) {
  4935. case Control.VERTICAL_ALIGNMENT_TOP:
  4936. y = 0;
  4937. break;
  4938. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4939. y = parentHeight - height;
  4940. break;
  4941. case Control.VERTICAL_ALIGNMENT_CENTER:
  4942. y = (parentHeight - height) / 2;
  4943. break;
  4944. }
  4945. if (this._paddingLeft.isPixel) {
  4946. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4947. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4948. }
  4949. else {
  4950. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4951. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4952. }
  4953. if (this._paddingRight.isPixel) {
  4954. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4955. }
  4956. else {
  4957. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4958. }
  4959. if (this._paddingTop.isPixel) {
  4960. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4961. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4962. }
  4963. else {
  4964. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4965. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4966. }
  4967. if (this._paddingBottom.isPixel) {
  4968. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4969. }
  4970. else {
  4971. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4972. }
  4973. if (this._left.isPixel) {
  4974. this._currentMeasure.left += this._left.getValue(this._host);
  4975. }
  4976. else {
  4977. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4978. }
  4979. if (this._top.isPixel) {
  4980. this._currentMeasure.top += this._top.getValue(this._host);
  4981. }
  4982. else {
  4983. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4984. }
  4985. this._currentMeasure.left += x;
  4986. this._currentMeasure.top += y;
  4987. };
  4988. /** @hidden */
  4989. Control.prototype._preMeasure = function (parentMeasure, context) {
  4990. // Do nothing
  4991. };
  4992. /** @hidden */
  4993. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4994. // Do nothing
  4995. };
  4996. /** @hidden */
  4997. Control.prototype._clipForChildren = function (context) {
  4998. // DO nothing
  4999. };
  5000. Control.prototype._clip = function (context, invalidatedRectangle) {
  5001. context.beginPath();
  5002. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5003. if (invalidatedRectangle) {
  5004. // Rotate the invalidated rect into the control's space
  5005. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5006. // Get the intersection of the rect in context space and the current context
  5007. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5008. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5009. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5010. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5011. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5012. Control._ClipMeasure.copyFrom(intersection);
  5013. }
  5014. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5015. var shadowOffsetX = this.shadowOffsetX;
  5016. var shadowOffsetY = this.shadowOffsetY;
  5017. var shadowBlur = this.shadowBlur;
  5018. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5019. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5020. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5021. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5022. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5023. }
  5024. else {
  5025. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5026. }
  5027. context.clip();
  5028. };
  5029. /** @hidden */
  5030. Control.prototype._render = function (context, invalidatedRectangle) {
  5031. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5032. this._isDirty = false;
  5033. return false;
  5034. }
  5035. context.save();
  5036. this._applyStates(context);
  5037. // Transform
  5038. this._transform(context);
  5039. // Clip
  5040. if (this.clipContent) {
  5041. this._clip(context, invalidatedRectangle);
  5042. }
  5043. if (this.onBeforeDrawObservable.hasObservers()) {
  5044. this.onBeforeDrawObservable.notifyObservers(this);
  5045. }
  5046. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5047. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5048. }
  5049. else {
  5050. this._draw(context, invalidatedRectangle);
  5051. }
  5052. if (this.useBitmapCache && this._wasDirty) {
  5053. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5054. }
  5055. this._renderHighlight(context);
  5056. if (this.onAfterDrawObservable.hasObservers()) {
  5057. this.onAfterDrawObservable.notifyObservers(this);
  5058. }
  5059. context.restore();
  5060. return true;
  5061. };
  5062. /** @hidden */
  5063. Control.prototype._draw = function (context, invalidatedRectangle) {
  5064. // Do nothing
  5065. };
  5066. /**
  5067. * Tests if a given coordinates belong to the current control
  5068. * @param x defines x coordinate to test
  5069. * @param y defines y coordinate to test
  5070. * @returns true if the coordinates are inside the control
  5071. */
  5072. Control.prototype.contains = function (x, y) {
  5073. // Invert transform
  5074. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5075. x = this._transformedPosition.x;
  5076. y = this._transformedPosition.y;
  5077. // Check
  5078. if (x < this._currentMeasure.left) {
  5079. return false;
  5080. }
  5081. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5082. return false;
  5083. }
  5084. if (y < this._currentMeasure.top) {
  5085. return false;
  5086. }
  5087. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5088. return false;
  5089. }
  5090. if (this.isPointerBlocker) {
  5091. this._host._shouldBlockPointer = true;
  5092. }
  5093. return true;
  5094. };
  5095. /** @hidden */
  5096. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5097. if (!this._isEnabled) {
  5098. return false;
  5099. }
  5100. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5101. return false;
  5102. }
  5103. if (!this.contains(x, y)) {
  5104. return false;
  5105. }
  5106. this._processObservables(type, x, y, pointerId, buttonIndex);
  5107. return true;
  5108. };
  5109. /** @hidden */
  5110. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5111. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5112. if (canNotify && this.parent != null) {
  5113. this.parent._onPointerMove(target, coordinates, pointerId);
  5114. }
  5115. };
  5116. /** @hidden */
  5117. Control.prototype._onPointerEnter = function (target) {
  5118. if (!this._isEnabled) {
  5119. return false;
  5120. }
  5121. if (this._enterCount > 0) {
  5122. return false;
  5123. }
  5124. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5125. this._enterCount = 0;
  5126. }
  5127. this._enterCount++;
  5128. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5129. if (canNotify && this.parent != null) {
  5130. this.parent._onPointerEnter(target);
  5131. }
  5132. return true;
  5133. };
  5134. /** @hidden */
  5135. Control.prototype._onPointerOut = function (target, force) {
  5136. if (force === void 0) { force = false; }
  5137. if (!force && (!this._isEnabled || target === this)) {
  5138. return;
  5139. }
  5140. this._enterCount = 0;
  5141. var canNotify = true;
  5142. if (!target.isAscendant(this)) {
  5143. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5144. }
  5145. if (canNotify && this.parent != null) {
  5146. this.parent._onPointerOut(target, force);
  5147. }
  5148. };
  5149. /** @hidden */
  5150. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5151. // Prevent pointerout to lose control context.
  5152. // Event redundancy is checked inside the function.
  5153. this._onPointerEnter(this);
  5154. if (this._downCount !== 0) {
  5155. return false;
  5156. }
  5157. this._downCount++;
  5158. this._downPointerIds[pointerId] = true;
  5159. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5160. if (canNotify && this.parent != null) {
  5161. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5162. }
  5163. return true;
  5164. };
  5165. /** @hidden */
  5166. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5167. if (!this._isEnabled) {
  5168. return;
  5169. }
  5170. this._downCount = 0;
  5171. delete this._downPointerIds[pointerId];
  5172. var canNotifyClick = notifyClick;
  5173. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5174. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5175. }
  5176. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5177. if (canNotify && this.parent != null) {
  5178. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5179. }
  5180. };
  5181. /** @hidden */
  5182. Control.prototype._forcePointerUp = function (pointerId) {
  5183. if (pointerId === void 0) { pointerId = null; }
  5184. if (pointerId !== null) {
  5185. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5186. }
  5187. else {
  5188. for (var key in this._downPointerIds) {
  5189. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5190. }
  5191. }
  5192. };
  5193. /** @hidden */
  5194. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5195. if (!this._isEnabled) {
  5196. return false;
  5197. }
  5198. this._dummyVector2.copyFromFloats(x, y);
  5199. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5200. this._onPointerMove(this, this._dummyVector2, pointerId);
  5201. var previousControlOver = this._host._lastControlOver[pointerId];
  5202. if (previousControlOver && previousControlOver !== this) {
  5203. previousControlOver._onPointerOut(this);
  5204. }
  5205. if (previousControlOver !== this) {
  5206. this._onPointerEnter(this);
  5207. }
  5208. this._host._lastControlOver[pointerId] = this;
  5209. return true;
  5210. }
  5211. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5212. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5213. this._host._registerLastControlDown(this, pointerId);
  5214. this._host._lastPickedControl = this;
  5215. return true;
  5216. }
  5217. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5218. if (this._host._lastControlDown[pointerId]) {
  5219. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5220. }
  5221. delete this._host._lastControlDown[pointerId];
  5222. return true;
  5223. }
  5224. return false;
  5225. };
  5226. Control.prototype._prepareFont = function () {
  5227. if (!this._font && !this._fontSet) {
  5228. return;
  5229. }
  5230. if (this._style) {
  5231. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5232. }
  5233. else {
  5234. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5235. }
  5236. this._fontOffset = Control._GetFontOffset(this._font);
  5237. };
  5238. /** Releases associated resources */
  5239. Control.prototype.dispose = function () {
  5240. this.onDirtyObservable.clear();
  5241. this.onBeforeDrawObservable.clear();
  5242. this.onAfterDrawObservable.clear();
  5243. this.onPointerDownObservable.clear();
  5244. this.onPointerEnterObservable.clear();
  5245. this.onPointerMoveObservable.clear();
  5246. this.onPointerOutObservable.clear();
  5247. this.onPointerUpObservable.clear();
  5248. this.onPointerClickObservable.clear();
  5249. if (this._styleObserver && this._style) {
  5250. this._style.onChangedObservable.remove(this._styleObserver);
  5251. this._styleObserver = null;
  5252. }
  5253. if (this.parent) {
  5254. this.parent.removeControl(this);
  5255. this.parent = null;
  5256. }
  5257. if (this._host) {
  5258. var index = this._host._linkedControls.indexOf(this);
  5259. if (index > -1) {
  5260. this.linkWithMesh(null);
  5261. }
  5262. }
  5263. };
  5264. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5265. /** HORIZONTAL_ALIGNMENT_LEFT */
  5266. get: function () {
  5267. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5268. },
  5269. enumerable: true,
  5270. configurable: true
  5271. });
  5272. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5273. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5274. get: function () {
  5275. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5276. },
  5277. enumerable: true,
  5278. configurable: true
  5279. });
  5280. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5281. /** HORIZONTAL_ALIGNMENT_CENTER */
  5282. get: function () {
  5283. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5284. },
  5285. enumerable: true,
  5286. configurable: true
  5287. });
  5288. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5289. /** VERTICAL_ALIGNMENT_TOP */
  5290. get: function () {
  5291. return Control._VERTICAL_ALIGNMENT_TOP;
  5292. },
  5293. enumerable: true,
  5294. configurable: true
  5295. });
  5296. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5297. /** VERTICAL_ALIGNMENT_BOTTOM */
  5298. get: function () {
  5299. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5300. },
  5301. enumerable: true,
  5302. configurable: true
  5303. });
  5304. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5305. /** VERTICAL_ALIGNMENT_CENTER */
  5306. get: function () {
  5307. return Control._VERTICAL_ALIGNMENT_CENTER;
  5308. },
  5309. enumerable: true,
  5310. configurable: true
  5311. });
  5312. /** @hidden */
  5313. Control._GetFontOffset = function (font) {
  5314. if (Control._FontHeightSizes[font]) {
  5315. return Control._FontHeightSizes[font];
  5316. }
  5317. var text = document.createElement("span");
  5318. text.innerHTML = "Hg";
  5319. text.style.font = font;
  5320. var block = document.createElement("div");
  5321. block.style.display = "inline-block";
  5322. block.style.width = "1px";
  5323. block.style.height = "0px";
  5324. block.style.verticalAlign = "bottom";
  5325. var div = document.createElement("div");
  5326. div.appendChild(text);
  5327. div.appendChild(block);
  5328. document.body.appendChild(div);
  5329. var fontAscent = 0;
  5330. var fontHeight = 0;
  5331. try {
  5332. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5333. block.style.verticalAlign = "baseline";
  5334. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5335. }
  5336. finally {
  5337. document.body.removeChild(div);
  5338. }
  5339. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5340. Control._FontHeightSizes[font] = result;
  5341. return result;
  5342. };
  5343. /** @hidden */
  5344. Control.drawEllipse = function (x, y, width, height, context) {
  5345. context.translate(x, y);
  5346. context.scale(width, height);
  5347. context.beginPath();
  5348. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5349. context.closePath();
  5350. context.scale(1 / width, 1 / height);
  5351. context.translate(-x, -y);
  5352. };
  5353. /**
  5354. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5355. */
  5356. Control.AllowAlphaInheritance = false;
  5357. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5358. // Statics
  5359. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5360. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5361. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5362. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5363. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5364. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5365. Control._FontHeightSizes = {};
  5366. /**
  5367. * Creates a stack panel that can be used to render headers
  5368. * @param control defines the control to associate with the header
  5369. * @param text defines the text of the header
  5370. * @param size defines the size of the header
  5371. * @param options defines options used to configure the header
  5372. * @returns a new StackPanel
  5373. * @ignore
  5374. * @hidden
  5375. */
  5376. Control.AddHeader = function () { };
  5377. return Control;
  5378. }());
  5379. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5380. /***/ }),
  5381. /***/ "./2D/controls/displayGrid.ts":
  5382. /*!************************************!*\
  5383. !*** ./2D/controls/displayGrid.ts ***!
  5384. \************************************/
  5385. /*! exports provided: DisplayGrid */
  5386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5387. "use strict";
  5388. __webpack_require__.r(__webpack_exports__);
  5389. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5390. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5391. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5392. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5393. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5394. /** Class used to render a grid */
  5395. var DisplayGrid = /** @class */ (function (_super) {
  5396. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5397. /**
  5398. * Creates a new GridDisplayRectangle
  5399. * @param name defines the control name
  5400. */
  5401. function DisplayGrid(name) {
  5402. var _this = _super.call(this, name) || this;
  5403. _this.name = name;
  5404. _this._cellWidth = 20;
  5405. _this._cellHeight = 20;
  5406. _this._minorLineTickness = 1;
  5407. _this._minorLineColor = "DarkGray";
  5408. _this._majorLineTickness = 2;
  5409. _this._majorLineColor = "White";
  5410. _this._majorLineFrequency = 5;
  5411. _this._background = "Black";
  5412. _this._displayMajorLines = true;
  5413. _this._displayMinorLines = true;
  5414. return _this;
  5415. }
  5416. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5417. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5418. get: function () {
  5419. return this._displayMinorLines;
  5420. },
  5421. set: function (value) {
  5422. if (this._displayMinorLines === value) {
  5423. return;
  5424. }
  5425. this._displayMinorLines = value;
  5426. this._markAsDirty();
  5427. },
  5428. enumerable: true,
  5429. configurable: true
  5430. });
  5431. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5432. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5433. get: function () {
  5434. return this._displayMajorLines;
  5435. },
  5436. set: function (value) {
  5437. if (this._displayMajorLines === value) {
  5438. return;
  5439. }
  5440. this._displayMajorLines = value;
  5441. this._markAsDirty();
  5442. },
  5443. enumerable: true,
  5444. configurable: true
  5445. });
  5446. Object.defineProperty(DisplayGrid.prototype, "background", {
  5447. /** Gets or sets background color (Black by default) */
  5448. get: function () {
  5449. return this._background;
  5450. },
  5451. set: function (value) {
  5452. if (this._background === value) {
  5453. return;
  5454. }
  5455. this._background = value;
  5456. this._markAsDirty();
  5457. },
  5458. enumerable: true,
  5459. configurable: true
  5460. });
  5461. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5462. /** Gets or sets the width of each cell (20 by default) */
  5463. get: function () {
  5464. return this._cellWidth;
  5465. },
  5466. set: function (value) {
  5467. this._cellWidth = value;
  5468. this._markAsDirty();
  5469. },
  5470. enumerable: true,
  5471. configurable: true
  5472. });
  5473. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5474. /** Gets or sets the height of each cell (20 by default) */
  5475. get: function () {
  5476. return this._cellHeight;
  5477. },
  5478. set: function (value) {
  5479. this._cellHeight = value;
  5480. this._markAsDirty();
  5481. },
  5482. enumerable: true,
  5483. configurable: true
  5484. });
  5485. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5486. /** Gets or sets the tickness of minor lines (1 by default) */
  5487. get: function () {
  5488. return this._minorLineTickness;
  5489. },
  5490. set: function (value) {
  5491. this._minorLineTickness = value;
  5492. this._markAsDirty();
  5493. },
  5494. enumerable: true,
  5495. configurable: true
  5496. });
  5497. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5498. /** Gets or sets the color of minor lines (DarkGray by default) */
  5499. get: function () {
  5500. return this._minorLineColor;
  5501. },
  5502. set: function (value) {
  5503. this._minorLineColor = value;
  5504. this._markAsDirty();
  5505. },
  5506. enumerable: true,
  5507. configurable: true
  5508. });
  5509. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5510. /** Gets or sets the tickness of major lines (2 by default) */
  5511. get: function () {
  5512. return this._majorLineTickness;
  5513. },
  5514. set: function (value) {
  5515. this._majorLineTickness = value;
  5516. this._markAsDirty();
  5517. },
  5518. enumerable: true,
  5519. configurable: true
  5520. });
  5521. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5522. /** Gets or sets the color of major lines (White by default) */
  5523. get: function () {
  5524. return this._majorLineColor;
  5525. },
  5526. set: function (value) {
  5527. this._majorLineColor = value;
  5528. this._markAsDirty();
  5529. },
  5530. enumerable: true,
  5531. configurable: true
  5532. });
  5533. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5534. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5535. get: function () {
  5536. return this._majorLineFrequency;
  5537. },
  5538. set: function (value) {
  5539. this._majorLineFrequency = value;
  5540. this._markAsDirty();
  5541. },
  5542. enumerable: true,
  5543. configurable: true
  5544. });
  5545. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5546. context.save();
  5547. this._applyStates(context);
  5548. if (this._isEnabled) {
  5549. if (this._background) {
  5550. context.fillStyle = this._background;
  5551. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5552. }
  5553. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5554. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5555. // Minor lines
  5556. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5557. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5558. if (this._displayMinorLines) {
  5559. context.strokeStyle = this._minorLineColor;
  5560. context.lineWidth = this._minorLineTickness;
  5561. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5562. var cellX = left + x * this.cellWidth;
  5563. context.beginPath();
  5564. context.moveTo(cellX, this._currentMeasure.top);
  5565. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5566. context.stroke();
  5567. }
  5568. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5569. var cellY = top_1 + y * this.cellHeight;
  5570. context.beginPath();
  5571. context.moveTo(this._currentMeasure.left, cellY);
  5572. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5573. context.stroke();
  5574. }
  5575. }
  5576. // Major lines
  5577. if (this._displayMajorLines) {
  5578. context.strokeStyle = this._majorLineColor;
  5579. context.lineWidth = this._majorLineTickness;
  5580. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5581. var cellX = left + x * this.cellWidth;
  5582. context.beginPath();
  5583. context.moveTo(cellX, this._currentMeasure.top);
  5584. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5585. context.stroke();
  5586. }
  5587. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5588. var cellY = top_1 + y * this.cellHeight;
  5589. context.moveTo(this._currentMeasure.left, cellY);
  5590. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5591. context.closePath();
  5592. context.stroke();
  5593. }
  5594. }
  5595. }
  5596. context.restore();
  5597. };
  5598. DisplayGrid.prototype._getTypeName = function () {
  5599. return "DisplayGrid";
  5600. };
  5601. return DisplayGrid;
  5602. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5603. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5604. /***/ }),
  5605. /***/ "./2D/controls/ellipse.ts":
  5606. /*!********************************!*\
  5607. !*** ./2D/controls/ellipse.ts ***!
  5608. \********************************/
  5609. /*! exports provided: Ellipse */
  5610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5611. "use strict";
  5612. __webpack_require__.r(__webpack_exports__);
  5613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5614. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5615. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5616. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5617. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5618. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5619. /** Class used to create 2D ellipse containers */
  5620. var Ellipse = /** @class */ (function (_super) {
  5621. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5622. /**
  5623. * Creates a new Ellipse
  5624. * @param name defines the control name
  5625. */
  5626. function Ellipse(name) {
  5627. var _this = _super.call(this, name) || this;
  5628. _this.name = name;
  5629. _this._thickness = 1;
  5630. return _this;
  5631. }
  5632. Object.defineProperty(Ellipse.prototype, "thickness", {
  5633. /** Gets or sets border thickness */
  5634. get: function () {
  5635. return this._thickness;
  5636. },
  5637. set: function (value) {
  5638. if (this._thickness === value) {
  5639. return;
  5640. }
  5641. this._thickness = value;
  5642. this._markAsDirty();
  5643. },
  5644. enumerable: true,
  5645. configurable: true
  5646. });
  5647. Ellipse.prototype._getTypeName = function () {
  5648. return "Ellipse";
  5649. };
  5650. Ellipse.prototype._localDraw = function (context) {
  5651. context.save();
  5652. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5653. context.shadowColor = this.shadowColor;
  5654. context.shadowBlur = this.shadowBlur;
  5655. context.shadowOffsetX = this.shadowOffsetX;
  5656. context.shadowOffsetY = this.shadowOffsetY;
  5657. }
  5658. _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);
  5659. if (this._background) {
  5660. context.fillStyle = this._background;
  5661. context.fill();
  5662. }
  5663. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5664. context.shadowBlur = 0;
  5665. context.shadowOffsetX = 0;
  5666. context.shadowOffsetY = 0;
  5667. }
  5668. if (this._thickness) {
  5669. if (this.color) {
  5670. context.strokeStyle = this.color;
  5671. }
  5672. context.lineWidth = this._thickness;
  5673. context.stroke();
  5674. }
  5675. context.restore();
  5676. };
  5677. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5678. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5679. this._measureForChildren.width -= 2 * this._thickness;
  5680. this._measureForChildren.height -= 2 * this._thickness;
  5681. this._measureForChildren.left += this._thickness;
  5682. this._measureForChildren.top += this._thickness;
  5683. };
  5684. Ellipse.prototype._clipForChildren = function (context) {
  5685. _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);
  5686. context.clip();
  5687. };
  5688. return Ellipse;
  5689. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5690. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5691. /***/ }),
  5692. /***/ "./2D/controls/grid.ts":
  5693. /*!*****************************!*\
  5694. !*** ./2D/controls/grid.ts ***!
  5695. \*****************************/
  5696. /*! exports provided: Grid */
  5697. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5698. "use strict";
  5699. __webpack_require__.r(__webpack_exports__);
  5700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5701. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5702. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5703. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5704. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5705. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  5706. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5707. /**
  5708. * Class used to create a 2D grid container
  5709. */
  5710. var Grid = /** @class */ (function (_super) {
  5711. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5712. /**
  5713. * Creates a new Grid
  5714. * @param name defines control name
  5715. */
  5716. function Grid(name) {
  5717. var _this = _super.call(this, name) || this;
  5718. _this.name = name;
  5719. _this._rowDefinitions = new Array();
  5720. _this._columnDefinitions = new Array();
  5721. _this._cells = {};
  5722. _this._childControls = new Array();
  5723. return _this;
  5724. }
  5725. Object.defineProperty(Grid.prototype, "columnCount", {
  5726. /**
  5727. * Gets the number of columns
  5728. */
  5729. get: function () {
  5730. return this._columnDefinitions.length;
  5731. },
  5732. enumerable: true,
  5733. configurable: true
  5734. });
  5735. Object.defineProperty(Grid.prototype, "rowCount", {
  5736. /**
  5737. * Gets the number of rows
  5738. */
  5739. get: function () {
  5740. return this._rowDefinitions.length;
  5741. },
  5742. enumerable: true,
  5743. configurable: true
  5744. });
  5745. Object.defineProperty(Grid.prototype, "children", {
  5746. /** Gets the list of children */
  5747. get: function () {
  5748. return this._childControls;
  5749. },
  5750. enumerable: true,
  5751. configurable: true
  5752. });
  5753. Object.defineProperty(Grid.prototype, "cells", {
  5754. /** Gets the list of cells (e.g. the containers) */
  5755. get: function () {
  5756. return this._cells;
  5757. },
  5758. enumerable: true,
  5759. configurable: true
  5760. });
  5761. /**
  5762. * Gets the definition of a specific row
  5763. * @param index defines the index of the row
  5764. * @returns the row definition
  5765. */
  5766. Grid.prototype.getRowDefinition = function (index) {
  5767. if (index < 0 || index >= this._rowDefinitions.length) {
  5768. return null;
  5769. }
  5770. return this._rowDefinitions[index];
  5771. };
  5772. /**
  5773. * Gets the definition of a specific column
  5774. * @param index defines the index of the column
  5775. * @returns the column definition
  5776. */
  5777. Grid.prototype.getColumnDefinition = function (index) {
  5778. if (index < 0 || index >= this._columnDefinitions.length) {
  5779. return null;
  5780. }
  5781. return this._columnDefinitions[index];
  5782. };
  5783. /**
  5784. * Adds a new row to the grid
  5785. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5786. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5787. * @returns the current grid
  5788. */
  5789. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5790. if (isPixel === void 0) { isPixel = false; }
  5791. 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));
  5792. this._markAsDirty();
  5793. return this;
  5794. };
  5795. /**
  5796. * Adds a new column to the grid
  5797. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5798. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5799. * @returns the current grid
  5800. */
  5801. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5802. if (isPixel === void 0) { isPixel = false; }
  5803. 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));
  5804. this._markAsDirty();
  5805. return this;
  5806. };
  5807. /**
  5808. * Update a row definition
  5809. * @param index defines the index of the row to update
  5810. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5811. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5812. * @returns the current grid
  5813. */
  5814. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5815. if (isPixel === void 0) { isPixel = false; }
  5816. if (index < 0 || index >= this._rowDefinitions.length) {
  5817. return this;
  5818. }
  5819. var current = this._rowDefinitions[index];
  5820. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5821. return this;
  5822. }
  5823. 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);
  5824. this._markAsDirty();
  5825. return this;
  5826. };
  5827. /**
  5828. * Update a column definition
  5829. * @param index defines the index of the column to update
  5830. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5831. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5832. * @returns the current grid
  5833. */
  5834. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5835. if (isPixel === void 0) { isPixel = false; }
  5836. if (index < 0 || index >= this._columnDefinitions.length) {
  5837. return this;
  5838. }
  5839. var current = this._columnDefinitions[index];
  5840. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5841. return this;
  5842. }
  5843. 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);
  5844. this._markAsDirty();
  5845. return this;
  5846. };
  5847. /**
  5848. * Gets the list of children stored in a specific cell
  5849. * @param row defines the row to check
  5850. * @param column defines the column to check
  5851. * @returns the list of controls
  5852. */
  5853. Grid.prototype.getChildrenAt = function (row, column) {
  5854. var cell = this._cells[row + ":" + column];
  5855. if (!cell) {
  5856. return null;
  5857. }
  5858. return cell.children;
  5859. };
  5860. /**
  5861. * Gets a string representing the child cell info (row x column)
  5862. * @param child defines the control to get info from
  5863. * @returns a string containing the child cell info (row x column)
  5864. */
  5865. Grid.prototype.getChildCellInfo = function (child) {
  5866. return child._tag;
  5867. };
  5868. Grid.prototype._removeCell = function (cell, key) {
  5869. if (!cell) {
  5870. return;
  5871. }
  5872. _super.prototype.removeControl.call(this, cell);
  5873. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5874. var control = _a[_i];
  5875. var childIndex = this._childControls.indexOf(control);
  5876. if (childIndex !== -1) {
  5877. this._childControls.splice(childIndex, 1);
  5878. }
  5879. }
  5880. delete this._cells[key];
  5881. };
  5882. Grid.prototype._offsetCell = function (previousKey, key) {
  5883. if (!this._cells[key]) {
  5884. return;
  5885. }
  5886. this._cells[previousKey] = this._cells[key];
  5887. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5888. var control = _a[_i];
  5889. control._tag = previousKey;
  5890. }
  5891. delete this._cells[key];
  5892. };
  5893. /**
  5894. * Remove a column definition at specified index
  5895. * @param index defines the index of the column to remove
  5896. * @returns the current grid
  5897. */
  5898. Grid.prototype.removeColumnDefinition = function (index) {
  5899. if (index < 0 || index >= this._columnDefinitions.length) {
  5900. return this;
  5901. }
  5902. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5903. var key = x + ":" + index;
  5904. var cell = this._cells[key];
  5905. this._removeCell(cell, key);
  5906. }
  5907. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5908. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5909. var previousKey = x + ":" + (y - 1);
  5910. var key = x + ":" + y;
  5911. this._offsetCell(previousKey, key);
  5912. }
  5913. }
  5914. this._columnDefinitions.splice(index, 1);
  5915. this._markAsDirty();
  5916. return this;
  5917. };
  5918. /**
  5919. * Remove a row definition at specified index
  5920. * @param index defines the index of the row to remove
  5921. * @returns the current grid
  5922. */
  5923. Grid.prototype.removeRowDefinition = function (index) {
  5924. if (index < 0 || index >= this._rowDefinitions.length) {
  5925. return this;
  5926. }
  5927. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5928. var key = index + ":" + y;
  5929. var cell = this._cells[key];
  5930. this._removeCell(cell, key);
  5931. }
  5932. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5933. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5934. var previousKey = x - 1 + ":" + y;
  5935. var key = x + ":" + y;
  5936. this._offsetCell(previousKey, key);
  5937. }
  5938. }
  5939. this._rowDefinitions.splice(index, 1);
  5940. this._markAsDirty();
  5941. return this;
  5942. };
  5943. /**
  5944. * Adds a new control to the current grid
  5945. * @param control defines the control to add
  5946. * @param row defines the row where to add the control (0 by default)
  5947. * @param column defines the column where to add the control (0 by default)
  5948. * @returns the current grid
  5949. */
  5950. Grid.prototype.addControl = function (control, row, column) {
  5951. if (row === void 0) { row = 0; }
  5952. if (column === void 0) { column = 0; }
  5953. if (this._rowDefinitions.length === 0) {
  5954. // Add default row definition
  5955. this.addRowDefinition(1, false);
  5956. }
  5957. if (this._columnDefinitions.length === 0) {
  5958. // Add default column definition
  5959. this.addColumnDefinition(1, false);
  5960. }
  5961. if (this._childControls.indexOf(control) !== -1) {
  5962. 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");
  5963. return this;
  5964. }
  5965. var x = Math.min(row, this._rowDefinitions.length - 1);
  5966. var y = Math.min(column, this._columnDefinitions.length - 1);
  5967. var key = x + ":" + y;
  5968. var goodContainer = this._cells[key];
  5969. if (!goodContainer) {
  5970. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5971. this._cells[key] = goodContainer;
  5972. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5973. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5974. _super.prototype.addControl.call(this, goodContainer);
  5975. }
  5976. goodContainer.addControl(control);
  5977. this._childControls.push(control);
  5978. control._tag = key;
  5979. control.parent = this;
  5980. this._markAsDirty();
  5981. return this;
  5982. };
  5983. /**
  5984. * Removes a control from the current container
  5985. * @param control defines the control to remove
  5986. * @returns the current container
  5987. */
  5988. Grid.prototype.removeControl = function (control) {
  5989. var index = this._childControls.indexOf(control);
  5990. if (index !== -1) {
  5991. this._childControls.splice(index, 1);
  5992. }
  5993. var cell = this._cells[control._tag];
  5994. if (cell) {
  5995. cell.removeControl(control);
  5996. control._tag = null;
  5997. }
  5998. this._markAsDirty();
  5999. return this;
  6000. };
  6001. Grid.prototype._getTypeName = function () {
  6002. return "Grid";
  6003. };
  6004. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6005. var widths = [];
  6006. var heights = [];
  6007. var lefts = [];
  6008. var tops = [];
  6009. var availableWidth = this._currentMeasure.width;
  6010. var globalWidthPercentage = 0;
  6011. var availableHeight = this._currentMeasure.height;
  6012. var globalHeightPercentage = 0;
  6013. // Heights
  6014. var index = 0;
  6015. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6016. var value = _a[_i];
  6017. if (value.isPixel) {
  6018. var height = value.getValue(this._host);
  6019. availableHeight -= height;
  6020. heights[index] = height;
  6021. }
  6022. else {
  6023. globalHeightPercentage += value.internalValue;
  6024. }
  6025. index++;
  6026. }
  6027. var top = 0;
  6028. index = 0;
  6029. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6030. var value = _c[_b];
  6031. tops.push(top);
  6032. if (!value.isPixel) {
  6033. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6034. top += height;
  6035. heights[index] = height;
  6036. }
  6037. else {
  6038. top += value.getValue(this._host);
  6039. }
  6040. index++;
  6041. }
  6042. // Widths
  6043. index = 0;
  6044. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6045. var value = _e[_d];
  6046. if (value.isPixel) {
  6047. var width = value.getValue(this._host);
  6048. availableWidth -= width;
  6049. widths[index] = width;
  6050. }
  6051. else {
  6052. globalWidthPercentage += value.internalValue;
  6053. }
  6054. index++;
  6055. }
  6056. var left = 0;
  6057. index = 0;
  6058. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6059. var value = _g[_f];
  6060. lefts.push(left);
  6061. if (!value.isPixel) {
  6062. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6063. left += width;
  6064. widths[index] = width;
  6065. }
  6066. else {
  6067. left += value.getValue(this._host);
  6068. }
  6069. index++;
  6070. }
  6071. definitionCallback(lefts, tops, widths, heights);
  6072. };
  6073. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6074. var _this = this;
  6075. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6076. // Setting child sizes
  6077. for (var key in _this._cells) {
  6078. if (!_this._cells.hasOwnProperty(key)) {
  6079. continue;
  6080. }
  6081. var split = key.split(":");
  6082. var x = parseInt(split[0]);
  6083. var y = parseInt(split[1]);
  6084. var cell = _this._cells[key];
  6085. cell.left = lefts[y] + "px";
  6086. cell.top = tops[x] + "px";
  6087. cell.width = widths[y] + "px";
  6088. cell.height = heights[x] + "px";
  6089. cell._left.ignoreAdaptiveScaling = true;
  6090. cell._top.ignoreAdaptiveScaling = true;
  6091. cell._width.ignoreAdaptiveScaling = true;
  6092. cell._height.ignoreAdaptiveScaling = true;
  6093. }
  6094. });
  6095. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6096. };
  6097. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6098. for (var key in this._cells) {
  6099. if (!this._cells.hasOwnProperty(key)) {
  6100. continue;
  6101. }
  6102. var child = this._cells[key];
  6103. child._markMatrixAsDirty();
  6104. }
  6105. };
  6106. Grid.prototype._renderHighlightSpecific = function (context) {
  6107. var _this = this;
  6108. _super.prototype._renderHighlightSpecific.call(this, context);
  6109. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6110. // Columns
  6111. for (var index = 0; index < lefts.length; index++) {
  6112. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6113. context.beginPath();
  6114. context.moveTo(left, _this._currentMeasure.top);
  6115. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6116. context.stroke();
  6117. }
  6118. // Rows
  6119. for (var index = 0; index < tops.length; index++) {
  6120. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6121. context.beginPath();
  6122. context.moveTo(_this._currentMeasure.left, top_1);
  6123. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6124. context.stroke();
  6125. }
  6126. });
  6127. context.restore();
  6128. };
  6129. /** Releases associated resources */
  6130. Grid.prototype.dispose = function () {
  6131. _super.prototype.dispose.call(this);
  6132. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6133. var control = _a[_i];
  6134. control.dispose();
  6135. }
  6136. this._childControls = [];
  6137. };
  6138. return Grid;
  6139. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6140. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6141. /***/ }),
  6142. /***/ "./2D/controls/image.ts":
  6143. /*!******************************!*\
  6144. !*** ./2D/controls/image.ts ***!
  6145. \******************************/
  6146. /*! exports provided: Image */
  6147. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6148. "use strict";
  6149. __webpack_require__.r(__webpack_exports__);
  6150. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6151. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6152. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6153. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6154. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6155. /**
  6156. * Class used to create 2D images
  6157. */
  6158. var Image = /** @class */ (function (_super) {
  6159. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6160. /**
  6161. * Creates a new Image
  6162. * @param name defines the control name
  6163. * @param url defines the image url
  6164. */
  6165. function Image(name, url) {
  6166. if (url === void 0) { url = null; }
  6167. var _this = _super.call(this, name) || this;
  6168. _this.name = name;
  6169. _this._workingCanvas = null;
  6170. _this._loaded = false;
  6171. _this._stretch = Image.STRETCH_FILL;
  6172. _this._autoScale = false;
  6173. _this._sourceLeft = 0;
  6174. _this._sourceTop = 0;
  6175. _this._sourceWidth = 0;
  6176. _this._sourceHeight = 0;
  6177. _this._cellWidth = 0;
  6178. _this._cellHeight = 0;
  6179. _this._cellId = -1;
  6180. _this._populateNinePatchSlicesFromImage = false;
  6181. /**
  6182. * Observable notified when the content is loaded
  6183. */
  6184. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6185. /**
  6186. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6187. */
  6188. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6189. _this.source = url;
  6190. return _this;
  6191. }
  6192. Object.defineProperty(Image.prototype, "isLoaded", {
  6193. /**
  6194. * Gets a boolean indicating that the content is loaded
  6195. */
  6196. get: function () {
  6197. return this._loaded;
  6198. },
  6199. enumerable: true,
  6200. configurable: true
  6201. });
  6202. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6203. /**
  6204. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6205. */
  6206. get: function () {
  6207. return this._populateNinePatchSlicesFromImage;
  6208. },
  6209. set: function (value) {
  6210. if (this._populateNinePatchSlicesFromImage === value) {
  6211. return;
  6212. }
  6213. this._populateNinePatchSlicesFromImage = value;
  6214. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6215. this._extractNinePatchSliceDataFromImage();
  6216. }
  6217. },
  6218. enumerable: true,
  6219. configurable: true
  6220. });
  6221. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6222. /**
  6223. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6224. * Beware using this as this will comsume more memory as the image has to be stored twice
  6225. */
  6226. get: function () {
  6227. return this._detectPointerOnOpaqueOnly;
  6228. },
  6229. set: function (value) {
  6230. if (this._detectPointerOnOpaqueOnly === value) {
  6231. return;
  6232. }
  6233. this._detectPointerOnOpaqueOnly = value;
  6234. },
  6235. enumerable: true,
  6236. configurable: true
  6237. });
  6238. Object.defineProperty(Image.prototype, "sliceLeft", {
  6239. /**
  6240. * Gets or sets the left value for slicing (9-patch)
  6241. */
  6242. get: function () {
  6243. return this._sliceLeft;
  6244. },
  6245. set: function (value) {
  6246. if (this._sliceLeft === value) {
  6247. return;
  6248. }
  6249. this._sliceLeft = value;
  6250. this._markAsDirty();
  6251. },
  6252. enumerable: true,
  6253. configurable: true
  6254. });
  6255. Object.defineProperty(Image.prototype, "sliceRight", {
  6256. /**
  6257. * Gets or sets the right value for slicing (9-patch)
  6258. */
  6259. get: function () {
  6260. return this._sliceRight;
  6261. },
  6262. set: function (value) {
  6263. if (this._sliceRight === value) {
  6264. return;
  6265. }
  6266. this._sliceRight = value;
  6267. this._markAsDirty();
  6268. },
  6269. enumerable: true,
  6270. configurable: true
  6271. });
  6272. Object.defineProperty(Image.prototype, "sliceTop", {
  6273. /**
  6274. * Gets or sets the top value for slicing (9-patch)
  6275. */
  6276. get: function () {
  6277. return this._sliceTop;
  6278. },
  6279. set: function (value) {
  6280. if (this._sliceTop === value) {
  6281. return;
  6282. }
  6283. this._sliceTop = value;
  6284. this._markAsDirty();
  6285. },
  6286. enumerable: true,
  6287. configurable: true
  6288. });
  6289. Object.defineProperty(Image.prototype, "sliceBottom", {
  6290. /**
  6291. * Gets or sets the bottom value for slicing (9-patch)
  6292. */
  6293. get: function () {
  6294. return this._sliceBottom;
  6295. },
  6296. set: function (value) {
  6297. if (this._sliceBottom === value) {
  6298. return;
  6299. }
  6300. this._sliceBottom = value;
  6301. this._markAsDirty();
  6302. },
  6303. enumerable: true,
  6304. configurable: true
  6305. });
  6306. Object.defineProperty(Image.prototype, "sourceLeft", {
  6307. /**
  6308. * Gets or sets the left coordinate in the source image
  6309. */
  6310. get: function () {
  6311. return this._sourceLeft;
  6312. },
  6313. set: function (value) {
  6314. if (this._sourceLeft === value) {
  6315. return;
  6316. }
  6317. this._sourceLeft = value;
  6318. this._markAsDirty();
  6319. },
  6320. enumerable: true,
  6321. configurable: true
  6322. });
  6323. Object.defineProperty(Image.prototype, "sourceTop", {
  6324. /**
  6325. * Gets or sets the top coordinate in the source image
  6326. */
  6327. get: function () {
  6328. return this._sourceTop;
  6329. },
  6330. set: function (value) {
  6331. if (this._sourceTop === value) {
  6332. return;
  6333. }
  6334. this._sourceTop = value;
  6335. this._markAsDirty();
  6336. },
  6337. enumerable: true,
  6338. configurable: true
  6339. });
  6340. Object.defineProperty(Image.prototype, "sourceWidth", {
  6341. /**
  6342. * Gets or sets the width to capture in the source image
  6343. */
  6344. get: function () {
  6345. return this._sourceWidth;
  6346. },
  6347. set: function (value) {
  6348. if (this._sourceWidth === value) {
  6349. return;
  6350. }
  6351. this._sourceWidth = value;
  6352. this._markAsDirty();
  6353. },
  6354. enumerable: true,
  6355. configurable: true
  6356. });
  6357. Object.defineProperty(Image.prototype, "sourceHeight", {
  6358. /**
  6359. * Gets or sets the height to capture in the source image
  6360. */
  6361. get: function () {
  6362. return this._sourceHeight;
  6363. },
  6364. set: function (value) {
  6365. if (this._sourceHeight === value) {
  6366. return;
  6367. }
  6368. this._sourceHeight = value;
  6369. this._markAsDirty();
  6370. },
  6371. enumerable: true,
  6372. configurable: true
  6373. });
  6374. Object.defineProperty(Image.prototype, "autoScale", {
  6375. /**
  6376. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6377. * @see http://doc.babylonjs.com/how_to/gui#image
  6378. */
  6379. get: function () {
  6380. return this._autoScale;
  6381. },
  6382. set: function (value) {
  6383. if (this._autoScale === value) {
  6384. return;
  6385. }
  6386. this._autoScale = value;
  6387. if (value && this._loaded) {
  6388. this.synchronizeSizeWithContent();
  6389. }
  6390. },
  6391. enumerable: true,
  6392. configurable: true
  6393. });
  6394. Object.defineProperty(Image.prototype, "stretch", {
  6395. /** Gets or sets the streching mode used by the image */
  6396. get: function () {
  6397. return this._stretch;
  6398. },
  6399. set: function (value) {
  6400. if (this._stretch === value) {
  6401. return;
  6402. }
  6403. this._stretch = value;
  6404. this._markAsDirty();
  6405. },
  6406. enumerable: true,
  6407. configurable: true
  6408. });
  6409. Object.defineProperty(Image.prototype, "domImage", {
  6410. get: function () {
  6411. return this._domImage;
  6412. },
  6413. /**
  6414. * Gets or sets the internal DOM image used to render the control
  6415. */
  6416. set: function (value) {
  6417. var _this = this;
  6418. this._domImage = value;
  6419. this._loaded = false;
  6420. if (this._domImage.width) {
  6421. this._onImageLoaded();
  6422. }
  6423. else {
  6424. this._domImage.onload = function () {
  6425. _this._onImageLoaded();
  6426. };
  6427. }
  6428. },
  6429. enumerable: true,
  6430. configurable: true
  6431. });
  6432. Image.prototype._onImageLoaded = function () {
  6433. this._imageWidth = this._domImage.width;
  6434. this._imageHeight = this._domImage.height;
  6435. this._loaded = true;
  6436. if (this._populateNinePatchSlicesFromImage) {
  6437. this._extractNinePatchSliceDataFromImage();
  6438. }
  6439. if (this._autoScale) {
  6440. this.synchronizeSizeWithContent();
  6441. }
  6442. this.onImageLoadedObservable.notifyObservers(this);
  6443. this._markAsDirty();
  6444. };
  6445. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6446. if (!this._workingCanvas) {
  6447. this._workingCanvas = document.createElement('canvas');
  6448. }
  6449. var canvas = this._workingCanvas;
  6450. var context = canvas.getContext('2d');
  6451. var width = this._domImage.width;
  6452. var height = this._domImage.height;
  6453. canvas.width = width;
  6454. canvas.height = height;
  6455. context.drawImage(this._domImage, 0, 0, width, height);
  6456. var imageData = context.getImageData(0, 0, width, height);
  6457. // Left and right
  6458. this._sliceLeft = -1;
  6459. this._sliceRight = -1;
  6460. for (var x = 0; x < width; x++) {
  6461. var alpha = imageData.data[x * 4 + 3];
  6462. if (alpha > 127 && this._sliceLeft === -1) {
  6463. this._sliceLeft = x;
  6464. continue;
  6465. }
  6466. if (alpha < 127 && this._sliceLeft > -1) {
  6467. this._sliceRight = x;
  6468. break;
  6469. }
  6470. }
  6471. // top and bottom
  6472. this._sliceTop = -1;
  6473. this._sliceBottom = -1;
  6474. for (var y = 0; y < height; y++) {
  6475. var alpha = imageData.data[y * width * 4 + 3];
  6476. if (alpha > 127 && this._sliceTop === -1) {
  6477. this._sliceTop = y;
  6478. continue;
  6479. }
  6480. if (alpha < 127 && this._sliceTop > -1) {
  6481. this._sliceBottom = y;
  6482. break;
  6483. }
  6484. }
  6485. };
  6486. Object.defineProperty(Image.prototype, "source", {
  6487. /**
  6488. * Gets or sets image source url
  6489. */
  6490. set: function (value) {
  6491. var _this = this;
  6492. if (this._source === value) {
  6493. return;
  6494. }
  6495. this._loaded = false;
  6496. this._source = value;
  6497. if (value) {
  6498. value = this._svgCheck(value);
  6499. }
  6500. this._domImage = document.createElement("img");
  6501. this._domImage.onload = function () {
  6502. _this._onImageLoaded();
  6503. };
  6504. if (value) {
  6505. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6506. this._domImage.src = value;
  6507. }
  6508. },
  6509. enumerable: true,
  6510. configurable: true
  6511. });
  6512. /**
  6513. * Checks for svg document with icon id present
  6514. */
  6515. Image.prototype._svgCheck = function (value) {
  6516. var _this = this;
  6517. if ((value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6518. var svgsrc = value.split('#')[0];
  6519. var elemid = value.split('#')[1];
  6520. // check if object alr exist in document
  6521. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6522. if (svgExist) {
  6523. // wait for object to load
  6524. svgExist.addEventListener("load", function () {
  6525. _this._getSVGAttribs(svgExist, elemid);
  6526. });
  6527. }
  6528. else {
  6529. // create document object
  6530. var svgImage = document.createElement("object");
  6531. svgImage.data = svgsrc;
  6532. svgImage.type = "image/svg+xml";
  6533. svgImage.width = "0%";
  6534. svgImage.height = "0%";
  6535. document.body.appendChild(svgImage);
  6536. // when the object has loaded, get the element attribs
  6537. svgImage.onload = function () {
  6538. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6539. if (svgobj) {
  6540. _this._getSVGAttribs(svgobj, elemid);
  6541. }
  6542. };
  6543. }
  6544. return svgsrc;
  6545. }
  6546. else {
  6547. return value;
  6548. }
  6549. };
  6550. /**
  6551. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6552. * given external svg file and icon id
  6553. */
  6554. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6555. var svgDoc = svgsrc.contentDocument;
  6556. // get viewbox width and height, get svg document width and height in px
  6557. if (svgDoc && svgDoc.documentElement) {
  6558. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6559. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6560. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6561. // get element bbox and matrix transform
  6562. var elem = svgDoc.getElementById(elemid);
  6563. if (vb && docwidth && docheight) {
  6564. var vb_width = Number(vb.split(" ")[2]);
  6565. var vb_height = Number(vb.split(" ")[3]);
  6566. var elem_bbox = elem.getBBox();
  6567. var elem_matrix_a = 1;
  6568. var elem_matrix_d = 1;
  6569. var elem_matrix_e = 0;
  6570. var elem_matrix_f = 0;
  6571. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6572. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6573. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6574. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6575. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6576. }
  6577. // compute source coordinates and dimensions
  6578. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6579. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6580. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6581. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6582. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6583. }
  6584. }
  6585. };
  6586. Object.defineProperty(Image.prototype, "cellWidth", {
  6587. /**
  6588. * Gets or sets the cell width to use when animation sheet is enabled
  6589. * @see http://doc.babylonjs.com/how_to/gui#image
  6590. */
  6591. get: function () {
  6592. return this._cellWidth;
  6593. },
  6594. set: function (value) {
  6595. if (this._cellWidth === value) {
  6596. return;
  6597. }
  6598. this._cellWidth = value;
  6599. this._markAsDirty();
  6600. },
  6601. enumerable: true,
  6602. configurable: true
  6603. });
  6604. Object.defineProperty(Image.prototype, "cellHeight", {
  6605. /**
  6606. * Gets or sets the cell height to use when animation sheet is enabled
  6607. * @see http://doc.babylonjs.com/how_to/gui#image
  6608. */
  6609. get: function () {
  6610. return this._cellHeight;
  6611. },
  6612. set: function (value) {
  6613. if (this._cellHeight === value) {
  6614. return;
  6615. }
  6616. this._cellHeight = value;
  6617. this._markAsDirty();
  6618. },
  6619. enumerable: true,
  6620. configurable: true
  6621. });
  6622. Object.defineProperty(Image.prototype, "cellId", {
  6623. /**
  6624. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6625. * @see http://doc.babylonjs.com/how_to/gui#image
  6626. */
  6627. get: function () {
  6628. return this._cellId;
  6629. },
  6630. set: function (value) {
  6631. if (this._cellId === value) {
  6632. return;
  6633. }
  6634. this._cellId = value;
  6635. this._markAsDirty();
  6636. },
  6637. enumerable: true,
  6638. configurable: true
  6639. });
  6640. /**
  6641. * Tests if a given coordinates belong to the current control
  6642. * @param x defines x coordinate to test
  6643. * @param y defines y coordinate to test
  6644. * @returns true if the coordinates are inside the control
  6645. */
  6646. Image.prototype.contains = function (x, y) {
  6647. if (!_super.prototype.contains.call(this, x, y)) {
  6648. return false;
  6649. }
  6650. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6651. return true;
  6652. }
  6653. var canvas = this._workingCanvas;
  6654. var context = canvas.getContext("2d");
  6655. var width = this._currentMeasure.width | 0;
  6656. var height = this._currentMeasure.height | 0;
  6657. var imageData = context.getImageData(0, 0, width, height).data;
  6658. x = (x - this._currentMeasure.left) | 0;
  6659. y = (y - this._currentMeasure.top) | 0;
  6660. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6661. return pickedPixel > 0;
  6662. };
  6663. Image.prototype._getTypeName = function () {
  6664. return "Image";
  6665. };
  6666. /** Force the control to synchronize with its content */
  6667. Image.prototype.synchronizeSizeWithContent = function () {
  6668. if (!this._loaded) {
  6669. return;
  6670. }
  6671. this.width = this._domImage.width + "px";
  6672. this.height = this._domImage.height + "px";
  6673. };
  6674. Image.prototype._processMeasures = function (parentMeasure, context) {
  6675. if (this._loaded) {
  6676. switch (this._stretch) {
  6677. case Image.STRETCH_NONE:
  6678. break;
  6679. case Image.STRETCH_FILL:
  6680. break;
  6681. case Image.STRETCH_UNIFORM:
  6682. break;
  6683. case Image.STRETCH_NINE_PATCH:
  6684. break;
  6685. case Image.STRETCH_EXTEND:
  6686. if (this._autoScale) {
  6687. this.synchronizeSizeWithContent();
  6688. }
  6689. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6690. this.parent.adaptWidthToChildren = true;
  6691. this.parent.adaptHeightToChildren = true;
  6692. }
  6693. break;
  6694. }
  6695. }
  6696. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6697. };
  6698. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6699. if (!this._detectPointerOnOpaqueOnly) {
  6700. return;
  6701. }
  6702. if (!this._workingCanvas) {
  6703. this._workingCanvas = document.createElement('canvas');
  6704. }
  6705. var canvas = this._workingCanvas;
  6706. var width = this._currentMeasure.width;
  6707. var height = this._currentMeasure.height;
  6708. var context = canvas.getContext("2d");
  6709. canvas.width = width;
  6710. canvas.height = height;
  6711. context.clearRect(0, 0, width, height);
  6712. };
  6713. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6714. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6715. if (!this._detectPointerOnOpaqueOnly) {
  6716. return;
  6717. }
  6718. var canvas = this._workingCanvas;
  6719. context = canvas.getContext("2d");
  6720. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6721. };
  6722. Image.prototype._draw = function (context) {
  6723. context.save();
  6724. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6725. context.shadowColor = this.shadowColor;
  6726. context.shadowBlur = this.shadowBlur;
  6727. context.shadowOffsetX = this.shadowOffsetX;
  6728. context.shadowOffsetY = this.shadowOffsetY;
  6729. }
  6730. var x, y, width, height;
  6731. if (this.cellId == -1) {
  6732. x = this._sourceLeft;
  6733. y = this._sourceTop;
  6734. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6735. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6736. }
  6737. else {
  6738. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6739. var column = (this.cellId / rowCount) >> 0;
  6740. var row = this.cellId % rowCount;
  6741. x = this.cellWidth * row;
  6742. y = this.cellHeight * column;
  6743. width = this.cellWidth;
  6744. height = this.cellHeight;
  6745. }
  6746. this._prepareWorkingCanvasForOpaqueDetection();
  6747. this._applyStates(context);
  6748. if (this._loaded) {
  6749. switch (this._stretch) {
  6750. case Image.STRETCH_NONE:
  6751. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6752. break;
  6753. case Image.STRETCH_FILL:
  6754. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6755. break;
  6756. case Image.STRETCH_UNIFORM:
  6757. var hRatio = this._currentMeasure.width / width;
  6758. var vRatio = this._currentMeasure.height / height;
  6759. var ratio = Math.min(hRatio, vRatio);
  6760. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6761. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6762. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6763. break;
  6764. case Image.STRETCH_EXTEND:
  6765. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6766. break;
  6767. case Image.STRETCH_NINE_PATCH:
  6768. this._renderNinePatch(context);
  6769. break;
  6770. }
  6771. }
  6772. context.restore();
  6773. };
  6774. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6775. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6776. };
  6777. Image.prototype._renderNinePatch = function (context) {
  6778. var height = this._imageHeight;
  6779. var leftWidth = this._sliceLeft;
  6780. var topHeight = this._sliceTop;
  6781. var bottomHeight = this._imageHeight - this._sliceBottom;
  6782. var rightWidth = this._imageWidth - this._sliceRight;
  6783. var left = 0;
  6784. var top = 0;
  6785. if (this._populateNinePatchSlicesFromImage) {
  6786. left = 1;
  6787. top = 1;
  6788. height -= 2;
  6789. leftWidth -= 1;
  6790. topHeight -= 1;
  6791. bottomHeight -= 1;
  6792. rightWidth -= 1;
  6793. }
  6794. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6795. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6796. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6797. // Corners
  6798. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6799. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6800. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6801. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6802. // Center
  6803. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop + 1, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight + 1);
  6804. // Borders
  6805. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6806. 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);
  6807. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6808. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6809. };
  6810. Image.prototype.dispose = function () {
  6811. _super.prototype.dispose.call(this);
  6812. this.onImageLoadedObservable.clear();
  6813. this.onSVGAttributesComputedObservable.clear();
  6814. };
  6815. // Static
  6816. /** STRETCH_NONE */
  6817. Image.STRETCH_NONE = 0;
  6818. /** STRETCH_FILL */
  6819. Image.STRETCH_FILL = 1;
  6820. /** STRETCH_UNIFORM */
  6821. Image.STRETCH_UNIFORM = 2;
  6822. /** STRETCH_EXTEND */
  6823. Image.STRETCH_EXTEND = 3;
  6824. /** NINE_PATCH */
  6825. Image.STRETCH_NINE_PATCH = 4;
  6826. return Image;
  6827. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6828. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  6829. /***/ }),
  6830. /***/ "./2D/controls/index.ts":
  6831. /*!******************************!*\
  6832. !*** ./2D/controls/index.ts ***!
  6833. \******************************/
  6834. /*! 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, name */
  6835. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6836. "use strict";
  6837. __webpack_require__.r(__webpack_exports__);
  6838. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6840. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6842. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6844. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6846. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6848. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6850. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6852. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6854. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6856. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6858. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6860. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6862. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6864. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6866. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6872. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6874. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6877. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6880. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6882. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6884. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6886. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6888. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6890. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6892. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_24__["name"]; });
  6894. /***/ }),
  6895. /***/ "./2D/controls/inputPassword.ts":
  6896. /*!**************************************!*\
  6897. !*** ./2D/controls/inputPassword.ts ***!
  6898. \**************************************/
  6899. /*! exports provided: InputPassword */
  6900. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6901. "use strict";
  6902. __webpack_require__.r(__webpack_exports__);
  6903. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6904. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6905. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6906. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  6907. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  6908. /**
  6909. * Class used to create a password control
  6910. */
  6911. var InputPassword = /** @class */ (function (_super) {
  6912. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  6913. function InputPassword() {
  6914. return _super !== null && _super.apply(this, arguments) || this;
  6915. }
  6916. InputPassword.prototype._beforeRenderText = function (text) {
  6917. var txt = "";
  6918. for (var i = 0; i < text.length; i++) {
  6919. txt += "\u2022";
  6920. }
  6921. return txt;
  6922. };
  6923. return InputPassword;
  6924. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6925. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  6926. /***/ }),
  6927. /***/ "./2D/controls/inputText.ts":
  6928. /*!**********************************!*\
  6929. !*** ./2D/controls/inputText.ts ***!
  6930. \**********************************/
  6931. /*! exports provided: InputText */
  6932. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6933. "use strict";
  6934. __webpack_require__.r(__webpack_exports__);
  6935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6936. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6937. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6938. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6939. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6940. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6941. /**
  6942. * Class used to create input text control
  6943. */
  6944. var InputText = /** @class */ (function (_super) {
  6945. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  6946. /**
  6947. * Creates a new InputText
  6948. * @param name defines the control name
  6949. * @param text defines the text of the control
  6950. */
  6951. function InputText(name, text) {
  6952. if (text === void 0) { text = ""; }
  6953. var _this = _super.call(this, name) || this;
  6954. _this.name = name;
  6955. _this._text = "";
  6956. _this._placeholderText = "";
  6957. _this._background = "#222222";
  6958. _this._focusedBackground = "#000000";
  6959. _this._focusedColor = "white";
  6960. _this._placeholderColor = "gray";
  6961. _this._thickness = 1;
  6962. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6963. _this._autoStretchWidth = true;
  6964. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6965. _this._isFocused = false;
  6966. _this._blinkIsEven = false;
  6967. _this._cursorOffset = 0;
  6968. _this._deadKey = false;
  6969. _this._addKey = true;
  6970. _this._currentKey = "";
  6971. _this._isTextHighlightOn = false;
  6972. _this._textHighlightColor = "#d5e0ff";
  6973. _this._highligherOpacity = 0.4;
  6974. _this._highlightedText = "";
  6975. _this._startHighlightIndex = 0;
  6976. _this._endHighlightIndex = 0;
  6977. _this._cursorIndex = -1;
  6978. _this._onFocusSelectAll = false;
  6979. _this._isPointerDown = false;
  6980. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6981. _this.promptMessage = "Please enter text:";
  6982. /** Force disable prompt on mobile device */
  6983. _this.disableMobilePrompt = false;
  6984. /** Observable raised when the text changes */
  6985. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6986. /** Observable raised just before an entered character is to be added */
  6987. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6988. /** Observable raised when the control gets the focus */
  6989. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6990. /** Observable raised when the control loses the focus */
  6991. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6992. /**Observable raised when the text is highlighted */
  6993. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6994. /**Observable raised when copy event is triggered */
  6995. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6996. /** Observable raised when cut event is triggered */
  6997. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6998. /** Observable raised when paste event is triggered */
  6999. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7000. /** Observable raised when a key event was processed */
  7001. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7002. _this.text = text;
  7003. _this.isPointerBlocker = true;
  7004. return _this;
  7005. }
  7006. Object.defineProperty(InputText.prototype, "maxWidth", {
  7007. /** Gets or sets the maximum width allowed by the control */
  7008. get: function () {
  7009. return this._maxWidth.toString(this._host);
  7010. },
  7011. set: function (value) {
  7012. if (this._maxWidth.toString(this._host) === value) {
  7013. return;
  7014. }
  7015. if (this._maxWidth.fromString(value)) {
  7016. this._markAsDirty();
  7017. }
  7018. },
  7019. enumerable: true,
  7020. configurable: true
  7021. });
  7022. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7023. /** Gets the maximum width allowed by the control in pixels */
  7024. get: function () {
  7025. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7026. },
  7027. enumerable: true,
  7028. configurable: true
  7029. });
  7030. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7031. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7032. get: function () {
  7033. return this._highligherOpacity;
  7034. },
  7035. set: function (value) {
  7036. if (this._highligherOpacity === value) {
  7037. return;
  7038. }
  7039. this._highligherOpacity = value;
  7040. this._markAsDirty();
  7041. },
  7042. enumerable: true,
  7043. configurable: true
  7044. });
  7045. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7046. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7047. get: function () {
  7048. return this._onFocusSelectAll;
  7049. },
  7050. set: function (value) {
  7051. if (this._onFocusSelectAll === value) {
  7052. return;
  7053. }
  7054. this._onFocusSelectAll = value;
  7055. this._markAsDirty();
  7056. },
  7057. enumerable: true,
  7058. configurable: true
  7059. });
  7060. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7061. /** Gets or sets the text hightlight color */
  7062. get: function () {
  7063. return this._textHighlightColor;
  7064. },
  7065. set: function (value) {
  7066. if (this._textHighlightColor === value) {
  7067. return;
  7068. }
  7069. this._textHighlightColor = value;
  7070. this._markAsDirty();
  7071. },
  7072. enumerable: true,
  7073. configurable: true
  7074. });
  7075. Object.defineProperty(InputText.prototype, "margin", {
  7076. /** Gets or sets control margin */
  7077. get: function () {
  7078. return this._margin.toString(this._host);
  7079. },
  7080. set: function (value) {
  7081. if (this._margin.toString(this._host) === value) {
  7082. return;
  7083. }
  7084. if (this._margin.fromString(value)) {
  7085. this._markAsDirty();
  7086. }
  7087. },
  7088. enumerable: true,
  7089. configurable: true
  7090. });
  7091. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7092. /** Gets control margin in pixels */
  7093. get: function () {
  7094. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7095. },
  7096. enumerable: true,
  7097. configurable: true
  7098. });
  7099. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7100. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7101. get: function () {
  7102. return this._autoStretchWidth;
  7103. },
  7104. set: function (value) {
  7105. if (this._autoStretchWidth === value) {
  7106. return;
  7107. }
  7108. this._autoStretchWidth = value;
  7109. this._markAsDirty();
  7110. },
  7111. enumerable: true,
  7112. configurable: true
  7113. });
  7114. Object.defineProperty(InputText.prototype, "thickness", {
  7115. /** Gets or sets border thickness */
  7116. get: function () {
  7117. return this._thickness;
  7118. },
  7119. set: function (value) {
  7120. if (this._thickness === value) {
  7121. return;
  7122. }
  7123. this._thickness = value;
  7124. this._markAsDirty();
  7125. },
  7126. enumerable: true,
  7127. configurable: true
  7128. });
  7129. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7130. /** Gets or sets the background color when focused */
  7131. get: function () {
  7132. return this._focusedBackground;
  7133. },
  7134. set: function (value) {
  7135. if (this._focusedBackground === value) {
  7136. return;
  7137. }
  7138. this._focusedBackground = value;
  7139. this._markAsDirty();
  7140. },
  7141. enumerable: true,
  7142. configurable: true
  7143. });
  7144. Object.defineProperty(InputText.prototype, "focusedColor", {
  7145. /** Gets or sets the background color when focused */
  7146. get: function () {
  7147. return this._focusedColor;
  7148. },
  7149. set: function (value) {
  7150. if (this._focusedColor === value) {
  7151. return;
  7152. }
  7153. this._focusedColor = value;
  7154. this._markAsDirty();
  7155. },
  7156. enumerable: true,
  7157. configurable: true
  7158. });
  7159. Object.defineProperty(InputText.prototype, "background", {
  7160. /** Gets or sets the background color */
  7161. get: function () {
  7162. return this._background;
  7163. },
  7164. set: function (value) {
  7165. if (this._background === value) {
  7166. return;
  7167. }
  7168. this._background = value;
  7169. this._markAsDirty();
  7170. },
  7171. enumerable: true,
  7172. configurable: true
  7173. });
  7174. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7175. /** Gets or sets the placeholder color */
  7176. get: function () {
  7177. return this._placeholderColor;
  7178. },
  7179. set: function (value) {
  7180. if (this._placeholderColor === value) {
  7181. return;
  7182. }
  7183. this._placeholderColor = value;
  7184. this._markAsDirty();
  7185. },
  7186. enumerable: true,
  7187. configurable: true
  7188. });
  7189. Object.defineProperty(InputText.prototype, "placeholderText", {
  7190. /** Gets or sets the text displayed when the control is empty */
  7191. get: function () {
  7192. return this._placeholderText;
  7193. },
  7194. set: function (value) {
  7195. if (this._placeholderText === value) {
  7196. return;
  7197. }
  7198. this._placeholderText = value;
  7199. this._markAsDirty();
  7200. },
  7201. enumerable: true,
  7202. configurable: true
  7203. });
  7204. Object.defineProperty(InputText.prototype, "deadKey", {
  7205. /** Gets or sets the dead key flag */
  7206. get: function () {
  7207. return this._deadKey;
  7208. },
  7209. set: function (flag) {
  7210. this._deadKey = flag;
  7211. },
  7212. enumerable: true,
  7213. configurable: true
  7214. });
  7215. Object.defineProperty(InputText.prototype, "highlightedText", {
  7216. /** Gets or sets the highlight text */
  7217. get: function () {
  7218. return this._highlightedText;
  7219. },
  7220. set: function (text) {
  7221. if (this._highlightedText === text) {
  7222. return;
  7223. }
  7224. this._highlightedText = text;
  7225. this._markAsDirty();
  7226. },
  7227. enumerable: true,
  7228. configurable: true
  7229. });
  7230. Object.defineProperty(InputText.prototype, "addKey", {
  7231. /** Gets or sets if the current key should be added */
  7232. get: function () {
  7233. return this._addKey;
  7234. },
  7235. set: function (flag) {
  7236. this._addKey = flag;
  7237. },
  7238. enumerable: true,
  7239. configurable: true
  7240. });
  7241. Object.defineProperty(InputText.prototype, "currentKey", {
  7242. /** Gets or sets the value of the current key being entered */
  7243. get: function () {
  7244. return this._currentKey;
  7245. },
  7246. set: function (key) {
  7247. this._currentKey = key;
  7248. },
  7249. enumerable: true,
  7250. configurable: true
  7251. });
  7252. Object.defineProperty(InputText.prototype, "text", {
  7253. /** Gets or sets the text displayed in the control */
  7254. get: function () {
  7255. return this._text;
  7256. },
  7257. set: function (value) {
  7258. var valueAsString = value.toString(); // Forcing convertion
  7259. if (this._text === valueAsString) {
  7260. return;
  7261. }
  7262. this._text = valueAsString;
  7263. this._markAsDirty();
  7264. this.onTextChangedObservable.notifyObservers(this);
  7265. },
  7266. enumerable: true,
  7267. configurable: true
  7268. });
  7269. Object.defineProperty(InputText.prototype, "width", {
  7270. /** Gets or sets control width */
  7271. get: function () {
  7272. return this._width.toString(this._host);
  7273. },
  7274. set: function (value) {
  7275. if (this._width.toString(this._host) === value) {
  7276. return;
  7277. }
  7278. if (this._width.fromString(value)) {
  7279. this._markAsDirty();
  7280. }
  7281. this.autoStretchWidth = false;
  7282. },
  7283. enumerable: true,
  7284. configurable: true
  7285. });
  7286. /** @hidden */
  7287. InputText.prototype.onBlur = function () {
  7288. this._isFocused = false;
  7289. this._scrollLeft = null;
  7290. this._cursorOffset = 0;
  7291. clearTimeout(this._blinkTimeout);
  7292. this._markAsDirty();
  7293. this.onBlurObservable.notifyObservers(this);
  7294. this._host.unRegisterClipboardEvents();
  7295. if (this._onClipboardObserver) {
  7296. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7297. }
  7298. var scene = this._host.getScene();
  7299. if (this._onPointerDblTapObserver && scene) {
  7300. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7301. }
  7302. };
  7303. /** @hidden */
  7304. InputText.prototype.onFocus = function () {
  7305. var _this = this;
  7306. if (!this._isEnabled) {
  7307. return;
  7308. }
  7309. this._scrollLeft = null;
  7310. this._isFocused = true;
  7311. this._blinkIsEven = false;
  7312. this._cursorOffset = 0;
  7313. this._markAsDirty();
  7314. this.onFocusObservable.notifyObservers(this);
  7315. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7316. var value = prompt(this.promptMessage);
  7317. if (value !== null) {
  7318. this.text = value;
  7319. }
  7320. this._host.focusedControl = null;
  7321. return;
  7322. }
  7323. this._host.registerClipboardEvents();
  7324. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7325. // process clipboard event, can be configured.
  7326. switch (clipboardInfo.type) {
  7327. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7328. _this._onCopyText(clipboardInfo.event);
  7329. _this.onTextCopyObservable.notifyObservers(_this);
  7330. break;
  7331. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7332. _this._onCutText(clipboardInfo.event);
  7333. _this.onTextCutObservable.notifyObservers(_this);
  7334. break;
  7335. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7336. _this._onPasteText(clipboardInfo.event);
  7337. _this.onTextPasteObservable.notifyObservers(_this);
  7338. break;
  7339. default: return;
  7340. }
  7341. });
  7342. var scene = this._host.getScene();
  7343. if (scene) {
  7344. //register the pointer double tap event
  7345. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7346. if (!_this._isFocused) {
  7347. return;
  7348. }
  7349. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7350. _this._processDblClick(pointerInfo);
  7351. }
  7352. });
  7353. }
  7354. if (this._onFocusSelectAll) {
  7355. this._selectAllText();
  7356. }
  7357. };
  7358. InputText.prototype._getTypeName = function () {
  7359. return "InputText";
  7360. };
  7361. /**
  7362. * Function called to get the list of controls that should not steal the focus from this control
  7363. * @returns an array of controls
  7364. */
  7365. InputText.prototype.keepsFocusWith = function () {
  7366. if (!this._connectedVirtualKeyboard) {
  7367. return null;
  7368. }
  7369. return [this._connectedVirtualKeyboard];
  7370. };
  7371. /** @hidden */
  7372. InputText.prototype.processKey = function (keyCode, key, evt) {
  7373. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7374. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7375. return;
  7376. }
  7377. //select all
  7378. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7379. this._selectAllText();
  7380. evt.preventDefault();
  7381. return;
  7382. }
  7383. // Specific cases
  7384. switch (keyCode) {
  7385. case 32: //SPACE
  7386. key = " "; //ie11 key for space is "Spacebar"
  7387. break;
  7388. case 191: //SLASH
  7389. if (evt) {
  7390. evt.preventDefault();
  7391. }
  7392. break;
  7393. case 8: // BACKSPACE
  7394. if (this._text && this._text.length > 0) {
  7395. //delete the highlighted text
  7396. if (this._isTextHighlightOn) {
  7397. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7398. this._isTextHighlightOn = false;
  7399. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7400. this._blinkIsEven = false;
  7401. if (evt) {
  7402. evt.preventDefault();
  7403. }
  7404. return;
  7405. }
  7406. //delete single character
  7407. if (this._cursorOffset === 0) {
  7408. this.text = this._text.substr(0, this._text.length - 1);
  7409. }
  7410. else {
  7411. var deletePosition = this._text.length - this._cursorOffset;
  7412. if (deletePosition > 0) {
  7413. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7414. }
  7415. }
  7416. }
  7417. if (evt) {
  7418. evt.preventDefault();
  7419. }
  7420. return;
  7421. case 46: // DELETE
  7422. if (this._isTextHighlightOn) {
  7423. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7424. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7425. while (decrementor > 0 && this._cursorOffset > 0) {
  7426. this._cursorOffset--;
  7427. }
  7428. this._isTextHighlightOn = false;
  7429. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7430. if (evt) {
  7431. evt.preventDefault();
  7432. }
  7433. return;
  7434. }
  7435. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7436. var deletePosition = this._text.length - this._cursorOffset;
  7437. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7438. this._cursorOffset--;
  7439. }
  7440. if (evt) {
  7441. evt.preventDefault();
  7442. }
  7443. return;
  7444. case 13: // RETURN
  7445. this._host.focusedControl = null;
  7446. this._isTextHighlightOn = false;
  7447. return;
  7448. case 35: // END
  7449. this._cursorOffset = 0;
  7450. this._blinkIsEven = false;
  7451. this._isTextHighlightOn = false;
  7452. this._markAsDirty();
  7453. return;
  7454. case 36: // HOME
  7455. this._cursorOffset = this._text.length;
  7456. this._blinkIsEven = false;
  7457. this._isTextHighlightOn = false;
  7458. this._markAsDirty();
  7459. return;
  7460. case 37: // LEFT
  7461. this._cursorOffset++;
  7462. if (this._cursorOffset > this._text.length) {
  7463. this._cursorOffset = this._text.length;
  7464. }
  7465. if (evt && evt.shiftKey) {
  7466. // update the cursor
  7467. this._blinkIsEven = false;
  7468. // shift + ctrl/cmd + <-
  7469. if (evt.ctrlKey || evt.metaKey) {
  7470. if (!this._isTextHighlightOn) {
  7471. if (this._text.length === this._cursorOffset) {
  7472. return;
  7473. }
  7474. else {
  7475. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7476. }
  7477. }
  7478. this._startHighlightIndex = 0;
  7479. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7480. this._cursorOffset = this._text.length;
  7481. this._isTextHighlightOn = true;
  7482. this._markAsDirty();
  7483. return;
  7484. }
  7485. //store the starting point
  7486. if (!this._isTextHighlightOn) {
  7487. this._isTextHighlightOn = true;
  7488. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7489. }
  7490. //if text is already highlighted
  7491. else if (this._cursorIndex === -1) {
  7492. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7493. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7494. }
  7495. //set the highlight indexes
  7496. if (this._cursorIndex < this._cursorOffset) {
  7497. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7498. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7499. }
  7500. else if (this._cursorIndex > this._cursorOffset) {
  7501. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7502. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7503. }
  7504. else {
  7505. this._isTextHighlightOn = false;
  7506. }
  7507. this._markAsDirty();
  7508. return;
  7509. }
  7510. if (this._isTextHighlightOn) {
  7511. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7512. this._isTextHighlightOn = false;
  7513. }
  7514. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7515. this._cursorOffset = this.text.length;
  7516. evt.preventDefault();
  7517. }
  7518. this._blinkIsEven = false;
  7519. this._isTextHighlightOn = false;
  7520. this._cursorIndex = -1;
  7521. this._markAsDirty();
  7522. return;
  7523. case 39: // RIGHT
  7524. this._cursorOffset--;
  7525. if (this._cursorOffset < 0) {
  7526. this._cursorOffset = 0;
  7527. }
  7528. if (evt && evt.shiftKey) {
  7529. //update the cursor
  7530. this._blinkIsEven = false;
  7531. //shift + ctrl/cmd + ->
  7532. if (evt.ctrlKey || evt.metaKey) {
  7533. if (!this._isTextHighlightOn) {
  7534. if (this._cursorOffset === 0) {
  7535. return;
  7536. }
  7537. else {
  7538. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7539. }
  7540. }
  7541. this._endHighlightIndex = this._text.length;
  7542. this._isTextHighlightOn = true;
  7543. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7544. this._cursorOffset = 0;
  7545. this._markAsDirty();
  7546. return;
  7547. }
  7548. if (!this._isTextHighlightOn) {
  7549. this._isTextHighlightOn = true;
  7550. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7551. }
  7552. //if text is already highlighted
  7553. else if (this._cursorIndex === -1) {
  7554. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7555. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7556. }
  7557. //set the highlight indexes
  7558. if (this._cursorIndex < this._cursorOffset) {
  7559. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7560. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7561. }
  7562. else if (this._cursorIndex > this._cursorOffset) {
  7563. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7564. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7565. }
  7566. else {
  7567. this._isTextHighlightOn = false;
  7568. }
  7569. this._markAsDirty();
  7570. return;
  7571. }
  7572. if (this._isTextHighlightOn) {
  7573. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7574. this._isTextHighlightOn = false;
  7575. }
  7576. //ctr + ->
  7577. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7578. this._cursorOffset = 0;
  7579. evt.preventDefault();
  7580. }
  7581. this._blinkIsEven = false;
  7582. this._isTextHighlightOn = false;
  7583. this._cursorIndex = -1;
  7584. this._markAsDirty();
  7585. return;
  7586. case 222: // Dead
  7587. if (evt) {
  7588. evt.preventDefault();
  7589. }
  7590. this._cursorIndex = -1;
  7591. this.deadKey = true;
  7592. break;
  7593. }
  7594. // Printable characters
  7595. if (key &&
  7596. ((keyCode === -1) || // Direct access
  7597. (keyCode === 32) || // Space
  7598. (keyCode > 47 && keyCode < 64) || // Numbers
  7599. (keyCode > 64 && keyCode < 91) || // Letters
  7600. (keyCode > 159 && keyCode < 193) || // Special characters
  7601. (keyCode > 218 && keyCode < 223) || // Special characters
  7602. (keyCode > 95 && keyCode < 112))) { // Numpad
  7603. this._currentKey = key;
  7604. this.onBeforeKeyAddObservable.notifyObservers(this);
  7605. key = this._currentKey;
  7606. if (this._addKey) {
  7607. if (this._isTextHighlightOn) {
  7608. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7609. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7610. this._isTextHighlightOn = false;
  7611. this._blinkIsEven = false;
  7612. this._markAsDirty();
  7613. }
  7614. else if (this._cursorOffset === 0) {
  7615. this.text += key;
  7616. }
  7617. else {
  7618. var insertPosition = this._text.length - this._cursorOffset;
  7619. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7620. }
  7621. }
  7622. }
  7623. };
  7624. /** @hidden */
  7625. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7626. //update the cursor
  7627. this._blinkIsEven = false;
  7628. if (this._cursorIndex === -1) {
  7629. this._cursorIndex = offset;
  7630. }
  7631. else {
  7632. if (this._cursorIndex < this._cursorOffset) {
  7633. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7634. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7635. }
  7636. else if (this._cursorIndex > this._cursorOffset) {
  7637. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7638. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7639. }
  7640. else {
  7641. this._isTextHighlightOn = false;
  7642. this._markAsDirty();
  7643. return;
  7644. }
  7645. }
  7646. this._isTextHighlightOn = true;
  7647. this._markAsDirty();
  7648. };
  7649. /** @hidden */
  7650. InputText.prototype._processDblClick = function (evt) {
  7651. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7652. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7653. this._endHighlightIndex = this._startHighlightIndex;
  7654. var rWord = /\w+/g, moveLeft, moveRight;
  7655. do {
  7656. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7657. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7658. } while (moveLeft || moveRight);
  7659. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7660. this.onTextHighlightObservable.notifyObservers(this);
  7661. this._isTextHighlightOn = true;
  7662. this._clickedCoordinate = null;
  7663. this._blinkIsEven = true;
  7664. this._cursorIndex = -1;
  7665. this._markAsDirty();
  7666. };
  7667. /** @hidden */
  7668. InputText.prototype._selectAllText = function () {
  7669. this._blinkIsEven = true;
  7670. this._isTextHighlightOn = true;
  7671. this._startHighlightIndex = 0;
  7672. this._endHighlightIndex = this._text.length;
  7673. this._cursorOffset = this._text.length;
  7674. this._cursorIndex = -1;
  7675. this._markAsDirty();
  7676. };
  7677. /**
  7678. * Handles the keyboard event
  7679. * @param evt Defines the KeyboardEvent
  7680. */
  7681. InputText.prototype.processKeyboard = function (evt) {
  7682. // process pressed key
  7683. this.processKey(evt.keyCode, evt.key, evt);
  7684. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7685. };
  7686. /** @hidden */
  7687. InputText.prototype._onCopyText = function (ev) {
  7688. this._isTextHighlightOn = false;
  7689. //when write permission to clipbaord data is denied
  7690. try {
  7691. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7692. }
  7693. catch (_a) { } //pass
  7694. this._host.clipboardData = this._highlightedText;
  7695. };
  7696. /** @hidden */
  7697. InputText.prototype._onCutText = function (ev) {
  7698. if (!this._highlightedText) {
  7699. return;
  7700. }
  7701. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7702. this._isTextHighlightOn = false;
  7703. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7704. //when write permission to clipbaord data is denied
  7705. try {
  7706. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7707. }
  7708. catch (_a) { } //pass
  7709. this._host.clipboardData = this._highlightedText;
  7710. this._highlightedText = "";
  7711. };
  7712. /** @hidden */
  7713. InputText.prototype._onPasteText = function (ev) {
  7714. var data = "";
  7715. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7716. data = ev.clipboardData.getData("text/plain");
  7717. }
  7718. else {
  7719. //get the cached data; returns blank string by default
  7720. data = this._host.clipboardData;
  7721. }
  7722. var insertPosition = this._text.length - this._cursorOffset;
  7723. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7724. };
  7725. InputText.prototype._draw = function (context, invalidatedRectangle) {
  7726. var _this = this;
  7727. context.save();
  7728. this._applyStates(context);
  7729. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7730. context.shadowColor = this.shadowColor;
  7731. context.shadowBlur = this.shadowBlur;
  7732. context.shadowOffsetX = this.shadowOffsetX;
  7733. context.shadowOffsetY = this.shadowOffsetY;
  7734. }
  7735. // Background
  7736. if (this._isFocused) {
  7737. if (this._focusedBackground) {
  7738. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7739. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7740. }
  7741. }
  7742. else if (this._background) {
  7743. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7744. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7745. }
  7746. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7747. context.shadowBlur = 0;
  7748. context.shadowOffsetX = 0;
  7749. context.shadowOffsetY = 0;
  7750. }
  7751. if (!this._fontOffset) {
  7752. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7753. }
  7754. // Text
  7755. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7756. if (this.color) {
  7757. context.fillStyle = this.color;
  7758. }
  7759. var text = this._beforeRenderText(this._text);
  7760. if (!this._isFocused && !this._text && this._placeholderText) {
  7761. text = this._placeholderText;
  7762. if (this._placeholderColor) {
  7763. context.fillStyle = this._placeholderColor;
  7764. }
  7765. }
  7766. this._textWidth = context.measureText(text).width;
  7767. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7768. if (this._autoStretchWidth) {
  7769. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7770. }
  7771. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7772. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7773. context.save();
  7774. context.beginPath();
  7775. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7776. context.clip();
  7777. if (this._isFocused && this._textWidth > availableWidth) {
  7778. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7779. if (!this._scrollLeft) {
  7780. this._scrollLeft = textLeft;
  7781. }
  7782. }
  7783. else {
  7784. this._scrollLeft = clipTextLeft;
  7785. }
  7786. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7787. // Cursor
  7788. if (this._isFocused) {
  7789. // Need to move cursor
  7790. if (this._clickedCoordinate) {
  7791. var rightPosition = this._scrollLeft + this._textWidth;
  7792. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7793. var currentSize = 0;
  7794. this._cursorOffset = 0;
  7795. var previousDist = 0;
  7796. do {
  7797. if (this._cursorOffset) {
  7798. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7799. }
  7800. this._cursorOffset++;
  7801. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7802. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7803. // Find closest move
  7804. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7805. this._cursorOffset--;
  7806. }
  7807. this._blinkIsEven = false;
  7808. this._clickedCoordinate = null;
  7809. }
  7810. // Render cursor
  7811. if (!this._blinkIsEven) {
  7812. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7813. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7814. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7815. if (cursorLeft < clipTextLeft) {
  7816. this._scrollLeft += (clipTextLeft - cursorLeft);
  7817. cursorLeft = clipTextLeft;
  7818. this._markAsDirty();
  7819. }
  7820. else if (cursorLeft > clipTextLeft + availableWidth) {
  7821. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7822. cursorLeft = clipTextLeft + availableWidth;
  7823. this._markAsDirty();
  7824. }
  7825. if (!this._isTextHighlightOn) {
  7826. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7827. }
  7828. }
  7829. clearTimeout(this._blinkTimeout);
  7830. this._blinkTimeout = setTimeout(function () {
  7831. _this._blinkIsEven = !_this._blinkIsEven;
  7832. _this._markAsDirty();
  7833. }, 500);
  7834. //show the highlighted text
  7835. if (this._isTextHighlightOn) {
  7836. clearTimeout(this._blinkTimeout);
  7837. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7838. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7839. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7840. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7841. if (highlightCursorLeft < clipTextLeft) {
  7842. width = width - (clipTextLeft - highlightCursorLeft);
  7843. if (!width) {
  7844. // when using left arrow on text.length > availableWidth;
  7845. // assigns the width of the first letter after clipTextLeft
  7846. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7847. }
  7848. highlightCursorLeft = clipTextLeft;
  7849. }
  7850. //for transparancy
  7851. context.globalAlpha = this._highligherOpacity;
  7852. context.fillStyle = this._textHighlightColor;
  7853. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7854. context.globalAlpha = 1.0;
  7855. }
  7856. }
  7857. context.restore();
  7858. // Border
  7859. if (this._thickness) {
  7860. if (this._isFocused) {
  7861. if (this.focusedColor) {
  7862. context.strokeStyle = this.focusedColor;
  7863. }
  7864. }
  7865. else {
  7866. if (this.color) {
  7867. context.strokeStyle = this.color;
  7868. }
  7869. }
  7870. context.lineWidth = this._thickness;
  7871. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7872. }
  7873. context.restore();
  7874. };
  7875. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7876. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7877. return false;
  7878. }
  7879. this._clickedCoordinate = coordinates.x;
  7880. this._isTextHighlightOn = false;
  7881. this._highlightedText = "";
  7882. this._cursorIndex = -1;
  7883. this._isPointerDown = true;
  7884. this._host._capturingControl[pointerId] = this;
  7885. if (this._host.focusedControl === this) {
  7886. // Move cursor
  7887. clearTimeout(this._blinkTimeout);
  7888. this._markAsDirty();
  7889. return true;
  7890. }
  7891. if (!this._isEnabled) {
  7892. return false;
  7893. }
  7894. this._host.focusedControl = this;
  7895. return true;
  7896. };
  7897. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7898. if (this._host.focusedControl === this && this._isPointerDown) {
  7899. this._clickedCoordinate = coordinates.x;
  7900. this._markAsDirty();
  7901. this._updateValueFromCursorIndex(this._cursorOffset);
  7902. }
  7903. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7904. };
  7905. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7906. this._isPointerDown = false;
  7907. delete this._host._capturingControl[pointerId];
  7908. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7909. };
  7910. InputText.prototype._beforeRenderText = function (text) {
  7911. return text;
  7912. };
  7913. InputText.prototype.dispose = function () {
  7914. _super.prototype.dispose.call(this);
  7915. this.onBlurObservable.clear();
  7916. this.onFocusObservable.clear();
  7917. this.onTextChangedObservable.clear();
  7918. this.onTextCopyObservable.clear();
  7919. this.onTextCutObservable.clear();
  7920. this.onTextPasteObservable.clear();
  7921. this.onTextHighlightObservable.clear();
  7922. this.onKeyboardEventProcessedObservable.clear();
  7923. };
  7924. return InputText;
  7925. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7926. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  7927. /***/ }),
  7928. /***/ "./2D/controls/line.ts":
  7929. /*!*****************************!*\
  7930. !*** ./2D/controls/line.ts ***!
  7931. \*****************************/
  7932. /*! exports provided: Line */
  7933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7934. "use strict";
  7935. __webpack_require__.r(__webpack_exports__);
  7936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7937. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7938. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  7939. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7940. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7941. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7942. /** Class used to render 2D lines */
  7943. var Line = /** @class */ (function (_super) {
  7944. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  7945. /**
  7946. * Creates a new Line
  7947. * @param name defines the control name
  7948. */
  7949. function Line(name) {
  7950. var _this = _super.call(this, name) || this;
  7951. _this.name = name;
  7952. _this._lineWidth = 1;
  7953. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7954. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7955. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7956. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7957. _this._dash = new Array();
  7958. _this.isHitTestVisible = false;
  7959. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7960. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7961. return _this;
  7962. }
  7963. Object.defineProperty(Line.prototype, "dash", {
  7964. /** Gets or sets the dash pattern */
  7965. get: function () {
  7966. return this._dash;
  7967. },
  7968. set: function (value) {
  7969. if (this._dash === value) {
  7970. return;
  7971. }
  7972. this._dash = value;
  7973. this._markAsDirty();
  7974. },
  7975. enumerable: true,
  7976. configurable: true
  7977. });
  7978. Object.defineProperty(Line.prototype, "connectedControl", {
  7979. /** Gets or sets the control connected with the line end */
  7980. get: function () {
  7981. return this._connectedControl;
  7982. },
  7983. set: function (value) {
  7984. var _this = this;
  7985. if (this._connectedControl === value) {
  7986. return;
  7987. }
  7988. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7989. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7990. this._connectedControlDirtyObserver = null;
  7991. }
  7992. if (value) {
  7993. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7994. }
  7995. this._connectedControl = value;
  7996. this._markAsDirty();
  7997. },
  7998. enumerable: true,
  7999. configurable: true
  8000. });
  8001. Object.defineProperty(Line.prototype, "x1", {
  8002. /** Gets or sets start coordinates on X axis */
  8003. get: function () {
  8004. return this._x1.toString(this._host);
  8005. },
  8006. set: function (value) {
  8007. if (this._x1.toString(this._host) === value) {
  8008. return;
  8009. }
  8010. if (this._x1.fromString(value)) {
  8011. this._markAsDirty();
  8012. }
  8013. },
  8014. enumerable: true,
  8015. configurable: true
  8016. });
  8017. Object.defineProperty(Line.prototype, "y1", {
  8018. /** Gets or sets start coordinates on Y axis */
  8019. get: function () {
  8020. return this._y1.toString(this._host);
  8021. },
  8022. set: function (value) {
  8023. if (this._y1.toString(this._host) === value) {
  8024. return;
  8025. }
  8026. if (this._y1.fromString(value)) {
  8027. this._markAsDirty();
  8028. }
  8029. },
  8030. enumerable: true,
  8031. configurable: true
  8032. });
  8033. Object.defineProperty(Line.prototype, "x2", {
  8034. /** Gets or sets end coordinates on X axis */
  8035. get: function () {
  8036. return this._x2.toString(this._host);
  8037. },
  8038. set: function (value) {
  8039. if (this._x2.toString(this._host) === value) {
  8040. return;
  8041. }
  8042. if (this._x2.fromString(value)) {
  8043. this._markAsDirty();
  8044. }
  8045. },
  8046. enumerable: true,
  8047. configurable: true
  8048. });
  8049. Object.defineProperty(Line.prototype, "y2", {
  8050. /** Gets or sets end coordinates on Y axis */
  8051. get: function () {
  8052. return this._y2.toString(this._host);
  8053. },
  8054. set: function (value) {
  8055. if (this._y2.toString(this._host) === value) {
  8056. return;
  8057. }
  8058. if (this._y2.fromString(value)) {
  8059. this._markAsDirty();
  8060. }
  8061. },
  8062. enumerable: true,
  8063. configurable: true
  8064. });
  8065. Object.defineProperty(Line.prototype, "lineWidth", {
  8066. /** Gets or sets line width */
  8067. get: function () {
  8068. return this._lineWidth;
  8069. },
  8070. set: function (value) {
  8071. if (this._lineWidth === value) {
  8072. return;
  8073. }
  8074. this._lineWidth = value;
  8075. this._markAsDirty();
  8076. },
  8077. enumerable: true,
  8078. configurable: true
  8079. });
  8080. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8081. /** Gets or sets horizontal alignment */
  8082. set: function (value) {
  8083. return;
  8084. },
  8085. enumerable: true,
  8086. configurable: true
  8087. });
  8088. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8089. /** Gets or sets vertical alignment */
  8090. set: function (value) {
  8091. return;
  8092. },
  8093. enumerable: true,
  8094. configurable: true
  8095. });
  8096. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8097. get: function () {
  8098. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8099. },
  8100. enumerable: true,
  8101. configurable: true
  8102. });
  8103. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8104. get: function () {
  8105. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8106. },
  8107. enumerable: true,
  8108. configurable: true
  8109. });
  8110. Line.prototype._getTypeName = function () {
  8111. return "Line";
  8112. };
  8113. Line.prototype._draw = function (context) {
  8114. context.save();
  8115. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8116. context.shadowColor = this.shadowColor;
  8117. context.shadowBlur = this.shadowBlur;
  8118. context.shadowOffsetX = this.shadowOffsetX;
  8119. context.shadowOffsetY = this.shadowOffsetY;
  8120. }
  8121. this._applyStates(context);
  8122. context.strokeStyle = this.color;
  8123. context.lineWidth = this._lineWidth;
  8124. context.setLineDash(this._dash);
  8125. context.beginPath();
  8126. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8127. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8128. context.stroke();
  8129. context.restore();
  8130. };
  8131. Line.prototype._measure = function () {
  8132. // Width / Height
  8133. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8134. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8135. };
  8136. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8137. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8138. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8139. };
  8140. /**
  8141. * Move one end of the line given 3D cartesian coordinates.
  8142. * @param position Targeted world position
  8143. * @param scene Scene
  8144. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8145. */
  8146. Line.prototype.moveToVector3 = function (position, scene, end) {
  8147. if (end === void 0) { end = false; }
  8148. if (!this._host || this.parent !== this._host._rootContainer) {
  8149. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8150. return;
  8151. }
  8152. var globalViewport = this._host._getGlobalViewport(scene);
  8153. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8154. this._moveToProjectedPosition(projectedPosition, end);
  8155. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8156. this.notRenderable = true;
  8157. return;
  8158. }
  8159. this.notRenderable = false;
  8160. };
  8161. /**
  8162. * Move one end of the line to a position in screen absolute space.
  8163. * @param projectedPosition Position in screen absolute space (X, Y)
  8164. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8165. */
  8166. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8167. if (end === void 0) { end = false; }
  8168. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8169. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8170. if (end) {
  8171. this.x2 = x;
  8172. this.y2 = y;
  8173. this._x2.ignoreAdaptiveScaling = true;
  8174. this._y2.ignoreAdaptiveScaling = true;
  8175. }
  8176. else {
  8177. this.x1 = x;
  8178. this.y1 = y;
  8179. this._x1.ignoreAdaptiveScaling = true;
  8180. this._y1.ignoreAdaptiveScaling = true;
  8181. }
  8182. };
  8183. return Line;
  8184. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8185. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8186. /***/ }),
  8187. /***/ "./2D/controls/multiLine.ts":
  8188. /*!**********************************!*\
  8189. !*** ./2D/controls/multiLine.ts ***!
  8190. \**********************************/
  8191. /*! exports provided: MultiLine */
  8192. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8193. "use strict";
  8194. __webpack_require__.r(__webpack_exports__);
  8195. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8196. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8197. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/perfCounter");
  8198. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8199. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8200. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8201. /**
  8202. * Class used to create multi line control
  8203. */
  8204. var MultiLine = /** @class */ (function (_super) {
  8205. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8206. /**
  8207. * Creates a new MultiLine
  8208. * @param name defines the control name
  8209. */
  8210. function MultiLine(name) {
  8211. var _this = _super.call(this, name) || this;
  8212. _this.name = name;
  8213. _this._lineWidth = 1;
  8214. /** Function called when a point is updated */
  8215. _this.onPointUpdate = function () {
  8216. _this._markAsDirty();
  8217. };
  8218. _this.isHitTestVisible = false;
  8219. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8220. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8221. _this._dash = [];
  8222. _this._points = [];
  8223. return _this;
  8224. }
  8225. Object.defineProperty(MultiLine.prototype, "dash", {
  8226. /** Gets or sets dash pattern */
  8227. get: function () {
  8228. return this._dash;
  8229. },
  8230. set: function (value) {
  8231. if (this._dash === value) {
  8232. return;
  8233. }
  8234. this._dash = value;
  8235. this._markAsDirty();
  8236. },
  8237. enumerable: true,
  8238. configurable: true
  8239. });
  8240. /**
  8241. * Gets point stored at specified index
  8242. * @param index defines the index to look for
  8243. * @returns the requested point if found
  8244. */
  8245. MultiLine.prototype.getAt = function (index) {
  8246. if (!this._points[index]) {
  8247. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8248. }
  8249. return this._points[index];
  8250. };
  8251. /**
  8252. * Adds new points to the point collection
  8253. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8254. * @returns the list of created MultiLinePoint
  8255. */
  8256. MultiLine.prototype.add = function () {
  8257. var _this = this;
  8258. var items = [];
  8259. for (var _i = 0; _i < arguments.length; _i++) {
  8260. items[_i] = arguments[_i];
  8261. }
  8262. return items.map(function (item) { return _this.push(item); });
  8263. };
  8264. /**
  8265. * Adds a new point to the point collection
  8266. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8267. * @returns the created MultiLinePoint
  8268. */
  8269. MultiLine.prototype.push = function (item) {
  8270. var point = this.getAt(this._points.length);
  8271. if (item == null) {
  8272. return point;
  8273. }
  8274. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8275. point.mesh = item;
  8276. }
  8277. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8278. point.control = item;
  8279. }
  8280. else if (item.x != null && item.y != null) {
  8281. point.x = item.x;
  8282. point.y = item.y;
  8283. }
  8284. return point;
  8285. };
  8286. /**
  8287. * Remove a specific value or point from the active point collection
  8288. * @param value defines the value or point to remove
  8289. */
  8290. MultiLine.prototype.remove = function (value) {
  8291. var index;
  8292. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8293. index = this._points.indexOf(value);
  8294. if (index === -1) {
  8295. return;
  8296. }
  8297. }
  8298. else {
  8299. index = value;
  8300. }
  8301. var point = this._points[index];
  8302. if (!point) {
  8303. return;
  8304. }
  8305. point.dispose();
  8306. this._points.splice(index, 1);
  8307. };
  8308. /**
  8309. * Resets this object to initial state (no point)
  8310. */
  8311. MultiLine.prototype.reset = function () {
  8312. while (this._points.length > 0) {
  8313. this.remove(this._points.length - 1);
  8314. }
  8315. };
  8316. /**
  8317. * Resets all links
  8318. */
  8319. MultiLine.prototype.resetLinks = function () {
  8320. this._points.forEach(function (point) {
  8321. if (point != null) {
  8322. point.resetLinks();
  8323. }
  8324. });
  8325. };
  8326. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8327. /** Gets or sets line width */
  8328. get: function () {
  8329. return this._lineWidth;
  8330. },
  8331. set: function (value) {
  8332. if (this._lineWidth === value) {
  8333. return;
  8334. }
  8335. this._lineWidth = value;
  8336. this._markAsDirty();
  8337. },
  8338. enumerable: true,
  8339. configurable: true
  8340. });
  8341. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8342. set: function (value) {
  8343. return;
  8344. },
  8345. enumerable: true,
  8346. configurable: true
  8347. });
  8348. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8349. set: function (value) {
  8350. return;
  8351. },
  8352. enumerable: true,
  8353. configurable: true
  8354. });
  8355. MultiLine.prototype._getTypeName = function () {
  8356. return "MultiLine";
  8357. };
  8358. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8359. context.save();
  8360. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8361. context.shadowColor = this.shadowColor;
  8362. context.shadowBlur = this.shadowBlur;
  8363. context.shadowOffsetX = this.shadowOffsetX;
  8364. context.shadowOffsetY = this.shadowOffsetY;
  8365. }
  8366. this._applyStates(context);
  8367. context.strokeStyle = this.color;
  8368. context.lineWidth = this._lineWidth;
  8369. context.setLineDash(this._dash);
  8370. context.beginPath();
  8371. var first = true; //first index is not necessarily 0
  8372. this._points.forEach(function (point) {
  8373. if (!point) {
  8374. return;
  8375. }
  8376. if (first) {
  8377. context.moveTo(point._point.x, point._point.y);
  8378. first = false;
  8379. }
  8380. else {
  8381. context.lineTo(point._point.x, point._point.y);
  8382. }
  8383. });
  8384. context.stroke();
  8385. context.restore();
  8386. };
  8387. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8388. var _this = this;
  8389. this._minX = null;
  8390. this._minY = null;
  8391. this._maxX = null;
  8392. this._maxY = null;
  8393. this._points.forEach(function (point, index) {
  8394. if (!point) {
  8395. return;
  8396. }
  8397. point.translate();
  8398. if (_this._minX == null || point._point.x < _this._minX) {
  8399. _this._minX = point._point.x;
  8400. }
  8401. if (_this._minY == null || point._point.y < _this._minY) {
  8402. _this._minY = point._point.y;
  8403. }
  8404. if (_this._maxX == null || point._point.x > _this._maxX) {
  8405. _this._maxX = point._point.x;
  8406. }
  8407. if (_this._maxY == null || point._point.y > _this._maxY) {
  8408. _this._maxY = point._point.y;
  8409. }
  8410. });
  8411. if (this._minX == null) {
  8412. this._minX = 0;
  8413. }
  8414. if (this._minY == null) {
  8415. this._minY = 0;
  8416. }
  8417. if (this._maxX == null) {
  8418. this._maxX = 0;
  8419. }
  8420. if (this._maxY == null) {
  8421. this._maxY = 0;
  8422. }
  8423. };
  8424. MultiLine.prototype._measure = function () {
  8425. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8426. return;
  8427. }
  8428. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8429. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8430. };
  8431. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8432. if (this._minX == null || this._minY == null) {
  8433. return;
  8434. }
  8435. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8436. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8437. };
  8438. MultiLine.prototype.dispose = function () {
  8439. this.reset();
  8440. _super.prototype.dispose.call(this);
  8441. };
  8442. return MultiLine;
  8443. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8444. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8445. /***/ }),
  8446. /***/ "./2D/controls/radioButton.ts":
  8447. /*!************************************!*\
  8448. !*** ./2D/controls/radioButton.ts ***!
  8449. \************************************/
  8450. /*! exports provided: RadioButton */
  8451. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8452. "use strict";
  8453. __webpack_require__.r(__webpack_exports__);
  8454. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8455. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8456. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  8457. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8458. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8459. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8460. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8461. /**
  8462. * Class used to create radio button controls
  8463. */
  8464. var RadioButton = /** @class */ (function (_super) {
  8465. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8466. /**
  8467. * Creates a new RadioButton
  8468. * @param name defines the control name
  8469. */
  8470. function RadioButton(name) {
  8471. var _this = _super.call(this, name) || this;
  8472. _this.name = name;
  8473. _this._isChecked = false;
  8474. _this._background = "black";
  8475. _this._checkSizeRatio = 0.8;
  8476. _this._thickness = 1;
  8477. /** Gets or sets group name */
  8478. _this.group = "";
  8479. /** Observable raised when isChecked is changed */
  8480. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8481. _this.isPointerBlocker = true;
  8482. return _this;
  8483. }
  8484. Object.defineProperty(RadioButton.prototype, "thickness", {
  8485. /** Gets or sets border thickness */
  8486. get: function () {
  8487. return this._thickness;
  8488. },
  8489. set: function (value) {
  8490. if (this._thickness === value) {
  8491. return;
  8492. }
  8493. this._thickness = value;
  8494. this._markAsDirty();
  8495. },
  8496. enumerable: true,
  8497. configurable: true
  8498. });
  8499. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8500. /** Gets or sets a value indicating the ratio between overall size and check size */
  8501. get: function () {
  8502. return this._checkSizeRatio;
  8503. },
  8504. set: function (value) {
  8505. value = Math.max(Math.min(1, value), 0);
  8506. if (this._checkSizeRatio === value) {
  8507. return;
  8508. }
  8509. this._checkSizeRatio = value;
  8510. this._markAsDirty();
  8511. },
  8512. enumerable: true,
  8513. configurable: true
  8514. });
  8515. Object.defineProperty(RadioButton.prototype, "background", {
  8516. /** Gets or sets background color */
  8517. get: function () {
  8518. return this._background;
  8519. },
  8520. set: function (value) {
  8521. if (this._background === value) {
  8522. return;
  8523. }
  8524. this._background = value;
  8525. this._markAsDirty();
  8526. },
  8527. enumerable: true,
  8528. configurable: true
  8529. });
  8530. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8531. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8532. get: function () {
  8533. return this._isChecked;
  8534. },
  8535. set: function (value) {
  8536. var _this = this;
  8537. if (this._isChecked === value) {
  8538. return;
  8539. }
  8540. this._isChecked = value;
  8541. this._markAsDirty();
  8542. this.onIsCheckedChangedObservable.notifyObservers(value);
  8543. if (this._isChecked && this._host) {
  8544. // Update all controls from same group
  8545. this._host.executeOnAllControls(function (control) {
  8546. if (control === _this) {
  8547. return;
  8548. }
  8549. if (control.group === undefined) {
  8550. return;
  8551. }
  8552. var childRadio = control;
  8553. if (childRadio.group === _this.group) {
  8554. childRadio.isChecked = false;
  8555. }
  8556. });
  8557. }
  8558. },
  8559. enumerable: true,
  8560. configurable: true
  8561. });
  8562. RadioButton.prototype._getTypeName = function () {
  8563. return "RadioButton";
  8564. };
  8565. RadioButton.prototype._draw = function (context) {
  8566. context.save();
  8567. this._applyStates(context);
  8568. var actualWidth = this._currentMeasure.width - this._thickness;
  8569. var actualHeight = this._currentMeasure.height - this._thickness;
  8570. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8571. context.shadowColor = this.shadowColor;
  8572. context.shadowBlur = this.shadowBlur;
  8573. context.shadowOffsetX = this.shadowOffsetX;
  8574. context.shadowOffsetY = this.shadowOffsetY;
  8575. }
  8576. // Outer
  8577. _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);
  8578. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8579. context.fill();
  8580. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8581. context.shadowBlur = 0;
  8582. context.shadowOffsetX = 0;
  8583. context.shadowOffsetY = 0;
  8584. }
  8585. context.strokeStyle = this.color;
  8586. context.lineWidth = this._thickness;
  8587. context.stroke();
  8588. // Inner
  8589. if (this._isChecked) {
  8590. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8591. var offsetWidth = actualWidth * this._checkSizeRatio;
  8592. var offseHeight = actualHeight * this._checkSizeRatio;
  8593. _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);
  8594. context.fill();
  8595. }
  8596. context.restore();
  8597. };
  8598. // Events
  8599. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8600. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8601. return false;
  8602. }
  8603. if (!this.isChecked) {
  8604. this.isChecked = true;
  8605. }
  8606. return true;
  8607. };
  8608. /**
  8609. * Utility function to easily create a radio button with a header
  8610. * @param title defines the label to use for the header
  8611. * @param group defines the group to use for the radio button
  8612. * @param isChecked defines the initial state of the radio button
  8613. * @param onValueChanged defines the callback to call when value changes
  8614. * @returns a StackPanel containing the radio button and a textBlock
  8615. */
  8616. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8617. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8618. panel.isVertical = false;
  8619. panel.height = "30px";
  8620. var radio = new RadioButton();
  8621. radio.width = "20px";
  8622. radio.height = "20px";
  8623. radio.isChecked = isChecked;
  8624. radio.color = "green";
  8625. radio.group = group;
  8626. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8627. panel.addControl(radio);
  8628. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8629. header.text = title;
  8630. header.width = "180px";
  8631. header.paddingLeft = "5px";
  8632. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8633. header.color = "white";
  8634. panel.addControl(header);
  8635. return panel;
  8636. };
  8637. return RadioButton;
  8638. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8639. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8640. /***/ }),
  8641. /***/ "./2D/controls/rectangle.ts":
  8642. /*!**********************************!*\
  8643. !*** ./2D/controls/rectangle.ts ***!
  8644. \**********************************/
  8645. /*! exports provided: Rectangle */
  8646. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8647. "use strict";
  8648. __webpack_require__.r(__webpack_exports__);
  8649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8650. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8651. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8652. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  8653. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8654. /** Class used to create rectangle container */
  8655. var Rectangle = /** @class */ (function (_super) {
  8656. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8657. /**
  8658. * Creates a new Rectangle
  8659. * @param name defines the control name
  8660. */
  8661. function Rectangle(name) {
  8662. var _this = _super.call(this, name) || this;
  8663. _this.name = name;
  8664. _this._thickness = 1;
  8665. _this._cornerRadius = 0;
  8666. return _this;
  8667. }
  8668. Object.defineProperty(Rectangle.prototype, "thickness", {
  8669. /** Gets or sets border thickness */
  8670. get: function () {
  8671. return this._thickness;
  8672. },
  8673. set: function (value) {
  8674. if (this._thickness === value) {
  8675. return;
  8676. }
  8677. this._thickness = value;
  8678. this._markAsDirty();
  8679. },
  8680. enumerable: true,
  8681. configurable: true
  8682. });
  8683. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8684. /** Gets or sets the corner radius angle */
  8685. get: function () {
  8686. return this._cornerRadius;
  8687. },
  8688. set: function (value) {
  8689. if (value < 0) {
  8690. value = 0;
  8691. }
  8692. if (this._cornerRadius === value) {
  8693. return;
  8694. }
  8695. this._cornerRadius = value;
  8696. this._markAsDirty();
  8697. },
  8698. enumerable: true,
  8699. configurable: true
  8700. });
  8701. Rectangle.prototype._getTypeName = function () {
  8702. return "Rectangle";
  8703. };
  8704. Rectangle.prototype._localDraw = function (context) {
  8705. context.save();
  8706. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8707. context.shadowColor = this.shadowColor;
  8708. context.shadowBlur = this.shadowBlur;
  8709. context.shadowOffsetX = this.shadowOffsetX;
  8710. context.shadowOffsetY = this.shadowOffsetY;
  8711. }
  8712. if (this._background) {
  8713. context.fillStyle = this._background;
  8714. if (this._cornerRadius) {
  8715. this._drawRoundedRect(context, this._thickness / 2);
  8716. context.fill();
  8717. }
  8718. else {
  8719. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8720. }
  8721. }
  8722. if (this._thickness) {
  8723. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8724. context.shadowBlur = 0;
  8725. context.shadowOffsetX = 0;
  8726. context.shadowOffsetY = 0;
  8727. }
  8728. if (this.color) {
  8729. context.strokeStyle = this.color;
  8730. }
  8731. context.lineWidth = this._thickness;
  8732. if (this._cornerRadius) {
  8733. this._drawRoundedRect(context, this._thickness / 2);
  8734. context.stroke();
  8735. }
  8736. else {
  8737. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8738. }
  8739. }
  8740. context.restore();
  8741. };
  8742. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8743. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8744. this._measureForChildren.width -= 2 * this._thickness;
  8745. this._measureForChildren.height -= 2 * this._thickness;
  8746. this._measureForChildren.left += this._thickness;
  8747. this._measureForChildren.top += this._thickness;
  8748. };
  8749. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8750. if (offset === void 0) { offset = 0; }
  8751. var x = this._currentMeasure.left + offset;
  8752. var y = this._currentMeasure.top + offset;
  8753. var width = this._currentMeasure.width - offset * 2;
  8754. var height = this._currentMeasure.height - offset * 2;
  8755. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8756. context.beginPath();
  8757. context.moveTo(x + radius, y);
  8758. context.lineTo(x + width - radius, y);
  8759. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8760. context.lineTo(x + width, y + height - radius);
  8761. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8762. context.lineTo(x + radius, y + height);
  8763. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8764. context.lineTo(x, y + radius);
  8765. context.quadraticCurveTo(x, y, x + radius, y);
  8766. context.closePath();
  8767. };
  8768. Rectangle.prototype._clipForChildren = function (context) {
  8769. if (this._cornerRadius) {
  8770. this._drawRoundedRect(context, this._thickness);
  8771. context.clip();
  8772. }
  8773. };
  8774. return Rectangle;
  8775. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8776. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  8777. /***/ }),
  8778. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8779. /*!***************************************************!*\
  8780. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8781. \***************************************************/
  8782. /*! exports provided: ScrollViewer */
  8783. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8784. "use strict";
  8785. __webpack_require__.r(__webpack_exports__);
  8786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8787. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8788. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/perfCounter");
  8789. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8790. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8791. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8792. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8793. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8794. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8795. /**
  8796. * Class used to hold a viewer window and sliders in a grid
  8797. */
  8798. var ScrollViewer = /** @class */ (function (_super) {
  8799. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  8800. /**
  8801. * Creates a new ScrollViewer
  8802. * @param name of ScrollViewer
  8803. */
  8804. function ScrollViewer(name) {
  8805. var _this = _super.call(this, name) || this;
  8806. _this._barSize = 20;
  8807. _this._pointerIsOver = false;
  8808. _this._wheelPrecision = 0.05;
  8809. _this.onDirtyObservable.add(function () {
  8810. _this._horizontalBarSpace.color = _this.color;
  8811. _this._verticalBarSpace.color = _this.color;
  8812. _this._dragSpace.color = _this.color;
  8813. });
  8814. _this.onPointerEnterObservable.add(function () {
  8815. _this._pointerIsOver = true;
  8816. });
  8817. _this.onPointerOutObservable.add(function () {
  8818. _this._pointerIsOver = false;
  8819. });
  8820. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8821. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8822. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8823. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8824. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8825. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8826. _this._grid.addColumnDefinition(1);
  8827. _this._grid.addColumnDefinition(0, true);
  8828. _this._grid.addRowDefinition(1);
  8829. _this._grid.addRowDefinition(0, true);
  8830. _super.prototype.addControl.call(_this, _this._grid);
  8831. _this._grid.addControl(_this._window, 0, 0);
  8832. _this._verticalBar.paddingLeft = 0;
  8833. _this._verticalBar.width = "100%";
  8834. _this._verticalBar.height = "100%";
  8835. _this._verticalBar.barOffset = 0;
  8836. _this._verticalBar.value = 0;
  8837. _this._verticalBar.maximum = 1;
  8838. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8839. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8840. _this._verticalBar.isVertical = true;
  8841. _this._verticalBar.rotation = Math.PI;
  8842. _this._verticalBar.isVisible = false;
  8843. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8844. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8845. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8846. _this._verticalBarSpace.thickness = 1;
  8847. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8848. _this._verticalBarSpace.addControl(_this._verticalBar);
  8849. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8850. _this._window.top = value * _this._endTop + "px";
  8851. });
  8852. _this._horizontalBar.paddingLeft = 0;
  8853. _this._horizontalBar.width = "100%";
  8854. _this._horizontalBar.height = "100%";
  8855. _this._horizontalBar.barOffset = 0;
  8856. _this._horizontalBar.value = 0;
  8857. _this._horizontalBar.maximum = 1;
  8858. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8859. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8860. _this._horizontalBar.isVisible = false;
  8861. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8862. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8863. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8864. _this._horizontalBarSpace.thickness = 1;
  8865. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8866. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8867. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8868. _this._window.left = value * _this._endLeft + "px";
  8869. });
  8870. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8871. _this._dragSpace.thickness = 1;
  8872. _this._grid.addControl(_this._dragSpace, 1, 1);
  8873. // Colors
  8874. _this.barColor = "grey";
  8875. _this.barBackground = "transparent";
  8876. return _this;
  8877. }
  8878. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8879. /**
  8880. * Gets the horizontal scrollbar
  8881. */
  8882. get: function () {
  8883. return this._horizontalBar;
  8884. },
  8885. enumerable: true,
  8886. configurable: true
  8887. });
  8888. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8889. /**
  8890. * Gets the vertical scrollbar
  8891. */
  8892. get: function () {
  8893. return this._verticalBar;
  8894. },
  8895. enumerable: true,
  8896. configurable: true
  8897. });
  8898. /**
  8899. * Adds a new control to the current container
  8900. * @param control defines the control to add
  8901. * @returns the current container
  8902. */
  8903. ScrollViewer.prototype.addControl = function (control) {
  8904. if (!control) {
  8905. return this;
  8906. }
  8907. this._window.addControl(control);
  8908. return this;
  8909. };
  8910. /**
  8911. * Removes a control from the current container
  8912. * @param control defines the control to remove
  8913. * @returns the current container
  8914. */
  8915. ScrollViewer.prototype.removeControl = function (control) {
  8916. this._window.removeControl(control);
  8917. return this;
  8918. };
  8919. Object.defineProperty(ScrollViewer.prototype, "children", {
  8920. /** Gets the list of children */
  8921. get: function () {
  8922. return this._window.children;
  8923. },
  8924. enumerable: true,
  8925. configurable: true
  8926. });
  8927. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8928. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8929. var child = _a[_i];
  8930. child._markMatrixAsDirty();
  8931. }
  8932. };
  8933. /** Reset the scroll viewer window to initial size */
  8934. ScrollViewer.prototype.resetWindow = function () {
  8935. this._window.width = "100%";
  8936. this._window.height = "100%";
  8937. };
  8938. ScrollViewer.prototype._getTypeName = function () {
  8939. return "ScrollViewer";
  8940. };
  8941. ScrollViewer.prototype._buildClientSizes = function () {
  8942. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8943. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8944. this._clientWidth = this._window.parentClientWidth;
  8945. this._clientHeight = this._window.parentClientHeight;
  8946. };
  8947. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8948. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8949. this._buildClientSizes();
  8950. };
  8951. ScrollViewer.prototype._postMeasure = function () {
  8952. _super.prototype._postMeasure.call(this);
  8953. this._updateScroller();
  8954. };
  8955. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8956. /**
  8957. * Gets or sets the mouse wheel precision
  8958. * from 0 to 1 with a default value of 0.05
  8959. * */
  8960. get: function () {
  8961. return this._wheelPrecision;
  8962. },
  8963. set: function (value) {
  8964. if (this._wheelPrecision === value) {
  8965. return;
  8966. }
  8967. if (value < 0) {
  8968. value = 0;
  8969. }
  8970. if (value > 1) {
  8971. value = 1;
  8972. }
  8973. this._wheelPrecision = value;
  8974. },
  8975. enumerable: true,
  8976. configurable: true
  8977. });
  8978. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8979. /** Gets or sets the bar color */
  8980. get: function () {
  8981. return this._barColor;
  8982. },
  8983. set: function (color) {
  8984. if (this._barColor === color) {
  8985. return;
  8986. }
  8987. this._barColor = color;
  8988. this._horizontalBar.color = color;
  8989. this._verticalBar.color = color;
  8990. },
  8991. enumerable: true,
  8992. configurable: true
  8993. });
  8994. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8995. /** Gets or sets the size of the bar */
  8996. get: function () {
  8997. return this._barSize;
  8998. },
  8999. set: function (value) {
  9000. if (this._barSize === value) {
  9001. return;
  9002. }
  9003. this._barSize = value;
  9004. this._markAsDirty();
  9005. if (this._horizontalBar.isVisible) {
  9006. this._grid.setRowDefinition(1, this._barSize, true);
  9007. }
  9008. if (this._verticalBar.isVisible) {
  9009. this._grid.setColumnDefinition(1, this._barSize, true);
  9010. }
  9011. },
  9012. enumerable: true,
  9013. configurable: true
  9014. });
  9015. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9016. /** Gets or sets the bar background */
  9017. get: function () {
  9018. return this._barBackground;
  9019. },
  9020. set: function (color) {
  9021. if (this._barBackground === color) {
  9022. return;
  9023. }
  9024. this._barBackground = color;
  9025. this._horizontalBar.background = color;
  9026. this._verticalBar.background = color;
  9027. this._dragSpace.background = color;
  9028. },
  9029. enumerable: true,
  9030. configurable: true
  9031. });
  9032. /** @hidden */
  9033. ScrollViewer.prototype._updateScroller = function () {
  9034. var windowContentsWidth = this._window._currentMeasure.width;
  9035. var windowContentsHeight = this._window._currentMeasure.height;
  9036. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  9037. this._grid.setRowDefinition(1, 0, true);
  9038. this._horizontalBar.isVisible = false;
  9039. this._horizontalBar.value = 0;
  9040. this._rebuildLayout = true;
  9041. }
  9042. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  9043. this._grid.setRowDefinition(1, this._barSize, true);
  9044. this._horizontalBar.isVisible = true;
  9045. this._rebuildLayout = true;
  9046. }
  9047. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  9048. this._grid.setColumnDefinition(1, 0, true);
  9049. this._verticalBar.isVisible = false;
  9050. this._verticalBar.value = 0;
  9051. this._rebuildLayout = true;
  9052. }
  9053. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  9054. this._grid.setColumnDefinition(1, this._barSize, true);
  9055. this._verticalBar.isVisible = true;
  9056. this._rebuildLayout = true;
  9057. }
  9058. this._buildClientSizes();
  9059. this._endLeft = this._clientWidth - windowContentsWidth;
  9060. this._endTop = this._clientHeight - windowContentsHeight;
  9061. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  9062. var newTop = this._verticalBar.value * this._endTop + "px";
  9063. if (newLeft !== this._window.left) {
  9064. this._window.left = newLeft;
  9065. this._rebuildLayout = true;
  9066. }
  9067. if (newTop !== this._window.top) {
  9068. this._window.top = newTop;
  9069. this._rebuildLayout = true;
  9070. }
  9071. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  9072. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  9073. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  9074. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  9075. };
  9076. ScrollViewer.prototype._link = function (host) {
  9077. _super.prototype._link.call(this, host);
  9078. this._attachWheel();
  9079. };
  9080. /** @hidden */
  9081. ScrollViewer.prototype._attachWheel = function () {
  9082. var _this = this;
  9083. if (!this._host || this._onPointerObserver) {
  9084. return;
  9085. }
  9086. var scene = this._host.getScene();
  9087. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  9088. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  9089. return;
  9090. }
  9091. if (_this._verticalBar.isVisible == true) {
  9092. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  9093. _this._verticalBar.value -= _this._wheelPrecision;
  9094. }
  9095. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9096. _this._verticalBar.value += _this._wheelPrecision;
  9097. }
  9098. }
  9099. if (_this._horizontalBar.isVisible == true) {
  9100. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9101. _this._horizontalBar.value += _this._wheelPrecision;
  9102. }
  9103. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  9104. _this._horizontalBar.value -= _this._wheelPrecision;
  9105. }
  9106. }
  9107. });
  9108. };
  9109. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9110. if (!this.isHighlighted) {
  9111. return;
  9112. }
  9113. _super.prototype._renderHighlightSpecific.call(this, context);
  9114. this._grid._renderHighlightSpecific(context);
  9115. context.restore();
  9116. };
  9117. /** Releases associated resources */
  9118. ScrollViewer.prototype.dispose = function () {
  9119. var scene = this._host.getScene();
  9120. if (scene && this._onPointerObserver) {
  9121. scene.onPointerObservable.remove(this._onPointerObserver);
  9122. this._onPointerObserver = null;
  9123. }
  9124. _super.prototype.dispose.call(this);
  9125. };
  9126. return ScrollViewer;
  9127. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  9128. babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9129. /***/ }),
  9130. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9131. /*!*********************************************************!*\
  9132. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9133. \*********************************************************/
  9134. /*! exports provided: _ScrollViewerWindow */
  9135. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9136. "use strict";
  9137. __webpack_require__.r(__webpack_exports__);
  9138. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9139. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9140. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9141. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9142. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9143. /**
  9144. * Class used to hold a the container for ScrollViewer
  9145. * @hidden
  9146. */
  9147. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9148. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9149. /**
  9150. * Creates a new ScrollViewerWindow
  9151. * @param name of ScrollViewerWindow
  9152. */
  9153. function _ScrollViewerWindow(name) {
  9154. return _super.call(this, name) || this;
  9155. }
  9156. _ScrollViewerWindow.prototype._getTypeName = function () {
  9157. return "ScrollViewerWindow";
  9158. };
  9159. /** @hidden */
  9160. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9161. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9162. this._measureForChildren.left = this._currentMeasure.left;
  9163. this._measureForChildren.top = this._currentMeasure.top;
  9164. this._measureForChildren.width = parentMeasure.width;
  9165. this._measureForChildren.height = parentMeasure.height;
  9166. };
  9167. _ScrollViewerWindow.prototype._postMeasure = function () {
  9168. var maxWidth = this.parentClientWidth;
  9169. var maxHeight = this.parentClientHeight;
  9170. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9171. var child = _a[_i];
  9172. if (!child.isVisible || child.notRenderable) {
  9173. continue;
  9174. }
  9175. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9176. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9177. }
  9178. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9179. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9180. }
  9181. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9182. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9183. }
  9184. if (this._currentMeasure.width !== maxWidth) {
  9185. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9186. this._currentMeasure.width = maxWidth;
  9187. this._rebuildLayout = true;
  9188. this._isDirty = true;
  9189. }
  9190. if (this._currentMeasure.height !== maxHeight) {
  9191. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9192. this._currentMeasure.height = maxHeight;
  9193. this._rebuildLayout = true;
  9194. this._isDirty = true;
  9195. }
  9196. _super.prototype._postMeasure.call(this);
  9197. };
  9198. return _ScrollViewerWindow;
  9199. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9200. /***/ }),
  9201. /***/ "./2D/controls/selector.ts":
  9202. /*!*********************************!*\
  9203. !*** ./2D/controls/selector.ts ***!
  9204. \*********************************/
  9205. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9206. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9207. "use strict";
  9208. __webpack_require__.r(__webpack_exports__);
  9209. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9211. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9212. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9213. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9214. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9215. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9216. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9217. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9218. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9219. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9220. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9221. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9222. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9223. /** Class used to create a RadioGroup
  9224. * which contains groups of radio buttons
  9225. */
  9226. var SelectorGroup = /** @class */ (function () {
  9227. /**
  9228. * Creates a new SelectorGroup
  9229. * @param name of group, used as a group heading
  9230. */
  9231. function SelectorGroup(
  9232. /** name of SelectorGroup */
  9233. name) {
  9234. this.name = name;
  9235. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9236. this._selectors = new Array();
  9237. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9238. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9239. this._groupHeader = this._addGroupHeader(name);
  9240. }
  9241. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9242. /** Gets the groupPanel of the SelectorGroup */
  9243. get: function () {
  9244. return this._groupPanel;
  9245. },
  9246. enumerable: true,
  9247. configurable: true
  9248. });
  9249. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9250. /** Gets the selectors array */
  9251. get: function () {
  9252. return this._selectors;
  9253. },
  9254. enumerable: true,
  9255. configurable: true
  9256. });
  9257. Object.defineProperty(SelectorGroup.prototype, "header", {
  9258. /** Gets and sets the group header */
  9259. get: function () {
  9260. return this._groupHeader.text;
  9261. },
  9262. set: function (label) {
  9263. if (this._groupHeader.text === "label") {
  9264. return;
  9265. }
  9266. this._groupHeader.text = label;
  9267. },
  9268. enumerable: true,
  9269. configurable: true
  9270. });
  9271. /** @hidden */
  9272. SelectorGroup.prototype._addGroupHeader = function (text) {
  9273. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9274. groupHeading.width = 0.9;
  9275. groupHeading.height = "30px";
  9276. groupHeading.textWrapping = true;
  9277. groupHeading.color = "black";
  9278. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9279. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9280. groupHeading.left = "2px";
  9281. this._groupPanel.addControl(groupHeading);
  9282. return groupHeading;
  9283. };
  9284. /** @hidden*/
  9285. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9286. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9287. return;
  9288. }
  9289. return this._selectors[selectorNb];
  9290. };
  9291. /** Removes the selector at the given position
  9292. * @param selectorNb the position of the selector within the group
  9293. */
  9294. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9295. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9296. return;
  9297. }
  9298. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9299. this._selectors.splice(selectorNb, 1);
  9300. };
  9301. return SelectorGroup;
  9302. }());
  9303. /** Class used to create a CheckboxGroup
  9304. * which contains groups of checkbox buttons
  9305. */
  9306. var CheckboxGroup = /** @class */ (function (_super) {
  9307. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  9308. function CheckboxGroup() {
  9309. return _super !== null && _super.apply(this, arguments) || this;
  9310. }
  9311. /** Adds a checkbox as a control
  9312. * @param text is the label for the selector
  9313. * @param func is the function called when the Selector is checked
  9314. * @param checked is true when Selector is checked
  9315. */
  9316. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9317. if (func === void 0) { func = function (s) { }; }
  9318. if (checked === void 0) { checked = false; }
  9319. var checked = checked || false;
  9320. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9321. button.width = "20px";
  9322. button.height = "20px";
  9323. button.color = "#364249";
  9324. button.background = "#CCCCCC";
  9325. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9326. button.onIsCheckedChangedObservable.add(function (state) {
  9327. func(state);
  9328. });
  9329. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9330. _selector.height = "30px";
  9331. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9332. _selector.left = "4px";
  9333. this.groupPanel.addControl(_selector);
  9334. this.selectors.push(_selector);
  9335. button.isChecked = checked;
  9336. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9337. button.color = this.groupPanel.parent.parent.buttonColor;
  9338. button.background = this.groupPanel.parent.parent.buttonBackground;
  9339. }
  9340. };
  9341. /** @hidden */
  9342. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9343. this.selectors[selectorNb].children[1].text = label;
  9344. };
  9345. /** @hidden */
  9346. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9347. this.selectors[selectorNb].children[1].color = color;
  9348. };
  9349. /** @hidden */
  9350. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9351. this.selectors[selectorNb].children[0].color = color;
  9352. };
  9353. /** @hidden */
  9354. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9355. this.selectors[selectorNb].children[0].background = color;
  9356. };
  9357. return CheckboxGroup;
  9358. }(SelectorGroup));
  9359. /** Class used to create a RadioGroup
  9360. * which contains groups of radio buttons
  9361. */
  9362. var RadioGroup = /** @class */ (function (_super) {
  9363. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  9364. function RadioGroup() {
  9365. var _this = _super !== null && _super.apply(this, arguments) || this;
  9366. _this._selectNb = 0;
  9367. return _this;
  9368. }
  9369. /** Adds a radio button as a control
  9370. * @param label is the label for the selector
  9371. * @param func is the function called when the Selector is checked
  9372. * @param checked is true when Selector is checked
  9373. */
  9374. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9375. if (func === void 0) { func = function (n) { }; }
  9376. if (checked === void 0) { checked = false; }
  9377. var nb = this._selectNb++;
  9378. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9379. button.name = label;
  9380. button.width = "20px";
  9381. button.height = "20px";
  9382. button.color = "#364249";
  9383. button.background = "#CCCCCC";
  9384. button.group = this.name;
  9385. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9386. button.onIsCheckedChangedObservable.add(function (state) {
  9387. if (state) {
  9388. func(nb);
  9389. }
  9390. });
  9391. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9392. _selector.height = "30px";
  9393. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9394. _selector.left = "4px";
  9395. this.groupPanel.addControl(_selector);
  9396. this.selectors.push(_selector);
  9397. button.isChecked = checked;
  9398. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9399. button.color = this.groupPanel.parent.parent.buttonColor;
  9400. button.background = this.groupPanel.parent.parent.buttonBackground;
  9401. }
  9402. };
  9403. /** @hidden */
  9404. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9405. this.selectors[selectorNb].children[1].text = label;
  9406. };
  9407. /** @hidden */
  9408. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9409. this.selectors[selectorNb].children[1].color = color;
  9410. };
  9411. /** @hidden */
  9412. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9413. this.selectors[selectorNb].children[0].color = color;
  9414. };
  9415. /** @hidden */
  9416. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9417. this.selectors[selectorNb].children[0].background = color;
  9418. };
  9419. return RadioGroup;
  9420. }(SelectorGroup));
  9421. /** Class used to create a SliderGroup
  9422. * which contains groups of slider buttons
  9423. */
  9424. var SliderGroup = /** @class */ (function (_super) {
  9425. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  9426. function SliderGroup() {
  9427. return _super !== null && _super.apply(this, arguments) || this;
  9428. }
  9429. /**
  9430. * Adds a slider to the SelectorGroup
  9431. * @param label is the label for the SliderBar
  9432. * @param func is the function called when the Slider moves
  9433. * @param unit is a string describing the units used, eg degrees or metres
  9434. * @param min is the minimum value for the Slider
  9435. * @param max is the maximum value for the Slider
  9436. * @param value is the start value for the Slider between min and max
  9437. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9438. */
  9439. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9440. if (func === void 0) { func = function (v) { }; }
  9441. if (unit === void 0) { unit = "Units"; }
  9442. if (min === void 0) { min = 0; }
  9443. if (max === void 0) { max = 0; }
  9444. if (value === void 0) { value = 0; }
  9445. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9446. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9447. button.name = unit;
  9448. button.value = value;
  9449. button.minimum = min;
  9450. button.maximum = max;
  9451. button.width = 0.9;
  9452. button.height = "20px";
  9453. button.color = "#364249";
  9454. button.background = "#CCCCCC";
  9455. button.borderColor = "black";
  9456. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9457. button.left = "4px";
  9458. button.paddingBottom = "4px";
  9459. button.onValueChangedObservable.add(function (value) {
  9460. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9461. func(value);
  9462. });
  9463. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9464. _selector.height = "60px";
  9465. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9466. _selector.left = "4px";
  9467. _selector.children[0].name = label;
  9468. this.groupPanel.addControl(_selector);
  9469. this.selectors.push(_selector);
  9470. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9471. button.color = this.groupPanel.parent.parent.buttonColor;
  9472. button.background = this.groupPanel.parent.parent.buttonBackground;
  9473. }
  9474. };
  9475. /** @hidden */
  9476. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9477. this.selectors[selectorNb].children[0].name = label;
  9478. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9479. };
  9480. /** @hidden */
  9481. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9482. this.selectors[selectorNb].children[0].color = color;
  9483. };
  9484. /** @hidden */
  9485. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9486. this.selectors[selectorNb].children[1].color = color;
  9487. };
  9488. /** @hidden */
  9489. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9490. this.selectors[selectorNb].children[1].background = color;
  9491. };
  9492. return SliderGroup;
  9493. }(SelectorGroup));
  9494. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9495. * @see http://doc.babylonjs.com/how_to/selector
  9496. */
  9497. var SelectionPanel = /** @class */ (function (_super) {
  9498. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  9499. /**
  9500. * Creates a new SelectionPanel
  9501. * @param name of SelectionPanel
  9502. * @param groups is an array of SelectionGroups
  9503. */
  9504. function SelectionPanel(
  9505. /** name of SelectionPanel */
  9506. name,
  9507. /** an array of SelectionGroups */
  9508. groups) {
  9509. if (groups === void 0) { groups = []; }
  9510. var _this = _super.call(this, name) || this;
  9511. _this.name = name;
  9512. _this.groups = groups;
  9513. _this._buttonColor = "#364249";
  9514. _this._buttonBackground = "#CCCCCC";
  9515. _this._headerColor = "black";
  9516. _this._barColor = "white";
  9517. _this._barHeight = "2px";
  9518. _this._spacerHeight = "20px";
  9519. _this._bars = new Array();
  9520. _this._groups = groups;
  9521. _this.thickness = 2;
  9522. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9523. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9524. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9525. _this._panel.top = 5;
  9526. _this._panel.left = 5;
  9527. _this._panel.width = 0.95;
  9528. if (groups.length > 0) {
  9529. for (var i = 0; i < groups.length - 1; i++) {
  9530. _this._panel.addControl(groups[i].groupPanel);
  9531. _this._addSpacer();
  9532. }
  9533. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9534. }
  9535. _this.addControl(_this._panel);
  9536. return _this;
  9537. }
  9538. SelectionPanel.prototype._getTypeName = function () {
  9539. return "SelectionPanel";
  9540. };
  9541. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9542. /** Gets or sets the headerColor */
  9543. get: function () {
  9544. return this._headerColor;
  9545. },
  9546. set: function (color) {
  9547. if (this._headerColor === color) {
  9548. return;
  9549. }
  9550. this._headerColor = color;
  9551. this._setHeaderColor();
  9552. },
  9553. enumerable: true,
  9554. configurable: true
  9555. });
  9556. SelectionPanel.prototype._setHeaderColor = function () {
  9557. for (var i = 0; i < this._groups.length; i++) {
  9558. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9559. }
  9560. };
  9561. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9562. /** Gets or sets the button color */
  9563. get: function () {
  9564. return this._buttonColor;
  9565. },
  9566. set: function (color) {
  9567. if (this._buttonColor === color) {
  9568. return;
  9569. }
  9570. this._buttonColor = color;
  9571. this._setbuttonColor();
  9572. },
  9573. enumerable: true,
  9574. configurable: true
  9575. });
  9576. SelectionPanel.prototype._setbuttonColor = function () {
  9577. for (var i = 0; i < this._groups.length; i++) {
  9578. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9579. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9580. }
  9581. }
  9582. };
  9583. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9584. /** Gets or sets the label color */
  9585. get: function () {
  9586. return this._labelColor;
  9587. },
  9588. set: function (color) {
  9589. if (this._labelColor === color) {
  9590. return;
  9591. }
  9592. this._labelColor = color;
  9593. this._setLabelColor();
  9594. },
  9595. enumerable: true,
  9596. configurable: true
  9597. });
  9598. SelectionPanel.prototype._setLabelColor = function () {
  9599. for (var i = 0; i < this._groups.length; i++) {
  9600. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9601. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9602. }
  9603. }
  9604. };
  9605. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9606. /** Gets or sets the button background */
  9607. get: function () {
  9608. return this._buttonBackground;
  9609. },
  9610. set: function (color) {
  9611. if (this._buttonBackground === color) {
  9612. return;
  9613. }
  9614. this._buttonBackground = color;
  9615. this._setButtonBackground();
  9616. },
  9617. enumerable: true,
  9618. configurable: true
  9619. });
  9620. SelectionPanel.prototype._setButtonBackground = function () {
  9621. for (var i = 0; i < this._groups.length; i++) {
  9622. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9623. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9624. }
  9625. }
  9626. };
  9627. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9628. /** Gets or sets the color of separator bar */
  9629. get: function () {
  9630. return this._barColor;
  9631. },
  9632. set: function (color) {
  9633. if (this._barColor === color) {
  9634. return;
  9635. }
  9636. this._barColor = color;
  9637. this._setBarColor();
  9638. },
  9639. enumerable: true,
  9640. configurable: true
  9641. });
  9642. SelectionPanel.prototype._setBarColor = function () {
  9643. for (var i = 0; i < this._bars.length; i++) {
  9644. this._bars[i].children[0].background = this._barColor;
  9645. }
  9646. };
  9647. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9648. /** Gets or sets the height of separator bar */
  9649. get: function () {
  9650. return this._barHeight;
  9651. },
  9652. set: function (value) {
  9653. if (this._barHeight === value) {
  9654. return;
  9655. }
  9656. this._barHeight = value;
  9657. this._setBarHeight();
  9658. },
  9659. enumerable: true,
  9660. configurable: true
  9661. });
  9662. SelectionPanel.prototype._setBarHeight = function () {
  9663. for (var i = 0; i < this._bars.length; i++) {
  9664. this._bars[i].children[0].height = this._barHeight;
  9665. }
  9666. };
  9667. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9668. /** Gets or sets the height of spacers*/
  9669. get: function () {
  9670. return this._spacerHeight;
  9671. },
  9672. set: function (value) {
  9673. if (this._spacerHeight === value) {
  9674. return;
  9675. }
  9676. this._spacerHeight = value;
  9677. this._setSpacerHeight();
  9678. },
  9679. enumerable: true,
  9680. configurable: true
  9681. });
  9682. SelectionPanel.prototype._setSpacerHeight = function () {
  9683. for (var i = 0; i < this._bars.length; i++) {
  9684. this._bars[i].height = this._spacerHeight;
  9685. }
  9686. };
  9687. /** Adds a bar between groups */
  9688. SelectionPanel.prototype._addSpacer = function () {
  9689. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9690. separator.width = 1;
  9691. separator.height = this._spacerHeight;
  9692. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9693. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9694. bar.width = 1;
  9695. bar.height = this._barHeight;
  9696. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9697. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9698. bar.background = this._barColor;
  9699. bar.color = "transparent";
  9700. separator.addControl(bar);
  9701. this._panel.addControl(separator);
  9702. this._bars.push(separator);
  9703. };
  9704. /** Add a group to the selection panel
  9705. * @param group is the selector group to add
  9706. */
  9707. SelectionPanel.prototype.addGroup = function (group) {
  9708. if (this._groups.length > 0) {
  9709. this._addSpacer();
  9710. }
  9711. this._panel.addControl(group.groupPanel);
  9712. this._groups.push(group);
  9713. group.groupPanel.children[0].color = this._headerColor;
  9714. for (var j = 0; j < group.selectors.length; j++) {
  9715. group._setSelectorButtonColor(j, this._buttonColor);
  9716. group._setSelectorButtonBackground(j, this._buttonBackground);
  9717. }
  9718. };
  9719. /** Remove the group from the given position
  9720. * @param groupNb is the position of the group in the list
  9721. */
  9722. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9723. if (groupNb < 0 || groupNb >= this._groups.length) {
  9724. return;
  9725. }
  9726. var group = this._groups[groupNb];
  9727. this._panel.removeControl(group.groupPanel);
  9728. this._groups.splice(groupNb, 1);
  9729. if (groupNb < this._bars.length) {
  9730. this._panel.removeControl(this._bars[groupNb]);
  9731. this._bars.splice(groupNb, 1);
  9732. }
  9733. };
  9734. /** Change a group header label
  9735. * @param label is the new group header label
  9736. * @param groupNb is the number of the group to relabel
  9737. * */
  9738. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9739. if (groupNb < 0 || groupNb >= this._groups.length) {
  9740. return;
  9741. }
  9742. var group = this._groups[groupNb];
  9743. group.groupPanel.children[0].text = label;
  9744. };
  9745. /** Change selector label to the one given
  9746. * @param label is the new selector label
  9747. * @param groupNb is the number of the groupcontaining the selector
  9748. * @param selectorNb is the number of the selector within a group to relabel
  9749. * */
  9750. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9751. if (groupNb < 0 || groupNb >= this._groups.length) {
  9752. return;
  9753. }
  9754. var group = this._groups[groupNb];
  9755. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9756. return;
  9757. }
  9758. group._setSelectorLabel(selectorNb, label);
  9759. };
  9760. /** For a given group position remove the selector at the given position
  9761. * @param groupNb is the number of the group to remove the selector from
  9762. * @param selectorNb is the number of the selector within the group
  9763. */
  9764. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9765. if (groupNb < 0 || groupNb >= this._groups.length) {
  9766. return;
  9767. }
  9768. var group = this._groups[groupNb];
  9769. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9770. return;
  9771. }
  9772. group.removeSelector(selectorNb);
  9773. };
  9774. /** For a given group position of correct type add a checkbox button
  9775. * @param groupNb is the number of the group to remove the selector from
  9776. * @param label is the label for the selector
  9777. * @param func is the function called when the Selector is checked
  9778. * @param checked is true when Selector is checked
  9779. */
  9780. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9781. if (func === void 0) { func = function () { }; }
  9782. if (checked === void 0) { checked = false; }
  9783. if (groupNb < 0 || groupNb >= this._groups.length) {
  9784. return;
  9785. }
  9786. var group = this._groups[groupNb];
  9787. group.addCheckbox(label, func, checked);
  9788. };
  9789. /** For a given group position of correct type add a radio button
  9790. * @param groupNb is the number of the group to remove the selector from
  9791. * @param label is the label for the selector
  9792. * @param func is the function called when the Selector is checked
  9793. * @param checked is true when Selector is checked
  9794. */
  9795. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9796. if (func === void 0) { func = function () { }; }
  9797. if (checked === void 0) { checked = false; }
  9798. if (groupNb < 0 || groupNb >= this._groups.length) {
  9799. return;
  9800. }
  9801. var group = this._groups[groupNb];
  9802. group.addRadio(label, func, checked);
  9803. };
  9804. /**
  9805. * For a given slider group add a slider
  9806. * @param groupNb is the number of the group to add the slider to
  9807. * @param label is the label for the Slider
  9808. * @param func is the function called when the Slider moves
  9809. * @param unit is a string describing the units used, eg degrees or metres
  9810. * @param min is the minimum value for the Slider
  9811. * @param max is the maximum value for the Slider
  9812. * @param value is the start value for the Slider between min and max
  9813. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9814. */
  9815. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9816. if (func === void 0) { func = function () { }; }
  9817. if (unit === void 0) { unit = "Units"; }
  9818. if (min === void 0) { min = 0; }
  9819. if (max === void 0) { max = 0; }
  9820. if (value === void 0) { value = 0; }
  9821. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9822. if (groupNb < 0 || groupNb >= this._groups.length) {
  9823. return;
  9824. }
  9825. var group = this._groups[groupNb];
  9826. group.addSlider(label, func, unit, min, max, value, onVal);
  9827. };
  9828. return SelectionPanel;
  9829. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9830. /***/ }),
  9831. /***/ "./2D/controls/sliders/baseSlider.ts":
  9832. /*!*******************************************!*\
  9833. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9834. \*******************************************/
  9835. /*! exports provided: BaseSlider */
  9836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9837. "use strict";
  9838. __webpack_require__.r(__webpack_exports__);
  9839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9840. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9841. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  9842. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9843. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9844. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9845. /**
  9846. * Class used to create slider controls
  9847. */
  9848. var BaseSlider = /** @class */ (function (_super) {
  9849. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  9850. /**
  9851. * Creates a new BaseSlider
  9852. * @param name defines the control name
  9853. */
  9854. function BaseSlider(name) {
  9855. var _this = _super.call(this, name) || this;
  9856. _this.name = name;
  9857. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9858. _this._minimum = 0;
  9859. _this._maximum = 100;
  9860. _this._value = 50;
  9861. _this._isVertical = false;
  9862. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9863. _this._isThumbClamped = false;
  9864. _this._displayThumb = true;
  9865. _this._step = 0;
  9866. _this._lastPointerDownID = -1;
  9867. // Shared rendering info
  9868. _this._effectiveBarOffset = 0;
  9869. /** Observable raised when the sldier value changes */
  9870. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9871. // Events
  9872. _this._pointerIsDown = false;
  9873. _this.isPointerBlocker = true;
  9874. return _this;
  9875. }
  9876. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9877. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9878. get: function () {
  9879. return this._displayThumb;
  9880. },
  9881. set: function (value) {
  9882. if (this._displayThumb === value) {
  9883. return;
  9884. }
  9885. this._displayThumb = value;
  9886. this._markAsDirty();
  9887. },
  9888. enumerable: true,
  9889. configurable: true
  9890. });
  9891. Object.defineProperty(BaseSlider.prototype, "step", {
  9892. /** Gets or sets a step to apply to values (0 by default) */
  9893. get: function () {
  9894. return this._step;
  9895. },
  9896. set: function (value) {
  9897. if (this._step === value) {
  9898. return;
  9899. }
  9900. this._step = value;
  9901. this._markAsDirty();
  9902. },
  9903. enumerable: true,
  9904. configurable: true
  9905. });
  9906. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9907. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9908. get: function () {
  9909. return this._barOffset.toString(this._host);
  9910. },
  9911. set: function (value) {
  9912. if (this._barOffset.toString(this._host) === value) {
  9913. return;
  9914. }
  9915. if (this._barOffset.fromString(value)) {
  9916. this._markAsDirty();
  9917. }
  9918. },
  9919. enumerable: true,
  9920. configurable: true
  9921. });
  9922. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9923. /** Gets main bar offset in pixels*/
  9924. get: function () {
  9925. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9926. },
  9927. enumerable: true,
  9928. configurable: true
  9929. });
  9930. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9931. /** Gets or sets thumb width */
  9932. get: function () {
  9933. return this._thumbWidth.toString(this._host);
  9934. },
  9935. set: function (value) {
  9936. if (this._thumbWidth.toString(this._host) === value) {
  9937. return;
  9938. }
  9939. if (this._thumbWidth.fromString(value)) {
  9940. this._markAsDirty();
  9941. }
  9942. },
  9943. enumerable: true,
  9944. configurable: true
  9945. });
  9946. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9947. /** Gets thumb width in pixels */
  9948. get: function () {
  9949. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9950. },
  9951. enumerable: true,
  9952. configurable: true
  9953. });
  9954. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9955. /** Gets or sets minimum value */
  9956. get: function () {
  9957. return this._minimum;
  9958. },
  9959. set: function (value) {
  9960. if (this._minimum === value) {
  9961. return;
  9962. }
  9963. this._minimum = value;
  9964. this._markAsDirty();
  9965. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9966. },
  9967. enumerable: true,
  9968. configurable: true
  9969. });
  9970. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9971. /** Gets or sets maximum value */
  9972. get: function () {
  9973. return this._maximum;
  9974. },
  9975. set: function (value) {
  9976. if (this._maximum === value) {
  9977. return;
  9978. }
  9979. this._maximum = value;
  9980. this._markAsDirty();
  9981. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9982. },
  9983. enumerable: true,
  9984. configurable: true
  9985. });
  9986. Object.defineProperty(BaseSlider.prototype, "value", {
  9987. /** Gets or sets current value */
  9988. get: function () {
  9989. return this._value;
  9990. },
  9991. set: function (value) {
  9992. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9993. if (this._value === value) {
  9994. return;
  9995. }
  9996. this._value = value;
  9997. this._markAsDirty();
  9998. this.onValueChangedObservable.notifyObservers(this._value);
  9999. },
  10000. enumerable: true,
  10001. configurable: true
  10002. });
  10003. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10004. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10005. get: function () {
  10006. return this._isVertical;
  10007. },
  10008. set: function (value) {
  10009. if (this._isVertical === value) {
  10010. return;
  10011. }
  10012. this._isVertical = value;
  10013. this._markAsDirty();
  10014. },
  10015. enumerable: true,
  10016. configurable: true
  10017. });
  10018. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10019. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10020. get: function () {
  10021. return this._isThumbClamped;
  10022. },
  10023. set: function (value) {
  10024. if (this._isThumbClamped === value) {
  10025. return;
  10026. }
  10027. this._isThumbClamped = value;
  10028. this._markAsDirty();
  10029. },
  10030. enumerable: true,
  10031. configurable: true
  10032. });
  10033. BaseSlider.prototype._getTypeName = function () {
  10034. return "BaseSlider";
  10035. };
  10036. BaseSlider.prototype._getThumbPosition = function () {
  10037. if (this.isVertical) {
  10038. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10039. }
  10040. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10041. };
  10042. BaseSlider.prototype._getThumbThickness = function (type) {
  10043. var thumbThickness = 0;
  10044. switch (type) {
  10045. case "circle":
  10046. if (this._thumbWidth.isPixel) {
  10047. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10048. }
  10049. else {
  10050. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10051. }
  10052. break;
  10053. case "rectangle":
  10054. if (this._thumbWidth.isPixel) {
  10055. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10056. }
  10057. else {
  10058. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10059. }
  10060. }
  10061. return thumbThickness;
  10062. };
  10063. BaseSlider.prototype._prepareRenderingData = function (type) {
  10064. // Main bar
  10065. this._effectiveBarOffset = 0;
  10066. this._renderLeft = this._currentMeasure.left;
  10067. this._renderTop = this._currentMeasure.top;
  10068. this._renderWidth = this._currentMeasure.width;
  10069. this._renderHeight = this._currentMeasure.height;
  10070. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10071. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10072. this._effectiveThumbThickness = this._getThumbThickness(type);
  10073. if (this.displayThumb) {
  10074. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10075. }
  10076. //throw error when height is less than width for vertical slider
  10077. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10078. console.error("Height should be greater than width");
  10079. return;
  10080. }
  10081. if (this._barOffset.isPixel) {
  10082. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10083. }
  10084. else {
  10085. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10086. }
  10087. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10088. if (this.isVertical) {
  10089. this._renderLeft += this._effectiveBarOffset;
  10090. if (!this.isThumbClamped && this.displayThumb) {
  10091. this._renderTop += (this._effectiveThumbThickness / 2);
  10092. }
  10093. this._renderHeight = this._backgroundBoxLength;
  10094. this._renderWidth = this._backgroundBoxThickness;
  10095. }
  10096. else {
  10097. this._renderTop += this._effectiveBarOffset;
  10098. if (!this.isThumbClamped && this.displayThumb) {
  10099. this._renderLeft += (this._effectiveThumbThickness / 2);
  10100. }
  10101. this._renderHeight = this._backgroundBoxThickness;
  10102. this._renderWidth = this._backgroundBoxLength;
  10103. }
  10104. };
  10105. /** @hidden */
  10106. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10107. if (this.rotation != 0) {
  10108. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10109. x = this._transformedPosition.x;
  10110. y = this._transformedPosition.y;
  10111. }
  10112. var value;
  10113. if (this._isVertical) {
  10114. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10115. }
  10116. else {
  10117. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10118. }
  10119. var mult = (1 / this._step) | 0;
  10120. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10121. };
  10122. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10123. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10124. return false;
  10125. }
  10126. this._pointerIsDown = true;
  10127. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10128. this._host._capturingControl[pointerId] = this;
  10129. this._lastPointerDownID = pointerId;
  10130. return true;
  10131. };
  10132. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10133. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10134. if (pointerId != this._lastPointerDownID) {
  10135. return;
  10136. }
  10137. if (this._pointerIsDown) {
  10138. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10139. }
  10140. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10141. };
  10142. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10143. this._pointerIsDown = false;
  10144. delete this._host._capturingControl[pointerId];
  10145. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10146. };
  10147. return BaseSlider;
  10148. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10149. /***/ }),
  10150. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10151. /*!*************************************************!*\
  10152. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10153. \*************************************************/
  10154. /*! exports provided: ImageBasedSlider */
  10155. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10156. "use strict";
  10157. __webpack_require__.r(__webpack_exports__);
  10158. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10159. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10160. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10161. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10162. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  10163. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10164. /**
  10165. * Class used to create slider controls based on images
  10166. */
  10167. var ImageBasedSlider = /** @class */ (function (_super) {
  10168. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  10169. /**
  10170. * Creates a new ImageBasedSlider
  10171. * @param name defines the control name
  10172. */
  10173. function ImageBasedSlider(name) {
  10174. var _this = _super.call(this, name) || this;
  10175. _this.name = name;
  10176. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10177. return _this;
  10178. }
  10179. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10180. get: function () {
  10181. return this._displayThumb && this.thumbImage != null;
  10182. },
  10183. set: function (value) {
  10184. if (this._displayThumb === value) {
  10185. return;
  10186. }
  10187. this._displayThumb = value;
  10188. this._markAsDirty();
  10189. },
  10190. enumerable: true,
  10191. configurable: true
  10192. });
  10193. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10194. /**
  10195. * Gets or sets the image used to render the background
  10196. */
  10197. get: function () {
  10198. return this._backgroundImage;
  10199. },
  10200. set: function (value) {
  10201. var _this = this;
  10202. if (this._backgroundImage === value) {
  10203. return;
  10204. }
  10205. this._backgroundImage = value;
  10206. if (value && !value.isLoaded) {
  10207. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10208. }
  10209. this._markAsDirty();
  10210. },
  10211. enumerable: true,
  10212. configurable: true
  10213. });
  10214. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10215. /**
  10216. * Gets or sets the image used to render the value bar
  10217. */
  10218. get: function () {
  10219. return this._valueBarImage;
  10220. },
  10221. set: function (value) {
  10222. var _this = this;
  10223. if (this._valueBarImage === value) {
  10224. return;
  10225. }
  10226. this._valueBarImage = value;
  10227. if (value && !value.isLoaded) {
  10228. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10229. }
  10230. this._markAsDirty();
  10231. },
  10232. enumerable: true,
  10233. configurable: true
  10234. });
  10235. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10236. /**
  10237. * Gets or sets the image used to render the thumb
  10238. */
  10239. get: function () {
  10240. return this._thumbImage;
  10241. },
  10242. set: function (value) {
  10243. var _this = this;
  10244. if (this._thumbImage === value) {
  10245. return;
  10246. }
  10247. this._thumbImage = value;
  10248. if (value && !value.isLoaded) {
  10249. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10250. }
  10251. this._markAsDirty();
  10252. },
  10253. enumerable: true,
  10254. configurable: true
  10255. });
  10256. ImageBasedSlider.prototype._getTypeName = function () {
  10257. return "ImageBasedSlider";
  10258. };
  10259. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  10260. context.save();
  10261. this._applyStates(context);
  10262. this._prepareRenderingData("rectangle");
  10263. var thumbPosition = this._getThumbPosition();
  10264. var left = this._renderLeft;
  10265. var top = this._renderTop;
  10266. var width = this._renderWidth;
  10267. var height = this._renderHeight;
  10268. // Background
  10269. if (this._backgroundImage) {
  10270. this._tempMeasure.copyFromFloats(left, top, width, height);
  10271. if (this.isThumbClamped && this.displayThumb) {
  10272. if (this.isVertical) {
  10273. this._tempMeasure.height += this._effectiveThumbThickness;
  10274. }
  10275. else {
  10276. this._tempMeasure.width += this._effectiveThumbThickness;
  10277. }
  10278. }
  10279. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10280. this._backgroundImage._draw(context);
  10281. }
  10282. // Bar
  10283. if (this._valueBarImage) {
  10284. if (this.isVertical) {
  10285. if (this.isThumbClamped && this.displayThumb) {
  10286. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10287. }
  10288. else {
  10289. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10290. }
  10291. }
  10292. else {
  10293. if (this.isThumbClamped && this.displayThumb) {
  10294. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10295. }
  10296. else {
  10297. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10298. }
  10299. }
  10300. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10301. this._valueBarImage._draw(context);
  10302. }
  10303. // Thumb
  10304. if (this.displayThumb) {
  10305. if (this.isVertical) {
  10306. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10307. }
  10308. else {
  10309. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10310. }
  10311. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10312. this._thumbImage._draw(context);
  10313. }
  10314. context.restore();
  10315. };
  10316. return ImageBasedSlider;
  10317. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10318. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  10319. /***/ }),
  10320. /***/ "./2D/controls/sliders/scrollBar.ts":
  10321. /*!******************************************!*\
  10322. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10323. \******************************************/
  10324. /*! exports provided: ScrollBar */
  10325. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10326. "use strict";
  10327. __webpack_require__.r(__webpack_exports__);
  10328. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10329. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10330. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10331. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10332. /**
  10333. * Class used to create slider controls
  10334. */
  10335. var ScrollBar = /** @class */ (function (_super) {
  10336. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  10337. /**
  10338. * Creates a new Slider
  10339. * @param name defines the control name
  10340. */
  10341. function ScrollBar(name) {
  10342. var _this = _super.call(this, name) || this;
  10343. _this.name = name;
  10344. _this._background = "black";
  10345. _this._borderColor = "white";
  10346. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10347. return _this;
  10348. }
  10349. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10350. /** Gets or sets border color */
  10351. get: function () {
  10352. return this._borderColor;
  10353. },
  10354. set: function (value) {
  10355. if (this._borderColor === value) {
  10356. return;
  10357. }
  10358. this._borderColor = value;
  10359. this._markAsDirty();
  10360. },
  10361. enumerable: true,
  10362. configurable: true
  10363. });
  10364. Object.defineProperty(ScrollBar.prototype, "background", {
  10365. /** Gets or sets background color */
  10366. get: function () {
  10367. return this._background;
  10368. },
  10369. set: function (value) {
  10370. if (this._background === value) {
  10371. return;
  10372. }
  10373. this._background = value;
  10374. this._markAsDirty();
  10375. },
  10376. enumerable: true,
  10377. configurable: true
  10378. });
  10379. ScrollBar.prototype._getTypeName = function () {
  10380. return "Scrollbar";
  10381. };
  10382. ScrollBar.prototype._getThumbThickness = function () {
  10383. var thumbThickness = 0;
  10384. if (this._thumbWidth.isPixel) {
  10385. thumbThickness = this._thumbWidth.getValue(this._host);
  10386. }
  10387. else {
  10388. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10389. }
  10390. return thumbThickness;
  10391. };
  10392. ScrollBar.prototype._draw = function (context) {
  10393. context.save();
  10394. this._applyStates(context);
  10395. this._prepareRenderingData("rectangle");
  10396. var left = this._renderLeft;
  10397. var thumbPosition = this._getThumbPosition();
  10398. context.fillStyle = this._background;
  10399. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10400. // Value bar
  10401. context.fillStyle = this.color;
  10402. // Thumb
  10403. if (this.isVertical) {
  10404. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10405. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10406. this._thumbMeasure.width = this._currentMeasure.width;
  10407. this._thumbMeasure.height = this._effectiveThumbThickness;
  10408. }
  10409. else {
  10410. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10411. this._thumbMeasure.top = this._currentMeasure.top;
  10412. this._thumbMeasure.width = this._effectiveThumbThickness;
  10413. this._thumbMeasure.height = this._currentMeasure.height;
  10414. }
  10415. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10416. context.restore();
  10417. };
  10418. /** @hidden */
  10419. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10420. if (this.rotation != 0) {
  10421. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10422. x = this._transformedPosition.x;
  10423. y = this._transformedPosition.y;
  10424. }
  10425. if (this._first) {
  10426. this._first = false;
  10427. this._originX = x;
  10428. this._originY = y;
  10429. // Check if move is required
  10430. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10431. if (this.isVertical) {
  10432. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10433. }
  10434. else {
  10435. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10436. }
  10437. }
  10438. }
  10439. // Delta mode
  10440. var delta = 0;
  10441. if (this.isVertical) {
  10442. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10443. }
  10444. else {
  10445. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10446. }
  10447. this.value += delta * (this.maximum - this.minimum);
  10448. this._originX = x;
  10449. this._originY = y;
  10450. };
  10451. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10452. this._first = true;
  10453. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10454. };
  10455. return ScrollBar;
  10456. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10457. /***/ }),
  10458. /***/ "./2D/controls/sliders/slider.ts":
  10459. /*!***************************************!*\
  10460. !*** ./2D/controls/sliders/slider.ts ***!
  10461. \***************************************/
  10462. /*! exports provided: Slider */
  10463. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10464. "use strict";
  10465. __webpack_require__.r(__webpack_exports__);
  10466. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10467. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10468. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10469. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  10470. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  10471. /**
  10472. * Class used to create slider controls
  10473. */
  10474. var Slider = /** @class */ (function (_super) {
  10475. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  10476. /**
  10477. * Creates a new Slider
  10478. * @param name defines the control name
  10479. */
  10480. function Slider(name) {
  10481. var _this = _super.call(this, name) || this;
  10482. _this.name = name;
  10483. _this._background = "black";
  10484. _this._borderColor = "white";
  10485. _this._isThumbCircle = false;
  10486. _this._displayValueBar = true;
  10487. return _this;
  10488. }
  10489. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10490. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10491. get: function () {
  10492. return this._displayValueBar;
  10493. },
  10494. set: function (value) {
  10495. if (this._displayValueBar === value) {
  10496. return;
  10497. }
  10498. this._displayValueBar = value;
  10499. this._markAsDirty();
  10500. },
  10501. enumerable: true,
  10502. configurable: true
  10503. });
  10504. Object.defineProperty(Slider.prototype, "borderColor", {
  10505. /** Gets or sets border color */
  10506. get: function () {
  10507. return this._borderColor;
  10508. },
  10509. set: function (value) {
  10510. if (this._borderColor === value) {
  10511. return;
  10512. }
  10513. this._borderColor = value;
  10514. this._markAsDirty();
  10515. },
  10516. enumerable: true,
  10517. configurable: true
  10518. });
  10519. Object.defineProperty(Slider.prototype, "background", {
  10520. /** Gets or sets background color */
  10521. get: function () {
  10522. return this._background;
  10523. },
  10524. set: function (value) {
  10525. if (this._background === value) {
  10526. return;
  10527. }
  10528. this._background = value;
  10529. this._markAsDirty();
  10530. },
  10531. enumerable: true,
  10532. configurable: true
  10533. });
  10534. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10535. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10536. get: function () {
  10537. return this._isThumbCircle;
  10538. },
  10539. set: function (value) {
  10540. if (this._isThumbCircle === value) {
  10541. return;
  10542. }
  10543. this._isThumbCircle = value;
  10544. this._markAsDirty();
  10545. },
  10546. enumerable: true,
  10547. configurable: true
  10548. });
  10549. Slider.prototype._getTypeName = function () {
  10550. return "Slider";
  10551. };
  10552. Slider.prototype._draw = function (context, invalidatedRectangle) {
  10553. context.save();
  10554. this._applyStates(context);
  10555. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10556. var left = this._renderLeft;
  10557. var top = this._renderTop;
  10558. var width = this._renderWidth;
  10559. var height = this._renderHeight;
  10560. var radius = 0;
  10561. if (this.isThumbClamped && this.isThumbCircle) {
  10562. if (this.isVertical) {
  10563. top += (this._effectiveThumbThickness / 2);
  10564. }
  10565. else {
  10566. left += (this._effectiveThumbThickness / 2);
  10567. }
  10568. radius = this._backgroundBoxThickness / 2;
  10569. }
  10570. else {
  10571. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10572. }
  10573. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10574. context.shadowColor = this.shadowColor;
  10575. context.shadowBlur = this.shadowBlur;
  10576. context.shadowOffsetX = this.shadowOffsetX;
  10577. context.shadowOffsetY = this.shadowOffsetY;
  10578. }
  10579. var thumbPosition = this._getThumbPosition();
  10580. context.fillStyle = this._background;
  10581. if (this.isVertical) {
  10582. if (this.isThumbClamped) {
  10583. if (this.isThumbCircle) {
  10584. context.beginPath();
  10585. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10586. context.fill();
  10587. context.fillRect(left, top, width, height);
  10588. }
  10589. else {
  10590. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10591. }
  10592. }
  10593. else {
  10594. context.fillRect(left, top, width, height);
  10595. }
  10596. }
  10597. else {
  10598. if (this.isThumbClamped) {
  10599. if (this.isThumbCircle) {
  10600. context.beginPath();
  10601. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10602. context.fill();
  10603. context.fillRect(left, top, width, height);
  10604. }
  10605. else {
  10606. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10607. }
  10608. }
  10609. else {
  10610. context.fillRect(left, top, width, height);
  10611. }
  10612. }
  10613. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10614. context.shadowBlur = 0;
  10615. context.shadowOffsetX = 0;
  10616. context.shadowOffsetY = 0;
  10617. }
  10618. // Value bar
  10619. context.fillStyle = this.color;
  10620. if (this._displayValueBar) {
  10621. if (this.isVertical) {
  10622. if (this.isThumbClamped) {
  10623. if (this.isThumbCircle) {
  10624. context.beginPath();
  10625. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10626. context.fill();
  10627. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10628. }
  10629. else {
  10630. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10631. }
  10632. }
  10633. else {
  10634. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10635. }
  10636. }
  10637. else {
  10638. if (this.isThumbClamped) {
  10639. if (this.isThumbCircle) {
  10640. context.beginPath();
  10641. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10642. context.fill();
  10643. context.fillRect(left, top, thumbPosition, height);
  10644. }
  10645. else {
  10646. context.fillRect(left, top, thumbPosition, height);
  10647. }
  10648. }
  10649. else {
  10650. context.fillRect(left, top, thumbPosition, height);
  10651. }
  10652. }
  10653. }
  10654. // Thumb
  10655. if (this.displayThumb) {
  10656. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10657. context.shadowColor = this.shadowColor;
  10658. context.shadowBlur = this.shadowBlur;
  10659. context.shadowOffsetX = this.shadowOffsetX;
  10660. context.shadowOffsetY = this.shadowOffsetY;
  10661. }
  10662. if (this._isThumbCircle) {
  10663. context.beginPath();
  10664. if (this.isVertical) {
  10665. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10666. }
  10667. else {
  10668. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10669. }
  10670. context.fill();
  10671. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10672. context.shadowBlur = 0;
  10673. context.shadowOffsetX = 0;
  10674. context.shadowOffsetY = 0;
  10675. }
  10676. context.strokeStyle = this._borderColor;
  10677. context.stroke();
  10678. }
  10679. else {
  10680. if (this.isVertical) {
  10681. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10682. }
  10683. else {
  10684. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10685. }
  10686. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10687. context.shadowBlur = 0;
  10688. context.shadowOffsetX = 0;
  10689. context.shadowOffsetY = 0;
  10690. }
  10691. context.strokeStyle = this._borderColor;
  10692. if (this.isVertical) {
  10693. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10694. }
  10695. else {
  10696. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10697. }
  10698. }
  10699. }
  10700. context.restore();
  10701. };
  10702. return Slider;
  10703. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10704. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  10705. /***/ }),
  10706. /***/ "./2D/controls/stackPanel.ts":
  10707. /*!***********************************!*\
  10708. !*** ./2D/controls/stackPanel.ts ***!
  10709. \***********************************/
  10710. /*! exports provided: StackPanel */
  10711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10712. "use strict";
  10713. __webpack_require__.r(__webpack_exports__);
  10714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10715. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10716. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  10717. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10718. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10719. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10720. /**
  10721. * Class used to create a 2D stack panel container
  10722. */
  10723. var StackPanel = /** @class */ (function (_super) {
  10724. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  10725. /**
  10726. * Creates a new StackPanel
  10727. * @param name defines control name
  10728. */
  10729. function StackPanel(name) {
  10730. var _this = _super.call(this, name) || this;
  10731. _this.name = name;
  10732. _this._isVertical = true;
  10733. _this._manualWidth = false;
  10734. _this._manualHeight = false;
  10735. _this._doNotTrackManualChanges = false;
  10736. /**
  10737. * Gets or sets a boolean indicating that layou warnings should be ignored
  10738. */
  10739. _this.ignoreLayoutWarnings = false;
  10740. return _this;
  10741. }
  10742. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10743. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10744. get: function () {
  10745. return this._isVertical;
  10746. },
  10747. set: function (value) {
  10748. if (this._isVertical === value) {
  10749. return;
  10750. }
  10751. this._isVertical = value;
  10752. this._markAsDirty();
  10753. },
  10754. enumerable: true,
  10755. configurable: true
  10756. });
  10757. Object.defineProperty(StackPanel.prototype, "width", {
  10758. get: function () {
  10759. return this._width.toString(this._host);
  10760. },
  10761. /**
  10762. * Gets or sets panel width.
  10763. * This value should not be set when in horizontal mode as it will be computed automatically
  10764. */
  10765. set: function (value) {
  10766. if (!this._doNotTrackManualChanges) {
  10767. this._manualWidth = true;
  10768. }
  10769. if (this._width.toString(this._host) === value) {
  10770. return;
  10771. }
  10772. if (this._width.fromString(value)) {
  10773. this._markAsDirty();
  10774. }
  10775. },
  10776. enumerable: true,
  10777. configurable: true
  10778. });
  10779. Object.defineProperty(StackPanel.prototype, "height", {
  10780. get: function () {
  10781. return this._height.toString(this._host);
  10782. },
  10783. /**
  10784. * Gets or sets panel height.
  10785. * This value should not be set when in vertical mode as it will be computed automatically
  10786. */
  10787. set: function (value) {
  10788. if (!this._doNotTrackManualChanges) {
  10789. this._manualHeight = true;
  10790. }
  10791. if (this._height.toString(this._host) === value) {
  10792. return;
  10793. }
  10794. if (this._height.fromString(value)) {
  10795. this._markAsDirty();
  10796. }
  10797. },
  10798. enumerable: true,
  10799. configurable: true
  10800. });
  10801. StackPanel.prototype._getTypeName = function () {
  10802. return "StackPanel";
  10803. };
  10804. /** @hidden */
  10805. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10806. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10807. var child = _a[_i];
  10808. if (this._isVertical) {
  10809. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10810. }
  10811. else {
  10812. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10813. }
  10814. }
  10815. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10816. };
  10817. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10818. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10819. this._measureForChildren.copyFrom(parentMeasure);
  10820. this._measureForChildren.left = this._currentMeasure.left;
  10821. this._measureForChildren.top = this._currentMeasure.top;
  10822. if (!this.isVertical || this._manualWidth) {
  10823. this._measureForChildren.width = this._currentMeasure.width;
  10824. }
  10825. if (this.isVertical || this._manualHeight) {
  10826. this._measureForChildren.height = this._currentMeasure.height;
  10827. }
  10828. };
  10829. StackPanel.prototype._postMeasure = function () {
  10830. var stackWidth = 0;
  10831. var stackHeight = 0;
  10832. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10833. var child = _a[_i];
  10834. if (!child.isVisible || child.notRenderable) {
  10835. continue;
  10836. }
  10837. if (this._isVertical) {
  10838. if (child.top !== stackHeight + "px") {
  10839. child.top = stackHeight + "px";
  10840. this._rebuildLayout = true;
  10841. child._top.ignoreAdaptiveScaling = true;
  10842. }
  10843. if (child._height.isPercentage) {
  10844. if (!this.ignoreLayoutWarnings) {
  10845. 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");
  10846. }
  10847. }
  10848. else {
  10849. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10850. }
  10851. }
  10852. else {
  10853. if (child.left !== stackWidth + "px") {
  10854. child.left = stackWidth + "px";
  10855. this._rebuildLayout = true;
  10856. child._left.ignoreAdaptiveScaling = true;
  10857. }
  10858. if (child._width.isPercentage) {
  10859. if (!this.ignoreLayoutWarnings) {
  10860. 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");
  10861. }
  10862. }
  10863. else {
  10864. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10865. }
  10866. }
  10867. }
  10868. this._doNotTrackManualChanges = true;
  10869. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10870. // User can now define their own height and width for stack panel.
  10871. var panelWidthChanged = false;
  10872. var panelHeightChanged = false;
  10873. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10874. var previousHeight = this.height;
  10875. this.height = stackHeight + "px";
  10876. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10877. }
  10878. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10879. var previousWidth = this.width;
  10880. this.width = stackWidth + "px";
  10881. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10882. }
  10883. if (panelHeightChanged) {
  10884. this._height.ignoreAdaptiveScaling = true;
  10885. }
  10886. if (panelWidthChanged) {
  10887. this._width.ignoreAdaptiveScaling = true;
  10888. }
  10889. this._doNotTrackManualChanges = false;
  10890. if (panelWidthChanged || panelHeightChanged) {
  10891. this._rebuildLayout = true;
  10892. }
  10893. _super.prototype._postMeasure.call(this);
  10894. };
  10895. return StackPanel;
  10896. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10897. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  10898. /***/ }),
  10899. /***/ "./2D/controls/statics.ts":
  10900. /*!********************************!*\
  10901. !*** ./2D/controls/statics.ts ***!
  10902. \********************************/
  10903. /*! exports provided: name */
  10904. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10905. "use strict";
  10906. __webpack_require__.r(__webpack_exports__);
  10907. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10908. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10909. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10910. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10911. /**
  10912. * Forcing an export so that this code will execute
  10913. * @hidden
  10914. */
  10915. var name = "Statics";
  10916. /**
  10917. * Creates a stack panel that can be used to render headers
  10918. * @param control defines the control to associate with the header
  10919. * @param text defines the text of the header
  10920. * @param size defines the size of the header
  10921. * @param options defines options used to configure the header
  10922. * @returns a new StackPanel
  10923. */
  10924. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10925. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10926. var isHorizontal = options ? options.isHorizontal : true;
  10927. var controlFirst = options ? options.controlFirst : true;
  10928. panel.isVertical = !isHorizontal;
  10929. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10930. header.text = text;
  10931. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10932. if (isHorizontal) {
  10933. header.width = size;
  10934. }
  10935. else {
  10936. header.height = size;
  10937. }
  10938. if (controlFirst) {
  10939. panel.addControl(control);
  10940. panel.addControl(header);
  10941. header.paddingLeft = "5px";
  10942. }
  10943. else {
  10944. panel.addControl(header);
  10945. panel.addControl(control);
  10946. header.paddingRight = "5px";
  10947. }
  10948. header.shadowBlur = control.shadowBlur;
  10949. header.shadowColor = control.shadowColor;
  10950. header.shadowOffsetX = control.shadowOffsetX;
  10951. header.shadowOffsetY = control.shadowOffsetY;
  10952. return panel;
  10953. };
  10954. /***/ }),
  10955. /***/ "./2D/controls/textBlock.ts":
  10956. /*!**********************************!*\
  10957. !*** ./2D/controls/textBlock.ts ***!
  10958. \**********************************/
  10959. /*! exports provided: TextWrapping, TextBlock */
  10960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10961. "use strict";
  10962. __webpack_require__.r(__webpack_exports__);
  10963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10964. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10965. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10966. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  10967. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10968. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10969. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10970. /**
  10971. * Enum that determines the text-wrapping mode to use.
  10972. */
  10973. var TextWrapping;
  10974. (function (TextWrapping) {
  10975. /**
  10976. * Clip the text when it's larger than Control.width; this is the default mode.
  10977. */
  10978. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10979. /**
  10980. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10981. */
  10982. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10983. /**
  10984. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10985. */
  10986. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10987. })(TextWrapping || (TextWrapping = {}));
  10988. /**
  10989. * Class used to create text block control
  10990. */
  10991. var TextBlock = /** @class */ (function (_super) {
  10992. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  10993. /**
  10994. * Creates a new TextBlock object
  10995. * @param name defines the name of the control
  10996. * @param text defines the text to display (emptry string by default)
  10997. */
  10998. function TextBlock(
  10999. /**
  11000. * Defines the name of the control
  11001. */
  11002. name, text) {
  11003. if (text === void 0) { text = ""; }
  11004. var _this = _super.call(this, name) || this;
  11005. _this.name = name;
  11006. _this._text = "";
  11007. _this._textWrapping = TextWrapping.Clip;
  11008. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  11009. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  11010. _this._resizeToFit = false;
  11011. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  11012. _this._outlineWidth = 0;
  11013. _this._outlineColor = "white";
  11014. /**
  11015. * An event triggered after the text is changed
  11016. */
  11017. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11018. /**
  11019. * An event triggered after the text was broken up into lines
  11020. */
  11021. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11022. _this.text = text;
  11023. return _this;
  11024. }
  11025. Object.defineProperty(TextBlock.prototype, "lines", {
  11026. /**
  11027. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  11028. */
  11029. get: function () {
  11030. return this._lines;
  11031. },
  11032. enumerable: true,
  11033. configurable: true
  11034. });
  11035. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  11036. /**
  11037. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11038. */
  11039. get: function () {
  11040. return this._resizeToFit;
  11041. },
  11042. /**
  11043. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11044. */
  11045. set: function (value) {
  11046. if (this._resizeToFit === value) {
  11047. return;
  11048. }
  11049. this._resizeToFit = value;
  11050. if (this._resizeToFit) {
  11051. this._width.ignoreAdaptiveScaling = true;
  11052. this._height.ignoreAdaptiveScaling = true;
  11053. }
  11054. this._markAsDirty();
  11055. },
  11056. enumerable: true,
  11057. configurable: true
  11058. });
  11059. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  11060. /**
  11061. * Gets or sets a boolean indicating if text must be wrapped
  11062. */
  11063. get: function () {
  11064. return this._textWrapping;
  11065. },
  11066. /**
  11067. * Gets or sets a boolean indicating if text must be wrapped
  11068. */
  11069. set: function (value) {
  11070. if (this._textWrapping === value) {
  11071. return;
  11072. }
  11073. this._textWrapping = +value;
  11074. this._markAsDirty();
  11075. },
  11076. enumerable: true,
  11077. configurable: true
  11078. });
  11079. Object.defineProperty(TextBlock.prototype, "text", {
  11080. /**
  11081. * Gets or sets text to display
  11082. */
  11083. get: function () {
  11084. return this._text;
  11085. },
  11086. /**
  11087. * Gets or sets text to display
  11088. */
  11089. set: function (value) {
  11090. if (this._text === value) {
  11091. return;
  11092. }
  11093. this._text = value;
  11094. this._markAsDirty();
  11095. this.onTextChangedObservable.notifyObservers(this);
  11096. },
  11097. enumerable: true,
  11098. configurable: true
  11099. });
  11100. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  11101. /**
  11102. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11103. */
  11104. get: function () {
  11105. return this._textHorizontalAlignment;
  11106. },
  11107. /**
  11108. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11109. */
  11110. set: function (value) {
  11111. if (this._textHorizontalAlignment === value) {
  11112. return;
  11113. }
  11114. this._textHorizontalAlignment = value;
  11115. this._markAsDirty();
  11116. },
  11117. enumerable: true,
  11118. configurable: true
  11119. });
  11120. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  11121. /**
  11122. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11123. */
  11124. get: function () {
  11125. return this._textVerticalAlignment;
  11126. },
  11127. /**
  11128. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11129. */
  11130. set: function (value) {
  11131. if (this._textVerticalAlignment === value) {
  11132. return;
  11133. }
  11134. this._textVerticalAlignment = value;
  11135. this._markAsDirty();
  11136. },
  11137. enumerable: true,
  11138. configurable: true
  11139. });
  11140. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  11141. /**
  11142. * Gets or sets line spacing value
  11143. */
  11144. get: function () {
  11145. return this._lineSpacing.toString(this._host);
  11146. },
  11147. /**
  11148. * Gets or sets line spacing value
  11149. */
  11150. set: function (value) {
  11151. if (this._lineSpacing.fromString(value)) {
  11152. this._markAsDirty();
  11153. }
  11154. },
  11155. enumerable: true,
  11156. configurable: true
  11157. });
  11158. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  11159. /**
  11160. * Gets or sets outlineWidth of the text to display
  11161. */
  11162. get: function () {
  11163. return this._outlineWidth;
  11164. },
  11165. /**
  11166. * Gets or sets outlineWidth of the text to display
  11167. */
  11168. set: function (value) {
  11169. if (this._outlineWidth === value) {
  11170. return;
  11171. }
  11172. this._outlineWidth = value;
  11173. this._markAsDirty();
  11174. },
  11175. enumerable: true,
  11176. configurable: true
  11177. });
  11178. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  11179. /**
  11180. * Gets or sets outlineColor of the text to display
  11181. */
  11182. get: function () {
  11183. return this._outlineColor;
  11184. },
  11185. /**
  11186. * Gets or sets outlineColor of the text to display
  11187. */
  11188. set: function (value) {
  11189. if (this._outlineColor === value) {
  11190. return;
  11191. }
  11192. this._outlineColor = value;
  11193. this._markAsDirty();
  11194. },
  11195. enumerable: true,
  11196. configurable: true
  11197. });
  11198. TextBlock.prototype._getTypeName = function () {
  11199. return "TextBlock";
  11200. };
  11201. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11202. if (!this._fontOffset) {
  11203. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11204. }
  11205. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11206. // Prepare lines
  11207. this._lines = this._breakLines(this._currentMeasure.width, context);
  11208. this.onLinesReadyObservable.notifyObservers(this);
  11209. var maxLineWidth = 0;
  11210. for (var i = 0; i < this._lines.length; i++) {
  11211. var line = this._lines[i];
  11212. if (line.width > maxLineWidth) {
  11213. maxLineWidth = line.width;
  11214. }
  11215. }
  11216. if (this._resizeToFit) {
  11217. if (this._textWrapping === TextWrapping.Clip) {
  11218. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11219. if (newWidth !== this._width.internalValue) {
  11220. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11221. this._rebuildLayout = true;
  11222. }
  11223. }
  11224. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11225. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11226. var lineSpacing = 0;
  11227. if (this._lineSpacing.isPixel) {
  11228. lineSpacing = this._lineSpacing.getValue(this._host);
  11229. }
  11230. else {
  11231. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11232. }
  11233. newHeight += (this._lines.length - 1) * lineSpacing;
  11234. }
  11235. if (newHeight !== this._height.internalValue) {
  11236. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11237. this._rebuildLayout = true;
  11238. }
  11239. }
  11240. };
  11241. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11242. var width = this._currentMeasure.width;
  11243. var x = 0;
  11244. switch (this._textHorizontalAlignment) {
  11245. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11246. x = 0;
  11247. break;
  11248. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11249. x = width - textWidth;
  11250. break;
  11251. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11252. x = (width - textWidth) / 2;
  11253. break;
  11254. }
  11255. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11256. context.shadowColor = this.shadowColor;
  11257. context.shadowBlur = this.shadowBlur;
  11258. context.shadowOffsetX = this.shadowOffsetX;
  11259. context.shadowOffsetY = this.shadowOffsetY;
  11260. }
  11261. if (this.outlineWidth) {
  11262. context.strokeText(text, this._currentMeasure.left + x, y);
  11263. }
  11264. context.fillText(text, this._currentMeasure.left + x, y);
  11265. };
  11266. /** @hidden */
  11267. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  11268. context.save();
  11269. this._applyStates(context);
  11270. // Render lines
  11271. this._renderLines(context);
  11272. context.restore();
  11273. };
  11274. TextBlock.prototype._applyStates = function (context) {
  11275. _super.prototype._applyStates.call(this, context);
  11276. if (this.outlineWidth) {
  11277. context.lineWidth = this.outlineWidth;
  11278. context.strokeStyle = this.outlineColor;
  11279. }
  11280. };
  11281. TextBlock.prototype._breakLines = function (refWidth, context) {
  11282. var lines = [];
  11283. var _lines = this.text.split("\n");
  11284. if (this._textWrapping === TextWrapping.Ellipsis) {
  11285. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11286. var _line = _lines_1[_i];
  11287. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11288. }
  11289. }
  11290. else if (this._textWrapping === TextWrapping.WordWrap) {
  11291. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11292. var _line = _lines_2[_a];
  11293. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11294. }
  11295. }
  11296. else {
  11297. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11298. var _line = _lines_3[_b];
  11299. lines.push(this._parseLine(_line, context));
  11300. }
  11301. }
  11302. return lines;
  11303. };
  11304. TextBlock.prototype._parseLine = function (line, context) {
  11305. if (line === void 0) { line = ''; }
  11306. return { text: line, width: context.measureText(line).width };
  11307. };
  11308. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11309. if (line === void 0) { line = ''; }
  11310. var lineWidth = context.measureText(line).width;
  11311. if (lineWidth > width) {
  11312. line += '…';
  11313. }
  11314. while (line.length > 2 && lineWidth > width) {
  11315. line = line.slice(0, -2) + '…';
  11316. lineWidth = context.measureText(line).width;
  11317. }
  11318. return { text: line, width: lineWidth };
  11319. };
  11320. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11321. if (line === void 0) { line = ''; }
  11322. var lines = [];
  11323. var words = line.split(' ');
  11324. var lineWidth = 0;
  11325. for (var n = 0; n < words.length; n++) {
  11326. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11327. var metrics = context.measureText(testLine);
  11328. var testWidth = metrics.width;
  11329. if (testWidth > width && n > 0) {
  11330. lines.push({ text: line, width: lineWidth });
  11331. line = words[n];
  11332. lineWidth = context.measureText(line).width;
  11333. }
  11334. else {
  11335. lineWidth = testWidth;
  11336. line = testLine;
  11337. }
  11338. }
  11339. lines.push({ text: line, width: lineWidth });
  11340. return lines;
  11341. };
  11342. TextBlock.prototype._renderLines = function (context) {
  11343. var height = this._currentMeasure.height;
  11344. var rootY = 0;
  11345. switch (this._textVerticalAlignment) {
  11346. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11347. rootY = this._fontOffset.ascent;
  11348. break;
  11349. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11350. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11351. break;
  11352. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11353. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11354. break;
  11355. }
  11356. rootY += this._currentMeasure.top;
  11357. for (var i = 0; i < this._lines.length; i++) {
  11358. var line = this._lines[i];
  11359. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11360. if (this._lineSpacing.isPixel) {
  11361. rootY += this._lineSpacing.getValue(this._host);
  11362. }
  11363. else {
  11364. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11365. }
  11366. }
  11367. this._drawText(line.text, line.width, rootY, context);
  11368. rootY += this._fontOffset.height;
  11369. }
  11370. };
  11371. /**
  11372. * Given a width constraint applied on the text block, find the expected height
  11373. * @returns expected height
  11374. */
  11375. TextBlock.prototype.computeExpectedHeight = function () {
  11376. if (this.text && this.widthInPixels) {
  11377. var context_1 = document.createElement('canvas').getContext('2d');
  11378. if (context_1) {
  11379. this._applyStates(context_1);
  11380. if (!this._fontOffset) {
  11381. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11382. }
  11383. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11384. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11385. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11386. var lineSpacing = 0;
  11387. if (this._lineSpacing.isPixel) {
  11388. lineSpacing = this._lineSpacing.getValue(this._host);
  11389. }
  11390. else {
  11391. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11392. }
  11393. newHeight += (lines.length - 1) * lineSpacing;
  11394. }
  11395. return newHeight;
  11396. }
  11397. }
  11398. return 0;
  11399. };
  11400. TextBlock.prototype.dispose = function () {
  11401. _super.prototype.dispose.call(this);
  11402. this.onTextChangedObservable.clear();
  11403. };
  11404. return TextBlock;
  11405. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11406. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  11407. /***/ }),
  11408. /***/ "./2D/controls/virtualKeyboard.ts":
  11409. /*!****************************************!*\
  11410. !*** ./2D/controls/virtualKeyboard.ts ***!
  11411. \****************************************/
  11412. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11413. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11414. "use strict";
  11415. __webpack_require__.r(__webpack_exports__);
  11416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11418. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11419. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  11420. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11421. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11422. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11423. /**
  11424. * Class used to store key control properties
  11425. */
  11426. var KeyPropertySet = /** @class */ (function () {
  11427. function KeyPropertySet() {
  11428. }
  11429. return KeyPropertySet;
  11430. }());
  11431. /**
  11432. * Class used to create virtual keyboard
  11433. */
  11434. var VirtualKeyboard = /** @class */ (function (_super) {
  11435. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  11436. function VirtualKeyboard() {
  11437. var _this = _super !== null && _super.apply(this, arguments) || this;
  11438. /** Observable raised when a key is pressed */
  11439. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11440. /** Gets or sets default key button width */
  11441. _this.defaultButtonWidth = "40px";
  11442. /** Gets or sets default key button height */
  11443. _this.defaultButtonHeight = "40px";
  11444. /** Gets or sets default key button left padding */
  11445. _this.defaultButtonPaddingLeft = "2px";
  11446. /** Gets or sets default key button right padding */
  11447. _this.defaultButtonPaddingRight = "2px";
  11448. /** Gets or sets default key button top padding */
  11449. _this.defaultButtonPaddingTop = "2px";
  11450. /** Gets or sets default key button bottom padding */
  11451. _this.defaultButtonPaddingBottom = "2px";
  11452. /** Gets or sets default key button foreground color */
  11453. _this.defaultButtonColor = "#DDD";
  11454. /** Gets or sets default key button background color */
  11455. _this.defaultButtonBackground = "#070707";
  11456. /** Gets or sets shift button foreground color */
  11457. _this.shiftButtonColor = "#7799FF";
  11458. /** Gets or sets shift button thickness*/
  11459. _this.selectedShiftThickness = 1;
  11460. /** Gets shift key state */
  11461. _this.shiftState = 0;
  11462. _this._currentlyConnectedInputText = null;
  11463. _this._connectedInputTexts = [];
  11464. _this._onKeyPressObserver = null;
  11465. return _this;
  11466. }
  11467. VirtualKeyboard.prototype._getTypeName = function () {
  11468. return "VirtualKeyboard";
  11469. };
  11470. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11471. var _this = this;
  11472. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11473. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11474. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11475. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11476. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11477. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11478. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11479. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11480. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11481. button.thickness = 0;
  11482. button.isFocusInvisible = true;
  11483. button.shadowColor = this.shadowColor;
  11484. button.shadowBlur = this.shadowBlur;
  11485. button.shadowOffsetX = this.shadowOffsetX;
  11486. button.shadowOffsetY = this.shadowOffsetY;
  11487. button.onPointerUpObservable.add(function () {
  11488. _this.onKeyPressObservable.notifyObservers(key);
  11489. });
  11490. return button;
  11491. };
  11492. /**
  11493. * Adds a new row of keys
  11494. * @param keys defines the list of keys to add
  11495. * @param propertySets defines the associated property sets
  11496. */
  11497. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11498. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11499. panel.isVertical = false;
  11500. panel.isFocusInvisible = true;
  11501. var maxKey = null;
  11502. for (var i = 0; i < keys.length; i++) {
  11503. var properties = null;
  11504. if (propertySets && propertySets.length === keys.length) {
  11505. properties = propertySets[i];
  11506. }
  11507. var key = this._createKey(keys[i], properties);
  11508. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  11509. maxKey = key;
  11510. }
  11511. panel.addControl(key);
  11512. }
  11513. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  11514. this.addControl(panel);
  11515. };
  11516. /**
  11517. * Set the shift key to a specific state
  11518. * @param shiftState defines the new shift state
  11519. */
  11520. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11521. if (!this.children) {
  11522. return;
  11523. }
  11524. for (var i = 0; i < this.children.length; i++) {
  11525. var row = this.children[i];
  11526. if (!row || !row.children) {
  11527. continue;
  11528. }
  11529. var rowContainer = row;
  11530. for (var j = 0; j < rowContainer.children.length; j++) {
  11531. var button = rowContainer.children[j];
  11532. if (!button || !button.children[0]) {
  11533. continue;
  11534. }
  11535. var button_tblock = button.children[0];
  11536. if (button_tblock.text === "\u21E7") {
  11537. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11538. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11539. }
  11540. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11541. }
  11542. }
  11543. };
  11544. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11545. /** Gets the input text control currently attached to the keyboard */
  11546. get: function () {
  11547. return this._currentlyConnectedInputText;
  11548. },
  11549. enumerable: true,
  11550. configurable: true
  11551. });
  11552. /**
  11553. * Connects the keyboard with an input text control
  11554. *
  11555. * @param input defines the target control
  11556. */
  11557. VirtualKeyboard.prototype.connect = function (input) {
  11558. var _this = this;
  11559. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11560. if (inputTextAlreadyConnected) {
  11561. return;
  11562. }
  11563. if (this._onKeyPressObserver === null) {
  11564. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11565. if (!_this._currentlyConnectedInputText) {
  11566. return;
  11567. }
  11568. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11569. switch (key) {
  11570. case "\u21E7":
  11571. _this.shiftState++;
  11572. if (_this.shiftState > 2) {
  11573. _this.shiftState = 0;
  11574. }
  11575. _this.applyShiftState(_this.shiftState);
  11576. return;
  11577. case "\u2190":
  11578. _this._currentlyConnectedInputText.processKey(8);
  11579. return;
  11580. case "\u21B5":
  11581. _this._currentlyConnectedInputText.processKey(13);
  11582. return;
  11583. }
  11584. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11585. if (_this.shiftState === 1) {
  11586. _this.shiftState = 0;
  11587. _this.applyShiftState(_this.shiftState);
  11588. }
  11589. });
  11590. }
  11591. this.isVisible = false;
  11592. this._currentlyConnectedInputText = input;
  11593. input._connectedVirtualKeyboard = this;
  11594. // Events hooking
  11595. var onFocusObserver = input.onFocusObservable.add(function () {
  11596. _this._currentlyConnectedInputText = input;
  11597. input._connectedVirtualKeyboard = _this;
  11598. _this.isVisible = true;
  11599. });
  11600. var onBlurObserver = input.onBlurObservable.add(function () {
  11601. input._connectedVirtualKeyboard = null;
  11602. _this._currentlyConnectedInputText = null;
  11603. _this.isVisible = false;
  11604. });
  11605. this._connectedInputTexts.push({
  11606. input: input,
  11607. onBlurObserver: onBlurObserver,
  11608. onFocusObserver: onFocusObserver
  11609. });
  11610. };
  11611. /**
  11612. * Disconnects the keyboard from connected InputText controls
  11613. *
  11614. * @param input optionally defines a target control, otherwise all are disconnected
  11615. */
  11616. VirtualKeyboard.prototype.disconnect = function (input) {
  11617. var _this = this;
  11618. if (input) {
  11619. // .find not available on IE
  11620. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11621. if (filtered.length === 1) {
  11622. this._removeConnectedInputObservables(filtered[0]);
  11623. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11624. if (this._currentlyConnectedInputText === input) {
  11625. this._currentlyConnectedInputText = null;
  11626. }
  11627. }
  11628. }
  11629. else {
  11630. this._connectedInputTexts.forEach(function (connectedInputText) {
  11631. _this._removeConnectedInputObservables(connectedInputText);
  11632. });
  11633. this._connectedInputTexts = [];
  11634. }
  11635. if (this._connectedInputTexts.length === 0) {
  11636. this._currentlyConnectedInputText = null;
  11637. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11638. this._onKeyPressObserver = null;
  11639. }
  11640. };
  11641. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11642. connectedInputText.input._connectedVirtualKeyboard = null;
  11643. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11644. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11645. };
  11646. /**
  11647. * Release all resources
  11648. */
  11649. VirtualKeyboard.prototype.dispose = function () {
  11650. _super.prototype.dispose.call(this);
  11651. this.disconnect();
  11652. };
  11653. // Statics
  11654. /**
  11655. * Creates a new keyboard using a default layout
  11656. *
  11657. * @param name defines control name
  11658. * @returns a new VirtualKeyboard
  11659. */
  11660. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11661. var returnValue = new VirtualKeyboard(name);
  11662. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11663. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11664. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11665. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11666. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11667. return returnValue;
  11668. };
  11669. return VirtualKeyboard;
  11670. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11671. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  11672. /***/ }),
  11673. /***/ "./2D/index.ts":
  11674. /*!*********************!*\
  11675. !*** ./2D/index.ts ***!
  11676. \*********************/
  11677. /*! 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, name */
  11678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11679. "use strict";
  11680. __webpack_require__.r(__webpack_exports__);
  11681. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  11712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11713. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11715. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11717. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11720. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11722. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11724. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11726. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11728. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  11729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  11730. /***/ }),
  11731. /***/ "./2D/math2D.ts":
  11732. /*!**********************!*\
  11733. !*** ./2D/math2D.ts ***!
  11734. \**********************/
  11735. /*! exports provided: Vector2WithInfo, Matrix2D */
  11736. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11737. "use strict";
  11738. __webpack_require__.r(__webpack_exports__);
  11739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11740. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11741. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11742. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  11743. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11744. /**
  11745. * Class used to transport Vector2 information for pointer events
  11746. */
  11747. var Vector2WithInfo = /** @class */ (function (_super) {
  11748. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  11749. /**
  11750. * Creates a new Vector2WithInfo
  11751. * @param source defines the vector2 data to transport
  11752. * @param buttonIndex defines the current mouse button index
  11753. */
  11754. function Vector2WithInfo(source,
  11755. /** defines the current mouse button index */
  11756. buttonIndex) {
  11757. if (buttonIndex === void 0) { buttonIndex = 0; }
  11758. var _this = _super.call(this, source.x, source.y) || this;
  11759. _this.buttonIndex = buttonIndex;
  11760. return _this;
  11761. }
  11762. return Vector2WithInfo;
  11763. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11764. /** Class used to provide 2D matrix features */
  11765. var Matrix2D = /** @class */ (function () {
  11766. /**
  11767. * Creates a new matrix
  11768. * @param m00 defines value for (0, 0)
  11769. * @param m01 defines value for (0, 1)
  11770. * @param m10 defines value for (1, 0)
  11771. * @param m11 defines value for (1, 1)
  11772. * @param m20 defines value for (2, 0)
  11773. * @param m21 defines value for (2, 1)
  11774. */
  11775. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11776. /** Gets the internal array of 6 floats used to store matrix data */
  11777. this.m = new Float32Array(6);
  11778. this.fromValues(m00, m01, m10, m11, m20, m21);
  11779. }
  11780. /**
  11781. * Fills the matrix from direct values
  11782. * @param m00 defines value for (0, 0)
  11783. * @param m01 defines value for (0, 1)
  11784. * @param m10 defines value for (1, 0)
  11785. * @param m11 defines value for (1, 1)
  11786. * @param m20 defines value for (2, 0)
  11787. * @param m21 defines value for (2, 1)
  11788. * @returns the current modified matrix
  11789. */
  11790. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11791. this.m[0] = m00;
  11792. this.m[1] = m01;
  11793. this.m[2] = m10;
  11794. this.m[3] = m11;
  11795. this.m[4] = m20;
  11796. this.m[5] = m21;
  11797. return this;
  11798. };
  11799. /**
  11800. * Gets matrix determinant
  11801. * @returns the determinant
  11802. */
  11803. Matrix2D.prototype.determinant = function () {
  11804. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11805. };
  11806. /**
  11807. * Inverses the matrix and stores it in a target matrix
  11808. * @param result defines the target matrix
  11809. * @returns the current matrix
  11810. */
  11811. Matrix2D.prototype.invertToRef = function (result) {
  11812. var l0 = this.m[0];
  11813. var l1 = this.m[1];
  11814. var l2 = this.m[2];
  11815. var l3 = this.m[3];
  11816. var l4 = this.m[4];
  11817. var l5 = this.m[5];
  11818. var det = this.determinant();
  11819. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11820. result.m[0] = 0;
  11821. result.m[1] = 0;
  11822. result.m[2] = 0;
  11823. result.m[3] = 0;
  11824. result.m[4] = 0;
  11825. result.m[5] = 0;
  11826. return this;
  11827. }
  11828. var detDiv = 1 / det;
  11829. var det4 = l2 * l5 - l3 * l4;
  11830. var det5 = l1 * l4 - l0 * l5;
  11831. result.m[0] = l3 * detDiv;
  11832. result.m[1] = -l1 * detDiv;
  11833. result.m[2] = -l2 * detDiv;
  11834. result.m[3] = l0 * detDiv;
  11835. result.m[4] = det4 * detDiv;
  11836. result.m[5] = det5 * detDiv;
  11837. return this;
  11838. };
  11839. /**
  11840. * Multiplies the current matrix with another one
  11841. * @param other defines the second operand
  11842. * @param result defines the target matrix
  11843. * @returns the current matrix
  11844. */
  11845. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11846. var l0 = this.m[0];
  11847. var l1 = this.m[1];
  11848. var l2 = this.m[2];
  11849. var l3 = this.m[3];
  11850. var l4 = this.m[4];
  11851. var l5 = this.m[5];
  11852. var r0 = other.m[0];
  11853. var r1 = other.m[1];
  11854. var r2 = other.m[2];
  11855. var r3 = other.m[3];
  11856. var r4 = other.m[4];
  11857. var r5 = other.m[5];
  11858. result.m[0] = l0 * r0 + l1 * r2;
  11859. result.m[1] = l0 * r1 + l1 * r3;
  11860. result.m[2] = l2 * r0 + l3 * r2;
  11861. result.m[3] = l2 * r1 + l3 * r3;
  11862. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11863. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11864. return this;
  11865. };
  11866. /**
  11867. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11868. * @param x defines the x coordinate to transform
  11869. * @param y defines the x coordinate to transform
  11870. * @param result defines the target vector2
  11871. * @returns the current matrix
  11872. */
  11873. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11874. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11875. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11876. return this;
  11877. };
  11878. // Statics
  11879. /**
  11880. * Creates an identity matrix
  11881. * @returns a new matrix
  11882. */
  11883. Matrix2D.Identity = function () {
  11884. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11885. };
  11886. /**
  11887. * Creates a translation matrix and stores it in a target matrix
  11888. * @param x defines the x coordinate of the translation
  11889. * @param y defines the y coordinate of the translation
  11890. * @param result defines the target matrix
  11891. */
  11892. Matrix2D.TranslationToRef = function (x, y, result) {
  11893. result.fromValues(1, 0, 0, 1, x, y);
  11894. };
  11895. /**
  11896. * Creates a scaling matrix and stores it in a target matrix
  11897. * @param x defines the x coordinate of the scaling
  11898. * @param y defines the y coordinate of the scaling
  11899. * @param result defines the target matrix
  11900. */
  11901. Matrix2D.ScalingToRef = function (x, y, result) {
  11902. result.fromValues(x, 0, 0, y, 0, 0);
  11903. };
  11904. /**
  11905. * Creates a rotation matrix and stores it in a target matrix
  11906. * @param angle defines the rotation angle
  11907. * @param result defines the target matrix
  11908. */
  11909. Matrix2D.RotationToRef = function (angle, result) {
  11910. var s = Math.sin(angle);
  11911. var c = Math.cos(angle);
  11912. result.fromValues(c, s, -s, c, 0, 0);
  11913. };
  11914. /**
  11915. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11916. * @param tx defines the x coordinate of the translation
  11917. * @param ty defines the y coordinate of the translation
  11918. * @param angle defines the rotation angle
  11919. * @param scaleX defines the x coordinate of the scaling
  11920. * @param scaleY defines the y coordinate of the scaling
  11921. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11922. * @param result defines the target matrix
  11923. */
  11924. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11925. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11926. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11927. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11928. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11929. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11930. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11931. if (parentMatrix) {
  11932. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11933. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11934. }
  11935. else {
  11936. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11937. }
  11938. };
  11939. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11940. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11941. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11942. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11943. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11944. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11945. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11946. return Matrix2D;
  11947. }());
  11948. /***/ }),
  11949. /***/ "./2D/measure.ts":
  11950. /*!***********************!*\
  11951. !*** ./2D/measure.ts ***!
  11952. \***********************/
  11953. /*! exports provided: Measure */
  11954. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11955. "use strict";
  11956. __webpack_require__.r(__webpack_exports__);
  11957. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11958. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  11959. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11960. /**
  11961. * Class used to store 2D control sizes
  11962. */
  11963. var Measure = /** @class */ (function () {
  11964. /**
  11965. * Creates a new measure
  11966. * @param left defines left coordinate
  11967. * @param top defines top coordinate
  11968. * @param width defines width dimension
  11969. * @param height defines height dimension
  11970. */
  11971. function Measure(
  11972. /** defines left coordinate */
  11973. left,
  11974. /** defines top coordinate */
  11975. top,
  11976. /** defines width dimension */
  11977. width,
  11978. /** defines height dimension */
  11979. height) {
  11980. this.left = left;
  11981. this.top = top;
  11982. this.width = width;
  11983. this.height = height;
  11984. }
  11985. /**
  11986. * Copy from another measure
  11987. * @param other defines the other measure to copy from
  11988. */
  11989. Measure.prototype.copyFrom = function (other) {
  11990. this.left = other.left;
  11991. this.top = other.top;
  11992. this.width = other.width;
  11993. this.height = other.height;
  11994. };
  11995. /**
  11996. * Copy from a group of 4 floats
  11997. * @param left defines left coordinate
  11998. * @param top defines top coordinate
  11999. * @param width defines width dimension
  12000. * @param height defines height dimension
  12001. */
  12002. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  12003. this.left = left;
  12004. this.top = top;
  12005. this.width = width;
  12006. this.height = height;
  12007. };
  12008. /**
  12009. * Computes the axis aligned bounding box measure for two given measures
  12010. * @param a Input measure
  12011. * @param b Input measure
  12012. * @param result the resulting bounding measure
  12013. */
  12014. Measure.CombineToRef = function (a, b, result) {
  12015. var left = Math.min(a.left, b.left);
  12016. var top = Math.min(a.top, b.top);
  12017. var right = Math.max(a.left + a.width, b.left + b.width);
  12018. var bottom = Math.max(a.top + a.height, b.top + b.height);
  12019. result.left = left;
  12020. result.top = top;
  12021. result.width = right - left;
  12022. result.height = bottom - top;
  12023. };
  12024. /**
  12025. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  12026. * @param transform the matrix to transform the measure before computing the AABB
  12027. * @param result the resulting AABB
  12028. */
  12029. Measure.prototype.transformToRef = function (transform, result) {
  12030. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  12031. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  12032. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12033. for (var i = 0; i < 4; i++) {
  12034. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  12035. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  12036. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  12037. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  12038. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  12039. }
  12040. result.left = min.x;
  12041. result.top = min.y;
  12042. result.width = max.x - min.x;
  12043. result.height = max.y - min.y;
  12044. };
  12045. /**
  12046. * Check equality between this measure and another one
  12047. * @param other defines the other measures
  12048. * @returns true if both measures are equals
  12049. */
  12050. Measure.prototype.isEqualsTo = function (other) {
  12051. if (this.left !== other.left) {
  12052. return false;
  12053. }
  12054. if (this.top !== other.top) {
  12055. return false;
  12056. }
  12057. if (this.width !== other.width) {
  12058. return false;
  12059. }
  12060. if (this.height !== other.height) {
  12061. return false;
  12062. }
  12063. return true;
  12064. };
  12065. /**
  12066. * Creates an empty measure
  12067. * @returns a new measure
  12068. */
  12069. Measure.Empty = function () {
  12070. return new Measure(0, 0, 0, 0);
  12071. };
  12072. return Measure;
  12073. }());
  12074. /***/ }),
  12075. /***/ "./2D/multiLinePoint.ts":
  12076. /*!******************************!*\
  12077. !*** ./2D/multiLinePoint.ts ***!
  12078. \******************************/
  12079. /*! exports provided: MultiLinePoint */
  12080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12081. "use strict";
  12082. __webpack_require__.r(__webpack_exports__);
  12083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  12084. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12085. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12086. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12087. /**
  12088. * Class used to store a point for a MultiLine object.
  12089. * The point can be pure 2D coordinates, a mesh or a control
  12090. */
  12091. var MultiLinePoint = /** @class */ (function () {
  12092. /**
  12093. * Creates a new MultiLinePoint
  12094. * @param multiLine defines the source MultiLine object
  12095. */
  12096. function MultiLinePoint(multiLine) {
  12097. this._multiLine = multiLine;
  12098. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12099. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12100. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12101. }
  12102. Object.defineProperty(MultiLinePoint.prototype, "x", {
  12103. /** Gets or sets x coordinate */
  12104. get: function () {
  12105. return this._x.toString(this._multiLine._host);
  12106. },
  12107. set: function (value) {
  12108. if (this._x.toString(this._multiLine._host) === value) {
  12109. return;
  12110. }
  12111. if (this._x.fromString(value)) {
  12112. this._multiLine._markAsDirty();
  12113. }
  12114. },
  12115. enumerable: true,
  12116. configurable: true
  12117. });
  12118. Object.defineProperty(MultiLinePoint.prototype, "y", {
  12119. /** Gets or sets y coordinate */
  12120. get: function () {
  12121. return this._y.toString(this._multiLine._host);
  12122. },
  12123. set: function (value) {
  12124. if (this._y.toString(this._multiLine._host) === value) {
  12125. return;
  12126. }
  12127. if (this._y.fromString(value)) {
  12128. this._multiLine._markAsDirty();
  12129. }
  12130. },
  12131. enumerable: true,
  12132. configurable: true
  12133. });
  12134. Object.defineProperty(MultiLinePoint.prototype, "control", {
  12135. /** Gets or sets the control associated with this point */
  12136. get: function () {
  12137. return this._control;
  12138. },
  12139. set: function (value) {
  12140. if (this._control === value) {
  12141. return;
  12142. }
  12143. if (this._control && this._controlObserver) {
  12144. this._control.onDirtyObservable.remove(this._controlObserver);
  12145. this._controlObserver = null;
  12146. }
  12147. this._control = value;
  12148. if (this._control) {
  12149. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  12150. }
  12151. this._multiLine._markAsDirty();
  12152. },
  12153. enumerable: true,
  12154. configurable: true
  12155. });
  12156. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  12157. /** Gets or sets the mesh associated with this point */
  12158. get: function () {
  12159. return this._mesh;
  12160. },
  12161. set: function (value) {
  12162. if (this._mesh === value) {
  12163. return;
  12164. }
  12165. if (this._mesh && this._meshObserver) {
  12166. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  12167. }
  12168. this._mesh = value;
  12169. if (this._mesh) {
  12170. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  12171. }
  12172. this._multiLine._markAsDirty();
  12173. },
  12174. enumerable: true,
  12175. configurable: true
  12176. });
  12177. /** Resets links */
  12178. MultiLinePoint.prototype.resetLinks = function () {
  12179. this.control = null;
  12180. this.mesh = null;
  12181. };
  12182. /**
  12183. * Gets a translation vector
  12184. * @returns the translation vector
  12185. */
  12186. MultiLinePoint.prototype.translate = function () {
  12187. this._point = this._translatePoint();
  12188. return this._point;
  12189. };
  12190. MultiLinePoint.prototype._translatePoint = function () {
  12191. if (this._mesh != null) {
  12192. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  12193. }
  12194. else if (this._control != null) {
  12195. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  12196. }
  12197. else {
  12198. var host = this._multiLine._host;
  12199. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  12200. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  12201. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  12202. }
  12203. };
  12204. /** Release associated resources */
  12205. MultiLinePoint.prototype.dispose = function () {
  12206. this.resetLinks();
  12207. };
  12208. return MultiLinePoint;
  12209. }());
  12210. /***/ }),
  12211. /***/ "./2D/style.ts":
  12212. /*!*********************!*\
  12213. !*** ./2D/style.ts ***!
  12214. \*********************/
  12215. /*! exports provided: Style */
  12216. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12217. "use strict";
  12218. __webpack_require__.r(__webpack_exports__);
  12219. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  12220. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12221. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12222. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12223. /**
  12224. * Define a style used by control to automatically setup properties based on a template.
  12225. * Only support font related properties so far
  12226. */
  12227. var Style = /** @class */ (function () {
  12228. /**
  12229. * Creates a new style object
  12230. * @param host defines the AdvancedDynamicTexture which hosts this style
  12231. */
  12232. function Style(host) {
  12233. this._fontFamily = "Arial";
  12234. this._fontStyle = "";
  12235. this._fontWeight = "";
  12236. /** @hidden */
  12237. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12238. /**
  12239. * Observable raised when the style values are changed
  12240. */
  12241. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12242. this._host = host;
  12243. }
  12244. Object.defineProperty(Style.prototype, "fontSize", {
  12245. /**
  12246. * Gets or sets the font size
  12247. */
  12248. get: function () {
  12249. return this._fontSize.toString(this._host);
  12250. },
  12251. set: function (value) {
  12252. if (this._fontSize.toString(this._host) === value) {
  12253. return;
  12254. }
  12255. if (this._fontSize.fromString(value)) {
  12256. this.onChangedObservable.notifyObservers(this);
  12257. }
  12258. },
  12259. enumerable: true,
  12260. configurable: true
  12261. });
  12262. Object.defineProperty(Style.prototype, "fontFamily", {
  12263. /**
  12264. * Gets or sets the font family
  12265. */
  12266. get: function () {
  12267. return this._fontFamily;
  12268. },
  12269. set: function (value) {
  12270. if (this._fontFamily === value) {
  12271. return;
  12272. }
  12273. this._fontFamily = value;
  12274. this.onChangedObservable.notifyObservers(this);
  12275. },
  12276. enumerable: true,
  12277. configurable: true
  12278. });
  12279. Object.defineProperty(Style.prototype, "fontStyle", {
  12280. /**
  12281. * Gets or sets the font style
  12282. */
  12283. get: function () {
  12284. return this._fontStyle;
  12285. },
  12286. set: function (value) {
  12287. if (this._fontStyle === value) {
  12288. return;
  12289. }
  12290. this._fontStyle = value;
  12291. this.onChangedObservable.notifyObservers(this);
  12292. },
  12293. enumerable: true,
  12294. configurable: true
  12295. });
  12296. Object.defineProperty(Style.prototype, "fontWeight", {
  12297. /** Gets or sets font weight */
  12298. get: function () {
  12299. return this._fontWeight;
  12300. },
  12301. set: function (value) {
  12302. if (this._fontWeight === value) {
  12303. return;
  12304. }
  12305. this._fontWeight = value;
  12306. this.onChangedObservable.notifyObservers(this);
  12307. },
  12308. enumerable: true,
  12309. configurable: true
  12310. });
  12311. /** Dispose all associated resources */
  12312. Style.prototype.dispose = function () {
  12313. this.onChangedObservable.clear();
  12314. };
  12315. return Style;
  12316. }());
  12317. /***/ }),
  12318. /***/ "./2D/valueAndUnit.ts":
  12319. /*!****************************!*\
  12320. !*** ./2D/valueAndUnit.ts ***!
  12321. \****************************/
  12322. /*! exports provided: ValueAndUnit */
  12323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12324. "use strict";
  12325. __webpack_require__.r(__webpack_exports__);
  12326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12327. /**
  12328. * Class used to specific a value and its associated unit
  12329. */
  12330. var ValueAndUnit = /** @class */ (function () {
  12331. /**
  12332. * Creates a new ValueAndUnit
  12333. * @param value defines the value to store
  12334. * @param unit defines the unit to store
  12335. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12336. */
  12337. function ValueAndUnit(value,
  12338. /** defines the unit to store */
  12339. unit,
  12340. /** defines a boolean indicating if the value can be negative */
  12341. negativeValueAllowed) {
  12342. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12343. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12344. this.unit = unit;
  12345. this.negativeValueAllowed = negativeValueAllowed;
  12346. this._value = 1;
  12347. /**
  12348. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12349. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12350. */
  12351. this.ignoreAdaptiveScaling = false;
  12352. this._value = value;
  12353. this._originalUnit = unit;
  12354. }
  12355. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12356. /** Gets a boolean indicating if the value is a percentage */
  12357. get: function () {
  12358. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12359. },
  12360. enumerable: true,
  12361. configurable: true
  12362. });
  12363. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12364. /** Gets a boolean indicating if the value is store as pixel */
  12365. get: function () {
  12366. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12367. },
  12368. enumerable: true,
  12369. configurable: true
  12370. });
  12371. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12372. /** Gets direct internal value */
  12373. get: function () {
  12374. return this._value;
  12375. },
  12376. enumerable: true,
  12377. configurable: true
  12378. });
  12379. /**
  12380. * Gets value as pixel
  12381. * @param host defines the root host
  12382. * @param refValue defines the reference value for percentages
  12383. * @returns the value as pixel
  12384. */
  12385. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12386. if (this.isPixel) {
  12387. return this.getValue(host);
  12388. }
  12389. return this.getValue(host) * refValue;
  12390. };
  12391. /**
  12392. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12393. * @param value defines the value to store
  12394. * @param unit defines the unit to store
  12395. * @returns the current ValueAndUnit
  12396. */
  12397. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12398. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12399. this._value = value;
  12400. this.unit = unit;
  12401. return this;
  12402. };
  12403. /**
  12404. * Gets the value accordingly to its unit
  12405. * @param host defines the root host
  12406. * @returns the value
  12407. */
  12408. ValueAndUnit.prototype.getValue = function (host) {
  12409. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12410. var width = 0;
  12411. var height = 0;
  12412. if (host.idealWidth) {
  12413. width = (this._value * host.getSize().width) / host.idealWidth;
  12414. }
  12415. if (host.idealHeight) {
  12416. height = (this._value * host.getSize().height) / host.idealHeight;
  12417. }
  12418. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12419. return window.innerWidth < window.innerHeight ? width : height;
  12420. }
  12421. if (host.idealWidth) { // horizontal
  12422. return width;
  12423. }
  12424. if (host.idealHeight) { // vertical
  12425. return height;
  12426. }
  12427. }
  12428. return this._value;
  12429. };
  12430. /**
  12431. * Gets a string representation of the value
  12432. * @param host defines the root host
  12433. * @param decimals defines an optional number of decimals to display
  12434. * @returns a string
  12435. */
  12436. ValueAndUnit.prototype.toString = function (host, decimals) {
  12437. switch (this.unit) {
  12438. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12439. var percentage = this.getValue(host) * 100;
  12440. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  12441. case ValueAndUnit.UNITMODE_PIXEL:
  12442. var pixels = this.getValue(host);
  12443. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  12444. }
  12445. return this.unit.toString();
  12446. };
  12447. /**
  12448. * Store a value parsed from a string
  12449. * @param source defines the source string
  12450. * @returns true if the value was successfully parsed
  12451. */
  12452. ValueAndUnit.prototype.fromString = function (source) {
  12453. var match = ValueAndUnit._Regex.exec(source.toString());
  12454. if (!match || match.length === 0) {
  12455. return false;
  12456. }
  12457. var sourceValue = parseFloat(match[1]);
  12458. var sourceUnit = this._originalUnit;
  12459. if (!this.negativeValueAllowed) {
  12460. if (sourceValue < 0) {
  12461. sourceValue = 0;
  12462. }
  12463. }
  12464. if (match.length === 4) {
  12465. switch (match[3]) {
  12466. case "px":
  12467. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12468. break;
  12469. case "%":
  12470. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12471. sourceValue /= 100.0;
  12472. break;
  12473. }
  12474. }
  12475. if (sourceValue === this._value && sourceUnit === this.unit) {
  12476. return false;
  12477. }
  12478. this._value = sourceValue;
  12479. this.unit = sourceUnit;
  12480. return true;
  12481. };
  12482. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12483. /** UNITMODE_PERCENTAGE */
  12484. get: function () {
  12485. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12486. },
  12487. enumerable: true,
  12488. configurable: true
  12489. });
  12490. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12491. /** UNITMODE_PIXEL */
  12492. get: function () {
  12493. return ValueAndUnit._UNITMODE_PIXEL;
  12494. },
  12495. enumerable: true,
  12496. configurable: true
  12497. });
  12498. // Static
  12499. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12500. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12501. ValueAndUnit._UNITMODE_PIXEL = 1;
  12502. return ValueAndUnit;
  12503. }());
  12504. /***/ }),
  12505. /***/ "./2D/xmlLoader.ts":
  12506. /*!*************************!*\
  12507. !*** ./2D/xmlLoader.ts ***!
  12508. \*************************/
  12509. /*! exports provided: XmlLoader */
  12510. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12511. "use strict";
  12512. __webpack_require__.r(__webpack_exports__);
  12513. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  12514. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  12515. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  12516. /**
  12517. * Class used to load GUI via XML.
  12518. */
  12519. var XmlLoader = /** @class */ (function () {
  12520. /**
  12521. * Create a new xml loader
  12522. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  12523. */
  12524. function XmlLoader(parentClass) {
  12525. if (parentClass === void 0) { parentClass = null; }
  12526. this._nodes = {};
  12527. this._nodeTypes = {
  12528. element: 1,
  12529. attribute: 2,
  12530. text: 3
  12531. };
  12532. this._isLoaded = false;
  12533. this._objectAttributes = {
  12534. "textHorizontalAlignment": 1,
  12535. "textVerticalAlignment": 2,
  12536. "horizontalAlignment": 3,
  12537. "verticalAlignment": 4,
  12538. "stretch": 5,
  12539. };
  12540. if (parentClass) {
  12541. this._parentClass = parentClass;
  12542. }
  12543. }
  12544. XmlLoader.prototype._getChainElement = function (attributeValue) {
  12545. var element = window;
  12546. if (this._parentClass) {
  12547. element = this._parentClass;
  12548. }
  12549. var value = attributeValue;
  12550. value = value.split(".");
  12551. for (var i = 0; i < value.length; i++) {
  12552. element = element[value[i]];
  12553. }
  12554. return element;
  12555. };
  12556. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  12557. var attribute = attributeName.split(".");
  12558. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  12559. return className[attribute[1]];
  12560. };
  12561. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  12562. if (linkParent === void 0) { linkParent = true; }
  12563. try {
  12564. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  12565. var guiNode = new className();
  12566. if (parent && linkParent) {
  12567. parent.addControl(guiNode);
  12568. }
  12569. for (var i = 0; i < node.attributes.length; i++) {
  12570. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  12571. continue;
  12572. }
  12573. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  12574. var element = this._getChainElement(node.attributes[i].value);
  12575. guiNode[node.attributes[i].name].add(element);
  12576. continue;
  12577. }
  12578. else if (node.attributes[i].name == "linkWithMesh") {
  12579. if (this._parentClass) {
  12580. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  12581. }
  12582. else {
  12583. guiNode.linkWithMesh(window[node.attributes[i].value]);
  12584. }
  12585. }
  12586. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  12587. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  12588. guiNode[node.attributes[i].name] = element;
  12589. }
  12590. else if (!this._objectAttributes[node.attributes[i].name]) {
  12591. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  12592. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  12593. }
  12594. else {
  12595. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  12596. }
  12597. }
  12598. else {
  12599. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  12600. }
  12601. }
  12602. if (!node.attributes.getNamedItem("id")) {
  12603. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  12604. return guiNode;
  12605. }
  12606. if (!this._nodes[node.attributes.getNamedItem("id").nodeValue]) {
  12607. this._nodes[node.attributes.getNamedItem("id").nodeValue] = guiNode;
  12608. }
  12609. else {
  12610. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  12611. }
  12612. return guiNode;
  12613. }
  12614. catch (e) {
  12615. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  12616. }
  12617. };
  12618. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  12619. var width;
  12620. var height;
  12621. var columns;
  12622. var rows = node.children;
  12623. var cells;
  12624. var isPixel = false;
  12625. var cellNode;
  12626. var rowNumber = -1;
  12627. var columnNumber = -1;
  12628. var totalColumnsNumber = 0;
  12629. for (var i = 0; i < rows.length; i++) {
  12630. if (rows[i].nodeType != this._nodeTypes.element) {
  12631. continue;
  12632. }
  12633. if (rows[i].nodeName != "Row") {
  12634. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  12635. }
  12636. rowNumber += 1;
  12637. columns = rows[i].children;
  12638. if (!rows[i].attributes.getNamedItem("height")) {
  12639. throw "XmlLoader Exception : Height must be defined for grid rows";
  12640. }
  12641. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  12642. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  12643. guiNode.addRowDefinition(height, isPixel);
  12644. for (var j = 0; j < columns.length; j++) {
  12645. if (columns[j].nodeType != this._nodeTypes.element) {
  12646. continue;
  12647. }
  12648. if (columns[j].nodeName != "Column") {
  12649. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  12650. }
  12651. columnNumber += 1;
  12652. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  12653. 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.";
  12654. }
  12655. if (rowNumber == 0) {
  12656. if (!columns[j].attributes.getNamedItem("width")) {
  12657. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  12658. }
  12659. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  12660. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  12661. guiNode.addColumnDefinition(width, isPixel);
  12662. }
  12663. cells = columns[j].children;
  12664. for (var k = 0; k < cells.length; k++) {
  12665. if (cells[k].nodeType != this._nodeTypes.element) {
  12666. continue;
  12667. }
  12668. cellNode = this._createGuiElement(cells[k], guiNode, false);
  12669. guiNode.addControl(cellNode, rowNumber, columnNumber);
  12670. if (cells[k].firstChild) {
  12671. this._parseXml(cells[k].firstChild, cellNode);
  12672. }
  12673. }
  12674. }
  12675. if (rowNumber == 0) {
  12676. totalColumnsNumber = columnNumber;
  12677. }
  12678. columnNumber = -1;
  12679. }
  12680. if (node.nextSibling) {
  12681. this._parseXml(node.nextSibling, parent);
  12682. }
  12683. };
  12684. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  12685. if (node.firstChild) {
  12686. this._parseXml(node.firstChild, guiNode);
  12687. }
  12688. if (node.nextSibling) {
  12689. this._parseXml(node.nextSibling, parent);
  12690. }
  12691. };
  12692. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  12693. if (this._parentClass) {
  12694. this._parentClass[variable] = source[iterator];
  12695. }
  12696. else {
  12697. window[variable] = source[iterator];
  12698. }
  12699. if (node.firstChild) {
  12700. this._parseXml(node.firstChild, guiNode, true);
  12701. }
  12702. };
  12703. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  12704. var dataSource = node.attributes.getNamedItem("dataSource").value;
  12705. if (!dataSource.includes(" in ")) {
  12706. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  12707. }
  12708. else {
  12709. var isArray = true;
  12710. var splittedSource = dataSource.split(" in ");
  12711. if (splittedSource.length < 2) {
  12712. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  12713. }
  12714. var source = splittedSource[1];
  12715. if (source.startsWith("{") && source.endsWith("}")) {
  12716. isArray = false;
  12717. }
  12718. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  12719. source = source.substring(1, source.length - 1);
  12720. }
  12721. if (this._parentClass) {
  12722. source = this._parentClass[source];
  12723. }
  12724. else {
  12725. source = window[source];
  12726. }
  12727. if (isArray) {
  12728. for (var i = 0; i < source.length; i++) {
  12729. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  12730. }
  12731. }
  12732. else {
  12733. for (var i in source) {
  12734. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  12735. }
  12736. }
  12737. if (node.nextSibling) {
  12738. this._parseXml(node.nextSibling, parent);
  12739. }
  12740. }
  12741. };
  12742. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  12743. if (generated === void 0) { generated = false; }
  12744. if (node.nodeType != this._nodeTypes.element) {
  12745. if (node.nextSibling) {
  12746. this._parseXml(node.nextSibling, parent, generated);
  12747. }
  12748. return;
  12749. }
  12750. if (generated) {
  12751. node.setAttribute("id", parent.id + parent._children.length + 1);
  12752. }
  12753. var guiNode = this._createGuiElement(node, parent);
  12754. if (node.nodeName == "Grid") {
  12755. this._parseGrid(node, guiNode, parent);
  12756. }
  12757. else if (!node.attributes.getNamedItem("dataSource")) {
  12758. this._parseElement(node, guiNode, parent);
  12759. }
  12760. else {
  12761. this._parseElementsFromSource(node, guiNode, parent);
  12762. }
  12763. };
  12764. /**
  12765. * Gets if the loading has finished.
  12766. * @returns whether the loading has finished or not
  12767. */
  12768. XmlLoader.prototype.isLoaded = function () {
  12769. return this._isLoaded;
  12770. };
  12771. /**
  12772. * Gets a loaded node / control by id.
  12773. * @param id the Controls id set in the xml
  12774. * @returns element of type Control
  12775. */
  12776. XmlLoader.prototype.getNodeById = function (id) {
  12777. return this._nodes[id];
  12778. };
  12779. /**
  12780. * Gets all loaded nodes / controls
  12781. * @returns Array of controls
  12782. */
  12783. XmlLoader.prototype.getNodes = function () {
  12784. return this._nodes;
  12785. };
  12786. /**
  12787. * Initiates the xml layout loading
  12788. * @param xmlFile defines the xml layout to load
  12789. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  12790. * @param callback defines the callback called on layout load.
  12791. */
  12792. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  12793. var xhttp = new XMLHttpRequest();
  12794. xhttp.onreadystatechange = function () {
  12795. if (xhttp.readyState == 4 && xhttp.status == 200) {
  12796. if (!xhttp.responseXML) {
  12797. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  12798. }
  12799. var xmlDoc = xhttp.responseXML.documentElement;
  12800. this._parseXml(xmlDoc.firstChild, rootNode);
  12801. this._isLoaded = true;
  12802. if (callback) {
  12803. callback();
  12804. }
  12805. }
  12806. }.bind(this);
  12807. xhttp.open("GET", xmlFile, true);
  12808. xhttp.send();
  12809. };
  12810. return XmlLoader;
  12811. }());
  12812. /***/ }),
  12813. /***/ "./3D/controls/abstractButton3D.ts":
  12814. /*!*****************************************!*\
  12815. !*** ./3D/controls/abstractButton3D.ts ***!
  12816. \*****************************************/
  12817. /*! exports provided: AbstractButton3D */
  12818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12819. "use strict";
  12820. __webpack_require__.r(__webpack_exports__);
  12821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12822. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12823. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  12824. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12825. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12826. /**
  12827. * Class used as a root to all buttons
  12828. */
  12829. var AbstractButton3D = /** @class */ (function (_super) {
  12830. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  12831. /**
  12832. * Creates a new button
  12833. * @param name defines the control name
  12834. */
  12835. function AbstractButton3D(name) {
  12836. return _super.call(this, name) || this;
  12837. }
  12838. AbstractButton3D.prototype._getTypeName = function () {
  12839. return "AbstractButton3D";
  12840. };
  12841. // Mesh association
  12842. AbstractButton3D.prototype._createNode = function (scene) {
  12843. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12844. };
  12845. return AbstractButton3D;
  12846. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12847. /***/ }),
  12848. /***/ "./3D/controls/button3D.ts":
  12849. /*!*********************************!*\
  12850. !*** ./3D/controls/button3D.ts ***!
  12851. \*********************************/
  12852. /*! exports provided: Button3D */
  12853. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12854. "use strict";
  12855. __webpack_require__.r(__webpack_exports__);
  12856. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12857. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12858. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12859. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12860. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12861. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12862. /**
  12863. * Class used to create a button in 3D
  12864. */
  12865. var Button3D = /** @class */ (function (_super) {
  12866. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  12867. /**
  12868. * Creates a new button
  12869. * @param name defines the control name
  12870. */
  12871. function Button3D(name) {
  12872. var _this = _super.call(this, name) || this;
  12873. _this._contentResolution = 512;
  12874. _this._contentScaleRatio = 2;
  12875. // Default animations
  12876. _this.pointerEnterAnimation = function () {
  12877. if (!_this.mesh) {
  12878. return;
  12879. }
  12880. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12881. };
  12882. _this.pointerOutAnimation = function () {
  12883. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12884. };
  12885. _this.pointerDownAnimation = function () {
  12886. if (!_this.mesh) {
  12887. return;
  12888. }
  12889. _this.mesh.scaling.scaleInPlace(0.95);
  12890. };
  12891. _this.pointerUpAnimation = function () {
  12892. if (!_this.mesh) {
  12893. return;
  12894. }
  12895. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12896. };
  12897. return _this;
  12898. }
  12899. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12900. /**
  12901. * Gets or sets the texture resolution used to render content (512 by default)
  12902. */
  12903. get: function () {
  12904. return this._contentResolution;
  12905. },
  12906. set: function (value) {
  12907. if (this._contentResolution === value) {
  12908. return;
  12909. }
  12910. this._contentResolution = value;
  12911. this._resetContent();
  12912. },
  12913. enumerable: true,
  12914. configurable: true
  12915. });
  12916. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12917. /**
  12918. * Gets or sets the texture scale ratio used to render content (2 by default)
  12919. */
  12920. get: function () {
  12921. return this._contentScaleRatio;
  12922. },
  12923. set: function (value) {
  12924. if (this._contentScaleRatio === value) {
  12925. return;
  12926. }
  12927. this._contentScaleRatio = value;
  12928. this._resetContent();
  12929. },
  12930. enumerable: true,
  12931. configurable: true
  12932. });
  12933. Button3D.prototype._disposeFacadeTexture = function () {
  12934. if (this._facadeTexture) {
  12935. this._facadeTexture.dispose();
  12936. this._facadeTexture = null;
  12937. }
  12938. };
  12939. Button3D.prototype._resetContent = function () {
  12940. this._disposeFacadeTexture();
  12941. this.content = this._content;
  12942. };
  12943. Object.defineProperty(Button3D.prototype, "content", {
  12944. /**
  12945. * Gets or sets the GUI 2D content used to display the button's facade
  12946. */
  12947. get: function () {
  12948. return this._content;
  12949. },
  12950. set: function (value) {
  12951. this._content = value;
  12952. if (!this._host || !this._host.utilityLayer) {
  12953. return;
  12954. }
  12955. if (!this._facadeTexture) {
  12956. 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);
  12957. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12958. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12959. this._facadeTexture.premulAlpha = true;
  12960. }
  12961. else {
  12962. this._facadeTexture.rootContainer.clearControls();
  12963. }
  12964. this._facadeTexture.addControl(value);
  12965. this._applyFacade(this._facadeTexture);
  12966. },
  12967. enumerable: true,
  12968. configurable: true
  12969. });
  12970. /**
  12971. * Apply the facade texture (created from the content property).
  12972. * This function can be overloaded by child classes
  12973. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12974. */
  12975. Button3D.prototype._applyFacade = function (facadeTexture) {
  12976. this._currentMaterial.emissiveTexture = facadeTexture;
  12977. };
  12978. Button3D.prototype._getTypeName = function () {
  12979. return "Button3D";
  12980. };
  12981. // Mesh association
  12982. Button3D.prototype._createNode = function (scene) {
  12983. var faceUV = new Array(6);
  12984. for (var i = 0; i < 6; i++) {
  12985. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12986. }
  12987. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12988. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  12989. width: 1.0,
  12990. height: 1.0,
  12991. depth: 0.08,
  12992. faceUV: faceUV
  12993. }, scene);
  12994. return mesh;
  12995. };
  12996. Button3D.prototype._affectMaterial = function (mesh) {
  12997. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12998. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12999. mesh.material = material;
  13000. this._currentMaterial = material;
  13001. this._resetContent();
  13002. };
  13003. /**
  13004. * Releases all associated resources
  13005. */
  13006. Button3D.prototype.dispose = function () {
  13007. _super.prototype.dispose.call(this);
  13008. this._disposeFacadeTexture();
  13009. if (this._currentMaterial) {
  13010. this._currentMaterial.dispose();
  13011. }
  13012. };
  13013. return Button3D;
  13014. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  13015. /***/ }),
  13016. /***/ "./3D/controls/container3D.ts":
  13017. /*!************************************!*\
  13018. !*** ./3D/controls/container3D.ts ***!
  13019. \************************************/
  13020. /*! exports provided: Container3D */
  13021. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13022. "use strict";
  13023. __webpack_require__.r(__webpack_exports__);
  13024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  13025. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13026. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  13027. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13028. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13029. /**
  13030. * Class used to create containers for controls
  13031. */
  13032. var Container3D = /** @class */ (function (_super) {
  13033. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  13034. /**
  13035. * Creates a new container
  13036. * @param name defines the container name
  13037. */
  13038. function Container3D(name) {
  13039. var _this = _super.call(this, name) || this;
  13040. _this._blockLayout = false;
  13041. /**
  13042. * Gets the list of child controls
  13043. */
  13044. _this._children = new Array();
  13045. return _this;
  13046. }
  13047. Object.defineProperty(Container3D.prototype, "children", {
  13048. /**
  13049. * Gets the list of child controls
  13050. */
  13051. get: function () {
  13052. return this._children;
  13053. },
  13054. enumerable: true,
  13055. configurable: true
  13056. });
  13057. Object.defineProperty(Container3D.prototype, "blockLayout", {
  13058. /**
  13059. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  13060. * This is helpful to optimize layout operation when adding multiple children in a row
  13061. */
  13062. get: function () {
  13063. return this._blockLayout;
  13064. },
  13065. set: function (value) {
  13066. if (this._blockLayout === value) {
  13067. return;
  13068. }
  13069. this._blockLayout = value;
  13070. if (!this._blockLayout) {
  13071. this._arrangeChildren();
  13072. }
  13073. },
  13074. enumerable: true,
  13075. configurable: true
  13076. });
  13077. /**
  13078. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  13079. * @returns the current container
  13080. */
  13081. Container3D.prototype.updateLayout = function () {
  13082. this._arrangeChildren();
  13083. return this;
  13084. };
  13085. /**
  13086. * Gets a boolean indicating if the given control is in the children of this control
  13087. * @param control defines the control to check
  13088. * @returns true if the control is in the child list
  13089. */
  13090. Container3D.prototype.containsControl = function (control) {
  13091. return this._children.indexOf(control) !== -1;
  13092. };
  13093. /**
  13094. * Adds a control to the children of this control
  13095. * @param control defines the control to add
  13096. * @returns the current container
  13097. */
  13098. Container3D.prototype.addControl = function (control) {
  13099. var index = this._children.indexOf(control);
  13100. if (index !== -1) {
  13101. return this;
  13102. }
  13103. control.parent = this;
  13104. control._host = this._host;
  13105. this._children.push(control);
  13106. if (this._host.utilityLayer) {
  13107. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  13108. if (control.node) {
  13109. control.node.parent = this.node;
  13110. }
  13111. if (!this.blockLayout) {
  13112. this._arrangeChildren();
  13113. }
  13114. }
  13115. return this;
  13116. };
  13117. /**
  13118. * This function will be called everytime a new control is added
  13119. */
  13120. Container3D.prototype._arrangeChildren = function () {
  13121. };
  13122. Container3D.prototype._createNode = function (scene) {
  13123. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  13124. };
  13125. /**
  13126. * Removes a control from the children of this control
  13127. * @param control defines the control to remove
  13128. * @returns the current container
  13129. */
  13130. Container3D.prototype.removeControl = function (control) {
  13131. var index = this._children.indexOf(control);
  13132. if (index !== -1) {
  13133. this._children.splice(index, 1);
  13134. control.parent = null;
  13135. control._disposeNode();
  13136. }
  13137. return this;
  13138. };
  13139. Container3D.prototype._getTypeName = function () {
  13140. return "Container3D";
  13141. };
  13142. /**
  13143. * Releases all associated resources
  13144. */
  13145. Container3D.prototype.dispose = function () {
  13146. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13147. var control = _a[_i];
  13148. control.dispose();
  13149. }
  13150. this._children = [];
  13151. _super.prototype.dispose.call(this);
  13152. };
  13153. /** Control rotation will remain unchanged */
  13154. Container3D.UNSET_ORIENTATION = 0;
  13155. /** Control will rotate to make it look at sphere central axis */
  13156. Container3D.FACEORIGIN_ORIENTATION = 1;
  13157. /** Control will rotate to make it look back at sphere central axis */
  13158. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  13159. /** Control will rotate to look at z axis (0, 0, 1) */
  13160. Container3D.FACEFORWARD_ORIENTATION = 3;
  13161. /** Control will rotate to look at negative z axis (0, 0, -1) */
  13162. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  13163. return Container3D;
  13164. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13165. /***/ }),
  13166. /***/ "./3D/controls/control3D.ts":
  13167. /*!**********************************!*\
  13168. !*** ./3D/controls/control3D.ts ***!
  13169. \**********************************/
  13170. /*! exports provided: Control3D */
  13171. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13172. "use strict";
  13173. __webpack_require__.r(__webpack_exports__);
  13174. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  13175. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  13176. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13177. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  13178. /**
  13179. * Class used as base class for controls
  13180. */
  13181. var Control3D = /** @class */ (function () {
  13182. /**
  13183. * Creates a new control
  13184. * @param name defines the control name
  13185. */
  13186. function Control3D(
  13187. /** Defines the control name */
  13188. name) {
  13189. this.name = name;
  13190. this._downCount = 0;
  13191. this._enterCount = -1;
  13192. this._downPointerIds = {};
  13193. this._isVisible = true;
  13194. /**
  13195. * An event triggered when the pointer move over the control
  13196. */
  13197. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13198. /**
  13199. * An event triggered when the pointer move out of the control
  13200. */
  13201. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13202. /**
  13203. * An event triggered when the pointer taps the control
  13204. */
  13205. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13206. /**
  13207. * An event triggered when pointer is up
  13208. */
  13209. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13210. /**
  13211. * An event triggered when a control is clicked on (with a mouse)
  13212. */
  13213. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13214. /**
  13215. * An event triggered when pointer enters the control
  13216. */
  13217. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13218. // Behaviors
  13219. this._behaviors = new Array();
  13220. }
  13221. Object.defineProperty(Control3D.prototype, "position", {
  13222. /** Gets or sets the control position in world space */
  13223. get: function () {
  13224. if (!this._node) {
  13225. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  13226. }
  13227. return this._node.position;
  13228. },
  13229. set: function (value) {
  13230. if (!this._node) {
  13231. return;
  13232. }
  13233. this._node.position = value;
  13234. },
  13235. enumerable: true,
  13236. configurable: true
  13237. });
  13238. Object.defineProperty(Control3D.prototype, "scaling", {
  13239. /** Gets or sets the control scaling in world space */
  13240. get: function () {
  13241. if (!this._node) {
  13242. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  13243. }
  13244. return this._node.scaling;
  13245. },
  13246. set: function (value) {
  13247. if (!this._node) {
  13248. return;
  13249. }
  13250. this._node.scaling = value;
  13251. },
  13252. enumerable: true,
  13253. configurable: true
  13254. });
  13255. Object.defineProperty(Control3D.prototype, "behaviors", {
  13256. /**
  13257. * Gets the list of attached behaviors
  13258. * @see http://doc.babylonjs.com/features/behaviour
  13259. */
  13260. get: function () {
  13261. return this._behaviors;
  13262. },
  13263. enumerable: true,
  13264. configurable: true
  13265. });
  13266. /**
  13267. * Attach a behavior to the control
  13268. * @see http://doc.babylonjs.com/features/behaviour
  13269. * @param behavior defines the behavior to attach
  13270. * @returns the current control
  13271. */
  13272. Control3D.prototype.addBehavior = function (behavior) {
  13273. var _this = this;
  13274. var index = this._behaviors.indexOf(behavior);
  13275. if (index !== -1) {
  13276. return this;
  13277. }
  13278. behavior.init();
  13279. var scene = this._host.scene;
  13280. if (scene.isLoading) {
  13281. // We defer the attach when the scene will be loaded
  13282. scene.onDataLoadedObservable.addOnce(function () {
  13283. behavior.attach(_this);
  13284. });
  13285. }
  13286. else {
  13287. behavior.attach(this);
  13288. }
  13289. this._behaviors.push(behavior);
  13290. return this;
  13291. };
  13292. /**
  13293. * Remove an attached behavior
  13294. * @see http://doc.babylonjs.com/features/behaviour
  13295. * @param behavior defines the behavior to attach
  13296. * @returns the current control
  13297. */
  13298. Control3D.prototype.removeBehavior = function (behavior) {
  13299. var index = this._behaviors.indexOf(behavior);
  13300. if (index === -1) {
  13301. return this;
  13302. }
  13303. this._behaviors[index].detach();
  13304. this._behaviors.splice(index, 1);
  13305. return this;
  13306. };
  13307. /**
  13308. * Gets an attached behavior by name
  13309. * @param name defines the name of the behavior to look for
  13310. * @see http://doc.babylonjs.com/features/behaviour
  13311. * @returns null if behavior was not found else the requested behavior
  13312. */
  13313. Control3D.prototype.getBehaviorByName = function (name) {
  13314. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13315. var behavior = _a[_i];
  13316. if (behavior.name === name) {
  13317. return behavior;
  13318. }
  13319. }
  13320. return null;
  13321. };
  13322. Object.defineProperty(Control3D.prototype, "isVisible", {
  13323. /** Gets or sets a boolean indicating if the control is visible */
  13324. get: function () {
  13325. return this._isVisible;
  13326. },
  13327. set: function (value) {
  13328. if (this._isVisible === value) {
  13329. return;
  13330. }
  13331. this._isVisible = value;
  13332. var mesh = this.mesh;
  13333. if (mesh) {
  13334. mesh.setEnabled(value);
  13335. }
  13336. },
  13337. enumerable: true,
  13338. configurable: true
  13339. });
  13340. Object.defineProperty(Control3D.prototype, "typeName", {
  13341. /**
  13342. * Gets a string representing the class name
  13343. */
  13344. get: function () {
  13345. return this._getTypeName();
  13346. },
  13347. enumerable: true,
  13348. configurable: true
  13349. });
  13350. /**
  13351. * Get the current class name of the control.
  13352. * @returns current class name
  13353. */
  13354. Control3D.prototype.getClassName = function () {
  13355. return this._getTypeName();
  13356. };
  13357. Control3D.prototype._getTypeName = function () {
  13358. return "Control3D";
  13359. };
  13360. Object.defineProperty(Control3D.prototype, "node", {
  13361. /**
  13362. * Gets the transform node used by this control
  13363. */
  13364. get: function () {
  13365. return this._node;
  13366. },
  13367. enumerable: true,
  13368. configurable: true
  13369. });
  13370. Object.defineProperty(Control3D.prototype, "mesh", {
  13371. /**
  13372. * Gets the mesh used to render this control
  13373. */
  13374. get: function () {
  13375. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  13376. return this._node;
  13377. }
  13378. return null;
  13379. },
  13380. enumerable: true,
  13381. configurable: true
  13382. });
  13383. /**
  13384. * Link the control as child of the given node
  13385. * @param node defines the node to link to. Use null to unlink the control
  13386. * @returns the current control
  13387. */
  13388. Control3D.prototype.linkToTransformNode = function (node) {
  13389. if (this._node) {
  13390. this._node.parent = node;
  13391. }
  13392. return this;
  13393. };
  13394. /** @hidden **/
  13395. Control3D.prototype._prepareNode = function (scene) {
  13396. if (!this._node) {
  13397. this._node = this._createNode(scene);
  13398. if (!this.node) {
  13399. return;
  13400. }
  13401. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  13402. this._node.position = this.position;
  13403. this._node.scaling = this.scaling;
  13404. var mesh = this.mesh;
  13405. if (mesh) {
  13406. mesh.isPickable = true;
  13407. this._affectMaterial(mesh);
  13408. }
  13409. }
  13410. };
  13411. /**
  13412. * Node creation.
  13413. * Can be overriden by children
  13414. * @param scene defines the scene where the node must be attached
  13415. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  13416. */
  13417. Control3D.prototype._createNode = function (scene) {
  13418. // Do nothing by default
  13419. return null;
  13420. };
  13421. /**
  13422. * Affect a material to the given mesh
  13423. * @param mesh defines the mesh which will represent the control
  13424. */
  13425. Control3D.prototype._affectMaterial = function (mesh) {
  13426. mesh.material = null;
  13427. };
  13428. // Pointers
  13429. /** @hidden */
  13430. Control3D.prototype._onPointerMove = function (target, coordinates) {
  13431. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  13432. };
  13433. /** @hidden */
  13434. Control3D.prototype._onPointerEnter = function (target) {
  13435. if (this._enterCount > 0) {
  13436. return false;
  13437. }
  13438. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  13439. this._enterCount = 0;
  13440. }
  13441. this._enterCount++;
  13442. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  13443. if (this.pointerEnterAnimation) {
  13444. this.pointerEnterAnimation();
  13445. }
  13446. return true;
  13447. };
  13448. /** @hidden */
  13449. Control3D.prototype._onPointerOut = function (target) {
  13450. this._enterCount = 0;
  13451. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  13452. if (this.pointerOutAnimation) {
  13453. this.pointerOutAnimation();
  13454. }
  13455. };
  13456. /** @hidden */
  13457. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  13458. if (this._downCount !== 0) {
  13459. this._downCount++;
  13460. return false;
  13461. }
  13462. this._downCount++;
  13463. this._downPointerIds[pointerId] = true;
  13464. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13465. if (this.pointerDownAnimation) {
  13466. this.pointerDownAnimation();
  13467. }
  13468. return true;
  13469. };
  13470. /** @hidden */
  13471. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  13472. this._downCount--;
  13473. delete this._downPointerIds[pointerId];
  13474. if (this._downCount < 0) {
  13475. // Handle if forcePointerUp was called prior to this
  13476. this._downCount = 0;
  13477. return;
  13478. }
  13479. if (this._downCount == 0) {
  13480. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  13481. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13482. }
  13483. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13484. if (this.pointerUpAnimation) {
  13485. this.pointerUpAnimation();
  13486. }
  13487. }
  13488. };
  13489. /** @hidden */
  13490. Control3D.prototype.forcePointerUp = function (pointerId) {
  13491. if (pointerId === void 0) { pointerId = null; }
  13492. if (pointerId !== null) {
  13493. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  13494. }
  13495. else {
  13496. for (var key in this._downPointerIds) {
  13497. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  13498. }
  13499. if (this._downCount > 0) {
  13500. this._downCount = 1;
  13501. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  13502. }
  13503. }
  13504. };
  13505. /** @hidden */
  13506. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  13507. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  13508. this._onPointerMove(this, pickedPoint);
  13509. var previousControlOver = this._host._lastControlOver[pointerId];
  13510. if (previousControlOver && previousControlOver !== this) {
  13511. previousControlOver._onPointerOut(this);
  13512. }
  13513. if (previousControlOver !== this) {
  13514. this._onPointerEnter(this);
  13515. }
  13516. this._host._lastControlOver[pointerId] = this;
  13517. return true;
  13518. }
  13519. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  13520. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  13521. this._host._lastControlDown[pointerId] = this;
  13522. this._host._lastPickedControl = this;
  13523. return true;
  13524. }
  13525. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  13526. if (this._host._lastControlDown[pointerId]) {
  13527. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  13528. }
  13529. delete this._host._lastControlDown[pointerId];
  13530. return true;
  13531. }
  13532. return false;
  13533. };
  13534. /** @hidden */
  13535. Control3D.prototype._disposeNode = function () {
  13536. if (this._node) {
  13537. this._node.dispose();
  13538. this._node = null;
  13539. }
  13540. };
  13541. /**
  13542. * Releases all associated resources
  13543. */
  13544. Control3D.prototype.dispose = function () {
  13545. this.onPointerDownObservable.clear();
  13546. this.onPointerEnterObservable.clear();
  13547. this.onPointerMoveObservable.clear();
  13548. this.onPointerOutObservable.clear();
  13549. this.onPointerUpObservable.clear();
  13550. this.onPointerClickObservable.clear();
  13551. this._disposeNode();
  13552. // Behaviors
  13553. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13554. var behavior = _a[_i];
  13555. behavior.detach();
  13556. }
  13557. };
  13558. return Control3D;
  13559. }());
  13560. /***/ }),
  13561. /***/ "./3D/controls/cylinderPanel.ts":
  13562. /*!**************************************!*\
  13563. !*** ./3D/controls/cylinderPanel.ts ***!
  13564. \**************************************/
  13565. /*! exports provided: CylinderPanel */
  13566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13567. "use strict";
  13568. __webpack_require__.r(__webpack_exports__);
  13569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13570. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13571. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  13572. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13573. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13574. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13575. /**
  13576. * Class used to create a container panel deployed on the surface of a cylinder
  13577. */
  13578. var CylinderPanel = /** @class */ (function (_super) {
  13579. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  13580. function CylinderPanel() {
  13581. var _this = _super !== null && _super.apply(this, arguments) || this;
  13582. _this._radius = 5.0;
  13583. return _this;
  13584. }
  13585. Object.defineProperty(CylinderPanel.prototype, "radius", {
  13586. /**
  13587. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  13588. */
  13589. get: function () {
  13590. return this._radius;
  13591. },
  13592. set: function (value) {
  13593. var _this = this;
  13594. if (this._radius === value) {
  13595. return;
  13596. }
  13597. this._radius = value;
  13598. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13599. _this._arrangeChildren();
  13600. });
  13601. },
  13602. enumerable: true,
  13603. configurable: true
  13604. });
  13605. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13606. var mesh = control.mesh;
  13607. if (!mesh) {
  13608. return;
  13609. }
  13610. var newPos = this._cylindricalMapping(nodePosition);
  13611. control.position = newPos;
  13612. switch (this.orientation) {
  13613. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13614. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13615. break;
  13616. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13617. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13618. break;
  13619. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13620. break;
  13621. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13622. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13623. break;
  13624. }
  13625. };
  13626. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13627. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13628. var yAngle = (source.x / this._radius);
  13629. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13630. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13631. };
  13632. return CylinderPanel;
  13633. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13634. /***/ }),
  13635. /***/ "./3D/controls/holographicButton.ts":
  13636. /*!******************************************!*\
  13637. !*** ./3D/controls/holographicButton.ts ***!
  13638. \******************************************/
  13639. /*! exports provided: HolographicButton */
  13640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13641. "use strict";
  13642. __webpack_require__.r(__webpack_exports__);
  13643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13644. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13645. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13646. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  13647. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13648. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13649. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13650. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13651. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13652. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13653. /**
  13654. * Class used to create a holographic button in 3D
  13655. */
  13656. var HolographicButton = /** @class */ (function (_super) {
  13657. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  13658. /**
  13659. * Creates a new button
  13660. * @param name defines the control name
  13661. */
  13662. function HolographicButton(name, shareMaterials) {
  13663. if (shareMaterials === void 0) { shareMaterials = true; }
  13664. var _this = _super.call(this, name) || this;
  13665. _this._shareMaterials = true;
  13666. _this._shareMaterials = shareMaterials;
  13667. // Default animations
  13668. _this.pointerEnterAnimation = function () {
  13669. if (!_this.mesh) {
  13670. return;
  13671. }
  13672. _this._frontPlate.setEnabled(true);
  13673. };
  13674. _this.pointerOutAnimation = function () {
  13675. if (!_this.mesh) {
  13676. return;
  13677. }
  13678. _this._frontPlate.setEnabled(false);
  13679. };
  13680. return _this;
  13681. }
  13682. HolographicButton.prototype._disposeTooltip = function () {
  13683. this._tooltipFade = null;
  13684. if (this._tooltipTextBlock) {
  13685. this._tooltipTextBlock.dispose();
  13686. }
  13687. if (this._tooltipTexture) {
  13688. this._tooltipTexture.dispose();
  13689. }
  13690. if (this._tooltipMesh) {
  13691. this._tooltipMesh.dispose();
  13692. }
  13693. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13694. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13695. };
  13696. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13697. get: function () {
  13698. if (this._tooltipTextBlock) {
  13699. return this._tooltipTextBlock.text;
  13700. }
  13701. return null;
  13702. },
  13703. /**
  13704. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13705. */
  13706. set: function (text) {
  13707. var _this = this;
  13708. if (!text) {
  13709. this._disposeTooltip();
  13710. return;
  13711. }
  13712. if (!this._tooltipFade) {
  13713. // Create tooltip with mesh and text
  13714. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13715. 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);
  13716. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13717. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13718. tooltipBackground.material = mat;
  13719. tooltipBackground.isPickable = false;
  13720. this._tooltipMesh.addChild(tooltipBackground);
  13721. tooltipBackground.position.z = 0.05;
  13722. this._tooltipMesh.scaling.y = 1 / 3;
  13723. this._tooltipMesh.position.y = 0.7;
  13724. this._tooltipMesh.position.z = -0.15;
  13725. this._tooltipMesh.isPickable = false;
  13726. this._tooltipMesh.parent = this._backPlate;
  13727. // Create text texture for the tooltip
  13728. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13729. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13730. this._tooltipTextBlock.scaleY = 3;
  13731. this._tooltipTextBlock.color = "white";
  13732. this._tooltipTextBlock.fontSize = 130;
  13733. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13734. // Add hover action to tooltip
  13735. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13736. this._tooltipFade.delay = 500;
  13737. this._tooltipMesh.addBehavior(this._tooltipFade);
  13738. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13739. if (_this._tooltipFade) {
  13740. _this._tooltipFade.fadeIn(true);
  13741. }
  13742. });
  13743. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13744. if (_this._tooltipFade) {
  13745. _this._tooltipFade.fadeIn(false);
  13746. }
  13747. });
  13748. }
  13749. if (this._tooltipTextBlock) {
  13750. this._tooltipTextBlock.text = text;
  13751. }
  13752. },
  13753. enumerable: true,
  13754. configurable: true
  13755. });
  13756. Object.defineProperty(HolographicButton.prototype, "text", {
  13757. /**
  13758. * Gets or sets text for the button
  13759. */
  13760. get: function () {
  13761. return this._text;
  13762. },
  13763. set: function (value) {
  13764. if (this._text === value) {
  13765. return;
  13766. }
  13767. this._text = value;
  13768. this._rebuildContent();
  13769. },
  13770. enumerable: true,
  13771. configurable: true
  13772. });
  13773. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13774. /**
  13775. * Gets or sets the image url for the button
  13776. */
  13777. get: function () {
  13778. return this._imageUrl;
  13779. },
  13780. set: function (value) {
  13781. if (this._imageUrl === value) {
  13782. return;
  13783. }
  13784. this._imageUrl = value;
  13785. this._rebuildContent();
  13786. },
  13787. enumerable: true,
  13788. configurable: true
  13789. });
  13790. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13791. /**
  13792. * Gets the back material used by this button
  13793. */
  13794. get: function () {
  13795. return this._backMaterial;
  13796. },
  13797. enumerable: true,
  13798. configurable: true
  13799. });
  13800. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13801. /**
  13802. * Gets the front material used by this button
  13803. */
  13804. get: function () {
  13805. return this._frontMaterial;
  13806. },
  13807. enumerable: true,
  13808. configurable: true
  13809. });
  13810. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13811. /**
  13812. * Gets the plate material used by this button
  13813. */
  13814. get: function () {
  13815. return this._plateMaterial;
  13816. },
  13817. enumerable: true,
  13818. configurable: true
  13819. });
  13820. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13821. /**
  13822. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13823. */
  13824. get: function () {
  13825. return this._shareMaterials;
  13826. },
  13827. enumerable: true,
  13828. configurable: true
  13829. });
  13830. HolographicButton.prototype._getTypeName = function () {
  13831. return "HolographicButton";
  13832. };
  13833. HolographicButton.prototype._rebuildContent = function () {
  13834. this._disposeFacadeTexture();
  13835. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13836. panel.isVertical = true;
  13837. if (this._imageUrl) {
  13838. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13839. image.source = this._imageUrl;
  13840. image.paddingTop = "40px";
  13841. image.height = "180px";
  13842. image.width = "100px";
  13843. image.paddingBottom = "40px";
  13844. panel.addControl(image);
  13845. }
  13846. if (this._text) {
  13847. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13848. text.text = this._text;
  13849. text.color = "white";
  13850. text.height = "30px";
  13851. text.fontSize = 24;
  13852. panel.addControl(text);
  13853. }
  13854. if (this._frontPlate) {
  13855. this.content = panel;
  13856. }
  13857. };
  13858. // Mesh association
  13859. HolographicButton.prototype._createNode = function (scene) {
  13860. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  13861. width: 1.0,
  13862. height: 1.0,
  13863. depth: 0.08
  13864. }, scene);
  13865. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  13866. width: 1.0,
  13867. height: 1.0,
  13868. depth: 0.08
  13869. }, scene);
  13870. this._frontPlate.parent = this._backPlate;
  13871. this._frontPlate.position.z = -0.08;
  13872. this._frontPlate.isPickable = false;
  13873. this._frontPlate.setEnabled(false);
  13874. this._textPlate = _super.prototype._createNode.call(this, scene);
  13875. this._textPlate.parent = this._backPlate;
  13876. this._textPlate.position.z = -0.08;
  13877. this._textPlate.isPickable = false;
  13878. return this._backPlate;
  13879. };
  13880. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13881. this._plateMaterial.emissiveTexture = facadeTexture;
  13882. this._plateMaterial.opacityTexture = facadeTexture;
  13883. };
  13884. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13885. var _this = this;
  13886. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13887. this._backMaterial.renderHoverLight = true;
  13888. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13889. if (pickedPoint) {
  13890. _this._backMaterial.hoverPosition = pickedPoint;
  13891. _this._backMaterial.hoverColor.a = 1.0;
  13892. }
  13893. else {
  13894. _this._backMaterial.hoverColor.a = 0;
  13895. }
  13896. });
  13897. };
  13898. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13899. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13900. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13901. this._frontMaterial.alpha = 0.5; // Additive
  13902. this._frontMaterial.renderBorders = true;
  13903. };
  13904. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13905. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13906. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13907. };
  13908. HolographicButton.prototype._affectMaterial = function (mesh) {
  13909. // Back
  13910. if (this._shareMaterials) {
  13911. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13912. this._createBackMaterial(mesh);
  13913. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13914. }
  13915. else {
  13916. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13917. }
  13918. // Front
  13919. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13920. this._createFrontMaterial(mesh);
  13921. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13922. }
  13923. else {
  13924. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13925. }
  13926. }
  13927. else {
  13928. this._createBackMaterial(mesh);
  13929. this._createFrontMaterial(mesh);
  13930. }
  13931. this._createPlateMaterial(mesh);
  13932. this._backPlate.material = this._backMaterial;
  13933. this._frontPlate.material = this._frontMaterial;
  13934. this._textPlate.material = this._plateMaterial;
  13935. this._rebuildContent();
  13936. };
  13937. /**
  13938. * Releases all associated resources
  13939. */
  13940. HolographicButton.prototype.dispose = function () {
  13941. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13942. this._disposeTooltip();
  13943. if (!this.shareMaterials) {
  13944. this._backMaterial.dispose();
  13945. this._frontMaterial.dispose();
  13946. this._plateMaterial.dispose();
  13947. if (this._pickedPointObserver) {
  13948. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13949. this._pickedPointObserver = null;
  13950. }
  13951. }
  13952. };
  13953. return HolographicButton;
  13954. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13955. /***/ }),
  13956. /***/ "./3D/controls/index.ts":
  13957. /*!******************************!*\
  13958. !*** ./3D/controls/index.ts ***!
  13959. \******************************/
  13960. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13961. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13962. "use strict";
  13963. __webpack_require__.r(__webpack_exports__);
  13964. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13966. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13968. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13970. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13972. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13974. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13976. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13978. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13980. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13982. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13984. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13986. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13988. /***/ }),
  13989. /***/ "./3D/controls/meshButton3D.ts":
  13990. /*!*************************************!*\
  13991. !*** ./3D/controls/meshButton3D.ts ***!
  13992. \*************************************/
  13993. /*! exports provided: MeshButton3D */
  13994. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13995. "use strict";
  13996. __webpack_require__.r(__webpack_exports__);
  13997. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13998. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13999. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14000. /**
  14001. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  14002. */
  14003. var MeshButton3D = /** @class */ (function (_super) {
  14004. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  14005. /**
  14006. * Creates a new 3D button based on a mesh
  14007. * @param mesh mesh to become a 3D button
  14008. * @param name defines the control name
  14009. */
  14010. function MeshButton3D(mesh, name) {
  14011. var _this = _super.call(this, name) || this;
  14012. _this._currentMesh = mesh;
  14013. /**
  14014. * Provides a default behavior on hover/out & up/down
  14015. * Override those function to create your own desired behavior specific to your mesh
  14016. */
  14017. _this.pointerEnterAnimation = function () {
  14018. if (!_this.mesh) {
  14019. return;
  14020. }
  14021. _this.mesh.scaling.scaleInPlace(1.1);
  14022. };
  14023. _this.pointerOutAnimation = function () {
  14024. if (!_this.mesh) {
  14025. return;
  14026. }
  14027. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  14028. };
  14029. _this.pointerDownAnimation = function () {
  14030. if (!_this.mesh) {
  14031. return;
  14032. }
  14033. _this.mesh.scaling.scaleInPlace(0.95);
  14034. };
  14035. _this.pointerUpAnimation = function () {
  14036. if (!_this.mesh) {
  14037. return;
  14038. }
  14039. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  14040. };
  14041. return _this;
  14042. }
  14043. MeshButton3D.prototype._getTypeName = function () {
  14044. return "MeshButton3D";
  14045. };
  14046. // Mesh association
  14047. MeshButton3D.prototype._createNode = function (scene) {
  14048. var _this = this;
  14049. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  14050. mesh.metadata = _this;
  14051. });
  14052. return this._currentMesh;
  14053. };
  14054. MeshButton3D.prototype._affectMaterial = function (mesh) {
  14055. };
  14056. return MeshButton3D;
  14057. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14058. /***/ }),
  14059. /***/ "./3D/controls/planePanel.ts":
  14060. /*!***********************************!*\
  14061. !*** ./3D/controls/planePanel.ts ***!
  14062. \***********************************/
  14063. /*! exports provided: PlanePanel */
  14064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14065. "use strict";
  14066. __webpack_require__.r(__webpack_exports__);
  14067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  14068. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14069. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  14070. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14071. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14072. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14073. /**
  14074. * Class used to create a container panel deployed on the surface of a plane
  14075. */
  14076. var PlanePanel = /** @class */ (function (_super) {
  14077. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  14078. function PlanePanel() {
  14079. return _super !== null && _super.apply(this, arguments) || this;
  14080. }
  14081. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  14082. var mesh = control.mesh;
  14083. if (!mesh) {
  14084. return;
  14085. }
  14086. control.position = nodePosition.clone();
  14087. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14088. target.copyFrom(nodePosition);
  14089. switch (this.orientation) {
  14090. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  14091. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  14092. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  14093. mesh.lookAt(target);
  14094. break;
  14095. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14096. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14097. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  14098. mesh.lookAt(target);
  14099. break;
  14100. }
  14101. };
  14102. return PlanePanel;
  14103. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  14104. /***/ }),
  14105. /***/ "./3D/controls/scatterPanel.ts":
  14106. /*!*************************************!*\
  14107. !*** ./3D/controls/scatterPanel.ts ***!
  14108. \*************************************/
  14109. /*! exports provided: ScatterPanel */
  14110. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14111. "use strict";
  14112. __webpack_require__.r(__webpack_exports__);
  14113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  14114. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14115. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  14116. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14117. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14118. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14119. /**
  14120. * Class used to create a container panel where items get randomized planar mapping
  14121. */
  14122. var ScatterPanel = /** @class */ (function (_super) {
  14123. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  14124. function ScatterPanel() {
  14125. var _this = _super !== null && _super.apply(this, arguments) || this;
  14126. _this._iteration = 100.0;
  14127. return _this;
  14128. }
  14129. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  14130. /**
  14131. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  14132. */
  14133. get: function () {
  14134. return this._iteration;
  14135. },
  14136. set: function (value) {
  14137. var _this = this;
  14138. if (this._iteration === value) {
  14139. return;
  14140. }
  14141. this._iteration = value;
  14142. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14143. _this._arrangeChildren();
  14144. });
  14145. },
  14146. enumerable: true,
  14147. configurable: true
  14148. });
  14149. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  14150. var mesh = control.mesh;
  14151. var newPos = this._scatterMapping(nodePosition);
  14152. if (!mesh) {
  14153. return;
  14154. }
  14155. switch (this.orientation) {
  14156. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14157. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14158. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  14159. break;
  14160. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14161. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14162. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  14163. break;
  14164. }
  14165. control.position = newPos;
  14166. };
  14167. ScatterPanel.prototype._scatterMapping = function (source) {
  14168. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  14169. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  14170. return source;
  14171. };
  14172. ScatterPanel.prototype._finalProcessing = function () {
  14173. var meshes = [];
  14174. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14175. var child = _a[_i];
  14176. if (!child.mesh) {
  14177. continue;
  14178. }
  14179. meshes.push(child.mesh);
  14180. }
  14181. for (var count = 0; count < this._iteration; count++) {
  14182. meshes.sort(function (a, b) {
  14183. var distance1 = a.position.lengthSquared();
  14184. var distance2 = b.position.lengthSquared();
  14185. if (distance1 < distance2) {
  14186. return 1;
  14187. }
  14188. else if (distance1 > distance2) {
  14189. return -1;
  14190. }
  14191. return 0;
  14192. });
  14193. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  14194. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  14195. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  14196. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14197. for (var i = 0; i < meshes.length - 1; i++) {
  14198. for (var j = i + 1; j < meshes.length; j++) {
  14199. if (i != j) {
  14200. meshes[j].position.subtractToRef(meshes[i].position, difference);
  14201. // Ignore Z axis
  14202. difference2D.x = difference.x;
  14203. difference2D.y = difference.y;
  14204. var combinedRadius = cellSize;
  14205. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  14206. var minSeparation = Math.min(distance, radiusPaddingSquared);
  14207. distance -= minSeparation;
  14208. if (distance < (Math.pow(combinedRadius, 2.0))) {
  14209. difference2D.normalize();
  14210. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  14211. meshes[j].position.addInPlace(difference);
  14212. meshes[i].position.subtractInPlace(difference);
  14213. }
  14214. }
  14215. }
  14216. }
  14217. }
  14218. };
  14219. return ScatterPanel;
  14220. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14221. /***/ }),
  14222. /***/ "./3D/controls/spherePanel.ts":
  14223. /*!************************************!*\
  14224. !*** ./3D/controls/spherePanel.ts ***!
  14225. \************************************/
  14226. /*! exports provided: SpherePanel */
  14227. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14228. "use strict";
  14229. __webpack_require__.r(__webpack_exports__);
  14230. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  14231. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14232. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  14233. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14234. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14235. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14236. /**
  14237. * Class used to create a container panel deployed on the surface of a sphere
  14238. */
  14239. var SpherePanel = /** @class */ (function (_super) {
  14240. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  14241. function SpherePanel() {
  14242. var _this = _super !== null && _super.apply(this, arguments) || this;
  14243. _this._radius = 5.0;
  14244. return _this;
  14245. }
  14246. Object.defineProperty(SpherePanel.prototype, "radius", {
  14247. /**
  14248. * Gets or sets the radius of the sphere where to project controls (5 by default)
  14249. */
  14250. get: function () {
  14251. return this._radius;
  14252. },
  14253. set: function (value) {
  14254. var _this = this;
  14255. if (this._radius === value) {
  14256. return;
  14257. }
  14258. this._radius = value;
  14259. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14260. _this._arrangeChildren();
  14261. });
  14262. },
  14263. enumerable: true,
  14264. configurable: true
  14265. });
  14266. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  14267. var mesh = control.mesh;
  14268. if (!mesh) {
  14269. return;
  14270. }
  14271. var newPos = this._sphericalMapping(nodePosition);
  14272. control.position = newPos;
  14273. switch (this.orientation) {
  14274. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14275. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  14276. break;
  14277. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14278. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  14279. break;
  14280. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14281. break;
  14282. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14283. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14284. break;
  14285. }
  14286. };
  14287. SpherePanel.prototype._sphericalMapping = function (source) {
  14288. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  14289. var xAngle = (source.y / this._radius);
  14290. var yAngle = -(source.x / this._radius);
  14291. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14292. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14293. };
  14294. return SpherePanel;
  14295. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14296. /***/ }),
  14297. /***/ "./3D/controls/stackPanel3D.ts":
  14298. /*!*************************************!*\
  14299. !*** ./3D/controls/stackPanel3D.ts ***!
  14300. \*************************************/
  14301. /*! exports provided: StackPanel3D */
  14302. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14303. "use strict";
  14304. __webpack_require__.r(__webpack_exports__);
  14305. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  14306. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14307. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  14308. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14309. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14310. /**
  14311. * Class used to create a stack panel in 3D on XY plane
  14312. */
  14313. var StackPanel3D = /** @class */ (function (_super) {
  14314. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  14315. /**
  14316. * Creates new StackPanel
  14317. * @param isVertical
  14318. */
  14319. function StackPanel3D(isVertical) {
  14320. if (isVertical === void 0) { isVertical = false; }
  14321. var _this = _super.call(this) || this;
  14322. _this._isVertical = false;
  14323. /**
  14324. * Gets or sets the distance between elements
  14325. */
  14326. _this.margin = 0.1;
  14327. _this._isVertical = isVertical;
  14328. return _this;
  14329. }
  14330. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  14331. /**
  14332. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  14333. */
  14334. get: function () {
  14335. return this._isVertical;
  14336. },
  14337. set: function (value) {
  14338. var _this = this;
  14339. if (this._isVertical === value) {
  14340. return;
  14341. }
  14342. this._isVertical = value;
  14343. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14344. _this._arrangeChildren();
  14345. });
  14346. },
  14347. enumerable: true,
  14348. configurable: true
  14349. });
  14350. StackPanel3D.prototype._arrangeChildren = function () {
  14351. var width = 0;
  14352. var height = 0;
  14353. var controlCount = 0;
  14354. var extendSizes = [];
  14355. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14356. // Measure
  14357. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14358. var child = _a[_i];
  14359. if (!child.mesh) {
  14360. continue;
  14361. }
  14362. controlCount++;
  14363. child.mesh.computeWorldMatrix(true);
  14364. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14365. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  14366. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14367. extendSizes.push(extendSize);
  14368. if (this._isVertical) {
  14369. height += extendSize.y;
  14370. }
  14371. else {
  14372. width += extendSize.x;
  14373. }
  14374. }
  14375. if (this._isVertical) {
  14376. height += (controlCount - 1) * this.margin / 2;
  14377. }
  14378. else {
  14379. width += (controlCount - 1) * this.margin / 2;
  14380. }
  14381. // Arrange
  14382. var offset;
  14383. if (this._isVertical) {
  14384. offset = -height;
  14385. }
  14386. else {
  14387. offset = -width;
  14388. }
  14389. var index = 0;
  14390. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14391. var child = _c[_b];
  14392. if (!child.mesh) {
  14393. continue;
  14394. }
  14395. controlCount--;
  14396. var extendSize = extendSizes[index++];
  14397. if (this._isVertical) {
  14398. child.position.y = offset + extendSize.y;
  14399. child.position.x = 0;
  14400. offset += extendSize.y * 2;
  14401. }
  14402. else {
  14403. child.position.x = offset + extendSize.x;
  14404. child.position.y = 0;
  14405. offset += extendSize.x * 2;
  14406. }
  14407. offset += (controlCount > 0 ? this.margin : 0);
  14408. }
  14409. };
  14410. return StackPanel3D;
  14411. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14412. /***/ }),
  14413. /***/ "./3D/controls/volumeBasedPanel.ts":
  14414. /*!*****************************************!*\
  14415. !*** ./3D/controls/volumeBasedPanel.ts ***!
  14416. \*****************************************/
  14417. /*! exports provided: VolumeBasedPanel */
  14418. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14419. "use strict";
  14420. __webpack_require__.r(__webpack_exports__);
  14421. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  14422. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14423. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  14424. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14425. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14426. /**
  14427. * Abstract class used to create a container panel deployed on the surface of a volume
  14428. */
  14429. var VolumeBasedPanel = /** @class */ (function (_super) {
  14430. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  14431. /**
  14432. * Creates new VolumeBasedPanel
  14433. */
  14434. function VolumeBasedPanel() {
  14435. var _this = _super.call(this) || this;
  14436. _this._columns = 10;
  14437. _this._rows = 0;
  14438. _this._rowThenColum = true;
  14439. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  14440. /**
  14441. * Gets or sets the distance between elements
  14442. */
  14443. _this.margin = 0;
  14444. return _this;
  14445. }
  14446. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  14447. /**
  14448. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  14449. * | Value | Type | Description |
  14450. * | ----- | ----------------------------------- | ----------- |
  14451. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  14452. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  14453. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  14454. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  14455. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  14456. */
  14457. get: function () {
  14458. return this._orientation;
  14459. },
  14460. set: function (value) {
  14461. var _this = this;
  14462. if (this._orientation === value) {
  14463. return;
  14464. }
  14465. this._orientation = value;
  14466. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14467. _this._arrangeChildren();
  14468. });
  14469. },
  14470. enumerable: true,
  14471. configurable: true
  14472. });
  14473. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  14474. /**
  14475. * Gets or sets the number of columns requested (10 by default).
  14476. * The panel will automatically compute the number of rows based on number of child controls.
  14477. */
  14478. get: function () {
  14479. return this._columns;
  14480. },
  14481. set: function (value) {
  14482. var _this = this;
  14483. if (this._columns === value) {
  14484. return;
  14485. }
  14486. this._columns = value;
  14487. this._rowThenColum = true;
  14488. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14489. _this._arrangeChildren();
  14490. });
  14491. },
  14492. enumerable: true,
  14493. configurable: true
  14494. });
  14495. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  14496. /**
  14497. * Gets or sets a the number of rows requested.
  14498. * The panel will automatically compute the number of columns based on number of child controls.
  14499. */
  14500. get: function () {
  14501. return this._rows;
  14502. },
  14503. set: function (value) {
  14504. var _this = this;
  14505. if (this._rows === value) {
  14506. return;
  14507. }
  14508. this._rows = value;
  14509. this._rowThenColum = false;
  14510. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14511. _this._arrangeChildren();
  14512. });
  14513. },
  14514. enumerable: true,
  14515. configurable: true
  14516. });
  14517. VolumeBasedPanel.prototype._arrangeChildren = function () {
  14518. this._cellWidth = 0;
  14519. this._cellHeight = 0;
  14520. var rows = 0;
  14521. var columns = 0;
  14522. var controlCount = 0;
  14523. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14524. // Measure
  14525. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14526. var child = _a[_i];
  14527. if (!child.mesh) {
  14528. continue;
  14529. }
  14530. controlCount++;
  14531. child.mesh.computeWorldMatrix(true);
  14532. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  14533. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  14534. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14535. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  14536. boundingBox.max.subtractToRef(boundingBox.min, diff);
  14537. diff.scaleInPlace(0.5);
  14538. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  14539. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  14540. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  14541. }
  14542. this._cellWidth += this.margin * 2;
  14543. this._cellHeight += this.margin * 2;
  14544. // Arrange
  14545. if (this._rowThenColum) {
  14546. columns = this._columns;
  14547. rows = Math.ceil(controlCount / this._columns);
  14548. }
  14549. else {
  14550. rows = this._rows;
  14551. columns = Math.ceil(controlCount / this._rows);
  14552. }
  14553. var startOffsetX = (columns * 0.5) * this._cellWidth;
  14554. var startOffsetY = (rows * 0.5) * this._cellHeight;
  14555. var nodeGrid = [];
  14556. var cellCounter = 0;
  14557. if (this._rowThenColum) {
  14558. for (var r = 0; r < rows; r++) {
  14559. for (var c = 0; c < columns; c++) {
  14560. 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));
  14561. cellCounter++;
  14562. if (cellCounter > controlCount) {
  14563. break;
  14564. }
  14565. }
  14566. }
  14567. }
  14568. else {
  14569. for (var c = 0; c < columns; c++) {
  14570. for (var r = 0; r < rows; r++) {
  14571. 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));
  14572. cellCounter++;
  14573. if (cellCounter > controlCount) {
  14574. break;
  14575. }
  14576. }
  14577. }
  14578. }
  14579. cellCounter = 0;
  14580. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14581. var child = _c[_b];
  14582. if (!child.mesh) {
  14583. continue;
  14584. }
  14585. this._mapGridNode(child, nodeGrid[cellCounter]);
  14586. cellCounter++;
  14587. }
  14588. this._finalProcessing();
  14589. };
  14590. /** Child classes can implement this function to provide additional processing */
  14591. VolumeBasedPanel.prototype._finalProcessing = function () {
  14592. };
  14593. return VolumeBasedPanel;
  14594. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14595. /***/ }),
  14596. /***/ "./3D/gui3DManager.ts":
  14597. /*!****************************!*\
  14598. !*** ./3D/gui3DManager.ts ***!
  14599. \****************************/
  14600. /*! exports provided: GUI3DManager */
  14601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14602. "use strict";
  14603. __webpack_require__.r(__webpack_exports__);
  14604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14605. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  14606. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14607. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14608. /**
  14609. * Class used to manage 3D user interface
  14610. * @see http://doc.babylonjs.com/how_to/gui3d
  14611. */
  14612. var GUI3DManager = /** @class */ (function () {
  14613. /**
  14614. * Creates a new GUI3DManager
  14615. * @param scene
  14616. */
  14617. function GUI3DManager(scene) {
  14618. var _this = this;
  14619. /** @hidden */
  14620. this._lastControlOver = {};
  14621. /** @hidden */
  14622. this._lastControlDown = {};
  14623. /**
  14624. * Observable raised when the point picked by the pointer events changed
  14625. */
  14626. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14627. // Shared resources
  14628. /** @hidden */
  14629. this._sharedMaterials = {};
  14630. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14631. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14632. _this._sceneDisposeObserver = null;
  14633. _this._utilityLayer = null;
  14634. _this.dispose();
  14635. });
  14636. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14637. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14638. this._utilityLayer.pickUtilitySceneFirst = false;
  14639. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14640. return mesh && mesh.metadata && mesh.metadata._node;
  14641. };
  14642. // Root
  14643. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14644. this._rootContainer._host = this;
  14645. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14646. // Events
  14647. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14648. _this._handlePointerOut(pointerId, true);
  14649. });
  14650. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14651. _this._doPicking(pi);
  14652. });
  14653. // Scene
  14654. this._utilityLayer.utilityLayerScene.autoClear = false;
  14655. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14656. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14657. }
  14658. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14659. /** Gets the hosting scene */
  14660. get: function () {
  14661. return this._scene;
  14662. },
  14663. enumerable: true,
  14664. configurable: true
  14665. });
  14666. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14667. /** Gets associated utility layer */
  14668. get: function () {
  14669. return this._utilityLayer;
  14670. },
  14671. enumerable: true,
  14672. configurable: true
  14673. });
  14674. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14675. var previousControlOver = this._lastControlOver[pointerId];
  14676. if (previousControlOver) {
  14677. previousControlOver._onPointerOut(previousControlOver);
  14678. delete this._lastControlOver[pointerId];
  14679. }
  14680. if (isPointerUp) {
  14681. if (this._lastControlDown[pointerId]) {
  14682. this._lastControlDown[pointerId].forcePointerUp();
  14683. delete this._lastControlDown[pointerId];
  14684. }
  14685. }
  14686. this.onPickedPointChangedObservable.notifyObservers(null);
  14687. };
  14688. GUI3DManager.prototype._doPicking = function (pi) {
  14689. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14690. return false;
  14691. }
  14692. var pointerEvent = (pi.event);
  14693. var pointerId = pointerEvent.pointerId || 0;
  14694. var buttonIndex = pointerEvent.button;
  14695. var pickingInfo = pi.pickInfo;
  14696. if (!pickingInfo || !pickingInfo.hit) {
  14697. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14698. return false;
  14699. }
  14700. var control = (pickingInfo.pickedMesh.metadata);
  14701. if (pickingInfo.pickedPoint) {
  14702. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14703. }
  14704. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14705. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14706. if (this._lastControlOver[pointerId]) {
  14707. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14708. }
  14709. delete this._lastControlOver[pointerId];
  14710. }
  14711. }
  14712. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14713. if (this._lastControlDown[pointerEvent.pointerId]) {
  14714. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14715. delete this._lastControlDown[pointerEvent.pointerId];
  14716. }
  14717. if (pointerEvent.pointerType === "touch") {
  14718. this._handlePointerOut(pointerId, false);
  14719. }
  14720. }
  14721. return true;
  14722. };
  14723. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14724. /**
  14725. * Gets the root container
  14726. */
  14727. get: function () {
  14728. return this._rootContainer;
  14729. },
  14730. enumerable: true,
  14731. configurable: true
  14732. });
  14733. /**
  14734. * Gets a boolean indicating if the given control is in the root child list
  14735. * @param control defines the control to check
  14736. * @returns true if the control is in the root child list
  14737. */
  14738. GUI3DManager.prototype.containsControl = function (control) {
  14739. return this._rootContainer.containsControl(control);
  14740. };
  14741. /**
  14742. * Adds a control to the root child list
  14743. * @param control defines the control to add
  14744. * @returns the current manager
  14745. */
  14746. GUI3DManager.prototype.addControl = function (control) {
  14747. this._rootContainer.addControl(control);
  14748. return this;
  14749. };
  14750. /**
  14751. * Removes a control from the root child list
  14752. * @param control defines the control to remove
  14753. * @returns the current container
  14754. */
  14755. GUI3DManager.prototype.removeControl = function (control) {
  14756. this._rootContainer.removeControl(control);
  14757. return this;
  14758. };
  14759. /**
  14760. * Releases all associated resources
  14761. */
  14762. GUI3DManager.prototype.dispose = function () {
  14763. this._rootContainer.dispose();
  14764. for (var materialName in this._sharedMaterials) {
  14765. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14766. continue;
  14767. }
  14768. this._sharedMaterials[materialName].dispose();
  14769. }
  14770. this._sharedMaterials = {};
  14771. if (this._pointerOutObserver && this._utilityLayer) {
  14772. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14773. this._pointerOutObserver = null;
  14774. }
  14775. this.onPickedPointChangedObservable.clear();
  14776. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14777. if (utilityLayerScene) {
  14778. if (this._pointerObserver) {
  14779. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14780. this._pointerObserver = null;
  14781. }
  14782. }
  14783. if (this._scene) {
  14784. if (this._sceneDisposeObserver) {
  14785. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14786. this._sceneDisposeObserver = null;
  14787. }
  14788. }
  14789. if (this._utilityLayer) {
  14790. this._utilityLayer.dispose();
  14791. }
  14792. };
  14793. return GUI3DManager;
  14794. }());
  14795. /***/ }),
  14796. /***/ "./3D/index.ts":
  14797. /*!*********************!*\
  14798. !*** ./3D/index.ts ***!
  14799. \*********************/
  14800. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14801. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14802. "use strict";
  14803. __webpack_require__.r(__webpack_exports__);
  14804. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14817. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14820. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14822. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14824. /***/ }),
  14825. /***/ "./3D/materials/fluentMaterial.ts":
  14826. /*!****************************************!*\
  14827. !*** ./3D/materials/fluentMaterial.ts ***!
  14828. \****************************************/
  14829. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14830. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14831. "use strict";
  14832. __webpack_require__.r(__webpack_exports__);
  14833. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14834. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14835. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14836. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  14837. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14838. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14839. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14840. /** @hidden */
  14841. var FluentMaterialDefines = /** @class */ (function (_super) {
  14842. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  14843. function FluentMaterialDefines() {
  14844. var _this = _super.call(this) || this;
  14845. _this.INNERGLOW = false;
  14846. _this.BORDER = false;
  14847. _this.HOVERLIGHT = false;
  14848. _this.TEXTURE = false;
  14849. _this.rebuild();
  14850. return _this;
  14851. }
  14852. return FluentMaterialDefines;
  14853. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14854. /**
  14855. * Class used to render controls with fluent desgin
  14856. */
  14857. var FluentMaterial = /** @class */ (function (_super) {
  14858. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  14859. /**
  14860. * Creates a new Fluent material
  14861. * @param name defines the name of the material
  14862. * @param scene defines the hosting scene
  14863. */
  14864. function FluentMaterial(name, scene) {
  14865. var _this = _super.call(this, name, scene) || this;
  14866. /**
  14867. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14868. */
  14869. _this.innerGlowColorIntensity = 0.5;
  14870. /**
  14871. * Gets or sets the inner glow color (white by default)
  14872. */
  14873. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14874. /**
  14875. * Gets or sets alpha value (default is 1.0)
  14876. */
  14877. _this.alpha = 1.0;
  14878. /**
  14879. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14880. */
  14881. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14882. /**
  14883. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14884. */
  14885. _this.renderBorders = false;
  14886. /**
  14887. * Gets or sets border width (default is 0.5)
  14888. */
  14889. _this.borderWidth = 0.5;
  14890. /**
  14891. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14892. */
  14893. _this.edgeSmoothingValue = 0.02;
  14894. /**
  14895. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14896. */
  14897. _this.borderMinValue = 0.1;
  14898. /**
  14899. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14900. */
  14901. _this.renderHoverLight = false;
  14902. /**
  14903. * Gets or sets the radius used to render the hover light (default is 1.0)
  14904. */
  14905. _this.hoverRadius = 1.0;
  14906. /**
  14907. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14908. */
  14909. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14910. /**
  14911. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14912. */
  14913. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14914. return _this;
  14915. }
  14916. FluentMaterial.prototype.needAlphaBlending = function () {
  14917. return this.alpha !== 1.0;
  14918. };
  14919. FluentMaterial.prototype.needAlphaTesting = function () {
  14920. return false;
  14921. };
  14922. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14923. return null;
  14924. };
  14925. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14926. if (this.isFrozen) {
  14927. if (this._wasPreviouslyReady && subMesh.effect) {
  14928. return true;
  14929. }
  14930. }
  14931. if (!subMesh._materialDefines) {
  14932. subMesh._materialDefines = new FluentMaterialDefines();
  14933. }
  14934. var scene = this.getScene();
  14935. var defines = subMesh._materialDefines;
  14936. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14937. if (defines._renderId === scene.getRenderId()) {
  14938. return true;
  14939. }
  14940. }
  14941. if (defines._areTexturesDirty) {
  14942. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14943. defines.BORDER = this.renderBorders;
  14944. defines.HOVERLIGHT = this.renderHoverLight;
  14945. if (this._albedoTexture) {
  14946. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14947. return false;
  14948. }
  14949. else {
  14950. defines.TEXTURE = true;
  14951. }
  14952. }
  14953. else {
  14954. defines.TEXTURE = false;
  14955. }
  14956. }
  14957. var engine = scene.getEngine();
  14958. // Get correct effect
  14959. if (defines.isDirty) {
  14960. defines.markAsProcessed();
  14961. scene.resetCachedMaterial();
  14962. //Attributes
  14963. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14964. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14965. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14966. var shaderName = "fluent";
  14967. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14968. "hoverColor", "hoverPosition", "hoverRadius"
  14969. ];
  14970. var samplers = ["albedoSampler"];
  14971. var uniformBuffers = new Array();
  14972. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14973. uniformsNames: uniforms,
  14974. uniformBuffersNames: uniformBuffers,
  14975. samplers: samplers,
  14976. defines: defines,
  14977. maxSimultaneousLights: 4
  14978. });
  14979. var join = defines.toString();
  14980. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14981. attributes: attribs,
  14982. uniformsNames: uniforms,
  14983. uniformBuffersNames: uniformBuffers,
  14984. samplers: samplers,
  14985. defines: join,
  14986. fallbacks: null,
  14987. onCompiled: this.onCompiled,
  14988. onError: this.onError,
  14989. indexParameters: { maxSimultaneousLights: 4 }
  14990. }, engine));
  14991. }
  14992. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14993. return false;
  14994. }
  14995. defines._renderId = scene.getRenderId();
  14996. this._wasPreviouslyReady = true;
  14997. return true;
  14998. };
  14999. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  15000. var scene = this.getScene();
  15001. var defines = subMesh._materialDefines;
  15002. if (!defines) {
  15003. return;
  15004. }
  15005. var effect = subMesh.effect;
  15006. if (!effect) {
  15007. return;
  15008. }
  15009. this._activeEffect = effect;
  15010. // Matrices
  15011. this.bindOnlyWorldMatrix(world);
  15012. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  15013. if (this._mustRebind(scene, effect)) {
  15014. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  15015. if (defines.INNERGLOW) {
  15016. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  15017. }
  15018. if (defines.BORDER) {
  15019. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  15020. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  15021. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  15022. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15023. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15024. }
  15025. if (defines.HOVERLIGHT) {
  15026. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  15027. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  15028. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  15029. }
  15030. if (defines.TEXTURE) {
  15031. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  15032. }
  15033. }
  15034. this._afterBind(mesh, this._activeEffect);
  15035. };
  15036. FluentMaterial.prototype.getActiveTextures = function () {
  15037. var activeTextures = _super.prototype.getActiveTextures.call(this);
  15038. return activeTextures;
  15039. };
  15040. FluentMaterial.prototype.hasTexture = function (texture) {
  15041. if (_super.prototype.hasTexture.call(this, texture)) {
  15042. return true;
  15043. }
  15044. return false;
  15045. };
  15046. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  15047. _super.prototype.dispose.call(this, forceDisposeEffect);
  15048. };
  15049. FluentMaterial.prototype.clone = function (name) {
  15050. var _this = this;
  15051. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  15052. };
  15053. FluentMaterial.prototype.serialize = function () {
  15054. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  15055. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  15056. return serializationObject;
  15057. };
  15058. FluentMaterial.prototype.getClassName = function () {
  15059. return "FluentMaterial";
  15060. };
  15061. // Statics
  15062. FluentMaterial.Parse = function (source, scene, rootUrl) {
  15063. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  15064. };
  15065. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15066. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15067. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15068. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  15069. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15070. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15071. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  15072. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15073. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15074. ], FluentMaterial.prototype, "alpha", void 0);
  15075. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15076. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15077. ], FluentMaterial.prototype, "albedoColor", void 0);
  15078. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15079. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15080. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15081. ], FluentMaterial.prototype, "renderBorders", void 0);
  15082. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15083. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15084. ], FluentMaterial.prototype, "borderWidth", void 0);
  15085. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15086. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15087. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  15088. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15089. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15090. ], FluentMaterial.prototype, "borderMinValue", void 0);
  15091. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15092. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15093. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15094. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  15095. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15096. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15097. ], FluentMaterial.prototype, "hoverRadius", void 0);
  15098. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15099. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  15100. ], FluentMaterial.prototype, "hoverColor", void 0);
  15101. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15102. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  15103. ], FluentMaterial.prototype, "hoverPosition", void 0);
  15104. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15105. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  15106. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  15107. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15108. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  15109. ], FluentMaterial.prototype, "albedoTexture", void 0);
  15110. return FluentMaterial;
  15111. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  15112. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  15113. /***/ }),
  15114. /***/ "./3D/materials/index.ts":
  15115. /*!*******************************!*\
  15116. !*** ./3D/materials/index.ts ***!
  15117. \*******************************/
  15118. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15119. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15120. "use strict";
  15121. __webpack_require__.r(__webpack_exports__);
  15122. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  15123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  15124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  15125. /***/ }),
  15126. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  15127. /*!*************************************************!*\
  15128. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  15129. \*************************************************/
  15130. /*! exports provided: fluentPixelShader */
  15131. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15132. "use strict";
  15133. __webpack_require__.r(__webpack_exports__);
  15134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  15135. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  15136. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  15137. var name = 'fluentPixelShader';
  15138. 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}";
  15139. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  15140. /** @hidden */
  15141. var fluentPixelShader = { name: name, shader: shader };
  15142. /***/ }),
  15143. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  15144. /*!***********************************************!*\
  15145. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  15146. \***********************************************/
  15147. /*! exports provided: fluentVertexShader */
  15148. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15149. "use strict";
  15150. __webpack_require__.r(__webpack_exports__);
  15151. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  15152. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  15153. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  15154. var name = 'fluentVertexShader';
  15155. 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";
  15156. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  15157. /** @hidden */
  15158. var fluentVertexShader = { name: name, shader: shader };
  15159. /***/ }),
  15160. /***/ "./3D/vector3WithInfo.ts":
  15161. /*!*******************************!*\
  15162. !*** ./3D/vector3WithInfo.ts ***!
  15163. \*******************************/
  15164. /*! exports provided: Vector3WithInfo */
  15165. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15166. "use strict";
  15167. __webpack_require__.r(__webpack_exports__);
  15168. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  15169. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15170. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  15171. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  15172. /**
  15173. * Class used to transport Vector3 information for pointer events
  15174. */
  15175. var Vector3WithInfo = /** @class */ (function (_super) {
  15176. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  15177. /**
  15178. * Creates a new Vector3WithInfo
  15179. * @param source defines the vector3 data to transport
  15180. * @param buttonIndex defines the current mouse button index
  15181. */
  15182. function Vector3WithInfo(source,
  15183. /** defines the current mouse button index */
  15184. buttonIndex) {
  15185. if (buttonIndex === void 0) { buttonIndex = 0; }
  15186. var _this = _super.call(this, source.x, source.y, source.z) || this;
  15187. _this.buttonIndex = buttonIndex;
  15188. return _this;
  15189. }
  15190. return Vector3WithInfo;
  15191. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  15192. /***/ }),
  15193. /***/ "./index.ts":
  15194. /*!******************!*\
  15195. !*** ./index.ts ***!
  15196. \******************/
  15197. /*! 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, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15198. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15199. "use strict";
  15200. __webpack_require__.r(__webpack_exports__);
  15201. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  15202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  15203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  15204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  15205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  15206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  15207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  15208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  15209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  15210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  15211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  15212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  15213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  15214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  15215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  15216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  15217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  15218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  15219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  15220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  15221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  15222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  15223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  15224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  15225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  15226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  15227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  15228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  15229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  15230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  15231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  15232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  15233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  15234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  15235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  15236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  15237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  15238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  15239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  15240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  15241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  15242. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  15243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  15244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  15245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  15246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  15247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  15248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  15249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  15250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  15251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  15252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  15253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  15254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  15255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  15256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  15257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15259. /***/ }),
  15260. /***/ "./legacy/legacy.ts":
  15261. /*!**************************!*\
  15262. !*** ./legacy/legacy.ts ***!
  15263. \**************************/
  15264. /*! 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, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15265. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15266. "use strict";
  15267. __webpack_require__.r(__webpack_exports__);
  15268. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  15269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  15270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  15271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  15272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  15273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  15274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  15275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  15276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  15277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  15278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  15279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  15280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  15281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  15282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  15283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  15284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  15285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  15286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  15287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  15288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  15289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  15290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  15291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  15292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  15293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  15294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  15295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  15296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  15297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  15298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  15299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  15300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  15301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  15302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  15303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  15304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  15305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  15306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  15307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  15308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  15309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  15310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  15311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  15324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  15325. /**
  15326. * Legacy support, defining window.BABYLON.GUI (global variable).
  15327. *
  15328. * This is the entry point for the UMD module.
  15329. * The entry point for a future ESM package should be index.ts
  15330. */
  15331. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  15332. if (typeof globalObject !== "undefined") {
  15333. globalObject.BABYLON = globalObject.BABYLON || {};
  15334. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  15335. }
  15336. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  15337. /***/ }),
  15338. /***/ "babylonjs/Misc/perfCounter":
  15339. /*!****************************************************************************************************!*\
  15340. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  15341. \****************************************************************************************************/
  15342. /*! no static exports found */
  15343. /***/ (function(module, exports) {
  15344. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__;
  15345. /***/ })
  15346. /******/ });
  15347. });
  15348. //# sourceMappingURL=babylon.gui.js.map