babylon.gui.js 748 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-gui", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-gui"] = factory(require("babylonjs"));
  8. else
  9. root["BABYLON"] = root["BABYLON"] || {}, root["BABYLON"]["GUI"] = factory(root["BABYLON"]);
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!***********************************************************!*\
  100. !*** C:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  126. /*! *****************************************************************************
  127. Copyright (c) Microsoft Corporation. All rights reserved.
  128. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  129. this file except in compliance with the License. You may obtain a copy of the
  130. License at http://www.apache.org/licenses/LICENSE-2.0
  131. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  132. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  133. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  134. MERCHANTABLITY OR NON-INFRINGEMENT.
  135. See the Apache Version 2.0 License for specific language governing permissions
  136. and limitations under the License.
  137. ***************************************************************************** */
  138. /* global Reflect, Promise */
  139. var extendStatics = function(d, b) {
  140. extendStatics = Object.setPrototypeOf ||
  141. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  142. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  143. return extendStatics(d, b);
  144. };
  145. function __extends(d, b) {
  146. extendStatics(d, b);
  147. function __() { this.constructor = d; }
  148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  149. }
  150. var __assign = function() {
  151. __assign = Object.assign || function __assign(t) {
  152. for (var s, i = 1, n = arguments.length; i < n; i++) {
  153. s = arguments[i];
  154. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  155. }
  156. return t;
  157. }
  158. return __assign.apply(this, arguments);
  159. }
  160. function __rest(s, e) {
  161. var t = {};
  162. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  163. t[p] = s[p];
  164. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  165. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  166. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  167. t[p[i]] = s[p[i]];
  168. }
  169. return t;
  170. }
  171. function __decorate(decorators, target, key, desc) {
  172. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  173. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  174. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  175. return c > 3 && r && Object.defineProperty(target, key, r), r;
  176. }
  177. function __param(paramIndex, decorator) {
  178. return function (target, key) { decorator(target, key, paramIndex); }
  179. }
  180. function __metadata(metadataKey, metadataValue) {
  181. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  182. }
  183. function __awaiter(thisArg, _arguments, P, generator) {
  184. return new (P || (P = Promise))(function (resolve, reject) {
  185. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  186. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  187. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  188. step((generator = generator.apply(thisArg, _arguments || [])).next());
  189. });
  190. }
  191. function __generator(thisArg, body) {
  192. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  193. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  194. function verb(n) { return function (v) { return step([n, v]); }; }
  195. function step(op) {
  196. if (f) throw new TypeError("Generator is already executing.");
  197. while (_) try {
  198. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  199. if (y = 0, t) op = [op[0] & 2, t.value];
  200. switch (op[0]) {
  201. case 0: case 1: t = op; break;
  202. case 4: _.label++; return { value: op[1], done: false };
  203. case 5: _.label++; y = op[1]; op = [0]; continue;
  204. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  205. default:
  206. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  207. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  208. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  209. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  210. if (t[2]) _.ops.pop();
  211. _.trys.pop(); continue;
  212. }
  213. op = body.call(thisArg, _);
  214. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  215. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  216. }
  217. }
  218. function __exportStar(m, exports) {
  219. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  220. }
  221. function __values(o) {
  222. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  223. if (m) return m.call(o);
  224. return {
  225. next: function () {
  226. if (o && i >= o.length) o = void 0;
  227. return { value: o && o[i++], done: !o };
  228. }
  229. };
  230. }
  231. function __read(o, n) {
  232. var m = typeof Symbol === "function" && o[Symbol.iterator];
  233. if (!m) return o;
  234. var i = m.call(o), r, ar = [], e;
  235. try {
  236. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  237. }
  238. catch (error) { e = { error: error }; }
  239. finally {
  240. try {
  241. if (r && !r.done && (m = i["return"])) m.call(i);
  242. }
  243. finally { if (e) throw e.error; }
  244. }
  245. return ar;
  246. }
  247. function __spread() {
  248. for (var ar = [], i = 0; i < arguments.length; i++)
  249. ar = ar.concat(__read(arguments[i]));
  250. return ar;
  251. }
  252. function __spreadArrays() {
  253. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  254. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  255. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  256. r[k] = a[j];
  257. return r;
  258. };
  259. function __await(v) {
  260. return this instanceof __await ? (this.v = v, this) : new __await(v);
  261. }
  262. function __asyncGenerator(thisArg, _arguments, generator) {
  263. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  264. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  265. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  266. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  267. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  268. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  269. function fulfill(value) { resume("next", value); }
  270. function reject(value) { resume("throw", value); }
  271. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  272. }
  273. function __asyncDelegator(o) {
  274. var i, p;
  275. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  276. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  277. }
  278. function __asyncValues(o) {
  279. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  280. var m = o[Symbol.asyncIterator], i;
  281. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  282. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  283. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  284. }
  285. function __makeTemplateObject(cooked, raw) {
  286. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  287. return cooked;
  288. };
  289. function __importStar(mod) {
  290. if (mod && mod.__esModule) return mod;
  291. var result = {};
  292. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  293. result.default = mod;
  294. return result;
  295. }
  296. function __importDefault(mod) {
  297. return (mod && mod.__esModule) ? mod : { default: mod };
  298. }
  299. /***/ }),
  300. /***/ "../../node_modules/webpack/buildin/global.js":
  301. /*!***********************************!*\
  302. !*** (webpack)/buildin/global.js ***!
  303. \***********************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports) {
  306. var g;
  307. // This works in non-strict mode
  308. g = (function() {
  309. return this;
  310. })();
  311. try {
  312. // This works if eval is allowed (see CSP)
  313. g = g || new Function("return this")();
  314. } catch (e) {
  315. // This works if the window reference is available
  316. if (typeof window === "object") g = window;
  317. }
  318. // g can still be undefined, but nothing to do about it...
  319. // We return undefined, instead of nothing here, so it's
  320. // easier to handle this case. if(!global) { ...}
  321. module.exports = g;
  322. /***/ }),
  323. /***/ "./2D/adtInstrumentation.ts":
  324. /*!**********************************!*\
  325. !*** ./2D/adtInstrumentation.ts ***!
  326. \**********************************/
  327. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  329. "use strict";
  330. __webpack_require__.r(__webpack_exports__);
  331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  332. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Misc/perfCounter");
  333. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  334. /**
  335. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  336. */
  337. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  338. /**
  339. * Instantiates a new advanced dynamic texture instrumentation.
  340. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  341. * @param texture Defines the AdvancedDynamicTexture to instrument
  342. */
  343. function AdvancedDynamicTextureInstrumentation(
  344. /**
  345. * Define the instrumented AdvancedDynamicTexture.
  346. */
  347. texture) {
  348. this.texture = texture;
  349. this._captureRenderTime = false;
  350. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  351. this._captureLayoutTime = false;
  352. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  353. // Observers
  354. this._onBeginRenderObserver = null;
  355. this._onEndRenderObserver = null;
  356. this._onBeginLayoutObserver = null;
  357. this._onEndLayoutObserver = null;
  358. }
  359. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  360. // Properties
  361. /**
  362. * Gets the perf counter used to capture render time
  363. */
  364. get: function () {
  365. return this._renderTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  371. /**
  372. * Gets the perf counter used to capture layout time
  373. */
  374. get: function () {
  375. return this._layoutTime;
  376. },
  377. enumerable: true,
  378. configurable: true
  379. });
  380. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  381. /**
  382. * Enable or disable the render time capture
  383. */
  384. get: function () {
  385. return this._captureRenderTime;
  386. },
  387. set: function (value) {
  388. var _this = this;
  389. if (value === this._captureRenderTime) {
  390. return;
  391. }
  392. this._captureRenderTime = value;
  393. if (value) {
  394. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  395. _this._renderTime.beginMonitoring();
  396. });
  397. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  398. _this._renderTime.endMonitoring(true);
  399. });
  400. }
  401. else {
  402. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  403. this._onBeginRenderObserver = null;
  404. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  405. this._onEndRenderObserver = null;
  406. }
  407. },
  408. enumerable: true,
  409. configurable: true
  410. });
  411. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  412. /**
  413. * Enable or disable the layout time capture
  414. */
  415. get: function () {
  416. return this._captureLayoutTime;
  417. },
  418. set: function (value) {
  419. var _this = this;
  420. if (value === this._captureLayoutTime) {
  421. return;
  422. }
  423. this._captureLayoutTime = value;
  424. if (value) {
  425. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  426. _this._layoutTime.beginMonitoring();
  427. });
  428. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  429. _this._layoutTime.endMonitoring(true);
  430. });
  431. }
  432. else {
  433. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  434. this._onBeginLayoutObserver = null;
  435. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  436. this._onEndLayoutObserver = null;
  437. }
  438. },
  439. enumerable: true,
  440. configurable: true
  441. });
  442. /**
  443. * Dispose and release associated resources.
  444. */
  445. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  446. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  447. this._onBeginRenderObserver = null;
  448. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  449. this._onEndRenderObserver = null;
  450. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  451. this._onBeginLayoutObserver = null;
  452. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  453. this._onEndLayoutObserver = null;
  454. this.texture = null;
  455. };
  456. return AdvancedDynamicTextureInstrumentation;
  457. }());
  458. /***/ }),
  459. /***/ "./2D/advancedDynamicTexture.ts":
  460. /*!**************************************!*\
  461. !*** ./2D/advancedDynamicTexture.ts ***!
  462. \**************************************/
  463. /*! exports provided: AdvancedDynamicTexture */
  464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  465. "use strict";
  466. __webpack_require__.r(__webpack_exports__);
  467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  469. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  470. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  471. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  472. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  473. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  474. /**
  475. * Class used to create texture to support 2D GUI elements
  476. * @see http://doc.babylonjs.com/how_to/gui
  477. */
  478. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  479. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AdvancedDynamicTexture, _super);
  480. /**
  481. * Creates a new AdvancedDynamicTexture
  482. * @param name defines the name of the texture
  483. * @param width defines the width of the texture
  484. * @param height defines the height of the texture
  485. * @param scene defines the hosting scene
  486. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  487. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  488. */
  489. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  490. if (width === void 0) { width = 0; }
  491. if (height === void 0) { height = 0; }
  492. if (generateMipMaps === void 0) { generateMipMaps = false; }
  493. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  494. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA) || this;
  495. _this._isDirty = false;
  496. /** @hidden */
  497. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  498. /** @hidden */
  499. _this._lastControlOver = {};
  500. /** @hidden */
  501. _this._lastControlDown = {};
  502. /** @hidden */
  503. _this._capturingControl = {};
  504. /** @hidden */
  505. _this._linkedControls = new Array();
  506. _this._isFullscreen = false;
  507. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  508. _this._idealWidth = 0;
  509. _this._idealHeight = 0;
  510. _this._useSmallestIdeal = false;
  511. _this._renderAtIdealSize = false;
  512. _this._blockNextFocusCheck = false;
  513. _this._renderScale = 1;
  514. _this._cursorChanged = false;
  515. /** @hidden */
  516. _this._numLayoutCalls = 0;
  517. /** @hidden */
  518. _this._numRenderCalls = 0;
  519. /**
  520. * Define type to string to ensure compatibility across browsers
  521. * Safari doesn't support DataTransfer constructor
  522. */
  523. _this._clipboardData = "";
  524. /**
  525. * Observable event triggered each time an clipboard event is received from the rendering canvas
  526. */
  527. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  528. /**
  529. * Observable event triggered each time a pointer down is intercepted by a control
  530. */
  531. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  532. /**
  533. * Observable event triggered before layout is evaluated
  534. */
  535. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  536. /**
  537. * Observable event triggered after the layout was evaluated
  538. */
  539. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  540. /**
  541. * Observable event triggered before the texture is rendered
  542. */
  543. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  544. /**
  545. * Observable event triggered after the texture was rendered
  546. */
  547. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  548. /**
  549. * Gets or sets a boolean defining if alpha is stored as premultiplied
  550. */
  551. _this.premulAlpha = false;
  552. _this._useInvalidateRectOptimization = true;
  553. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  554. _this._invalidatedRectangle = null;
  555. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  556. /** @hidden */
  557. _this.onClipboardCopy = function (rawEvt) {
  558. var evt = rawEvt;
  559. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  560. _this.onClipboardObservable.notifyObservers(ev);
  561. evt.preventDefault();
  562. };
  563. /** @hidden */
  564. _this.onClipboardCut = function (rawEvt) {
  565. var evt = rawEvt;
  566. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  567. _this.onClipboardObservable.notifyObservers(ev);
  568. evt.preventDefault();
  569. };
  570. /** @hidden */
  571. _this.onClipboardPaste = function (rawEvt) {
  572. var evt = rawEvt;
  573. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  574. _this.onClipboardObservable.notifyObservers(ev);
  575. evt.preventDefault();
  576. };
  577. scene = _this.getScene();
  578. if (!scene || !_this._texture) {
  579. return _this;
  580. }
  581. _this._rootElement = scene.getEngine().getInputElement();
  582. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  583. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  584. if (!_this._focusedControl) {
  585. return;
  586. }
  587. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  588. _this._focusedControl.processKeyboard(info.event);
  589. }
  590. info.skipOnPointerObservable = true;
  591. });
  592. _this._rootContainer._link(_this);
  593. _this.hasAlpha = true;
  594. if (!width || !height) {
  595. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  596. _this._onResize();
  597. }
  598. _this._texture.isReady = true;
  599. return _this;
  600. }
  601. Object.defineProperty(AdvancedDynamicTexture.prototype, "numLayoutCalls", {
  602. /** Gets the number of layout calls made the last time the ADT has been rendered */
  603. get: function () {
  604. return this._numLayoutCalls;
  605. },
  606. enumerable: true,
  607. configurable: true
  608. });
  609. Object.defineProperty(AdvancedDynamicTexture.prototype, "numRenderCalls", {
  610. /** Gets the number of render calls made the last time the ADT has been rendered */
  611. get: function () {
  612. return this._numRenderCalls;
  613. },
  614. enumerable: true,
  615. configurable: true
  616. });
  617. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  618. /**
  619. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  620. * Useful when you want more antialiasing
  621. */
  622. get: function () {
  623. return this._renderScale;
  624. },
  625. set: function (value) {
  626. if (value === this._renderScale) {
  627. return;
  628. }
  629. this._renderScale = value;
  630. this._onResize();
  631. },
  632. enumerable: true,
  633. configurable: true
  634. });
  635. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  636. /** Gets or sets the background color */
  637. get: function () {
  638. return this._background;
  639. },
  640. set: function (value) {
  641. if (this._background === value) {
  642. return;
  643. }
  644. this._background = value;
  645. this.markAsDirty();
  646. },
  647. enumerable: true,
  648. configurable: true
  649. });
  650. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  651. /**
  652. * Gets or sets the ideal width used to design controls.
  653. * The GUI will then rescale everything accordingly
  654. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  655. */
  656. get: function () {
  657. return this._idealWidth;
  658. },
  659. set: function (value) {
  660. if (this._idealWidth === value) {
  661. return;
  662. }
  663. this._idealWidth = value;
  664. this.markAsDirty();
  665. this._rootContainer._markAllAsDirty();
  666. },
  667. enumerable: true,
  668. configurable: true
  669. });
  670. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  671. /**
  672. * Gets or sets the ideal height used to design controls.
  673. * The GUI will then rescale everything accordingly
  674. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  675. */
  676. get: function () {
  677. return this._idealHeight;
  678. },
  679. set: function (value) {
  680. if (this._idealHeight === value) {
  681. return;
  682. }
  683. this._idealHeight = value;
  684. this.markAsDirty();
  685. this._rootContainer._markAllAsDirty();
  686. },
  687. enumerable: true,
  688. configurable: true
  689. });
  690. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  691. /**
  692. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  693. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  694. */
  695. get: function () {
  696. return this._useSmallestIdeal;
  697. },
  698. set: function (value) {
  699. if (this._useSmallestIdeal === value) {
  700. return;
  701. }
  702. this._useSmallestIdeal = value;
  703. this.markAsDirty();
  704. this._rootContainer._markAllAsDirty();
  705. },
  706. enumerable: true,
  707. configurable: true
  708. });
  709. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  710. /**
  711. * Gets or sets a boolean indicating if adaptive scaling must be used
  712. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  713. */
  714. get: function () {
  715. return this._renderAtIdealSize;
  716. },
  717. set: function (value) {
  718. if (this._renderAtIdealSize === value) {
  719. return;
  720. }
  721. this._renderAtIdealSize = value;
  722. this._onResize();
  723. },
  724. enumerable: true,
  725. configurable: true
  726. });
  727. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealRatio", {
  728. /**
  729. * Gets the ratio used when in "ideal mode"
  730. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  731. * */
  732. get: function () {
  733. var rwidth = 0;
  734. var rheight = 0;
  735. if (this._idealWidth) {
  736. rwidth = (this.getSize().width) / this._idealWidth;
  737. }
  738. if (this._idealHeight) {
  739. rheight = (this.getSize().height) / this._idealHeight;
  740. }
  741. if (this._useSmallestIdeal && this._idealWidth && this._idealHeight) {
  742. return window.innerWidth < window.innerHeight ? rwidth : rheight;
  743. }
  744. if (this._idealWidth) { // horizontal
  745. return rwidth;
  746. }
  747. if (this._idealHeight) { // vertical
  748. return rheight;
  749. }
  750. return 1;
  751. },
  752. enumerable: true,
  753. configurable: true
  754. });
  755. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  756. /**
  757. * Gets the underlying layer used to render the texture when in fullscreen mode
  758. */
  759. get: function () {
  760. return this._layerToDispose;
  761. },
  762. enumerable: true,
  763. configurable: true
  764. });
  765. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  766. /**
  767. * Gets the root container control
  768. */
  769. get: function () {
  770. return this._rootContainer;
  771. },
  772. enumerable: true,
  773. configurable: true
  774. });
  775. /**
  776. * Returns an array containing the root container.
  777. * This is mostly used to let the Inspector introspects the ADT
  778. * @returns an array containing the rootContainer
  779. */
  780. AdvancedDynamicTexture.prototype.getChildren = function () {
  781. return [this._rootContainer];
  782. };
  783. /**
  784. * Will return all controls that are inside this texture
  785. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  786. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  787. * @return all child controls
  788. */
  789. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  790. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  791. };
  792. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  793. /**
  794. * Gets or sets the current focused control
  795. */
  796. get: function () {
  797. return this._focusedControl;
  798. },
  799. set: function (control) {
  800. if (this._focusedControl == control) {
  801. return;
  802. }
  803. if (this._focusedControl) {
  804. this._focusedControl.onBlur();
  805. }
  806. if (control) {
  807. control.onFocus();
  808. }
  809. this._focusedControl = control;
  810. },
  811. enumerable: true,
  812. configurable: true
  813. });
  814. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  815. /**
  816. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  817. */
  818. get: function () {
  819. if (!this.layer) {
  820. return true;
  821. }
  822. return (!this.layer.isBackground);
  823. },
  824. set: function (value) {
  825. if (!this.layer) {
  826. return;
  827. }
  828. if (this.layer.isBackground === !value) {
  829. return;
  830. }
  831. this.layer.isBackground = !value;
  832. },
  833. enumerable: true,
  834. configurable: true
  835. });
  836. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  837. /**
  838. * Gets or set information about clipboardData
  839. */
  840. get: function () {
  841. return this._clipboardData;
  842. },
  843. set: function (value) {
  844. this._clipboardData = value;
  845. },
  846. enumerable: true,
  847. configurable: true
  848. });
  849. /**
  850. * Get the current class name of the texture useful for serialization or dynamic coding.
  851. * @returns "AdvancedDynamicTexture"
  852. */
  853. AdvancedDynamicTexture.prototype.getClassName = function () {
  854. return "AdvancedDynamicTexture";
  855. };
  856. /**
  857. * Function used to execute a function on all controls
  858. * @param func defines the function to execute
  859. * @param container defines the container where controls belong. If null the root container will be used
  860. */
  861. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  862. if (!container) {
  863. container = this._rootContainer;
  864. }
  865. func(container);
  866. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  867. var child = _a[_i];
  868. if (child.children) {
  869. this.executeOnAllControls(func, child);
  870. continue;
  871. }
  872. func(child);
  873. }
  874. };
  875. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  876. /**
  877. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  878. */
  879. get: function () {
  880. return this._useInvalidateRectOptimization;
  881. },
  882. set: function (value) {
  883. this._useInvalidateRectOptimization = value;
  884. },
  885. enumerable: true,
  886. configurable: true
  887. });
  888. /**
  889. * Invalidates a rectangle area on the gui texture
  890. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  891. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  892. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  893. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  894. */
  895. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  896. if (!this._useInvalidateRectOptimization) {
  897. return;
  898. }
  899. if (!this._invalidatedRectangle) {
  900. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  901. }
  902. else {
  903. // Compute intersection
  904. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  905. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  906. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  907. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  908. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  909. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  910. }
  911. };
  912. /**
  913. * Marks the texture as dirty forcing a complete update
  914. */
  915. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  916. this._isDirty = true;
  917. };
  918. /**
  919. * Helper function used to create a new style
  920. * @returns a new style
  921. * @see http://doc.babylonjs.com/how_to/gui#styles
  922. */
  923. AdvancedDynamicTexture.prototype.createStyle = function () {
  924. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  925. };
  926. /**
  927. * Adds a new control to the root container
  928. * @param control defines the control to add
  929. * @returns the current texture
  930. */
  931. AdvancedDynamicTexture.prototype.addControl = function (control) {
  932. this._rootContainer.addControl(control);
  933. return this;
  934. };
  935. /**
  936. * Removes a control from the root container
  937. * @param control defines the control to remove
  938. * @returns the current texture
  939. */
  940. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  941. this._rootContainer.removeControl(control);
  942. return this;
  943. };
  944. /**
  945. * Release all resources
  946. */
  947. AdvancedDynamicTexture.prototype.dispose = function () {
  948. var scene = this.getScene();
  949. if (!scene) {
  950. return;
  951. }
  952. this._rootElement = null;
  953. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  954. if (this._resizeObserver) {
  955. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  956. }
  957. if (this._pointerMoveObserver) {
  958. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  959. }
  960. if (this._pointerObserver) {
  961. scene.onPointerObservable.remove(this._pointerObserver);
  962. }
  963. if (this._preKeyboardObserver) {
  964. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  965. }
  966. if (this._canvasPointerOutObserver) {
  967. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  968. }
  969. if (this._layerToDispose) {
  970. this._layerToDispose.texture = null;
  971. this._layerToDispose.dispose();
  972. this._layerToDispose = null;
  973. }
  974. this._rootContainer.dispose();
  975. this.onClipboardObservable.clear();
  976. this.onControlPickedObservable.clear();
  977. this.onBeginRenderObservable.clear();
  978. this.onEndRenderObservable.clear();
  979. this.onBeginLayoutObservable.clear();
  980. this.onEndLayoutObservable.clear();
  981. _super.prototype.dispose.call(this);
  982. };
  983. AdvancedDynamicTexture.prototype._onResize = function () {
  984. var scene = this.getScene();
  985. if (!scene) {
  986. return;
  987. }
  988. // Check size
  989. var engine = scene.getEngine();
  990. var textureSize = this.getSize();
  991. var renderWidth = engine.getRenderWidth() * this._renderScale;
  992. var renderHeight = engine.getRenderHeight() * this._renderScale;
  993. if (this._renderAtIdealSize) {
  994. if (this._idealWidth) {
  995. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  996. renderWidth = this._idealWidth;
  997. }
  998. else if (this._idealHeight) {
  999. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  1000. renderHeight = this._idealHeight;
  1001. }
  1002. }
  1003. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  1004. this.scaleTo(renderWidth, renderHeight);
  1005. this.markAsDirty();
  1006. if (this._idealWidth || this._idealHeight) {
  1007. this._rootContainer._markAllAsDirty();
  1008. }
  1009. }
  1010. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  1011. };
  1012. /** @hidden */
  1013. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  1014. var engine = scene.getEngine();
  1015. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  1016. };
  1017. /**
  1018. * Get screen coordinates for a vector3
  1019. * @param position defines the position to project
  1020. * @param worldMatrix defines the world matrix to use
  1021. * @returns the projected position
  1022. */
  1023. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  1024. var scene = this.getScene();
  1025. if (!scene) {
  1026. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  1027. }
  1028. var globalViewport = this._getGlobalViewport(scene);
  1029. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1030. projectedPosition.scaleInPlace(this.renderScale);
  1031. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  1032. };
  1033. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  1034. if (this._layerToDispose) {
  1035. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  1036. return;
  1037. }
  1038. }
  1039. if (this._isFullscreen && this._linkedControls.length) {
  1040. var scene = this.getScene();
  1041. if (!scene) {
  1042. return;
  1043. }
  1044. var globalViewport = this._getGlobalViewport(scene);
  1045. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  1046. var control = _a[_i];
  1047. if (!control.isVisible) {
  1048. continue;
  1049. }
  1050. var mesh = control._linkedMesh;
  1051. if (!mesh || mesh.isDisposed()) {
  1052. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1053. control.linkWithMesh(null);
  1054. });
  1055. continue;
  1056. }
  1057. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1058. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1059. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1060. control.notRenderable = true;
  1061. continue;
  1062. }
  1063. control.notRenderable = false;
  1064. // Account for RenderScale.
  1065. projectedPosition.scaleInPlace(this.renderScale);
  1066. control._moveToProjectedPosition(projectedPosition);
  1067. }
  1068. }
  1069. if (!this._isDirty && !this._rootContainer.isDirty) {
  1070. return;
  1071. }
  1072. this._isDirty = false;
  1073. this._render();
  1074. this.update(true, this.premulAlpha);
  1075. };
  1076. AdvancedDynamicTexture.prototype._render = function () {
  1077. var textureSize = this.getSize();
  1078. var renderWidth = textureSize.width;
  1079. var renderHeight = textureSize.height;
  1080. var context = this.getContext();
  1081. context.font = "18px Arial";
  1082. context.strokeStyle = "white";
  1083. // Layout
  1084. this.onBeginLayoutObservable.notifyObservers(this);
  1085. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1086. this._numLayoutCalls = 0;
  1087. this._rootContainer._layout(measure, context);
  1088. this.onEndLayoutObservable.notifyObservers(this);
  1089. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1090. // Clear
  1091. if (this._invalidatedRectangle) {
  1092. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1093. }
  1094. else {
  1095. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1096. }
  1097. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1098. if (this._background) {
  1099. context.save();
  1100. context.fillStyle = this._background;
  1101. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1102. context.restore();
  1103. }
  1104. // Render
  1105. this.onBeginRenderObservable.notifyObservers(this);
  1106. this._numRenderCalls = 0;
  1107. this._rootContainer._render(context, this._invalidatedRectangle);
  1108. this.onEndRenderObservable.notifyObservers(this);
  1109. this._invalidatedRectangle = null;
  1110. };
  1111. /** @hidden */
  1112. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1113. if (this._rootElement) {
  1114. this._rootElement.style.cursor = cursor;
  1115. this._cursorChanged = true;
  1116. }
  1117. };
  1118. /** @hidden */
  1119. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1120. this._lastControlDown[pointerId] = control;
  1121. this.onControlPickedObservable.notifyObservers(control);
  1122. };
  1123. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  1124. var scene = this.getScene();
  1125. if (!scene) {
  1126. return;
  1127. }
  1128. var engine = scene.getEngine();
  1129. var textureSize = this.getSize();
  1130. if (this._isFullscreen) {
  1131. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1132. var viewport = camera.viewport;
  1133. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1134. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1135. }
  1136. if (this._capturingControl[pointerId]) {
  1137. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1138. return;
  1139. }
  1140. this._cursorChanged = false;
  1141. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex, deltaX, deltaY)) {
  1142. this._changeCursor("");
  1143. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1144. if (this._lastControlOver[pointerId]) {
  1145. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1146. delete this._lastControlOver[pointerId];
  1147. }
  1148. }
  1149. }
  1150. if (!this._cursorChanged) {
  1151. this._changeCursor("");
  1152. }
  1153. this._manageFocus();
  1154. };
  1155. /** @hidden */
  1156. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1157. for (var pointerId in list) {
  1158. if (!list.hasOwnProperty(pointerId)) {
  1159. continue;
  1160. }
  1161. var lastControlOver = list[pointerId];
  1162. if (lastControlOver === control) {
  1163. delete list[pointerId];
  1164. }
  1165. }
  1166. };
  1167. /** @hidden */
  1168. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1169. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1170. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1171. };
  1172. /** Attach to all scene events required to support pointer events */
  1173. AdvancedDynamicTexture.prototype.attach = function () {
  1174. var _this = this;
  1175. var scene = this.getScene();
  1176. if (!scene) {
  1177. return;
  1178. }
  1179. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1180. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1181. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1182. return;
  1183. }
  1184. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1185. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1186. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN
  1187. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  1188. return;
  1189. }
  1190. if (!scene) {
  1191. return;
  1192. }
  1193. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1194. var engine = scene.getEngine();
  1195. if (!camera) {
  1196. tempViewport.x = 0;
  1197. tempViewport.y = 0;
  1198. tempViewport.width = engine.getRenderWidth();
  1199. tempViewport.height = engine.getRenderHeight();
  1200. }
  1201. else {
  1202. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1203. }
  1204. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1205. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1206. _this._shouldBlockPointer = false;
  1207. // Do picking modifies _shouldBlockPointer
  1208. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button, pi.event.deltaX, pi.event.deltaY);
  1209. // Avoid overwriting a true skipOnPointerObservable to false
  1210. if (_this._shouldBlockPointer) {
  1211. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1212. }
  1213. });
  1214. this._attachToOnPointerOut(scene);
  1215. };
  1216. /**
  1217. * Register the clipboard Events onto the canvas
  1218. */
  1219. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1220. self.addEventListener("copy", this.onClipboardCopy, false);
  1221. self.addEventListener("cut", this.onClipboardCut, false);
  1222. self.addEventListener("paste", this.onClipboardPaste, false);
  1223. };
  1224. /**
  1225. * Unregister the clipboard Events from the canvas
  1226. */
  1227. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1228. self.removeEventListener("copy", this.onClipboardCopy);
  1229. self.removeEventListener("cut", this.onClipboardCut);
  1230. self.removeEventListener("paste", this.onClipboardPaste);
  1231. };
  1232. /**
  1233. * Connect the texture to a hosting mesh to enable interactions
  1234. * @param mesh defines the mesh to attach to
  1235. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1236. */
  1237. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1238. var _this = this;
  1239. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1240. var scene = this.getScene();
  1241. if (!scene) {
  1242. return;
  1243. }
  1244. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1245. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1246. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1247. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1248. return;
  1249. }
  1250. var pointerId = pi.event.pointerId || 0;
  1251. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1252. var uv = pi.pickInfo.getTextureCoordinates();
  1253. if (uv) {
  1254. var size = _this.getSize();
  1255. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1256. }
  1257. }
  1258. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1259. if (_this._lastControlDown[pointerId]) {
  1260. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1261. }
  1262. delete _this._lastControlDown[pointerId];
  1263. if (_this.focusedControl) {
  1264. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1265. var canMoveFocus = true;
  1266. if (friendlyControls) {
  1267. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1268. var control = friendlyControls_1[_i];
  1269. // Same host, no need to keep the focus
  1270. if (_this === control._host) {
  1271. continue;
  1272. }
  1273. // Different hosts
  1274. var otherHost = control._host;
  1275. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1276. canMoveFocus = false;
  1277. break;
  1278. }
  1279. }
  1280. }
  1281. if (canMoveFocus) {
  1282. _this.focusedControl = null;
  1283. }
  1284. }
  1285. }
  1286. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1287. if (_this._lastControlOver[pointerId]) {
  1288. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1289. }
  1290. delete _this._lastControlOver[pointerId];
  1291. }
  1292. });
  1293. mesh.enablePointerMoveEvents = supportPointerMove;
  1294. this._attachToOnPointerOut(scene);
  1295. };
  1296. /**
  1297. * Move the focus to a specific control
  1298. * @param control defines the control which will receive the focus
  1299. */
  1300. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1301. this.focusedControl = control;
  1302. this._lastPickedControl = control;
  1303. this._blockNextFocusCheck = true;
  1304. };
  1305. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1306. if (this._blockNextFocusCheck) {
  1307. this._blockNextFocusCheck = false;
  1308. this._lastPickedControl = this._focusedControl;
  1309. return;
  1310. }
  1311. // Focus management
  1312. if (this._focusedControl) {
  1313. if (this._focusedControl !== this._lastPickedControl) {
  1314. if (this._lastPickedControl.isFocusInvisible) {
  1315. return;
  1316. }
  1317. this.focusedControl = null;
  1318. }
  1319. }
  1320. };
  1321. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1322. var _this = this;
  1323. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1324. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1325. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1326. }
  1327. delete _this._lastControlOver[pointerEvent.pointerId];
  1328. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1329. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1330. delete _this._lastControlDown[pointerEvent.pointerId];
  1331. }
  1332. });
  1333. };
  1334. // Statics
  1335. /**
  1336. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1337. * @param mesh defines the mesh which will receive the texture
  1338. * @param width defines the texture width (1024 by default)
  1339. * @param height defines the texture height (1024 by default)
  1340. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1341. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1342. * @returns a new AdvancedDynamicTexture
  1343. */
  1344. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1345. if (width === void 0) { width = 1024; }
  1346. if (height === void 0) { height = 1024; }
  1347. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1348. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1349. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1350. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1351. material.backFaceCulling = false;
  1352. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1353. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1354. if (onlyAlphaTesting) {
  1355. material.diffuseTexture = result;
  1356. material.emissiveTexture = result;
  1357. result.hasAlpha = true;
  1358. }
  1359. else {
  1360. material.emissiveTexture = result;
  1361. material.opacityTexture = result;
  1362. }
  1363. mesh.material = material;
  1364. result.attachToMesh(mesh, supportPointerMove);
  1365. return result;
  1366. };
  1367. /**
  1368. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1369. * In this mode the texture will rely on a layer for its rendering.
  1370. * This allows it to be treated like any other layer.
  1371. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1372. * LayerMask is set through advancedTexture.layer.layerMask
  1373. * @param name defines name for the texture
  1374. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1375. * @param scene defines the hsoting scene
  1376. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1377. * @returns a new AdvancedDynamicTexture
  1378. */
  1379. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1380. if (foreground === void 0) { foreground = true; }
  1381. if (scene === void 0) { scene = null; }
  1382. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1383. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1384. // Display
  1385. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1386. layer.texture = result;
  1387. result._layerToDispose = layer;
  1388. result._isFullscreen = true;
  1389. // Attach
  1390. result.attach();
  1391. return result;
  1392. };
  1393. return AdvancedDynamicTexture;
  1394. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1395. /***/ }),
  1396. /***/ "./2D/controls/button.ts":
  1397. /*!*******************************!*\
  1398. !*** ./2D/controls/button.ts ***!
  1399. \*******************************/
  1400. /*! exports provided: Button */
  1401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1402. "use strict";
  1403. __webpack_require__.r(__webpack_exports__);
  1404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1405. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1406. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1407. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1408. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1409. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1410. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  1411. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1412. /**
  1413. * Class used to create 2D buttons
  1414. */
  1415. var Button = /** @class */ (function (_super) {
  1416. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1417. /**
  1418. * Creates a new Button
  1419. * @param name defines the name of the button
  1420. */
  1421. function Button(name) {
  1422. var _this = _super.call(this, name) || this;
  1423. _this.name = name;
  1424. /**
  1425. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1426. */
  1427. _this.delegatePickingToChildren = false;
  1428. _this.thickness = 1;
  1429. _this.isPointerBlocker = true;
  1430. var alphaStore = null;
  1431. _this.pointerEnterAnimation = function () {
  1432. alphaStore = _this.alpha;
  1433. _this.alpha -= 0.1;
  1434. };
  1435. _this.pointerOutAnimation = function () {
  1436. if (alphaStore !== null) {
  1437. _this.alpha = alphaStore;
  1438. }
  1439. };
  1440. _this.pointerDownAnimation = function () {
  1441. _this.scaleX -= 0.05;
  1442. _this.scaleY -= 0.05;
  1443. };
  1444. _this.pointerUpAnimation = function () {
  1445. _this.scaleX += 0.05;
  1446. _this.scaleY += 0.05;
  1447. };
  1448. return _this;
  1449. }
  1450. Object.defineProperty(Button.prototype, "image", {
  1451. /**
  1452. * Returns the image part of the button (if any)
  1453. */
  1454. get: function () {
  1455. return this._image;
  1456. },
  1457. enumerable: true,
  1458. configurable: true
  1459. });
  1460. Object.defineProperty(Button.prototype, "textBlock", {
  1461. /**
  1462. * Returns the image part of the button (if any)
  1463. */
  1464. get: function () {
  1465. return this._textBlock;
  1466. },
  1467. enumerable: true,
  1468. configurable: true
  1469. });
  1470. Button.prototype._getTypeName = function () {
  1471. return "Button";
  1472. };
  1473. // While being a container, the button behaves like a control.
  1474. /** @hidden */
  1475. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  1476. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1477. return false;
  1478. }
  1479. if (!_super.prototype.contains.call(this, x, y)) {
  1480. return false;
  1481. }
  1482. if (this.delegatePickingToChildren) {
  1483. var contains = false;
  1484. for (var index = this._children.length - 1; index >= 0; index--) {
  1485. var child = this._children[index];
  1486. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1487. contains = true;
  1488. break;
  1489. }
  1490. }
  1491. if (!contains) {
  1492. return false;
  1493. }
  1494. }
  1495. this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  1496. return true;
  1497. };
  1498. /** @hidden */
  1499. Button.prototype._onPointerEnter = function (target) {
  1500. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1501. return false;
  1502. }
  1503. if (this.pointerEnterAnimation) {
  1504. this.pointerEnterAnimation();
  1505. }
  1506. return true;
  1507. };
  1508. /** @hidden */
  1509. Button.prototype._onPointerOut = function (target, force) {
  1510. if (force === void 0) { force = false; }
  1511. if (this.pointerOutAnimation) {
  1512. this.pointerOutAnimation();
  1513. }
  1514. _super.prototype._onPointerOut.call(this, target, force);
  1515. };
  1516. /** @hidden */
  1517. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1518. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1519. return false;
  1520. }
  1521. if (this.pointerDownAnimation) {
  1522. this.pointerDownAnimation();
  1523. }
  1524. return true;
  1525. };
  1526. /** @hidden */
  1527. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1528. if (this.pointerUpAnimation) {
  1529. this.pointerUpAnimation();
  1530. }
  1531. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1532. };
  1533. // Statics
  1534. /**
  1535. * Creates a new button made with an image and a text
  1536. * @param name defines the name of the button
  1537. * @param text defines the text of the button
  1538. * @param imageUrl defines the url of the image
  1539. * @returns a new Button
  1540. */
  1541. Button.CreateImageButton = function (name, text, imageUrl) {
  1542. var result = new Button(name);
  1543. // Adding text
  1544. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1545. textBlock.textWrapping = true;
  1546. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1547. textBlock.paddingLeft = "20%";
  1548. result.addControl(textBlock);
  1549. // Adding image
  1550. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1551. iconImage.width = "20%";
  1552. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1553. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1554. result.addControl(iconImage);
  1555. // Store
  1556. result._image = iconImage;
  1557. result._textBlock = textBlock;
  1558. return result;
  1559. };
  1560. /**
  1561. * Creates a new button made with an image
  1562. * @param name defines the name of the button
  1563. * @param imageUrl defines the url of the image
  1564. * @returns a new Button
  1565. */
  1566. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1567. var result = new Button(name);
  1568. // Adding image
  1569. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1570. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1571. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1572. result.addControl(iconImage);
  1573. // Store
  1574. result._image = iconImage;
  1575. return result;
  1576. };
  1577. /**
  1578. * Creates a new button made with a text
  1579. * @param name defines the name of the button
  1580. * @param text defines the text of the button
  1581. * @returns a new Button
  1582. */
  1583. Button.CreateSimpleButton = function (name, text) {
  1584. var result = new Button(name);
  1585. // Adding text
  1586. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1587. textBlock.textWrapping = true;
  1588. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1589. result.addControl(textBlock);
  1590. // Store
  1591. result._textBlock = textBlock;
  1592. return result;
  1593. };
  1594. /**
  1595. * Creates a new button made with an image and a centered text
  1596. * @param name defines the name of the button
  1597. * @param text defines the text of the button
  1598. * @param imageUrl defines the url of the image
  1599. * @returns a new Button
  1600. */
  1601. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1602. var result = new Button(name);
  1603. // Adding image
  1604. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1605. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1606. result.addControl(iconImage);
  1607. // Adding text
  1608. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1609. textBlock.textWrapping = true;
  1610. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1611. result.addControl(textBlock);
  1612. // Store
  1613. result._image = iconImage;
  1614. result._textBlock = textBlock;
  1615. return result;
  1616. };
  1617. return Button;
  1618. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1619. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1620. /***/ }),
  1621. /***/ "./2D/controls/checkbox.ts":
  1622. /*!*********************************!*\
  1623. !*** ./2D/controls/checkbox.ts ***!
  1624. \*********************************/
  1625. /*! exports provided: Checkbox */
  1626. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1627. "use strict";
  1628. __webpack_require__.r(__webpack_exports__);
  1629. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1630. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1631. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1632. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1633. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1634. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1635. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1636. /**
  1637. * Class used to represent a 2D checkbox
  1638. */
  1639. var Checkbox = /** @class */ (function (_super) {
  1640. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1641. /**
  1642. * Creates a new CheckBox
  1643. * @param name defines the control name
  1644. */
  1645. function Checkbox(name) {
  1646. var _this = _super.call(this, name) || this;
  1647. _this.name = name;
  1648. _this._isChecked = false;
  1649. _this._background = "black";
  1650. _this._checkSizeRatio = 0.8;
  1651. _this._thickness = 1;
  1652. /**
  1653. * Observable raised when isChecked property changes
  1654. */
  1655. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1656. _this.isPointerBlocker = true;
  1657. return _this;
  1658. }
  1659. Object.defineProperty(Checkbox.prototype, "thickness", {
  1660. /** Gets or sets border thickness */
  1661. get: function () {
  1662. return this._thickness;
  1663. },
  1664. set: function (value) {
  1665. if (this._thickness === value) {
  1666. return;
  1667. }
  1668. this._thickness = value;
  1669. this._markAsDirty();
  1670. },
  1671. enumerable: true,
  1672. configurable: true
  1673. });
  1674. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1675. /** Gets or sets a value indicating the ratio between overall size and check size */
  1676. get: function () {
  1677. return this._checkSizeRatio;
  1678. },
  1679. set: function (value) {
  1680. value = Math.max(Math.min(1, value), 0);
  1681. if (this._checkSizeRatio === value) {
  1682. return;
  1683. }
  1684. this._checkSizeRatio = value;
  1685. this._markAsDirty();
  1686. },
  1687. enumerable: true,
  1688. configurable: true
  1689. });
  1690. Object.defineProperty(Checkbox.prototype, "background", {
  1691. /** Gets or sets background color */
  1692. get: function () {
  1693. return this._background;
  1694. },
  1695. set: function (value) {
  1696. if (this._background === value) {
  1697. return;
  1698. }
  1699. this._background = value;
  1700. this._markAsDirty();
  1701. },
  1702. enumerable: true,
  1703. configurable: true
  1704. });
  1705. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1706. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1707. get: function () {
  1708. return this._isChecked;
  1709. },
  1710. set: function (value) {
  1711. if (this._isChecked === value) {
  1712. return;
  1713. }
  1714. this._isChecked = value;
  1715. this._markAsDirty();
  1716. this.onIsCheckedChangedObservable.notifyObservers(value);
  1717. },
  1718. enumerable: true,
  1719. configurable: true
  1720. });
  1721. Checkbox.prototype._getTypeName = function () {
  1722. return "Checkbox";
  1723. };
  1724. /** @hidden */
  1725. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1726. context.save();
  1727. this._applyStates(context);
  1728. var actualWidth = this._currentMeasure.width - this._thickness;
  1729. var actualHeight = this._currentMeasure.height - this._thickness;
  1730. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1731. context.shadowColor = this.shadowColor;
  1732. context.shadowBlur = this.shadowBlur;
  1733. context.shadowOffsetX = this.shadowOffsetX;
  1734. context.shadowOffsetY = this.shadowOffsetY;
  1735. }
  1736. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1737. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1738. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1739. context.shadowBlur = 0;
  1740. context.shadowOffsetX = 0;
  1741. context.shadowOffsetY = 0;
  1742. }
  1743. if (this._isChecked) {
  1744. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1745. var offsetWidth = actualWidth * this._checkSizeRatio;
  1746. var offseHeight = actualHeight * this._checkSizeRatio;
  1747. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1748. }
  1749. context.strokeStyle = this.color;
  1750. context.lineWidth = this._thickness;
  1751. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1752. context.restore();
  1753. };
  1754. // Events
  1755. /** @hidden */
  1756. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1757. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1758. return false;
  1759. }
  1760. this.isChecked = !this.isChecked;
  1761. return true;
  1762. };
  1763. /**
  1764. * Utility function to easily create a checkbox with a header
  1765. * @param title defines the label to use for the header
  1766. * @param onValueChanged defines the callback to call when value changes
  1767. * @returns a StackPanel containing the checkbox and a textBlock
  1768. */
  1769. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1770. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1771. panel.isVertical = false;
  1772. panel.height = "30px";
  1773. var checkbox = new Checkbox();
  1774. checkbox.width = "20px";
  1775. checkbox.height = "20px";
  1776. checkbox.isChecked = true;
  1777. checkbox.color = "green";
  1778. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1779. panel.addControl(checkbox);
  1780. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1781. header.text = title;
  1782. header.width = "180px";
  1783. header.paddingLeft = "5px";
  1784. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1785. header.color = "white";
  1786. panel.addControl(header);
  1787. return panel;
  1788. };
  1789. return Checkbox;
  1790. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1791. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1792. /***/ }),
  1793. /***/ "./2D/controls/colorpicker.ts":
  1794. /*!************************************!*\
  1795. !*** ./2D/controls/colorpicker.ts ***!
  1796. \************************************/
  1797. /*! exports provided: ColorPicker */
  1798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1799. "use strict";
  1800. __webpack_require__.r(__webpack_exports__);
  1801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1802. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1803. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1804. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1805. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1806. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1807. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1808. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1809. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1810. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1811. /** Class used to create color pickers */
  1812. var ColorPicker = /** @class */ (function (_super) {
  1813. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1814. /**
  1815. * Creates a new ColorPicker
  1816. * @param name defines the control name
  1817. */
  1818. function ColorPicker(name) {
  1819. var _this = _super.call(this, name) || this;
  1820. _this.name = name;
  1821. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1822. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1823. _this._pointerStartedOnSquare = false;
  1824. _this._pointerStartedOnWheel = false;
  1825. _this._squareLeft = 0;
  1826. _this._squareTop = 0;
  1827. _this._squareSize = 0;
  1828. _this._h = 360;
  1829. _this._s = 1;
  1830. _this._v = 1;
  1831. _this._lastPointerDownID = -1;
  1832. /**
  1833. * Observable raised when the value changes
  1834. */
  1835. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1836. // Events
  1837. _this._pointerIsDown = false;
  1838. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1839. _this.size = "200px";
  1840. _this.isPointerBlocker = true;
  1841. return _this;
  1842. }
  1843. Object.defineProperty(ColorPicker.prototype, "value", {
  1844. /** Gets or sets the color of the color picker */
  1845. get: function () {
  1846. return this._value;
  1847. },
  1848. set: function (value) {
  1849. if (this._value.equals(value)) {
  1850. return;
  1851. }
  1852. this._value.copyFrom(value);
  1853. this._value.toHSVToRef(this._tmpColor);
  1854. this._h = this._tmpColor.r;
  1855. this._s = Math.max(this._tmpColor.g, 0.00001);
  1856. this._v = Math.max(this._tmpColor.b, 0.00001);
  1857. this._markAsDirty();
  1858. if (this._value.r <= ColorPicker._Epsilon) {
  1859. this._value.r = 0;
  1860. }
  1861. if (this._value.g <= ColorPicker._Epsilon) {
  1862. this._value.g = 0;
  1863. }
  1864. if (this._value.b <= ColorPicker._Epsilon) {
  1865. this._value.b = 0;
  1866. }
  1867. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1868. this._value.r = 1.0;
  1869. }
  1870. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1871. this._value.g = 1.0;
  1872. }
  1873. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1874. this._value.b = 1.0;
  1875. }
  1876. this.onValueChangedObservable.notifyObservers(this._value);
  1877. },
  1878. enumerable: true,
  1879. configurable: true
  1880. });
  1881. Object.defineProperty(ColorPicker.prototype, "width", {
  1882. /**
  1883. * Gets or sets control width
  1884. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1885. */
  1886. get: function () {
  1887. return this._width.toString(this._host);
  1888. },
  1889. set: function (value) {
  1890. if (this._width.toString(this._host) === value) {
  1891. return;
  1892. }
  1893. if (this._width.fromString(value)) {
  1894. this._height.fromString(value);
  1895. this._markAsDirty();
  1896. }
  1897. },
  1898. enumerable: true,
  1899. configurable: true
  1900. });
  1901. Object.defineProperty(ColorPicker.prototype, "height", {
  1902. /**
  1903. * Gets or sets control height
  1904. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1905. */
  1906. get: function () {
  1907. return this._height.toString(this._host);
  1908. },
  1909. /** Gets or sets control height */
  1910. set: function (value) {
  1911. if (this._height.toString(this._host) === value) {
  1912. return;
  1913. }
  1914. if (this._height.fromString(value)) {
  1915. this._width.fromString(value);
  1916. this._markAsDirty();
  1917. }
  1918. },
  1919. enumerable: true,
  1920. configurable: true
  1921. });
  1922. Object.defineProperty(ColorPicker.prototype, "size", {
  1923. /** Gets or sets control size */
  1924. get: function () {
  1925. return this.width;
  1926. },
  1927. set: function (value) {
  1928. this.width = value;
  1929. },
  1930. enumerable: true,
  1931. configurable: true
  1932. });
  1933. ColorPicker.prototype._getTypeName = function () {
  1934. return "ColorPicker";
  1935. };
  1936. /** @hidden */
  1937. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1938. if (parentMeasure.width < parentMeasure.height) {
  1939. this._currentMeasure.height = parentMeasure.width;
  1940. }
  1941. else {
  1942. this._currentMeasure.width = parentMeasure.height;
  1943. }
  1944. };
  1945. ColorPicker.prototype._updateSquareProps = function () {
  1946. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1947. var wheelThickness = radius * .2;
  1948. var innerDiameter = (radius - wheelThickness) * 2;
  1949. var squareSize = innerDiameter / (Math.sqrt(2));
  1950. var offset = radius - squareSize * .5;
  1951. this._squareLeft = this._currentMeasure.left + offset;
  1952. this._squareTop = this._currentMeasure.top + offset;
  1953. this._squareSize = squareSize;
  1954. };
  1955. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1956. var lgh = context.createLinearGradient(left, top, width + left, top);
  1957. lgh.addColorStop(0, '#fff');
  1958. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1959. context.fillStyle = lgh;
  1960. context.fillRect(left, top, width, height);
  1961. var lgv = context.createLinearGradient(left, top, left, height + top);
  1962. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1963. lgv.addColorStop(1, '#000');
  1964. context.fillStyle = lgv;
  1965. context.fillRect(left, top, width, height);
  1966. };
  1967. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1968. context.beginPath();
  1969. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1970. context.lineWidth = 3;
  1971. context.strokeStyle = '#333333';
  1972. context.stroke();
  1973. context.beginPath();
  1974. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1975. context.lineWidth = 3;
  1976. context.strokeStyle = '#ffffff';
  1977. context.stroke();
  1978. };
  1979. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1980. var canvas = document.createElement("canvas");
  1981. canvas.width = radius * 2;
  1982. canvas.height = radius * 2;
  1983. var context = canvas.getContext("2d");
  1984. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1985. var data = image.data;
  1986. var color = this._tmpColor;
  1987. var maxDistSq = radius * radius;
  1988. var innerRadius = radius - thickness;
  1989. var minDistSq = innerRadius * innerRadius;
  1990. for (var x = -radius; x < radius; x++) {
  1991. for (var y = -radius; y < radius; y++) {
  1992. var distSq = x * x + y * y;
  1993. if (distSq > maxDistSq || distSq < minDistSq) {
  1994. continue;
  1995. }
  1996. var dist = Math.sqrt(distSq);
  1997. var ang = Math.atan2(y, x);
  1998. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1999. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  2000. data[index] = color.r * 255;
  2001. data[index + 1] = color.g * 255;
  2002. data[index + 2] = color.b * 255;
  2003. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2004. //apply less alpha to bigger color pickers
  2005. var alphaAmount = .2;
  2006. var maxAlpha = .2;
  2007. var minAlpha = .04;
  2008. var lowerRadius = 50;
  2009. var upperRadius = 150;
  2010. if (radius < lowerRadius) {
  2011. alphaAmount = maxAlpha;
  2012. }
  2013. else if (radius > upperRadius) {
  2014. alphaAmount = minAlpha;
  2015. }
  2016. else {
  2017. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  2018. }
  2019. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2020. if (alphaRatio < alphaAmount) {
  2021. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  2022. }
  2023. else if (alphaRatio > 1 - alphaAmount) {
  2024. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  2025. }
  2026. else {
  2027. data[index + 3] = 255;
  2028. }
  2029. }
  2030. }
  2031. context.putImageData(image, 0, 0);
  2032. return canvas;
  2033. };
  2034. /** @hidden */
  2035. ColorPicker.prototype._draw = function (context) {
  2036. context.save();
  2037. this._applyStates(context);
  2038. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2039. var wheelThickness = radius * .2;
  2040. var left = this._currentMeasure.left;
  2041. var top = this._currentMeasure.top;
  2042. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2043. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2044. }
  2045. this._updateSquareProps();
  2046. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2047. context.shadowColor = this.shadowColor;
  2048. context.shadowBlur = this.shadowBlur;
  2049. context.shadowOffsetX = this.shadowOffsetX;
  2050. context.shadowOffsetY = this.shadowOffsetY;
  2051. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2052. }
  2053. context.drawImage(this._colorWheelCanvas, left, top);
  2054. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2055. context.shadowBlur = 0;
  2056. context.shadowOffsetX = 0;
  2057. context.shadowOffsetY = 0;
  2058. }
  2059. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2060. var cx = this._squareLeft + this._squareSize * this._s;
  2061. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2062. this._drawCircle(cx, cy, radius * .04, context);
  2063. var dist = radius - wheelThickness * .5;
  2064. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2065. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2066. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2067. context.restore();
  2068. };
  2069. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2070. if (this._pointerStartedOnWheel) {
  2071. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2072. var centerX = radius + this._currentMeasure.left;
  2073. var centerY = radius + this._currentMeasure.top;
  2074. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2075. }
  2076. else if (this._pointerStartedOnSquare) {
  2077. this._updateSquareProps();
  2078. this._s = (x - this._squareLeft) / this._squareSize;
  2079. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2080. this._s = Math.min(this._s, 1);
  2081. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2082. this._v = Math.min(this._v, 1);
  2083. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2084. }
  2085. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2086. this.value = this._tmpColor;
  2087. };
  2088. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2089. this._updateSquareProps();
  2090. var left = this._squareLeft;
  2091. var top = this._squareTop;
  2092. var size = this._squareSize;
  2093. if (x >= left && x <= left + size &&
  2094. y >= top && y <= top + size) {
  2095. return true;
  2096. }
  2097. return false;
  2098. };
  2099. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2100. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2101. var centerX = radius + this._currentMeasure.left;
  2102. var centerY = radius + this._currentMeasure.top;
  2103. var wheelThickness = radius * .2;
  2104. var innerRadius = radius - wheelThickness;
  2105. var radiusSq = radius * radius;
  2106. var innerRadiusSq = innerRadius * innerRadius;
  2107. var dx = x - centerX;
  2108. var dy = y - centerY;
  2109. var distSq = dx * dx + dy * dy;
  2110. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2111. return true;
  2112. }
  2113. return false;
  2114. };
  2115. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2116. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2117. return false;
  2118. }
  2119. this._pointerIsDown = true;
  2120. this._pointerStartedOnSquare = false;
  2121. this._pointerStartedOnWheel = false;
  2122. // Invert transform
  2123. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2124. var x = this._transformedPosition.x;
  2125. var y = this._transformedPosition.y;
  2126. if (this._isPointOnSquare(x, y)) {
  2127. this._pointerStartedOnSquare = true;
  2128. }
  2129. else if (this._isPointOnWheel(x, y)) {
  2130. this._pointerStartedOnWheel = true;
  2131. }
  2132. this._updateValueFromPointer(x, y);
  2133. this._host._capturingControl[pointerId] = this;
  2134. this._lastPointerDownID = pointerId;
  2135. return true;
  2136. };
  2137. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2138. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2139. if (pointerId != this._lastPointerDownID) {
  2140. return;
  2141. }
  2142. // Invert transform
  2143. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2144. var x = this._transformedPosition.x;
  2145. var y = this._transformedPosition.y;
  2146. if (this._pointerIsDown) {
  2147. this._updateValueFromPointer(x, y);
  2148. }
  2149. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2150. };
  2151. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2152. this._pointerIsDown = false;
  2153. delete this._host._capturingControl[pointerId];
  2154. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2155. };
  2156. /**
  2157. * This function expands the color picker by creating a color picker dialog with manual
  2158. * color value input and the ability to save colors into an array to be used later in
  2159. * subsequent launches of the dialogue.
  2160. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2161. * @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.
  2162. * @returns picked color as a hex string and the saved colors array as hex strings.
  2163. */
  2164. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2165. return new Promise(function (resolve, reject) {
  2166. // Default options
  2167. options.pickerWidth = options.pickerWidth || "640px";
  2168. options.pickerHeight = options.pickerHeight || "400px";
  2169. options.headerHeight = options.headerHeight || "35px";
  2170. options.lastColor = options.lastColor || "#000000";
  2171. options.swatchLimit = options.swatchLimit || 20;
  2172. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2173. // Window size settings
  2174. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2175. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2176. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2177. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2178. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2179. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2180. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2181. // Button Colors
  2182. var buttonColor = "#c0c0c0";
  2183. var buttonBackgroundColor = "#535353";
  2184. var buttonBackgroundHoverColor = "#414141";
  2185. var buttonBackgroundClickColor = "515151";
  2186. var buttonDisabledColor = "#555555";
  2187. var buttonDisabledBackgroundColor = "#454545";
  2188. var currentSwatchesOutlineColor = "#404040";
  2189. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2190. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2191. var iconColorDark = "#aaaaaa";
  2192. var iconColorLight = "#ffffff";
  2193. var closeIconColor;
  2194. // Button settings
  2195. var buttonFontSize;
  2196. var butEdit;
  2197. var buttonWidth;
  2198. var buttonHeight;
  2199. // Input Text Colors
  2200. var inputFieldLabels = ["R", "G", "B"];
  2201. var inputTextBackgroundColor = "#454545";
  2202. var inputTextColor = "#f0f0f0";
  2203. // This is the current color as set by either the picker or by entering a value
  2204. var currentColor;
  2205. // This int is used for naming swatches and serves as the index for calling them from the list
  2206. var swatchNumber;
  2207. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2208. var swatchDrawer;
  2209. var editSwatchMode = false;
  2210. // Color InputText fields that will be updated upon value change
  2211. var picker;
  2212. var rValInt;
  2213. var gValInt;
  2214. var bValInt;
  2215. var rValDec;
  2216. var gValDec;
  2217. var bValDec;
  2218. var hexVal;
  2219. var newSwatch;
  2220. var lastVal;
  2221. var activeField;
  2222. /**
  2223. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2224. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2225. * are will receive no update. This is to prevent the input from the user being overwritten.
  2226. */
  2227. function updateValues(value, inputField) {
  2228. activeField = inputField;
  2229. var pickedColor = value.toHexString();
  2230. newSwatch.background = pickedColor;
  2231. if (rValInt.name != activeField) {
  2232. rValInt.text = Math.floor(value.r * 255).toString();
  2233. }
  2234. if (gValInt.name != activeField) {
  2235. gValInt.text = Math.floor(value.g * 255).toString();
  2236. }
  2237. if (bValInt.name != activeField) {
  2238. bValInt.text = Math.floor(value.b * 255).toString();
  2239. }
  2240. if (rValDec.name != activeField) {
  2241. rValDec.text = value.r.toString();
  2242. }
  2243. if (gValDec.name != activeField) {
  2244. gValDec.text = value.g.toString();
  2245. }
  2246. if (bValDec.name != activeField) {
  2247. bValDec.text = value.b.toString();
  2248. }
  2249. if (hexVal.name != activeField) {
  2250. var minusPound = pickedColor.split("#");
  2251. hexVal.text = minusPound[1];
  2252. }
  2253. if (picker.name != activeField) {
  2254. picker.value = value;
  2255. }
  2256. }
  2257. // 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.
  2258. function updateInt(field, channel) {
  2259. var newValue = field.text;
  2260. var checkVal = /[^0-9]/g.test(newValue);
  2261. if (checkVal) {
  2262. field.text = lastVal;
  2263. return;
  2264. }
  2265. else {
  2266. if (newValue != "") {
  2267. if (Math.floor(parseInt(newValue)) < 0) {
  2268. newValue = "0";
  2269. }
  2270. else if (Math.floor(parseInt(newValue)) > 255) {
  2271. newValue = "255";
  2272. }
  2273. else if (isNaN(parseInt(newValue))) {
  2274. newValue = "0";
  2275. }
  2276. }
  2277. if (activeField == field.name) {
  2278. lastVal = newValue;
  2279. }
  2280. }
  2281. if (newValue != "") {
  2282. newValue = parseInt(newValue).toString();
  2283. field.text = newValue;
  2284. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2285. if (activeField == field.name) {
  2286. if (channel == "r") {
  2287. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2288. }
  2289. else if (channel == "g") {
  2290. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2291. }
  2292. else {
  2293. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2294. }
  2295. }
  2296. }
  2297. }
  2298. // 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.
  2299. function updateFloat(field, channel) {
  2300. var newValue = field.text;
  2301. var checkVal = /[^0-9\.]/g.test(newValue);
  2302. if (checkVal) {
  2303. field.text = lastVal;
  2304. return;
  2305. }
  2306. else {
  2307. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2308. if (parseFloat(newValue) < 0.0) {
  2309. newValue = "0.0";
  2310. }
  2311. else if (parseFloat(newValue) > 1.0) {
  2312. newValue = "1.0";
  2313. }
  2314. else if (isNaN(parseFloat(newValue))) {
  2315. newValue = "0.0";
  2316. }
  2317. }
  2318. if (activeField == field.name) {
  2319. lastVal = newValue;
  2320. }
  2321. }
  2322. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2323. newValue = parseFloat(newValue).toString();
  2324. field.text = newValue;
  2325. }
  2326. else {
  2327. newValue = "0.0";
  2328. }
  2329. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2330. if (activeField == field.name) {
  2331. if (channel == "r") {
  2332. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2333. }
  2334. else if (channel == "g") {
  2335. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2336. }
  2337. else {
  2338. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2339. }
  2340. }
  2341. }
  2342. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2343. function deleteSwatch(index) {
  2344. if (options.savedColors) {
  2345. options.savedColors.splice(index, 1);
  2346. }
  2347. if (options.savedColors && options.savedColors.length == 0) {
  2348. setEditButtonVisibility(false);
  2349. editSwatchMode = false;
  2350. }
  2351. }
  2352. // Creates and styles an individual swatch when updateSwatches is called.
  2353. function createSwatch() {
  2354. if (options.savedColors && options.savedColors[swatchNumber]) {
  2355. if (editSwatchMode) {
  2356. var icon = "b";
  2357. }
  2358. else {
  2359. var icon = "";
  2360. }
  2361. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2362. swatch.fontFamily = "BabylonJSglyphs";
  2363. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2364. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2365. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2366. if (swatchLuminence > luminanceLimit) {
  2367. swatch.color = iconColorDark;
  2368. }
  2369. else {
  2370. swatch.color = iconColorLight;
  2371. }
  2372. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2373. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2374. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2375. swatch.background = options.savedColors[swatchNumber];
  2376. swatch.thickness = 2;
  2377. var metadata_1 = swatchNumber;
  2378. swatch.pointerDownAnimation = function () {
  2379. swatch.thickness = 4;
  2380. };
  2381. swatch.pointerUpAnimation = function () {
  2382. swatch.thickness = 3;
  2383. };
  2384. swatch.pointerEnterAnimation = function () {
  2385. swatch.thickness = 3;
  2386. };
  2387. swatch.pointerOutAnimation = function () {
  2388. swatch.thickness = 2;
  2389. };
  2390. swatch.onPointerClickObservable.add(function () {
  2391. if (!editSwatchMode) {
  2392. if (options.savedColors) {
  2393. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2394. }
  2395. }
  2396. else {
  2397. deleteSwatch(metadata_1);
  2398. updateSwatches("", butSave);
  2399. }
  2400. });
  2401. return swatch;
  2402. }
  2403. else {
  2404. return null;
  2405. }
  2406. }
  2407. // Mode switch to render button text and close symbols on swatch controls
  2408. function editSwatches(mode) {
  2409. if (mode !== undefined) {
  2410. editSwatchMode = mode;
  2411. }
  2412. if (editSwatchMode) {
  2413. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2414. var thisButton = swatchDrawer.children[i];
  2415. thisButton.textBlock.text = "b";
  2416. }
  2417. if (butEdit !== undefined) {
  2418. butEdit.textBlock.text = "Done";
  2419. }
  2420. }
  2421. else {
  2422. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2423. var thisButton = swatchDrawer.children[i];
  2424. thisButton.textBlock.text = "";
  2425. }
  2426. if (butEdit !== undefined) {
  2427. butEdit.textBlock.text = "Edit";
  2428. }
  2429. }
  2430. }
  2431. /**
  2432. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2433. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2434. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2435. * saved colors there are and how many can be stored per row.
  2436. */
  2437. function updateSwatches(color, button) {
  2438. if (options.savedColors) {
  2439. if (color != "") {
  2440. options.savedColors.push(color);
  2441. }
  2442. swatchNumber = 0;
  2443. swatchDrawer.clearControls();
  2444. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2445. if (rowCount == 0) {
  2446. var gutterCount = 0;
  2447. }
  2448. else {
  2449. var gutterCount = rowCount + 1;
  2450. }
  2451. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2452. var currentRows = swatchDrawer.rowCount;
  2453. for (var i = 0; i < currentRows; i++) {
  2454. swatchDrawer.removeRowDefinition(0);
  2455. }
  2456. for (var i = 0; i < rowCount + gutterCount; i++) {
  2457. if (i % 2) {
  2458. swatchDrawer.addRowDefinition(swatchSize, true);
  2459. }
  2460. else {
  2461. swatchDrawer.addRowDefinition(gutterSize, true);
  2462. }
  2463. }
  2464. }
  2465. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2466. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2467. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2468. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2469. var totalButtonsThisRow = options.numSwatchesPerLine;
  2470. }
  2471. else {
  2472. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2473. }
  2474. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2475. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2476. if (x > options.numSwatchesPerLine) {
  2477. continue;
  2478. }
  2479. var swatch = createSwatch();
  2480. if (swatch != null) {
  2481. swatchDrawer.addControl(swatch, y, w);
  2482. w += 2;
  2483. swatchNumber++;
  2484. }
  2485. else {
  2486. continue;
  2487. }
  2488. }
  2489. }
  2490. if (options.savedColors.length >= options.swatchLimit) {
  2491. disableButton(button, true);
  2492. }
  2493. else {
  2494. disableButton(button, false);
  2495. }
  2496. }
  2497. }
  2498. // Shows or hides edit swatches button depending on if there are saved swatches
  2499. function setEditButtonVisibility(enableButton) {
  2500. if (enableButton) {
  2501. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2502. butEdit.width = buttonWidth;
  2503. butEdit.height = buttonHeight;
  2504. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2505. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2506. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2507. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2508. butEdit.thickness = 2;
  2509. butEdit.color = buttonColor;
  2510. butEdit.fontSize = buttonFontSize;
  2511. butEdit.background = buttonBackgroundColor;
  2512. butEdit.onPointerEnterObservable.add(function () {
  2513. butEdit.background = buttonBackgroundHoverColor;
  2514. });
  2515. butEdit.onPointerOutObservable.add(function () {
  2516. butEdit.background = buttonBackgroundColor;
  2517. });
  2518. butEdit.pointerDownAnimation = function () {
  2519. butEdit.background = buttonBackgroundClickColor;
  2520. };
  2521. butEdit.pointerUpAnimation = function () {
  2522. butEdit.background = buttonBackgroundHoverColor;
  2523. };
  2524. butEdit.onPointerClickObservable.add(function () {
  2525. if (editSwatchMode) {
  2526. editSwatchMode = false;
  2527. }
  2528. else {
  2529. editSwatchMode = true;
  2530. }
  2531. editSwatches();
  2532. });
  2533. pickerGrid.addControl(butEdit, 1, 0);
  2534. }
  2535. else {
  2536. pickerGrid.removeControl(butEdit);
  2537. }
  2538. }
  2539. // Called when the user hits the limit of saved colors in the drawer.
  2540. function disableButton(button, disabled) {
  2541. if (disabled) {
  2542. button.color = buttonDisabledColor;
  2543. button.background = buttonDisabledBackgroundColor;
  2544. }
  2545. else {
  2546. button.color = buttonColor;
  2547. button.background = buttonBackgroundColor;
  2548. }
  2549. }
  2550. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2551. function closePicker(color) {
  2552. if (options.savedColors && options.savedColors.length > 0) {
  2553. resolve({
  2554. savedColors: options.savedColors,
  2555. pickedColor: color
  2556. });
  2557. }
  2558. else {
  2559. resolve({
  2560. pickedColor: color
  2561. });
  2562. }
  2563. advancedTexture.removeControl(dialogContainer);
  2564. }
  2565. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2566. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2567. dialogContainer.name = "Dialog Container";
  2568. dialogContainer.width = options.pickerWidth;
  2569. if (options.savedColors) {
  2570. dialogContainer.height = containerSize;
  2571. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2572. dialogContainer.addRowDefinition(topRow, false);
  2573. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2574. }
  2575. else {
  2576. dialogContainer.height = options.pickerHeight;
  2577. dialogContainer.addRowDefinition(1.0, false);
  2578. }
  2579. advancedTexture.addControl(dialogContainer);
  2580. // Swatch drawer which contains all saved color buttons
  2581. if (options.savedColors) {
  2582. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2583. swatchDrawer.name = "Swatch Drawer";
  2584. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2585. swatchDrawer.background = buttonBackgroundColor;
  2586. swatchDrawer.width = options.pickerWidth;
  2587. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2588. if (initialRows == 0) {
  2589. var gutterCount = 0;
  2590. }
  2591. else {
  2592. var gutterCount = initialRows + 1;
  2593. }
  2594. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2595. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2596. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2597. if (i % 2 != 0) {
  2598. swatchDrawer.addRowDefinition(swatchSize, true);
  2599. }
  2600. else {
  2601. swatchDrawer.addRowDefinition(gutterSize, true);
  2602. }
  2603. }
  2604. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2605. if (i % 2 != 0) {
  2606. swatchDrawer.addColumnDefinition(swatchSize, true);
  2607. }
  2608. else {
  2609. swatchDrawer.addColumnDefinition(gutterSize, true);
  2610. }
  2611. }
  2612. dialogContainer.addControl(swatchDrawer, 1, 0);
  2613. }
  2614. // Picker container
  2615. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2616. pickerPanel.name = "Picker Panel";
  2617. pickerPanel.height = options.pickerHeight;
  2618. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2619. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2620. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2621. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2622. dialogContainer.addControl(pickerPanel, 0, 0);
  2623. // Picker container header
  2624. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2625. header.name = "Dialogue Header Bar";
  2626. header.background = "#cccccc";
  2627. header.thickness = 0;
  2628. pickerPanel.addControl(header, 0, 0);
  2629. // Header close button
  2630. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2631. closeButton.fontFamily = "BabylonJSglyphs";
  2632. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2633. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2634. closeButton.color = closeIconColor.toHexString();
  2635. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2636. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2637. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2638. closeButton.height = closeButton.width = options.headerHeight;
  2639. closeButton.background = header.background;
  2640. closeButton.thickness = 0;
  2641. closeButton.pointerDownAnimation = function () {
  2642. };
  2643. closeButton.pointerUpAnimation = function () {
  2644. closeButton.background = header.background;
  2645. };
  2646. closeButton.pointerEnterAnimation = function () {
  2647. closeButton.color = header.background;
  2648. closeButton.background = "red";
  2649. };
  2650. closeButton.pointerOutAnimation = function () {
  2651. closeButton.color = closeIconColor.toHexString();
  2652. closeButton.background = header.background;
  2653. };
  2654. closeButton.onPointerClickObservable.add(function () {
  2655. closePicker(currentSwatch.background);
  2656. });
  2657. pickerPanel.addControl(closeButton, 0, 0);
  2658. // Dialog container body
  2659. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2660. dialogBody.name = "Dialogue Body";
  2661. dialogBody.background = buttonBackgroundColor;
  2662. var dialogBodyCols = [0.4375, 0.5625];
  2663. dialogBody.addRowDefinition(1.0, false);
  2664. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2665. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2666. pickerPanel.addControl(dialogBody, 1, 0);
  2667. // Picker grid
  2668. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2669. pickerGrid.name = "Picker Grid";
  2670. pickerGrid.addRowDefinition(0.85, false);
  2671. pickerGrid.addRowDefinition(0.15, false);
  2672. dialogBody.addControl(pickerGrid, 0, 0);
  2673. // Picker control
  2674. picker = new ColorPicker();
  2675. picker.name = "GUI Color Picker";
  2676. if (options.pickerHeight < options.pickerWidth) {
  2677. picker.width = 0.89;
  2678. }
  2679. else {
  2680. picker.height = 0.89;
  2681. }
  2682. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2683. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2684. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2685. picker.onPointerDownObservable.add(function () {
  2686. activeField = picker.name;
  2687. lastVal = "";
  2688. editSwatches(false);
  2689. });
  2690. picker.onValueChangedObservable.add(function (value) {
  2691. if (activeField == picker.name) {
  2692. updateValues(value, picker.name);
  2693. }
  2694. });
  2695. pickerGrid.addControl(picker, 0, 0);
  2696. // Picker body right quarant
  2697. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2698. pickerBodyRight.name = "Dialogue Right Half";
  2699. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2700. var pickerBodyRightRows = [0.514, 0.486];
  2701. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2702. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2703. dialogBody.addControl(pickerBodyRight, 1, 1);
  2704. // Picker container swatches and buttons
  2705. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2706. pickerSwatchesButtons.name = "Swatches and Buttons";
  2707. var pickerButtonsCol = [0.417, 0.583];
  2708. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2709. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2710. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2711. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2712. // Picker Swatches quadrant
  2713. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2714. pickerSwatches.name = "New and Current Swatches";
  2715. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2716. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2717. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2718. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2719. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2720. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2721. // Active swatches
  2722. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2723. activeSwatches.name = "Active Swatches";
  2724. activeSwatches.width = 0.67;
  2725. activeSwatches.addRowDefinition(0.5, false);
  2726. activeSwatches.addRowDefinition(0.5, false);
  2727. pickerSwatches.addControl(activeSwatches, 2, 0);
  2728. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2729. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2730. if (options.pickerWidth > options.pickerHeight) {
  2731. var labelTextSize = labelHeight;
  2732. }
  2733. else {
  2734. var labelTextSize = labelWidth;
  2735. }
  2736. // New color swatch and previous color button
  2737. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2738. newText.text = "new";
  2739. newText.name = "New Color Label";
  2740. newText.color = buttonColor;
  2741. newText.fontSize = labelTextSize;
  2742. pickerSwatches.addControl(newText, 1, 0);
  2743. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2744. newSwatch.name = "New Color Swatch";
  2745. newSwatch.background = options.lastColor;
  2746. newSwatch.thickness = 0;
  2747. activeSwatches.addControl(newSwatch, 0, 0);
  2748. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2749. currentSwatch.background = options.lastColor;
  2750. currentSwatch.thickness = 0;
  2751. currentSwatch.onPointerClickObservable.add(function () {
  2752. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2753. updateValues(revertColor, currentSwatch.name);
  2754. editSwatches(false);
  2755. });
  2756. currentSwatch.pointerDownAnimation = function () { };
  2757. currentSwatch.pointerUpAnimation = function () { };
  2758. currentSwatch.pointerEnterAnimation = function () { };
  2759. currentSwatch.pointerOutAnimation = function () { };
  2760. activeSwatches.addControl(currentSwatch, 1, 0);
  2761. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2762. swatchOutline.name = "Swatch Outline";
  2763. swatchOutline.width = 0.67;
  2764. swatchOutline.thickness = 2;
  2765. swatchOutline.color = currentSwatchesOutlineColor;
  2766. swatchOutline.isHitTestVisible = false;
  2767. pickerSwatches.addControl(swatchOutline, 2, 0);
  2768. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2769. currentText.name = "Current Color Label";
  2770. currentText.text = "current";
  2771. currentText.color = buttonColor;
  2772. currentText.fontSize = labelTextSize;
  2773. pickerSwatches.addControl(currentText, 3, 0);
  2774. // Buttons grid
  2775. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2776. buttonGrid.name = "Button Grid";
  2777. buttonGrid.height = 0.8;
  2778. var buttonGridRows = 1 / 3;
  2779. buttonGrid.addRowDefinition(buttonGridRows, false);
  2780. buttonGrid.addRowDefinition(buttonGridRows, false);
  2781. buttonGrid.addRowDefinition(buttonGridRows, false);
  2782. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2783. // Determine pixel width and height for all buttons from overall panel dimensions
  2784. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2785. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2786. // Determine button type size
  2787. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2788. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2789. }
  2790. else {
  2791. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2792. }
  2793. // Panel Buttons
  2794. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2795. butOK.width = buttonWidth;
  2796. butOK.height = buttonHeight;
  2797. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2798. butOK.thickness = 2;
  2799. butOK.color = buttonColor;
  2800. butOK.fontSize = buttonFontSize;
  2801. butOK.background = buttonBackgroundColor;
  2802. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2803. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2804. butOK.pointerDownAnimation = function () {
  2805. butOK.background = buttonBackgroundClickColor;
  2806. };
  2807. butOK.pointerUpAnimation = function () {
  2808. butOK.background = buttonBackgroundHoverColor;
  2809. };
  2810. butOK.onPointerClickObservable.add(function () {
  2811. editSwatches(false);
  2812. closePicker(newSwatch.background);
  2813. });
  2814. buttonGrid.addControl(butOK, 0, 0);
  2815. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2816. butCancel.width = buttonWidth;
  2817. butCancel.height = buttonHeight;
  2818. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2819. butCancel.thickness = 2;
  2820. butCancel.color = buttonColor;
  2821. butCancel.fontSize = buttonFontSize;
  2822. butCancel.background = buttonBackgroundColor;
  2823. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2824. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2825. butCancel.pointerDownAnimation = function () {
  2826. butCancel.background = buttonBackgroundClickColor;
  2827. };
  2828. butCancel.pointerUpAnimation = function () {
  2829. butCancel.background = buttonBackgroundHoverColor;
  2830. };
  2831. butCancel.onPointerClickObservable.add(function () {
  2832. editSwatches(false);
  2833. closePicker(currentSwatch.background);
  2834. });
  2835. buttonGrid.addControl(butCancel, 1, 0);
  2836. if (options.savedColors) {
  2837. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2838. butSave.width = buttonWidth;
  2839. butSave.height = buttonHeight;
  2840. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2841. butSave.thickness = 2;
  2842. butSave.fontSize = buttonFontSize;
  2843. if (options.savedColors.length < options.swatchLimit) {
  2844. butSave.color = buttonColor;
  2845. butSave.background = buttonBackgroundColor;
  2846. }
  2847. else {
  2848. disableButton(butSave, true);
  2849. }
  2850. butSave.onPointerEnterObservable.add(function () {
  2851. if (options.savedColors) {
  2852. if (options.savedColors.length < options.swatchLimit) {
  2853. butSave.background = buttonBackgroundHoverColor;
  2854. }
  2855. }
  2856. });
  2857. butSave.onPointerOutObservable.add(function () {
  2858. if (options.savedColors) {
  2859. if (options.savedColors.length < options.swatchLimit) {
  2860. butSave.background = buttonBackgroundColor;
  2861. }
  2862. }
  2863. });
  2864. butSave.pointerDownAnimation = function () {
  2865. if (options.savedColors) {
  2866. if (options.savedColors.length < options.swatchLimit) {
  2867. butSave.background = buttonBackgroundClickColor;
  2868. }
  2869. }
  2870. };
  2871. butSave.pointerUpAnimation = function () {
  2872. if (options.savedColors) {
  2873. if (options.savedColors.length < options.swatchLimit) {
  2874. butSave.background = buttonBackgroundHoverColor;
  2875. }
  2876. }
  2877. };
  2878. butSave.onPointerClickObservable.add(function () {
  2879. if (options.savedColors) {
  2880. if (options.savedColors.length == 0) {
  2881. setEditButtonVisibility(true);
  2882. }
  2883. if (options.savedColors.length < options.swatchLimit) {
  2884. updateSwatches(newSwatch.background, butSave);
  2885. }
  2886. editSwatches(false);
  2887. }
  2888. });
  2889. if (options.savedColors.length > 0) {
  2890. setEditButtonVisibility(true);
  2891. }
  2892. buttonGrid.addControl(butSave, 2, 0);
  2893. }
  2894. // Picker color values input
  2895. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2896. pickerColorValues.name = "Dialog Lower Right";
  2897. pickerColorValues.addRowDefinition(0.02, false);
  2898. pickerColorValues.addRowDefinition(0.63, false);
  2899. pickerColorValues.addRowDefinition(0.21, false);
  2900. pickerColorValues.addRowDefinition(0.14, false);
  2901. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2902. // RGB values text boxes
  2903. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2904. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2905. rgbValuesQuadrant.name = "RGB Values";
  2906. rgbValuesQuadrant.width = 0.82;
  2907. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2908. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2909. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2910. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2911. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2912. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2913. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2914. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2915. for (var i = 0; i < inputFieldLabels.length; i++) {
  2916. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2917. labelText.text = inputFieldLabels[i];
  2918. labelText.color = buttonColor;
  2919. labelText.fontSize = buttonFontSize;
  2920. rgbValuesQuadrant.addControl(labelText, i, 0);
  2921. }
  2922. // Input fields for RGB values
  2923. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2924. rValInt.width = 0.83;
  2925. rValInt.height = 0.72;
  2926. rValInt.name = "rIntField";
  2927. rValInt.fontSize = buttonFontSize;
  2928. rValInt.text = (currentColor.r * 255).toString();
  2929. rValInt.color = inputTextColor;
  2930. rValInt.background = inputTextBackgroundColor;
  2931. rValInt.onFocusObservable.add(function () {
  2932. activeField = rValInt.name;
  2933. lastVal = rValInt.text;
  2934. editSwatches(false);
  2935. });
  2936. rValInt.onBlurObservable.add(function () {
  2937. if (rValInt.text == "") {
  2938. rValInt.text = "0";
  2939. }
  2940. updateInt(rValInt, "r");
  2941. if (activeField == rValInt.name) {
  2942. activeField = "";
  2943. }
  2944. });
  2945. rValInt.onTextChangedObservable.add(function () {
  2946. if (activeField == rValInt.name) {
  2947. updateInt(rValInt, "r");
  2948. }
  2949. });
  2950. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2951. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2952. gValInt.width = 0.83;
  2953. gValInt.height = 0.72;
  2954. gValInt.name = "gIntField";
  2955. gValInt.fontSize = buttonFontSize;
  2956. gValInt.text = (currentColor.g * 255).toString();
  2957. gValInt.color = inputTextColor;
  2958. gValInt.background = inputTextBackgroundColor;
  2959. gValInt.onFocusObservable.add(function () {
  2960. activeField = gValInt.name;
  2961. lastVal = gValInt.text;
  2962. editSwatches(false);
  2963. });
  2964. gValInt.onBlurObservable.add(function () {
  2965. if (gValInt.text == "") {
  2966. gValInt.text = "0";
  2967. }
  2968. updateInt(gValInt, "g");
  2969. if (activeField == gValInt.name) {
  2970. activeField = "";
  2971. }
  2972. });
  2973. gValInt.onTextChangedObservable.add(function () {
  2974. if (activeField == gValInt.name) {
  2975. updateInt(gValInt, "g");
  2976. }
  2977. });
  2978. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2979. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2980. bValInt.width = 0.83;
  2981. bValInt.height = 0.72;
  2982. bValInt.name = "bIntField";
  2983. bValInt.fontSize = buttonFontSize;
  2984. bValInt.text = (currentColor.b * 255).toString();
  2985. bValInt.color = inputTextColor;
  2986. bValInt.background = inputTextBackgroundColor;
  2987. bValInt.onFocusObservable.add(function () {
  2988. activeField = bValInt.name;
  2989. lastVal = bValInt.text;
  2990. editSwatches(false);
  2991. });
  2992. bValInt.onBlurObservable.add(function () {
  2993. if (bValInt.text == "") {
  2994. bValInt.text = "0";
  2995. }
  2996. updateInt(bValInt, "b");
  2997. if (activeField == bValInt.name) {
  2998. activeField = "";
  2999. }
  3000. });
  3001. bValInt.onTextChangedObservable.add(function () {
  3002. if (activeField == bValInt.name) {
  3003. updateInt(bValInt, "b");
  3004. }
  3005. });
  3006. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  3007. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3008. rValDec.width = 0.95;
  3009. rValDec.height = 0.72;
  3010. rValDec.name = "rDecField";
  3011. rValDec.fontSize = buttonFontSize;
  3012. rValDec.text = currentColor.r.toString();
  3013. rValDec.color = inputTextColor;
  3014. rValDec.background = inputTextBackgroundColor;
  3015. rValDec.onFocusObservable.add(function () {
  3016. activeField = rValDec.name;
  3017. lastVal = rValDec.text;
  3018. editSwatches(false);
  3019. });
  3020. rValDec.onBlurObservable.add(function () {
  3021. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3022. rValDec.text = "0";
  3023. updateFloat(rValDec, "r");
  3024. }
  3025. if (activeField == rValDec.name) {
  3026. activeField = "";
  3027. }
  3028. });
  3029. rValDec.onTextChangedObservable.add(function () {
  3030. if (activeField == rValDec.name) {
  3031. updateFloat(rValDec, "r");
  3032. }
  3033. });
  3034. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3035. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3036. gValDec.width = 0.95;
  3037. gValDec.height = 0.72;
  3038. gValDec.name = "gDecField";
  3039. gValDec.fontSize = buttonFontSize;
  3040. gValDec.text = currentColor.g.toString();
  3041. gValDec.color = inputTextColor;
  3042. gValDec.background = inputTextBackgroundColor;
  3043. gValDec.onFocusObservable.add(function () {
  3044. activeField = gValDec.name;
  3045. lastVal = gValDec.text;
  3046. editSwatches(false);
  3047. });
  3048. gValDec.onBlurObservable.add(function () {
  3049. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3050. gValDec.text = "0";
  3051. updateFloat(gValDec, "g");
  3052. }
  3053. if (activeField == gValDec.name) {
  3054. activeField = "";
  3055. }
  3056. });
  3057. gValDec.onTextChangedObservable.add(function () {
  3058. if (activeField == gValDec.name) {
  3059. updateFloat(gValDec, "g");
  3060. }
  3061. });
  3062. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3063. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3064. bValDec.width = 0.95;
  3065. bValDec.height = 0.72;
  3066. bValDec.name = "bDecField";
  3067. bValDec.fontSize = buttonFontSize;
  3068. bValDec.text = currentColor.b.toString();
  3069. bValDec.color = inputTextColor;
  3070. bValDec.background = inputTextBackgroundColor;
  3071. bValDec.onFocusObservable.add(function () {
  3072. activeField = bValDec.name;
  3073. lastVal = bValDec.text;
  3074. editSwatches(false);
  3075. });
  3076. bValDec.onBlurObservable.add(function () {
  3077. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3078. bValDec.text = "0";
  3079. updateFloat(bValDec, "b");
  3080. }
  3081. if (activeField == bValDec.name) {
  3082. activeField = "";
  3083. }
  3084. });
  3085. bValDec.onTextChangedObservable.add(function () {
  3086. if (activeField == bValDec.name) {
  3087. updateFloat(bValDec, "b");
  3088. }
  3089. });
  3090. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3091. // Hex value input
  3092. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3093. hexValueQuadrant.name = "Hex Value";
  3094. hexValueQuadrant.width = 0.82;
  3095. hexValueQuadrant.addRowDefinition(1.0, false);
  3096. hexValueQuadrant.addColumnDefinition(0.1, false);
  3097. hexValueQuadrant.addColumnDefinition(0.9, false);
  3098. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3099. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3100. labelText.text = "#";
  3101. labelText.color = buttonColor;
  3102. labelText.fontSize = buttonFontSize;
  3103. hexValueQuadrant.addControl(labelText, 0, 0);
  3104. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3105. hexVal.width = 0.96;
  3106. hexVal.height = 0.72;
  3107. hexVal.name = "hexField";
  3108. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3109. hexVal.fontSize = buttonFontSize;
  3110. var minusPound = options.lastColor.split("#");
  3111. hexVal.text = minusPound[1];
  3112. hexVal.color = inputTextColor;
  3113. hexVal.background = inputTextBackgroundColor;
  3114. hexVal.onFocusObservable.add(function () {
  3115. activeField = hexVal.name;
  3116. lastVal = hexVal.text;
  3117. editSwatches(false);
  3118. });
  3119. hexVal.onBlurObservable.add(function () {
  3120. if (hexVal.text.length == 3) {
  3121. var val = hexVal.text.split("");
  3122. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3123. }
  3124. if (hexVal.text == "") {
  3125. hexVal.text = "000000";
  3126. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3127. }
  3128. if (activeField == hexVal.name) {
  3129. activeField = "";
  3130. }
  3131. });
  3132. hexVal.onTextChangedObservable.add(function () {
  3133. var newHexValue = hexVal.text;
  3134. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3135. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3136. hexVal.text = lastVal;
  3137. }
  3138. else {
  3139. if (hexVal.text.length < 6) {
  3140. var leadingZero = 6 - hexVal.text.length;
  3141. for (var i = 0; i < leadingZero; i++) {
  3142. newHexValue = "0" + newHexValue;
  3143. }
  3144. }
  3145. if (hexVal.text.length == 3) {
  3146. var val = hexVal.text.split("");
  3147. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3148. }
  3149. newHexValue = "#" + newHexValue;
  3150. if (activeField == hexVal.name) {
  3151. lastVal = hexVal.text;
  3152. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3153. }
  3154. }
  3155. });
  3156. hexValueQuadrant.addControl(hexVal, 0, 1);
  3157. if (options.savedColors && options.savedColors.length > 0) {
  3158. updateSwatches("", butSave);
  3159. }
  3160. });
  3161. };
  3162. ColorPicker._Epsilon = 0.000001;
  3163. return ColorPicker;
  3164. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3165. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3166. /***/ }),
  3167. /***/ "./2D/controls/container.ts":
  3168. /*!**********************************!*\
  3169. !*** ./2D/controls/container.ts ***!
  3170. \**********************************/
  3171. /*! exports provided: Container */
  3172. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3173. "use strict";
  3174. __webpack_require__.r(__webpack_exports__);
  3175. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3176. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3177. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/perfCounter");
  3178. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3179. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3180. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3181. /**
  3182. * Root class for 2D containers
  3183. * @see http://doc.babylonjs.com/how_to/gui#containers
  3184. */
  3185. var Container = /** @class */ (function (_super) {
  3186. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3187. /**
  3188. * Creates a new Container
  3189. * @param name defines the name of the container
  3190. */
  3191. function Container(name) {
  3192. var _this = _super.call(this, name) || this;
  3193. _this.name = name;
  3194. /** @hidden */
  3195. _this._children = new Array();
  3196. /** @hidden */
  3197. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3198. /** @hidden */
  3199. _this._background = "";
  3200. /** @hidden */
  3201. _this._adaptWidthToChildren = false;
  3202. /** @hidden */
  3203. _this._adaptHeightToChildren = false;
  3204. /**
  3205. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3206. */
  3207. _this.logLayoutCycleErrors = false;
  3208. /**
  3209. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3210. */
  3211. _this.maxLayoutCycle = 3;
  3212. return _this;
  3213. }
  3214. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3215. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3216. get: function () {
  3217. return this._adaptHeightToChildren;
  3218. },
  3219. set: function (value) {
  3220. if (this._adaptHeightToChildren === value) {
  3221. return;
  3222. }
  3223. this._adaptHeightToChildren = value;
  3224. if (value) {
  3225. this.height = "100%";
  3226. }
  3227. this._markAsDirty();
  3228. },
  3229. enumerable: true,
  3230. configurable: true
  3231. });
  3232. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3233. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3234. get: function () {
  3235. return this._adaptWidthToChildren;
  3236. },
  3237. set: function (value) {
  3238. if (this._adaptWidthToChildren === value) {
  3239. return;
  3240. }
  3241. this._adaptWidthToChildren = value;
  3242. if (value) {
  3243. this.width = "100%";
  3244. }
  3245. this._markAsDirty();
  3246. },
  3247. enumerable: true,
  3248. configurable: true
  3249. });
  3250. Object.defineProperty(Container.prototype, "background", {
  3251. /** Gets or sets background color */
  3252. get: function () {
  3253. return this._background;
  3254. },
  3255. set: function (value) {
  3256. if (this._background === value) {
  3257. return;
  3258. }
  3259. this._background = value;
  3260. this._markAsDirty();
  3261. },
  3262. enumerable: true,
  3263. configurable: true
  3264. });
  3265. Object.defineProperty(Container.prototype, "children", {
  3266. /** Gets the list of children */
  3267. get: function () {
  3268. return this._children;
  3269. },
  3270. enumerable: true,
  3271. configurable: true
  3272. });
  3273. Container.prototype._getTypeName = function () {
  3274. return "Container";
  3275. };
  3276. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3277. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3278. var child = _a[_i];
  3279. child._markMatrixAsDirty();
  3280. }
  3281. };
  3282. /**
  3283. * Gets a child using its name
  3284. * @param name defines the child name to look for
  3285. * @returns the child control if found
  3286. */
  3287. Container.prototype.getChildByName = function (name) {
  3288. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3289. var child = _a[_i];
  3290. if (child.name === name) {
  3291. return child;
  3292. }
  3293. }
  3294. return null;
  3295. };
  3296. /**
  3297. * Gets a child using its type and its name
  3298. * @param name defines the child name to look for
  3299. * @param type defines the child type to look for
  3300. * @returns the child control if found
  3301. */
  3302. Container.prototype.getChildByType = function (name, type) {
  3303. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3304. var child = _a[_i];
  3305. if (child.typeName === type) {
  3306. return child;
  3307. }
  3308. }
  3309. return null;
  3310. };
  3311. /**
  3312. * Search for a specific control in children
  3313. * @param control defines the control to look for
  3314. * @returns true if the control is in child list
  3315. */
  3316. Container.prototype.containsControl = function (control) {
  3317. return this.children.indexOf(control) !== -1;
  3318. };
  3319. /**
  3320. * Adds a new control to the current container
  3321. * @param control defines the control to add
  3322. * @returns the current container
  3323. */
  3324. Container.prototype.addControl = function (control) {
  3325. if (!control) {
  3326. return this;
  3327. }
  3328. var index = this._children.indexOf(control);
  3329. if (index !== -1) {
  3330. return this;
  3331. }
  3332. control._link(this._host);
  3333. control._markAllAsDirty();
  3334. this._reOrderControl(control);
  3335. this._markAsDirty();
  3336. return this;
  3337. };
  3338. /**
  3339. * Removes all controls from the current container
  3340. * @returns the current container
  3341. */
  3342. Container.prototype.clearControls = function () {
  3343. var children = this.children.slice();
  3344. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3345. var child = children_1[_i];
  3346. this.removeControl(child);
  3347. }
  3348. return this;
  3349. };
  3350. /**
  3351. * Removes a control from the current container
  3352. * @param control defines the control to remove
  3353. * @returns the current container
  3354. */
  3355. Container.prototype.removeControl = function (control) {
  3356. var index = this._children.indexOf(control);
  3357. if (index !== -1) {
  3358. this._children.splice(index, 1);
  3359. control.parent = null;
  3360. }
  3361. control.linkWithMesh(null);
  3362. if (this._host) {
  3363. this._host._cleanControlAfterRemoval(control);
  3364. }
  3365. this._markAsDirty();
  3366. return this;
  3367. };
  3368. /** @hidden */
  3369. Container.prototype._reOrderControl = function (control) {
  3370. this.removeControl(control);
  3371. var wasAdded = false;
  3372. for (var index = 0; index < this._children.length; index++) {
  3373. if (this._children[index].zIndex > control.zIndex) {
  3374. this._children.splice(index, 0, control);
  3375. wasAdded = true;
  3376. break;
  3377. }
  3378. }
  3379. if (!wasAdded) {
  3380. this._children.push(control);
  3381. }
  3382. control.parent = this;
  3383. this._markAsDirty();
  3384. };
  3385. /** @hidden */
  3386. Container.prototype._offsetLeft = function (offset) {
  3387. _super.prototype._offsetLeft.call(this, offset);
  3388. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3389. var child = _a[_i];
  3390. child._offsetLeft(offset);
  3391. }
  3392. };
  3393. /** @hidden */
  3394. Container.prototype._offsetTop = function (offset) {
  3395. _super.prototype._offsetTop.call(this, offset);
  3396. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3397. var child = _a[_i];
  3398. child._offsetTop(offset);
  3399. }
  3400. };
  3401. /** @hidden */
  3402. Container.prototype._markAllAsDirty = function () {
  3403. _super.prototype._markAllAsDirty.call(this);
  3404. for (var index = 0; index < this._children.length; index++) {
  3405. this._children[index]._markAllAsDirty();
  3406. }
  3407. };
  3408. /** @hidden */
  3409. Container.prototype._localDraw = function (context) {
  3410. if (this._background) {
  3411. context.save();
  3412. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3413. context.shadowColor = this.shadowColor;
  3414. context.shadowBlur = this.shadowBlur;
  3415. context.shadowOffsetX = this.shadowOffsetX;
  3416. context.shadowOffsetY = this.shadowOffsetY;
  3417. }
  3418. context.fillStyle = this._background;
  3419. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3420. context.restore();
  3421. }
  3422. };
  3423. /** @hidden */
  3424. Container.prototype._link = function (host) {
  3425. _super.prototype._link.call(this, host);
  3426. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3427. var child = _a[_i];
  3428. child._link(host);
  3429. }
  3430. };
  3431. /** @hidden */
  3432. Container.prototype._beforeLayout = function () {
  3433. // Do nothing
  3434. };
  3435. /** @hidden */
  3436. Container.prototype._processMeasures = function (parentMeasure, context) {
  3437. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3438. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3439. this._evaluateClippingState(parentMeasure);
  3440. }
  3441. };
  3442. /** @hidden */
  3443. Container.prototype._layout = function (parentMeasure, context) {
  3444. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3445. return false;
  3446. }
  3447. this.host._numLayoutCalls++;
  3448. if (this._isDirty) {
  3449. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3450. }
  3451. var rebuildCount = 0;
  3452. context.save();
  3453. this._applyStates(context);
  3454. this._beforeLayout();
  3455. do {
  3456. var computedWidth = -1;
  3457. var computedHeight = -1;
  3458. this._rebuildLayout = false;
  3459. this._processMeasures(parentMeasure, context);
  3460. if (!this._isClipped) {
  3461. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3462. var child = _a[_i];
  3463. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3464. if (child._layout(this._measureForChildren, context)) {
  3465. if (this.adaptWidthToChildren && child._width.isPixel) {
  3466. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3467. }
  3468. if (this.adaptHeightToChildren && child._height.isPixel) {
  3469. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3470. }
  3471. }
  3472. }
  3473. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3474. if (this.width !== computedWidth + "px") {
  3475. this.width = computedWidth + "px";
  3476. this._rebuildLayout = true;
  3477. }
  3478. }
  3479. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3480. if (this.height !== computedHeight + "px") {
  3481. this.height = computedHeight + "px";
  3482. this._rebuildLayout = true;
  3483. }
  3484. }
  3485. this._postMeasure();
  3486. }
  3487. rebuildCount++;
  3488. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3489. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3490. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3491. }
  3492. context.restore();
  3493. if (this._isDirty) {
  3494. this.invalidateRect();
  3495. this._isDirty = false;
  3496. }
  3497. return true;
  3498. };
  3499. Container.prototype._postMeasure = function () {
  3500. // Do nothing by default
  3501. };
  3502. /** @hidden */
  3503. Container.prototype._draw = function (context, invalidatedRectangle) {
  3504. this._localDraw(context);
  3505. if (this.clipChildren) {
  3506. this._clipForChildren(context);
  3507. }
  3508. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3509. var child = _a[_i];
  3510. // Only redraw parts of the screen that are invalidated
  3511. if (invalidatedRectangle) {
  3512. if (!child._intersectsRect(invalidatedRectangle)) {
  3513. continue;
  3514. }
  3515. }
  3516. child._render(context, invalidatedRectangle);
  3517. }
  3518. };
  3519. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3520. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3521. if (!this.children) {
  3522. return;
  3523. }
  3524. for (var index = 0; index < this.children.length; index++) {
  3525. var item = this.children[index];
  3526. if (!predicate || predicate(item)) {
  3527. results.push(item);
  3528. }
  3529. if (!directDescendantsOnly) {
  3530. item.getDescendantsToRef(results, false, predicate);
  3531. }
  3532. }
  3533. };
  3534. /** @hidden */
  3535. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  3536. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3537. return false;
  3538. }
  3539. if (!_super.prototype.contains.call(this, x, y)) {
  3540. return false;
  3541. }
  3542. // Checking backwards to pick closest first
  3543. for (var index = this._children.length - 1; index >= 0; index--) {
  3544. var child = this._children[index];
  3545. if (child._processPicking(x, y, type, pointerId, buttonIndex, deltaX, deltaY)) {
  3546. if (child.hoverCursor) {
  3547. this._host._changeCursor(child.hoverCursor);
  3548. }
  3549. return true;
  3550. }
  3551. }
  3552. if (!this.isHitTestVisible) {
  3553. return false;
  3554. }
  3555. return this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  3556. };
  3557. /** @hidden */
  3558. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3559. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3560. this._measureForChildren.copyFrom(this._currentMeasure);
  3561. };
  3562. /** Releases associated resources */
  3563. Container.prototype.dispose = function () {
  3564. _super.prototype.dispose.call(this);
  3565. for (var index = this.children.length - 1; index >= 0; index--) {
  3566. this.children[index].dispose();
  3567. }
  3568. };
  3569. return Container;
  3570. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3571. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3572. /***/ }),
  3573. /***/ "./2D/controls/control.ts":
  3574. /*!********************************!*\
  3575. !*** ./2D/controls/control.ts ***!
  3576. \********************************/
  3577. /*! exports provided: Control */
  3578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3579. "use strict";
  3580. __webpack_require__.r(__webpack_exports__);
  3581. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3582. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  3583. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3584. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3585. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3586. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3587. /**
  3588. * Root class used for all 2D controls
  3589. * @see http://doc.babylonjs.com/how_to/gui#controls
  3590. */
  3591. var Control = /** @class */ (function () {
  3592. // Functions
  3593. /**
  3594. * Creates a new control
  3595. * @param name defines the name of the control
  3596. */
  3597. function Control(
  3598. /** defines the name of the control */
  3599. name) {
  3600. this.name = name;
  3601. this._alpha = 1;
  3602. this._alphaSet = false;
  3603. this._zIndex = 0;
  3604. /** @hidden */
  3605. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3606. this._fontFamily = "Arial";
  3607. this._fontStyle = "";
  3608. this._fontWeight = "";
  3609. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3610. /** @hidden */
  3611. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3612. /** @hidden */
  3613. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3614. this._color = "";
  3615. this._style = null;
  3616. /** @hidden */
  3617. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3618. /** @hidden */
  3619. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3620. /** @hidden */
  3621. this._isDirty = true;
  3622. /** @hidden */
  3623. this._wasDirty = false;
  3624. /** @hidden */
  3625. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3626. /** @hidden */
  3627. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3628. /** @hidden */
  3629. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3630. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3631. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3632. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3633. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3634. /** @hidden */
  3635. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3636. /** @hidden */
  3637. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3638. this._scaleX = 1.0;
  3639. this._scaleY = 1.0;
  3640. this._rotation = 0;
  3641. this._transformCenterX = 0.5;
  3642. this._transformCenterY = 0.5;
  3643. /** @hidden */
  3644. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3645. /** @hidden */
  3646. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3647. /** @hidden */
  3648. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3649. this._isMatrixDirty = true;
  3650. this._isVisible = true;
  3651. this._isHighlighted = false;
  3652. this._fontSet = false;
  3653. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3654. this._downCount = 0;
  3655. this._enterCount = -1;
  3656. this._doNotRender = false;
  3657. this._downPointerIds = {};
  3658. this._isEnabled = true;
  3659. this._disabledColor = "#9a9a9a";
  3660. /** @hidden */
  3661. this._rebuildLayout = false;
  3662. /** @hidden */
  3663. this._customData = {};
  3664. /** @hidden */
  3665. this._isClipped = false;
  3666. /** @hidden */
  3667. this._automaticSize = false;
  3668. /**
  3669. * Gets or sets an object used to store user defined information for the node
  3670. */
  3671. this.metadata = null;
  3672. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3673. this.isHitTestVisible = true;
  3674. /** Gets or sets a boolean indicating if the control can block pointer events */
  3675. this.isPointerBlocker = false;
  3676. /** Gets or sets a boolean indicating if the control can be focusable */
  3677. this.isFocusInvisible = false;
  3678. /**
  3679. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3680. * 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
  3681. */
  3682. this.clipChildren = true;
  3683. /**
  3684. * Gets or sets a boolean indicating that control content must be clipped
  3685. * 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
  3686. */
  3687. this.clipContent = true;
  3688. /**
  3689. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3690. */
  3691. this.useBitmapCache = false;
  3692. this._shadowOffsetX = 0;
  3693. this._shadowOffsetY = 0;
  3694. this._shadowBlur = 0;
  3695. this._shadowColor = 'black';
  3696. /** Gets or sets the cursor to use when the control is hovered */
  3697. this.hoverCursor = "";
  3698. /** @hidden */
  3699. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3700. /** @hidden */
  3701. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3702. /**
  3703. * An event triggered when pointer wheel is scrolled
  3704. */
  3705. this.onWheelObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3706. /**
  3707. * An event triggered when the pointer move over the control.
  3708. */
  3709. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3710. /**
  3711. * An event triggered when the pointer move out of the control.
  3712. */
  3713. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3714. /**
  3715. * An event triggered when the pointer taps the control
  3716. */
  3717. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3718. /**
  3719. * An event triggered when pointer up
  3720. */
  3721. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3722. /**
  3723. * An event triggered when a control is clicked on
  3724. */
  3725. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3726. /**
  3727. * An event triggered when pointer enters the control
  3728. */
  3729. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3730. /**
  3731. * An event triggered when the control is marked as dirty
  3732. */
  3733. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3734. /**
  3735. * An event triggered before drawing the control
  3736. */
  3737. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3738. /**
  3739. * An event triggered after the control was drawn
  3740. */
  3741. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3742. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3743. }
  3744. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3745. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3746. get: function () {
  3747. return this._shadowOffsetX;
  3748. },
  3749. set: function (value) {
  3750. if (this._shadowOffsetX === value) {
  3751. return;
  3752. }
  3753. this._shadowOffsetX = value;
  3754. this._markAsDirty();
  3755. },
  3756. enumerable: true,
  3757. configurable: true
  3758. });
  3759. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3760. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3761. get: function () {
  3762. return this._shadowOffsetY;
  3763. },
  3764. set: function (value) {
  3765. if (this._shadowOffsetY === value) {
  3766. return;
  3767. }
  3768. this._shadowOffsetY = value;
  3769. this._markAsDirty();
  3770. },
  3771. enumerable: true,
  3772. configurable: true
  3773. });
  3774. Object.defineProperty(Control.prototype, "shadowBlur", {
  3775. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3776. get: function () {
  3777. return this._shadowBlur;
  3778. },
  3779. set: function (value) {
  3780. if (this._shadowBlur === value) {
  3781. return;
  3782. }
  3783. this._shadowBlur = value;
  3784. this._markAsDirty();
  3785. },
  3786. enumerable: true,
  3787. configurable: true
  3788. });
  3789. Object.defineProperty(Control.prototype, "shadowColor", {
  3790. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3791. get: function () {
  3792. return this._shadowColor;
  3793. },
  3794. set: function (value) {
  3795. if (this._shadowColor === value) {
  3796. return;
  3797. }
  3798. this._shadowColor = value;
  3799. this._markAsDirty();
  3800. },
  3801. enumerable: true,
  3802. configurable: true
  3803. });
  3804. Object.defineProperty(Control.prototype, "typeName", {
  3805. // Properties
  3806. /** Gets the control type name */
  3807. get: function () {
  3808. return this._getTypeName();
  3809. },
  3810. enumerable: true,
  3811. configurable: true
  3812. });
  3813. /**
  3814. * Get the current class name of the control.
  3815. * @returns current class name
  3816. */
  3817. Control.prototype.getClassName = function () {
  3818. return this._getTypeName();
  3819. };
  3820. Object.defineProperty(Control.prototype, "host", {
  3821. /**
  3822. * Get the hosting AdvancedDynamicTexture
  3823. */
  3824. get: function () {
  3825. return this._host;
  3826. },
  3827. enumerable: true,
  3828. configurable: true
  3829. });
  3830. Object.defineProperty(Control.prototype, "fontOffset", {
  3831. /** Gets or set information about font offsets (used to render and align text) */
  3832. get: function () {
  3833. return this._fontOffset;
  3834. },
  3835. set: function (offset) {
  3836. this._fontOffset = offset;
  3837. },
  3838. enumerable: true,
  3839. configurable: true
  3840. });
  3841. Object.defineProperty(Control.prototype, "alpha", {
  3842. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3843. get: function () {
  3844. return this._alpha;
  3845. },
  3846. set: function (value) {
  3847. if (this._alpha === value) {
  3848. return;
  3849. }
  3850. this._alphaSet = true;
  3851. this._alpha = value;
  3852. this._markAsDirty();
  3853. },
  3854. enumerable: true,
  3855. configurable: true
  3856. });
  3857. Object.defineProperty(Control.prototype, "isHighlighted", {
  3858. /**
  3859. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3860. */
  3861. get: function () {
  3862. return this._isHighlighted;
  3863. },
  3864. set: function (value) {
  3865. if (this._isHighlighted === value) {
  3866. return;
  3867. }
  3868. this._isHighlighted = value;
  3869. this._markAsDirty();
  3870. },
  3871. enumerable: true,
  3872. configurable: true
  3873. });
  3874. Object.defineProperty(Control.prototype, "scaleX", {
  3875. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3876. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3877. */
  3878. get: function () {
  3879. return this._scaleX;
  3880. },
  3881. set: function (value) {
  3882. if (this._scaleX === value) {
  3883. return;
  3884. }
  3885. this._scaleX = value;
  3886. this._markAsDirty();
  3887. this._markMatrixAsDirty();
  3888. },
  3889. enumerable: true,
  3890. configurable: true
  3891. });
  3892. Object.defineProperty(Control.prototype, "scaleY", {
  3893. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3894. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3895. */
  3896. get: function () {
  3897. return this._scaleY;
  3898. },
  3899. set: function (value) {
  3900. if (this._scaleY === value) {
  3901. return;
  3902. }
  3903. this._scaleY = value;
  3904. this._markAsDirty();
  3905. this._markMatrixAsDirty();
  3906. },
  3907. enumerable: true,
  3908. configurable: true
  3909. });
  3910. Object.defineProperty(Control.prototype, "rotation", {
  3911. /** Gets or sets the rotation angle (0 by default)
  3912. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3913. */
  3914. get: function () {
  3915. return this._rotation;
  3916. },
  3917. set: function (value) {
  3918. if (this._rotation === value) {
  3919. return;
  3920. }
  3921. this._rotation = value;
  3922. this._markAsDirty();
  3923. this._markMatrixAsDirty();
  3924. },
  3925. enumerable: true,
  3926. configurable: true
  3927. });
  3928. Object.defineProperty(Control.prototype, "transformCenterY", {
  3929. /** Gets or sets the transformation center on Y axis (0 by default)
  3930. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3931. */
  3932. get: function () {
  3933. return this._transformCenterY;
  3934. },
  3935. set: function (value) {
  3936. if (this._transformCenterY === value) {
  3937. return;
  3938. }
  3939. this._transformCenterY = value;
  3940. this._markAsDirty();
  3941. this._markMatrixAsDirty();
  3942. },
  3943. enumerable: true,
  3944. configurable: true
  3945. });
  3946. Object.defineProperty(Control.prototype, "transformCenterX", {
  3947. /** Gets or sets the transformation center on X axis (0 by default)
  3948. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3949. */
  3950. get: function () {
  3951. return this._transformCenterX;
  3952. },
  3953. set: function (value) {
  3954. if (this._transformCenterX === value) {
  3955. return;
  3956. }
  3957. this._transformCenterX = value;
  3958. this._markAsDirty();
  3959. this._markMatrixAsDirty();
  3960. },
  3961. enumerable: true,
  3962. configurable: true
  3963. });
  3964. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3965. /**
  3966. * Gets or sets the horizontal alignment
  3967. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3968. */
  3969. get: function () {
  3970. return this._horizontalAlignment;
  3971. },
  3972. set: function (value) {
  3973. if (this._horizontalAlignment === value) {
  3974. return;
  3975. }
  3976. this._horizontalAlignment = value;
  3977. this._markAsDirty();
  3978. },
  3979. enumerable: true,
  3980. configurable: true
  3981. });
  3982. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3983. /**
  3984. * Gets or sets the vertical alignment
  3985. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3986. */
  3987. get: function () {
  3988. return this._verticalAlignment;
  3989. },
  3990. set: function (value) {
  3991. if (this._verticalAlignment === value) {
  3992. return;
  3993. }
  3994. this._verticalAlignment = value;
  3995. this._markAsDirty();
  3996. },
  3997. enumerable: true,
  3998. configurable: true
  3999. });
  4000. Object.defineProperty(Control.prototype, "width", {
  4001. /**
  4002. * Gets or sets control width
  4003. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4004. */
  4005. get: function () {
  4006. return this._width.toString(this._host);
  4007. },
  4008. set: function (value) {
  4009. if (this._width.toString(this._host) === value) {
  4010. return;
  4011. }
  4012. if (this._width.fromString(value)) {
  4013. this._markAsDirty();
  4014. }
  4015. },
  4016. enumerable: true,
  4017. configurable: true
  4018. });
  4019. Object.defineProperty(Control.prototype, "widthInPixels", {
  4020. /**
  4021. * Gets or sets the control width in pixel
  4022. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4023. */
  4024. get: function () {
  4025. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4026. },
  4027. set: function (value) {
  4028. if (isNaN(value)) {
  4029. return;
  4030. }
  4031. this.width = value + "px";
  4032. },
  4033. enumerable: true,
  4034. configurable: true
  4035. });
  4036. Object.defineProperty(Control.prototype, "height", {
  4037. /**
  4038. * Gets or sets control height
  4039. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4040. */
  4041. get: function () {
  4042. return this._height.toString(this._host);
  4043. },
  4044. set: function (value) {
  4045. if (this._height.toString(this._host) === value) {
  4046. return;
  4047. }
  4048. if (this._height.fromString(value)) {
  4049. this._markAsDirty();
  4050. }
  4051. },
  4052. enumerable: true,
  4053. configurable: true
  4054. });
  4055. Object.defineProperty(Control.prototype, "heightInPixels", {
  4056. /**
  4057. * Gets or sets control height in pixel
  4058. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4059. */
  4060. get: function () {
  4061. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4062. },
  4063. set: function (value) {
  4064. if (isNaN(value)) {
  4065. return;
  4066. }
  4067. this.height = value + "px";
  4068. },
  4069. enumerable: true,
  4070. configurable: true
  4071. });
  4072. Object.defineProperty(Control.prototype, "fontFamily", {
  4073. /** Gets or set font family */
  4074. get: function () {
  4075. if (!this._fontSet) {
  4076. return "";
  4077. }
  4078. return this._fontFamily;
  4079. },
  4080. set: function (value) {
  4081. if (this._fontFamily === value) {
  4082. return;
  4083. }
  4084. this._fontFamily = value;
  4085. this._resetFontCache();
  4086. },
  4087. enumerable: true,
  4088. configurable: true
  4089. });
  4090. Object.defineProperty(Control.prototype, "fontStyle", {
  4091. /** Gets or sets font style */
  4092. get: function () {
  4093. return this._fontStyle;
  4094. },
  4095. set: function (value) {
  4096. if (this._fontStyle === value) {
  4097. return;
  4098. }
  4099. this._fontStyle = value;
  4100. this._resetFontCache();
  4101. },
  4102. enumerable: true,
  4103. configurable: true
  4104. });
  4105. Object.defineProperty(Control.prototype, "fontWeight", {
  4106. /** Gets or sets font weight */
  4107. get: function () {
  4108. return this._fontWeight;
  4109. },
  4110. set: function (value) {
  4111. if (this._fontWeight === value) {
  4112. return;
  4113. }
  4114. this._fontWeight = value;
  4115. this._resetFontCache();
  4116. },
  4117. enumerable: true,
  4118. configurable: true
  4119. });
  4120. Object.defineProperty(Control.prototype, "style", {
  4121. /**
  4122. * Gets or sets style
  4123. * @see http://doc.babylonjs.com/how_to/gui#styles
  4124. */
  4125. get: function () {
  4126. return this._style;
  4127. },
  4128. set: function (value) {
  4129. var _this = this;
  4130. if (this._style) {
  4131. this._style.onChangedObservable.remove(this._styleObserver);
  4132. this._styleObserver = null;
  4133. }
  4134. this._style = value;
  4135. if (this._style) {
  4136. this._styleObserver = this._style.onChangedObservable.add(function () {
  4137. _this._markAsDirty();
  4138. _this._resetFontCache();
  4139. });
  4140. }
  4141. this._markAsDirty();
  4142. this._resetFontCache();
  4143. },
  4144. enumerable: true,
  4145. configurable: true
  4146. });
  4147. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4148. /** @hidden */
  4149. get: function () {
  4150. return this._fontSize.isPercentage;
  4151. },
  4152. enumerable: true,
  4153. configurable: true
  4154. });
  4155. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4156. /** Gets or sets font size in pixels */
  4157. get: function () {
  4158. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4159. if (fontSizeToUse.isPixel) {
  4160. return fontSizeToUse.getValue(this._host);
  4161. }
  4162. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4163. },
  4164. set: function (value) {
  4165. if (isNaN(value)) {
  4166. return;
  4167. }
  4168. this.fontSize = value + "px";
  4169. },
  4170. enumerable: true,
  4171. configurable: true
  4172. });
  4173. Object.defineProperty(Control.prototype, "fontSize", {
  4174. /** Gets or sets font size */
  4175. get: function () {
  4176. return this._fontSize.toString(this._host);
  4177. },
  4178. set: function (value) {
  4179. if (this._fontSize.toString(this._host) === value) {
  4180. return;
  4181. }
  4182. if (this._fontSize.fromString(value)) {
  4183. this._markAsDirty();
  4184. this._resetFontCache();
  4185. }
  4186. },
  4187. enumerable: true,
  4188. configurable: true
  4189. });
  4190. Object.defineProperty(Control.prototype, "color", {
  4191. /** Gets or sets foreground color */
  4192. get: function () {
  4193. return this._color;
  4194. },
  4195. set: function (value) {
  4196. if (this._color === value) {
  4197. return;
  4198. }
  4199. this._color = value;
  4200. this._markAsDirty();
  4201. },
  4202. enumerable: true,
  4203. configurable: true
  4204. });
  4205. Object.defineProperty(Control.prototype, "zIndex", {
  4206. /** Gets or sets z index which is used to reorder controls on the z axis */
  4207. get: function () {
  4208. return this._zIndex;
  4209. },
  4210. set: function (value) {
  4211. if (this.zIndex === value) {
  4212. return;
  4213. }
  4214. this._zIndex = value;
  4215. if (this.parent) {
  4216. this.parent._reOrderControl(this);
  4217. }
  4218. },
  4219. enumerable: true,
  4220. configurable: true
  4221. });
  4222. Object.defineProperty(Control.prototype, "notRenderable", {
  4223. /** Gets or sets a boolean indicating if the control can be rendered */
  4224. get: function () {
  4225. return this._doNotRender;
  4226. },
  4227. set: function (value) {
  4228. if (this._doNotRender === value) {
  4229. return;
  4230. }
  4231. this._doNotRender = value;
  4232. this._markAsDirty();
  4233. },
  4234. enumerable: true,
  4235. configurable: true
  4236. });
  4237. Object.defineProperty(Control.prototype, "isVisible", {
  4238. /** Gets or sets a boolean indicating if the control is visible */
  4239. get: function () {
  4240. return this._isVisible;
  4241. },
  4242. set: function (value) {
  4243. if (this._isVisible === value) {
  4244. return;
  4245. }
  4246. this._isVisible = value;
  4247. this._markAsDirty(true);
  4248. },
  4249. enumerable: true,
  4250. configurable: true
  4251. });
  4252. Object.defineProperty(Control.prototype, "isDirty", {
  4253. /** Gets a boolean indicating that the control needs to update its rendering */
  4254. get: function () {
  4255. return this._isDirty;
  4256. },
  4257. enumerable: true,
  4258. configurable: true
  4259. });
  4260. Object.defineProperty(Control.prototype, "linkedMesh", {
  4261. /**
  4262. * Gets the current linked mesh (or null if none)
  4263. */
  4264. get: function () {
  4265. return this._linkedMesh;
  4266. },
  4267. enumerable: true,
  4268. configurable: true
  4269. });
  4270. Object.defineProperty(Control.prototype, "paddingLeft", {
  4271. /**
  4272. * Gets or sets a value indicating the padding to use on the left of the control
  4273. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4274. */
  4275. get: function () {
  4276. return this._paddingLeft.toString(this._host);
  4277. },
  4278. set: function (value) {
  4279. if (this._paddingLeft.fromString(value)) {
  4280. this._markAsDirty();
  4281. }
  4282. },
  4283. enumerable: true,
  4284. configurable: true
  4285. });
  4286. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4287. /**
  4288. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4289. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4290. */
  4291. get: function () {
  4292. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4293. },
  4294. set: function (value) {
  4295. if (isNaN(value)) {
  4296. return;
  4297. }
  4298. this.paddingLeft = value + "px";
  4299. },
  4300. enumerable: true,
  4301. configurable: true
  4302. });
  4303. Object.defineProperty(Control.prototype, "paddingRight", {
  4304. /**
  4305. * Gets or sets a value indicating the padding to use on the right of the control
  4306. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4307. */
  4308. get: function () {
  4309. return this._paddingRight.toString(this._host);
  4310. },
  4311. set: function (value) {
  4312. if (this._paddingRight.fromString(value)) {
  4313. this._markAsDirty();
  4314. }
  4315. },
  4316. enumerable: true,
  4317. configurable: true
  4318. });
  4319. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4320. /**
  4321. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4322. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4323. */
  4324. get: function () {
  4325. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4326. },
  4327. set: function (value) {
  4328. if (isNaN(value)) {
  4329. return;
  4330. }
  4331. this.paddingRight = value + "px";
  4332. },
  4333. enumerable: true,
  4334. configurable: true
  4335. });
  4336. Object.defineProperty(Control.prototype, "paddingTop", {
  4337. /**
  4338. * Gets or sets a value indicating the padding to use on the top of the control
  4339. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4340. */
  4341. get: function () {
  4342. return this._paddingTop.toString(this._host);
  4343. },
  4344. set: function (value) {
  4345. if (this._paddingTop.fromString(value)) {
  4346. this._markAsDirty();
  4347. }
  4348. },
  4349. enumerable: true,
  4350. configurable: true
  4351. });
  4352. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4353. /**
  4354. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4355. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4356. */
  4357. get: function () {
  4358. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4359. },
  4360. set: function (value) {
  4361. if (isNaN(value)) {
  4362. return;
  4363. }
  4364. this.paddingTop = value + "px";
  4365. },
  4366. enumerable: true,
  4367. configurable: true
  4368. });
  4369. Object.defineProperty(Control.prototype, "paddingBottom", {
  4370. /**
  4371. * Gets or sets a value indicating the padding to use on the bottom of the control
  4372. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4373. */
  4374. get: function () {
  4375. return this._paddingBottom.toString(this._host);
  4376. },
  4377. set: function (value) {
  4378. if (this._paddingBottom.fromString(value)) {
  4379. this._markAsDirty();
  4380. }
  4381. },
  4382. enumerable: true,
  4383. configurable: true
  4384. });
  4385. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4386. /**
  4387. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4388. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4389. */
  4390. get: function () {
  4391. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4392. },
  4393. set: function (value) {
  4394. if (isNaN(value)) {
  4395. return;
  4396. }
  4397. this.paddingBottom = value + "px";
  4398. },
  4399. enumerable: true,
  4400. configurable: true
  4401. });
  4402. Object.defineProperty(Control.prototype, "left", {
  4403. /**
  4404. * Gets or sets a value indicating the left coordinate of the control
  4405. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4406. */
  4407. get: function () {
  4408. return this._left.toString(this._host);
  4409. },
  4410. set: function (value) {
  4411. if (this._left.fromString(value)) {
  4412. this._markAsDirty();
  4413. }
  4414. },
  4415. enumerable: true,
  4416. configurable: true
  4417. });
  4418. Object.defineProperty(Control.prototype, "leftInPixels", {
  4419. /**
  4420. * Gets or sets a value indicating the left coordinate in pixels of the control
  4421. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4422. */
  4423. get: function () {
  4424. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4425. },
  4426. set: function (value) {
  4427. if (isNaN(value)) {
  4428. return;
  4429. }
  4430. this.left = value + "px";
  4431. },
  4432. enumerable: true,
  4433. configurable: true
  4434. });
  4435. Object.defineProperty(Control.prototype, "top", {
  4436. /**
  4437. * Gets or sets a value indicating the top coordinate of the control
  4438. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4439. */
  4440. get: function () {
  4441. return this._top.toString(this._host);
  4442. },
  4443. set: function (value) {
  4444. if (this._top.fromString(value)) {
  4445. this._markAsDirty();
  4446. }
  4447. },
  4448. enumerable: true,
  4449. configurable: true
  4450. });
  4451. Object.defineProperty(Control.prototype, "topInPixels", {
  4452. /**
  4453. * Gets or sets a value indicating the top coordinate in pixels of the control
  4454. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4455. */
  4456. get: function () {
  4457. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4458. },
  4459. set: function (value) {
  4460. if (isNaN(value)) {
  4461. return;
  4462. }
  4463. this.top = value + "px";
  4464. },
  4465. enumerable: true,
  4466. configurable: true
  4467. });
  4468. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4469. /**
  4470. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4471. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4472. */
  4473. get: function () {
  4474. return this._linkOffsetX.toString(this._host);
  4475. },
  4476. set: function (value) {
  4477. if (this._linkOffsetX.fromString(value)) {
  4478. this._markAsDirty();
  4479. }
  4480. },
  4481. enumerable: true,
  4482. configurable: true
  4483. });
  4484. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4485. /**
  4486. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4487. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4488. */
  4489. get: function () {
  4490. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4491. },
  4492. set: function (value) {
  4493. if (isNaN(value)) {
  4494. return;
  4495. }
  4496. this.linkOffsetX = value + "px";
  4497. },
  4498. enumerable: true,
  4499. configurable: true
  4500. });
  4501. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4502. /**
  4503. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4504. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4505. */
  4506. get: function () {
  4507. return this._linkOffsetY.toString(this._host);
  4508. },
  4509. set: function (value) {
  4510. if (this._linkOffsetY.fromString(value)) {
  4511. this._markAsDirty();
  4512. }
  4513. },
  4514. enumerable: true,
  4515. configurable: true
  4516. });
  4517. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4518. /**
  4519. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4520. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4521. */
  4522. get: function () {
  4523. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4524. },
  4525. set: function (value) {
  4526. if (isNaN(value)) {
  4527. return;
  4528. }
  4529. this.linkOffsetY = value + "px";
  4530. },
  4531. enumerable: true,
  4532. configurable: true
  4533. });
  4534. Object.defineProperty(Control.prototype, "centerX", {
  4535. /** Gets the center coordinate on X axis */
  4536. get: function () {
  4537. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4538. },
  4539. enumerable: true,
  4540. configurable: true
  4541. });
  4542. Object.defineProperty(Control.prototype, "centerY", {
  4543. /** Gets the center coordinate on Y axis */
  4544. get: function () {
  4545. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4546. },
  4547. enumerable: true,
  4548. configurable: true
  4549. });
  4550. Object.defineProperty(Control.prototype, "isEnabled", {
  4551. /** Gets or sets if control is Enabled*/
  4552. get: function () {
  4553. return this._isEnabled;
  4554. },
  4555. set: function (value) {
  4556. if (this._isEnabled === value) {
  4557. return;
  4558. }
  4559. this._isEnabled = value;
  4560. this._markAsDirty();
  4561. },
  4562. enumerable: true,
  4563. configurable: true
  4564. });
  4565. Object.defineProperty(Control.prototype, "disabledColor", {
  4566. /** Gets or sets background color of control if it's disabled*/
  4567. get: function () {
  4568. return this._disabledColor;
  4569. },
  4570. set: function (value) {
  4571. if (this._disabledColor === value) {
  4572. return;
  4573. }
  4574. this._disabledColor = value;
  4575. this._markAsDirty();
  4576. },
  4577. enumerable: true,
  4578. configurable: true
  4579. });
  4580. /** @hidden */
  4581. Control.prototype._getTypeName = function () {
  4582. return "Control";
  4583. };
  4584. /**
  4585. * Gets the first ascendant in the hierarchy of the given type
  4586. * @param className defines the required type
  4587. * @returns the ascendant or null if not found
  4588. */
  4589. Control.prototype.getAscendantOfClass = function (className) {
  4590. if (!this.parent) {
  4591. return null;
  4592. }
  4593. if (this.parent.getClassName() === className) {
  4594. return this.parent;
  4595. }
  4596. return this.parent.getAscendantOfClass(className);
  4597. };
  4598. /** @hidden */
  4599. Control.prototype._resetFontCache = function () {
  4600. this._fontSet = true;
  4601. this._markAsDirty();
  4602. };
  4603. /**
  4604. * Determines if a container is an ascendant of the current control
  4605. * @param container defines the container to look for
  4606. * @returns true if the container is one of the ascendant of the control
  4607. */
  4608. Control.prototype.isAscendant = function (container) {
  4609. if (!this.parent) {
  4610. return false;
  4611. }
  4612. if (this.parent === container) {
  4613. return true;
  4614. }
  4615. return this.parent.isAscendant(container);
  4616. };
  4617. /**
  4618. * Gets coordinates in local control space
  4619. * @param globalCoordinates defines the coordinates to transform
  4620. * @returns the new coordinates in local space
  4621. */
  4622. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4623. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4624. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4625. return result;
  4626. };
  4627. /**
  4628. * Gets coordinates in local control space
  4629. * @param globalCoordinates defines the coordinates to transform
  4630. * @param result defines the target vector2 where to store the result
  4631. * @returns the current control
  4632. */
  4633. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4634. result.x = globalCoordinates.x - this._currentMeasure.left;
  4635. result.y = globalCoordinates.y - this._currentMeasure.top;
  4636. return this;
  4637. };
  4638. /**
  4639. * Gets coordinates in parent local control space
  4640. * @param globalCoordinates defines the coordinates to transform
  4641. * @returns the new coordinates in parent local space
  4642. */
  4643. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4644. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4645. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4646. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4647. return result;
  4648. };
  4649. /**
  4650. * Move the current control to a vector3 position projected onto the screen.
  4651. * @param position defines the target position
  4652. * @param scene defines the hosting scene
  4653. */
  4654. Control.prototype.moveToVector3 = function (position, scene) {
  4655. if (!this._host || this.parent !== this._host._rootContainer) {
  4656. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4657. return;
  4658. }
  4659. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4660. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4661. var globalViewport = this._host._getGlobalViewport(scene);
  4662. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4663. this._moveToProjectedPosition(projectedPosition);
  4664. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4665. this.notRenderable = true;
  4666. return;
  4667. }
  4668. this.notRenderable = false;
  4669. };
  4670. /**
  4671. * Will store all controls that have this control as ascendant in a given array
  4672. * @param results defines the array where to store the descendants
  4673. * @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
  4674. * @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
  4675. */
  4676. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4677. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4678. // Do nothing by default
  4679. };
  4680. /**
  4681. * Will return all controls that have this control as ascendant
  4682. * @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
  4683. * @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
  4684. * @return all child controls
  4685. */
  4686. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4687. var results = new Array();
  4688. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4689. return results;
  4690. };
  4691. /**
  4692. * Link current control with a target mesh
  4693. * @param mesh defines the mesh to link with
  4694. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4695. */
  4696. Control.prototype.linkWithMesh = function (mesh) {
  4697. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4698. if (mesh) {
  4699. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4700. }
  4701. return;
  4702. }
  4703. var index = this._host._linkedControls.indexOf(this);
  4704. if (index !== -1) {
  4705. this._linkedMesh = mesh;
  4706. if (!mesh) {
  4707. this._host._linkedControls.splice(index, 1);
  4708. }
  4709. return;
  4710. }
  4711. else if (!mesh) {
  4712. return;
  4713. }
  4714. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4715. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4716. this._linkedMesh = mesh;
  4717. this._host._linkedControls.push(this);
  4718. };
  4719. /** @hidden */
  4720. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4721. var oldLeft = this._left.getValue(this._host);
  4722. var oldTop = this._top.getValue(this._host);
  4723. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4724. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4725. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4726. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4727. newLeft = oldLeft;
  4728. }
  4729. if (Math.abs(newTop - oldTop) < 0.5) {
  4730. newTop = oldTop;
  4731. }
  4732. }
  4733. this.left = newLeft + "px";
  4734. this.top = newTop + "px";
  4735. this._left.ignoreAdaptiveScaling = true;
  4736. this._top.ignoreAdaptiveScaling = true;
  4737. this._markAsDirty();
  4738. };
  4739. /** @hidden */
  4740. Control.prototype._offsetLeft = function (offset) {
  4741. this._isDirty = true;
  4742. this._currentMeasure.left += offset;
  4743. };
  4744. /** @hidden */
  4745. Control.prototype._offsetTop = function (offset) {
  4746. this._isDirty = true;
  4747. this._currentMeasure.top += offset;
  4748. };
  4749. /** @hidden */
  4750. Control.prototype._markMatrixAsDirty = function () {
  4751. this._isMatrixDirty = true;
  4752. this._flagDescendantsAsMatrixDirty();
  4753. };
  4754. /** @hidden */
  4755. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4756. // No child
  4757. };
  4758. /** @hidden */
  4759. Control.prototype._intersectsRect = function (rect) {
  4760. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4761. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4762. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4763. return false;
  4764. }
  4765. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4766. return false;
  4767. }
  4768. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4769. return false;
  4770. }
  4771. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4772. return false;
  4773. }
  4774. return true;
  4775. };
  4776. /** @hidden */
  4777. Control.prototype.invalidateRect = function () {
  4778. this._transform();
  4779. if (this.host && this.host.useInvalidateRectOptimization) {
  4780. // Rotate by transform to get the measure transformed to global space
  4781. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4782. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4783. // the previous measure is used to properly clear a control that is scaled down
  4784. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4785. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4786. // Expand rect based on shadows
  4787. var shadowOffsetX = this.shadowOffsetX;
  4788. var shadowOffsetY = this.shadowOffsetY;
  4789. var shadowBlur = this.shadowBlur;
  4790. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4791. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4792. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4793. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4794. 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));
  4795. }
  4796. else {
  4797. 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));
  4798. }
  4799. }
  4800. };
  4801. /** @hidden */
  4802. Control.prototype._markAsDirty = function (force) {
  4803. if (force === void 0) { force = false; }
  4804. if (!this._isVisible && !force) {
  4805. return;
  4806. }
  4807. this._isDirty = true;
  4808. // Redraw only this rectangle
  4809. if (this._host) {
  4810. this._host.markAsDirty();
  4811. }
  4812. };
  4813. /** @hidden */
  4814. Control.prototype._markAllAsDirty = function () {
  4815. this._markAsDirty();
  4816. if (this._font) {
  4817. this._prepareFont();
  4818. }
  4819. };
  4820. /** @hidden */
  4821. Control.prototype._link = function (host) {
  4822. this._host = host;
  4823. if (this._host) {
  4824. this.uniqueId = this._host.getScene().getUniqueId();
  4825. }
  4826. };
  4827. /** @hidden */
  4828. Control.prototype._transform = function (context) {
  4829. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4830. return;
  4831. }
  4832. // postTranslate
  4833. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4834. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4835. if (context) {
  4836. context.translate(offsetX, offsetY);
  4837. // rotate
  4838. context.rotate(this._rotation);
  4839. // scale
  4840. context.scale(this._scaleX, this._scaleY);
  4841. // preTranslate
  4842. context.translate(-offsetX, -offsetY);
  4843. }
  4844. // Need to update matrices?
  4845. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4846. this._cachedOffsetX = offsetX;
  4847. this._cachedOffsetY = offsetY;
  4848. this._isMatrixDirty = false;
  4849. this._flagDescendantsAsMatrixDirty();
  4850. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4851. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4852. }
  4853. };
  4854. /** @hidden */
  4855. Control.prototype._renderHighlight = function (context) {
  4856. if (!this.isHighlighted) {
  4857. return;
  4858. }
  4859. context.save();
  4860. context.strokeStyle = "#4affff";
  4861. context.lineWidth = 2;
  4862. this._renderHighlightSpecific(context);
  4863. context.restore();
  4864. };
  4865. /** @hidden */
  4866. Control.prototype._renderHighlightSpecific = function (context) {
  4867. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4868. };
  4869. /** @hidden */
  4870. Control.prototype._applyStates = function (context) {
  4871. if (this._isFontSizeInPercentage) {
  4872. this._fontSet = true;
  4873. }
  4874. if (this._fontSet) {
  4875. this._prepareFont();
  4876. this._fontSet = false;
  4877. }
  4878. if (this._font) {
  4879. context.font = this._font;
  4880. }
  4881. if (this._color) {
  4882. context.fillStyle = this._color;
  4883. }
  4884. if (Control.AllowAlphaInheritance) {
  4885. context.globalAlpha *= this._alpha;
  4886. }
  4887. else if (this._alphaSet) {
  4888. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4889. }
  4890. };
  4891. /** @hidden */
  4892. Control.prototype._layout = function (parentMeasure, context) {
  4893. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4894. return false;
  4895. }
  4896. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4897. this.host._numLayoutCalls++;
  4898. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4899. context.save();
  4900. this._applyStates(context);
  4901. var rebuildCount = 0;
  4902. do {
  4903. this._rebuildLayout = false;
  4904. this._processMeasures(parentMeasure, context);
  4905. rebuildCount++;
  4906. } while (this._rebuildLayout && rebuildCount < 3);
  4907. if (rebuildCount >= 3) {
  4908. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4909. }
  4910. context.restore();
  4911. this.invalidateRect();
  4912. this._evaluateClippingState(parentMeasure);
  4913. }
  4914. this._wasDirty = this._isDirty;
  4915. this._isDirty = false;
  4916. return true;
  4917. };
  4918. /** @hidden */
  4919. Control.prototype._processMeasures = function (parentMeasure, context) {
  4920. this._currentMeasure.copyFrom(parentMeasure);
  4921. // Let children take some pre-measurement actions
  4922. this._preMeasure(parentMeasure, context);
  4923. this._measure();
  4924. this._computeAlignment(parentMeasure, context);
  4925. // Convert to int values
  4926. this._currentMeasure.left = this._currentMeasure.left | 0;
  4927. this._currentMeasure.top = this._currentMeasure.top | 0;
  4928. this._currentMeasure.width = this._currentMeasure.width | 0;
  4929. this._currentMeasure.height = this._currentMeasure.height | 0;
  4930. // Let children add more features
  4931. this._additionalProcessing(parentMeasure, context);
  4932. this._cachedParentMeasure.copyFrom(parentMeasure);
  4933. if (this.onDirtyObservable.hasObservers()) {
  4934. this.onDirtyObservable.notifyObservers(this);
  4935. }
  4936. };
  4937. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4938. if (this.parent && this.parent.clipChildren) {
  4939. // Early clip
  4940. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4941. this._isClipped = true;
  4942. return;
  4943. }
  4944. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4945. this._isClipped = true;
  4946. return;
  4947. }
  4948. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4949. this._isClipped = true;
  4950. return;
  4951. }
  4952. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4953. this._isClipped = true;
  4954. return;
  4955. }
  4956. }
  4957. this._isClipped = false;
  4958. };
  4959. /** @hidden */
  4960. Control.prototype._measure = function () {
  4961. // Width / Height
  4962. if (this._width.isPixel) {
  4963. this._currentMeasure.width = this._width.getValue(this._host);
  4964. }
  4965. else {
  4966. this._currentMeasure.width *= this._width.getValue(this._host);
  4967. }
  4968. if (this._height.isPixel) {
  4969. this._currentMeasure.height = this._height.getValue(this._host);
  4970. }
  4971. else {
  4972. this._currentMeasure.height *= this._height.getValue(this._host);
  4973. }
  4974. };
  4975. /** @hidden */
  4976. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4977. var width = this._currentMeasure.width;
  4978. var height = this._currentMeasure.height;
  4979. var parentWidth = parentMeasure.width;
  4980. var parentHeight = parentMeasure.height;
  4981. // Left / top
  4982. var x = 0;
  4983. var y = 0;
  4984. switch (this.horizontalAlignment) {
  4985. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4986. x = 0;
  4987. break;
  4988. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4989. x = parentWidth - width;
  4990. break;
  4991. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4992. x = (parentWidth - width) / 2;
  4993. break;
  4994. }
  4995. switch (this.verticalAlignment) {
  4996. case Control.VERTICAL_ALIGNMENT_TOP:
  4997. y = 0;
  4998. break;
  4999. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  5000. y = parentHeight - height;
  5001. break;
  5002. case Control.VERTICAL_ALIGNMENT_CENTER:
  5003. y = (parentHeight - height) / 2;
  5004. break;
  5005. }
  5006. if (this._paddingLeft.isPixel) {
  5007. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  5008. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  5009. }
  5010. else {
  5011. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  5012. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  5013. }
  5014. if (this._paddingRight.isPixel) {
  5015. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  5016. }
  5017. else {
  5018. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  5019. }
  5020. if (this._paddingTop.isPixel) {
  5021. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  5022. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  5023. }
  5024. else {
  5025. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  5026. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  5027. }
  5028. if (this._paddingBottom.isPixel) {
  5029. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  5030. }
  5031. else {
  5032. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  5033. }
  5034. if (this._left.isPixel) {
  5035. this._currentMeasure.left += this._left.getValue(this._host);
  5036. }
  5037. else {
  5038. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  5039. }
  5040. if (this._top.isPixel) {
  5041. this._currentMeasure.top += this._top.getValue(this._host);
  5042. }
  5043. else {
  5044. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5045. }
  5046. this._currentMeasure.left += x;
  5047. this._currentMeasure.top += y;
  5048. };
  5049. /** @hidden */
  5050. Control.prototype._preMeasure = function (parentMeasure, context) {
  5051. // Do nothing
  5052. };
  5053. /** @hidden */
  5054. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5055. // Do nothing
  5056. };
  5057. /** @hidden */
  5058. Control.prototype._clipForChildren = function (context) {
  5059. // DO nothing
  5060. };
  5061. Control.prototype._clip = function (context, invalidatedRectangle) {
  5062. context.beginPath();
  5063. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5064. if (invalidatedRectangle) {
  5065. // Rotate the invalidated rect into the control's space
  5066. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5067. // Get the intersection of the rect in context space and the current context
  5068. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5069. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5070. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5071. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5072. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5073. Control._ClipMeasure.copyFrom(intersection);
  5074. }
  5075. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5076. var shadowOffsetX = this.shadowOffsetX;
  5077. var shadowOffsetY = this.shadowOffsetY;
  5078. var shadowBlur = this.shadowBlur;
  5079. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5080. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5081. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5082. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5083. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5084. }
  5085. else {
  5086. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5087. }
  5088. context.clip();
  5089. };
  5090. /** @hidden */
  5091. Control.prototype._render = function (context, invalidatedRectangle) {
  5092. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5093. this._isDirty = false;
  5094. return false;
  5095. }
  5096. this.host._numRenderCalls++;
  5097. context.save();
  5098. this._applyStates(context);
  5099. // Transform
  5100. this._transform(context);
  5101. // Clip
  5102. if (this.clipContent) {
  5103. this._clip(context, invalidatedRectangle);
  5104. }
  5105. if (this.onBeforeDrawObservable.hasObservers()) {
  5106. this.onBeforeDrawObservable.notifyObservers(this);
  5107. }
  5108. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5109. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5110. }
  5111. else {
  5112. this._draw(context, invalidatedRectangle);
  5113. }
  5114. if (this.useBitmapCache && this._wasDirty) {
  5115. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5116. }
  5117. this._renderHighlight(context);
  5118. if (this.onAfterDrawObservable.hasObservers()) {
  5119. this.onAfterDrawObservable.notifyObservers(this);
  5120. }
  5121. context.restore();
  5122. return true;
  5123. };
  5124. /** @hidden */
  5125. Control.prototype._draw = function (context, invalidatedRectangle) {
  5126. // Do nothing
  5127. };
  5128. /**
  5129. * Tests if a given coordinates belong to the current control
  5130. * @param x defines x coordinate to test
  5131. * @param y defines y coordinate to test
  5132. * @returns true if the coordinates are inside the control
  5133. */
  5134. Control.prototype.contains = function (x, y) {
  5135. // Invert transform
  5136. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5137. x = this._transformedPosition.x;
  5138. y = this._transformedPosition.y;
  5139. // Check
  5140. if (x < this._currentMeasure.left) {
  5141. return false;
  5142. }
  5143. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5144. return false;
  5145. }
  5146. if (y < this._currentMeasure.top) {
  5147. return false;
  5148. }
  5149. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5150. return false;
  5151. }
  5152. if (this.isPointerBlocker) {
  5153. this._host._shouldBlockPointer = true;
  5154. }
  5155. return true;
  5156. };
  5157. /** @hidden */
  5158. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  5159. if (!this._isEnabled) {
  5160. return false;
  5161. }
  5162. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5163. return false;
  5164. }
  5165. if (!this.contains(x, y)) {
  5166. return false;
  5167. }
  5168. this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  5169. return true;
  5170. };
  5171. /** @hidden */
  5172. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5173. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5174. if (canNotify && this.parent != null) {
  5175. this.parent._onPointerMove(target, coordinates, pointerId);
  5176. }
  5177. };
  5178. /** @hidden */
  5179. Control.prototype._onPointerEnter = function (target) {
  5180. if (!this._isEnabled) {
  5181. return false;
  5182. }
  5183. if (this._enterCount > 0) {
  5184. return false;
  5185. }
  5186. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5187. this._enterCount = 0;
  5188. }
  5189. this._enterCount++;
  5190. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5191. if (canNotify && this.parent != null) {
  5192. this.parent._onPointerEnter(target);
  5193. }
  5194. return true;
  5195. };
  5196. /** @hidden */
  5197. Control.prototype._onPointerOut = function (target, force) {
  5198. if (force === void 0) { force = false; }
  5199. if (!force && (!this._isEnabled || target === this)) {
  5200. return;
  5201. }
  5202. this._enterCount = 0;
  5203. var canNotify = true;
  5204. if (!target.isAscendant(this)) {
  5205. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5206. }
  5207. if (canNotify && this.parent != null) {
  5208. this.parent._onPointerOut(target, force);
  5209. }
  5210. };
  5211. /** @hidden */
  5212. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5213. // Prevent pointerout to lose control context.
  5214. // Event redundancy is checked inside the function.
  5215. this._onPointerEnter(this);
  5216. if (this._downCount !== 0) {
  5217. return false;
  5218. }
  5219. this._downCount++;
  5220. this._downPointerIds[pointerId] = true;
  5221. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5222. if (canNotify && this.parent != null) {
  5223. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5224. }
  5225. return true;
  5226. };
  5227. /** @hidden */
  5228. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5229. if (!this._isEnabled) {
  5230. return;
  5231. }
  5232. this._downCount = 0;
  5233. delete this._downPointerIds[pointerId];
  5234. var canNotifyClick = notifyClick;
  5235. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5236. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5237. }
  5238. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5239. if (canNotify && this.parent != null) {
  5240. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5241. }
  5242. };
  5243. /** @hidden */
  5244. Control.prototype._forcePointerUp = function (pointerId) {
  5245. if (pointerId === void 0) { pointerId = null; }
  5246. if (pointerId !== null) {
  5247. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5248. }
  5249. else {
  5250. for (var key in this._downPointerIds) {
  5251. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5252. }
  5253. }
  5254. };
  5255. /** @hidden */
  5256. Control.prototype._onWheelScroll = function (deltaX, deltaY) {
  5257. if (!this._isEnabled) {
  5258. return;
  5259. }
  5260. var canNotify = this.onWheelObservable.notifyObservers(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"](deltaX, deltaY));
  5261. if (canNotify && this.parent != null) {
  5262. this.parent._onWheelScroll(deltaX, deltaY);
  5263. }
  5264. };
  5265. /** @hidden */
  5266. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex, deltaX, deltaY) {
  5267. if (!this._isEnabled) {
  5268. return false;
  5269. }
  5270. this._dummyVector2.copyFromFloats(x, y);
  5271. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5272. this._onPointerMove(this, this._dummyVector2, pointerId);
  5273. var previousControlOver = this._host._lastControlOver[pointerId];
  5274. if (previousControlOver && previousControlOver !== this) {
  5275. previousControlOver._onPointerOut(this);
  5276. }
  5277. if (previousControlOver !== this) {
  5278. this._onPointerEnter(this);
  5279. }
  5280. this._host._lastControlOver[pointerId] = this;
  5281. return true;
  5282. }
  5283. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5284. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5285. this._host._registerLastControlDown(this, pointerId);
  5286. this._host._lastPickedControl = this;
  5287. return true;
  5288. }
  5289. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5290. if (this._host._lastControlDown[pointerId]) {
  5291. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5292. }
  5293. delete this._host._lastControlDown[pointerId];
  5294. return true;
  5295. }
  5296. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERWHEEL) {
  5297. if (this._host._lastControlOver[pointerId]) {
  5298. this._host._lastControlOver[pointerId]._onWheelScroll(deltaX, deltaY);
  5299. return true;
  5300. }
  5301. }
  5302. return false;
  5303. };
  5304. Control.prototype._prepareFont = function () {
  5305. if (!this._font && !this._fontSet) {
  5306. return;
  5307. }
  5308. if (this._style) {
  5309. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5310. }
  5311. else {
  5312. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5313. }
  5314. this._fontOffset = Control._GetFontOffset(this._font);
  5315. };
  5316. /** Releases associated resources */
  5317. Control.prototype.dispose = function () {
  5318. this.onDirtyObservable.clear();
  5319. this.onBeforeDrawObservable.clear();
  5320. this.onAfterDrawObservable.clear();
  5321. this.onPointerDownObservable.clear();
  5322. this.onPointerEnterObservable.clear();
  5323. this.onPointerMoveObservable.clear();
  5324. this.onPointerOutObservable.clear();
  5325. this.onPointerUpObservable.clear();
  5326. this.onPointerClickObservable.clear();
  5327. this.onWheelObservable.clear();
  5328. if (this._styleObserver && this._style) {
  5329. this._style.onChangedObservable.remove(this._styleObserver);
  5330. this._styleObserver = null;
  5331. }
  5332. if (this.parent) {
  5333. this.parent.removeControl(this);
  5334. this.parent = null;
  5335. }
  5336. if (this._host) {
  5337. var index = this._host._linkedControls.indexOf(this);
  5338. if (index > -1) {
  5339. this.linkWithMesh(null);
  5340. }
  5341. }
  5342. };
  5343. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5344. /** HORIZONTAL_ALIGNMENT_LEFT */
  5345. get: function () {
  5346. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5347. },
  5348. enumerable: true,
  5349. configurable: true
  5350. });
  5351. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5352. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5353. get: function () {
  5354. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5355. },
  5356. enumerable: true,
  5357. configurable: true
  5358. });
  5359. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5360. /** HORIZONTAL_ALIGNMENT_CENTER */
  5361. get: function () {
  5362. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5363. },
  5364. enumerable: true,
  5365. configurable: true
  5366. });
  5367. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5368. /** VERTICAL_ALIGNMENT_TOP */
  5369. get: function () {
  5370. return Control._VERTICAL_ALIGNMENT_TOP;
  5371. },
  5372. enumerable: true,
  5373. configurable: true
  5374. });
  5375. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5376. /** VERTICAL_ALIGNMENT_BOTTOM */
  5377. get: function () {
  5378. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5379. },
  5380. enumerable: true,
  5381. configurable: true
  5382. });
  5383. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5384. /** VERTICAL_ALIGNMENT_CENTER */
  5385. get: function () {
  5386. return Control._VERTICAL_ALIGNMENT_CENTER;
  5387. },
  5388. enumerable: true,
  5389. configurable: true
  5390. });
  5391. /** @hidden */
  5392. Control._GetFontOffset = function (font) {
  5393. if (Control._FontHeightSizes[font]) {
  5394. return Control._FontHeightSizes[font];
  5395. }
  5396. var text = document.createElement("span");
  5397. text.innerHTML = "Hg";
  5398. text.style.font = font;
  5399. var block = document.createElement("div");
  5400. block.style.display = "inline-block";
  5401. block.style.width = "1px";
  5402. block.style.height = "0px";
  5403. block.style.verticalAlign = "bottom";
  5404. var div = document.createElement("div");
  5405. div.appendChild(text);
  5406. div.appendChild(block);
  5407. document.body.appendChild(div);
  5408. var fontAscent = 0;
  5409. var fontHeight = 0;
  5410. try {
  5411. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5412. block.style.verticalAlign = "baseline";
  5413. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5414. }
  5415. finally {
  5416. document.body.removeChild(div);
  5417. }
  5418. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5419. Control._FontHeightSizes[font] = result;
  5420. return result;
  5421. };
  5422. /** @hidden */
  5423. Control.drawEllipse = function (x, y, width, height, context) {
  5424. context.translate(x, y);
  5425. context.scale(width, height);
  5426. context.beginPath();
  5427. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5428. context.closePath();
  5429. context.scale(1 / width, 1 / height);
  5430. context.translate(-x, -y);
  5431. };
  5432. /**
  5433. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5434. */
  5435. Control.AllowAlphaInheritance = false;
  5436. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5437. // Statics
  5438. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5439. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5440. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5441. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5442. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5443. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5444. Control._FontHeightSizes = {};
  5445. /**
  5446. * Creates a stack panel that can be used to render headers
  5447. * @param control defines the control to associate with the header
  5448. * @param text defines the text of the header
  5449. * @param size defines the size of the header
  5450. * @param options defines options used to configure the header
  5451. * @returns a new StackPanel
  5452. * @ignore
  5453. * @hidden
  5454. */
  5455. Control.AddHeader = function () { };
  5456. return Control;
  5457. }());
  5458. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5459. /***/ }),
  5460. /***/ "./2D/controls/displayGrid.ts":
  5461. /*!************************************!*\
  5462. !*** ./2D/controls/displayGrid.ts ***!
  5463. \************************************/
  5464. /*! exports provided: DisplayGrid */
  5465. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5466. "use strict";
  5467. __webpack_require__.r(__webpack_exports__);
  5468. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5469. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5470. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5471. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5472. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5473. /** Class used to render a grid */
  5474. var DisplayGrid = /** @class */ (function (_super) {
  5475. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5476. /**
  5477. * Creates a new GridDisplayRectangle
  5478. * @param name defines the control name
  5479. */
  5480. function DisplayGrid(name) {
  5481. var _this = _super.call(this, name) || this;
  5482. _this.name = name;
  5483. _this._cellWidth = 20;
  5484. _this._cellHeight = 20;
  5485. _this._minorLineTickness = 1;
  5486. _this._minorLineColor = "DarkGray";
  5487. _this._majorLineTickness = 2;
  5488. _this._majorLineColor = "White";
  5489. _this._majorLineFrequency = 5;
  5490. _this._background = "Black";
  5491. _this._displayMajorLines = true;
  5492. _this._displayMinorLines = true;
  5493. return _this;
  5494. }
  5495. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5496. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5497. get: function () {
  5498. return this._displayMinorLines;
  5499. },
  5500. set: function (value) {
  5501. if (this._displayMinorLines === value) {
  5502. return;
  5503. }
  5504. this._displayMinorLines = value;
  5505. this._markAsDirty();
  5506. },
  5507. enumerable: true,
  5508. configurable: true
  5509. });
  5510. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5511. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5512. get: function () {
  5513. return this._displayMajorLines;
  5514. },
  5515. set: function (value) {
  5516. if (this._displayMajorLines === value) {
  5517. return;
  5518. }
  5519. this._displayMajorLines = value;
  5520. this._markAsDirty();
  5521. },
  5522. enumerable: true,
  5523. configurable: true
  5524. });
  5525. Object.defineProperty(DisplayGrid.prototype, "background", {
  5526. /** Gets or sets background color (Black by default) */
  5527. get: function () {
  5528. return this._background;
  5529. },
  5530. set: function (value) {
  5531. if (this._background === value) {
  5532. return;
  5533. }
  5534. this._background = value;
  5535. this._markAsDirty();
  5536. },
  5537. enumerable: true,
  5538. configurable: true
  5539. });
  5540. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5541. /** Gets or sets the width of each cell (20 by default) */
  5542. get: function () {
  5543. return this._cellWidth;
  5544. },
  5545. set: function (value) {
  5546. this._cellWidth = value;
  5547. this._markAsDirty();
  5548. },
  5549. enumerable: true,
  5550. configurable: true
  5551. });
  5552. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5553. /** Gets or sets the height of each cell (20 by default) */
  5554. get: function () {
  5555. return this._cellHeight;
  5556. },
  5557. set: function (value) {
  5558. this._cellHeight = value;
  5559. this._markAsDirty();
  5560. },
  5561. enumerable: true,
  5562. configurable: true
  5563. });
  5564. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5565. /** Gets or sets the tickness of minor lines (1 by default) */
  5566. get: function () {
  5567. return this._minorLineTickness;
  5568. },
  5569. set: function (value) {
  5570. this._minorLineTickness = value;
  5571. this._markAsDirty();
  5572. },
  5573. enumerable: true,
  5574. configurable: true
  5575. });
  5576. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5577. /** Gets or sets the color of minor lines (DarkGray by default) */
  5578. get: function () {
  5579. return this._minorLineColor;
  5580. },
  5581. set: function (value) {
  5582. this._minorLineColor = value;
  5583. this._markAsDirty();
  5584. },
  5585. enumerable: true,
  5586. configurable: true
  5587. });
  5588. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5589. /** Gets or sets the tickness of major lines (2 by default) */
  5590. get: function () {
  5591. return this._majorLineTickness;
  5592. },
  5593. set: function (value) {
  5594. this._majorLineTickness = value;
  5595. this._markAsDirty();
  5596. },
  5597. enumerable: true,
  5598. configurable: true
  5599. });
  5600. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5601. /** Gets or sets the color of major lines (White by default) */
  5602. get: function () {
  5603. return this._majorLineColor;
  5604. },
  5605. set: function (value) {
  5606. this._majorLineColor = value;
  5607. this._markAsDirty();
  5608. },
  5609. enumerable: true,
  5610. configurable: true
  5611. });
  5612. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5613. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5614. get: function () {
  5615. return this._majorLineFrequency;
  5616. },
  5617. set: function (value) {
  5618. this._majorLineFrequency = value;
  5619. this._markAsDirty();
  5620. },
  5621. enumerable: true,
  5622. configurable: true
  5623. });
  5624. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5625. context.save();
  5626. this._applyStates(context);
  5627. if (this._isEnabled) {
  5628. if (this._background) {
  5629. context.fillStyle = this._background;
  5630. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5631. }
  5632. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5633. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5634. // Minor lines
  5635. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5636. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5637. if (this._displayMinorLines) {
  5638. context.strokeStyle = this._minorLineColor;
  5639. context.lineWidth = this._minorLineTickness;
  5640. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5641. var cellX = left + x * this.cellWidth;
  5642. context.beginPath();
  5643. context.moveTo(cellX, this._currentMeasure.top);
  5644. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5645. context.stroke();
  5646. }
  5647. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5648. var cellY = top_1 + y * this.cellHeight;
  5649. context.beginPath();
  5650. context.moveTo(this._currentMeasure.left, cellY);
  5651. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5652. context.stroke();
  5653. }
  5654. }
  5655. // Major lines
  5656. if (this._displayMajorLines) {
  5657. context.strokeStyle = this._majorLineColor;
  5658. context.lineWidth = this._majorLineTickness;
  5659. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5660. var cellX = left + x * this.cellWidth;
  5661. context.beginPath();
  5662. context.moveTo(cellX, this._currentMeasure.top);
  5663. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5664. context.stroke();
  5665. }
  5666. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5667. var cellY = top_1 + y * this.cellHeight;
  5668. context.moveTo(this._currentMeasure.left, cellY);
  5669. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5670. context.closePath();
  5671. context.stroke();
  5672. }
  5673. }
  5674. }
  5675. context.restore();
  5676. };
  5677. DisplayGrid.prototype._getTypeName = function () {
  5678. return "DisplayGrid";
  5679. };
  5680. return DisplayGrid;
  5681. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5682. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5683. /***/ }),
  5684. /***/ "./2D/controls/ellipse.ts":
  5685. /*!********************************!*\
  5686. !*** ./2D/controls/ellipse.ts ***!
  5687. \********************************/
  5688. /*! exports provided: Ellipse */
  5689. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5690. "use strict";
  5691. __webpack_require__.r(__webpack_exports__);
  5692. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5693. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5694. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5695. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5696. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5697. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5698. /** Class used to create 2D ellipse containers */
  5699. var Ellipse = /** @class */ (function (_super) {
  5700. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5701. /**
  5702. * Creates a new Ellipse
  5703. * @param name defines the control name
  5704. */
  5705. function Ellipse(name) {
  5706. var _this = _super.call(this, name) || this;
  5707. _this.name = name;
  5708. _this._thickness = 1;
  5709. return _this;
  5710. }
  5711. Object.defineProperty(Ellipse.prototype, "thickness", {
  5712. /** Gets or sets border thickness */
  5713. get: function () {
  5714. return this._thickness;
  5715. },
  5716. set: function (value) {
  5717. if (this._thickness === value) {
  5718. return;
  5719. }
  5720. this._thickness = value;
  5721. this._markAsDirty();
  5722. },
  5723. enumerable: true,
  5724. configurable: true
  5725. });
  5726. Ellipse.prototype._getTypeName = function () {
  5727. return "Ellipse";
  5728. };
  5729. Ellipse.prototype._localDraw = function (context) {
  5730. context.save();
  5731. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5732. context.shadowColor = this.shadowColor;
  5733. context.shadowBlur = this.shadowBlur;
  5734. context.shadowOffsetX = this.shadowOffsetX;
  5735. context.shadowOffsetY = this.shadowOffsetY;
  5736. }
  5737. _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);
  5738. if (this._background) {
  5739. context.fillStyle = this._background;
  5740. context.fill();
  5741. }
  5742. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5743. context.shadowBlur = 0;
  5744. context.shadowOffsetX = 0;
  5745. context.shadowOffsetY = 0;
  5746. }
  5747. if (this._thickness) {
  5748. if (this.color) {
  5749. context.strokeStyle = this.color;
  5750. }
  5751. context.lineWidth = this._thickness;
  5752. context.stroke();
  5753. }
  5754. context.restore();
  5755. };
  5756. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5757. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5758. this._measureForChildren.width -= 2 * this._thickness;
  5759. this._measureForChildren.height -= 2 * this._thickness;
  5760. this._measureForChildren.left += this._thickness;
  5761. this._measureForChildren.top += this._thickness;
  5762. };
  5763. Ellipse.prototype._clipForChildren = function (context) {
  5764. _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);
  5765. context.clip();
  5766. };
  5767. return Ellipse;
  5768. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5769. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5770. /***/ }),
  5771. /***/ "./2D/controls/grid.ts":
  5772. /*!*****************************!*\
  5773. !*** ./2D/controls/grid.ts ***!
  5774. \*****************************/
  5775. /*! exports provided: Grid */
  5776. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5777. "use strict";
  5778. __webpack_require__.r(__webpack_exports__);
  5779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5780. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5781. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5782. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5783. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5784. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  5785. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5786. /**
  5787. * Class used to create a 2D grid container
  5788. */
  5789. var Grid = /** @class */ (function (_super) {
  5790. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5791. /**
  5792. * Creates a new Grid
  5793. * @param name defines control name
  5794. */
  5795. function Grid(name) {
  5796. var _this = _super.call(this, name) || this;
  5797. _this.name = name;
  5798. _this._rowDefinitions = new Array();
  5799. _this._columnDefinitions = new Array();
  5800. _this._cells = {};
  5801. _this._childControls = new Array();
  5802. return _this;
  5803. }
  5804. Object.defineProperty(Grid.prototype, "columnCount", {
  5805. /**
  5806. * Gets the number of columns
  5807. */
  5808. get: function () {
  5809. return this._columnDefinitions.length;
  5810. },
  5811. enumerable: true,
  5812. configurable: true
  5813. });
  5814. Object.defineProperty(Grid.prototype, "rowCount", {
  5815. /**
  5816. * Gets the number of rows
  5817. */
  5818. get: function () {
  5819. return this._rowDefinitions.length;
  5820. },
  5821. enumerable: true,
  5822. configurable: true
  5823. });
  5824. Object.defineProperty(Grid.prototype, "children", {
  5825. /** Gets the list of children */
  5826. get: function () {
  5827. return this._childControls;
  5828. },
  5829. enumerable: true,
  5830. configurable: true
  5831. });
  5832. Object.defineProperty(Grid.prototype, "cells", {
  5833. /** Gets the list of cells (e.g. the containers) */
  5834. get: function () {
  5835. return this._cells;
  5836. },
  5837. enumerable: true,
  5838. configurable: true
  5839. });
  5840. /**
  5841. * Gets the definition of a specific row
  5842. * @param index defines the index of the row
  5843. * @returns the row definition
  5844. */
  5845. Grid.prototype.getRowDefinition = function (index) {
  5846. if (index < 0 || index >= this._rowDefinitions.length) {
  5847. return null;
  5848. }
  5849. return this._rowDefinitions[index];
  5850. };
  5851. /**
  5852. * Gets the definition of a specific column
  5853. * @param index defines the index of the column
  5854. * @returns the column definition
  5855. */
  5856. Grid.prototype.getColumnDefinition = function (index) {
  5857. if (index < 0 || index >= this._columnDefinitions.length) {
  5858. return null;
  5859. }
  5860. return this._columnDefinitions[index];
  5861. };
  5862. /**
  5863. * Adds a new row to the grid
  5864. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5865. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5866. * @returns the current grid
  5867. */
  5868. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5869. if (isPixel === void 0) { isPixel = false; }
  5870. 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));
  5871. this._markAsDirty();
  5872. return this;
  5873. };
  5874. /**
  5875. * Adds a new column to the grid
  5876. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5877. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5878. * @returns the current grid
  5879. */
  5880. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5881. if (isPixel === void 0) { isPixel = false; }
  5882. 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));
  5883. this._markAsDirty();
  5884. return this;
  5885. };
  5886. /**
  5887. * Update a row definition
  5888. * @param index defines the index of the row to update
  5889. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5890. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5891. * @returns the current grid
  5892. */
  5893. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5894. if (isPixel === void 0) { isPixel = false; }
  5895. if (index < 0 || index >= this._rowDefinitions.length) {
  5896. return this;
  5897. }
  5898. var current = this._rowDefinitions[index];
  5899. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5900. return this;
  5901. }
  5902. 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);
  5903. this._markAsDirty();
  5904. return this;
  5905. };
  5906. /**
  5907. * Update a column definition
  5908. * @param index defines the index of the column to update
  5909. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5910. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5911. * @returns the current grid
  5912. */
  5913. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5914. if (isPixel === void 0) { isPixel = false; }
  5915. if (index < 0 || index >= this._columnDefinitions.length) {
  5916. return this;
  5917. }
  5918. var current = this._columnDefinitions[index];
  5919. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5920. return this;
  5921. }
  5922. 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);
  5923. this._markAsDirty();
  5924. return this;
  5925. };
  5926. /**
  5927. * Gets the list of children stored in a specific cell
  5928. * @param row defines the row to check
  5929. * @param column defines the column to check
  5930. * @returns the list of controls
  5931. */
  5932. Grid.prototype.getChildrenAt = function (row, column) {
  5933. var cell = this._cells[row + ":" + column];
  5934. if (!cell) {
  5935. return null;
  5936. }
  5937. return cell.children;
  5938. };
  5939. /**
  5940. * Gets a string representing the child cell info (row x column)
  5941. * @param child defines the control to get info from
  5942. * @returns a string containing the child cell info (row x column)
  5943. */
  5944. Grid.prototype.getChildCellInfo = function (child) {
  5945. return child._tag;
  5946. };
  5947. Grid.prototype._removeCell = function (cell, key) {
  5948. if (!cell) {
  5949. return;
  5950. }
  5951. _super.prototype.removeControl.call(this, cell);
  5952. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5953. var control = _a[_i];
  5954. var childIndex = this._childControls.indexOf(control);
  5955. if (childIndex !== -1) {
  5956. this._childControls.splice(childIndex, 1);
  5957. }
  5958. }
  5959. delete this._cells[key];
  5960. };
  5961. Grid.prototype._offsetCell = function (previousKey, key) {
  5962. if (!this._cells[key]) {
  5963. return;
  5964. }
  5965. this._cells[previousKey] = this._cells[key];
  5966. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5967. var control = _a[_i];
  5968. control._tag = previousKey;
  5969. }
  5970. delete this._cells[key];
  5971. };
  5972. /**
  5973. * Remove a column definition at specified index
  5974. * @param index defines the index of the column to remove
  5975. * @returns the current grid
  5976. */
  5977. Grid.prototype.removeColumnDefinition = function (index) {
  5978. if (index < 0 || index >= this._columnDefinitions.length) {
  5979. return this;
  5980. }
  5981. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5982. var key = x + ":" + index;
  5983. var cell = this._cells[key];
  5984. this._removeCell(cell, key);
  5985. }
  5986. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5987. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5988. var previousKey = x + ":" + (y - 1);
  5989. var key = x + ":" + y;
  5990. this._offsetCell(previousKey, key);
  5991. }
  5992. }
  5993. this._columnDefinitions.splice(index, 1);
  5994. this._markAsDirty();
  5995. return this;
  5996. };
  5997. /**
  5998. * Remove a row definition at specified index
  5999. * @param index defines the index of the row to remove
  6000. * @returns the current grid
  6001. */
  6002. Grid.prototype.removeRowDefinition = function (index) {
  6003. if (index < 0 || index >= this._rowDefinitions.length) {
  6004. return this;
  6005. }
  6006. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6007. var key = index + ":" + y;
  6008. var cell = this._cells[key];
  6009. this._removeCell(cell, key);
  6010. }
  6011. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6012. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  6013. var previousKey = x - 1 + ":" + y;
  6014. var key = x + ":" + y;
  6015. this._offsetCell(previousKey, key);
  6016. }
  6017. }
  6018. this._rowDefinitions.splice(index, 1);
  6019. this._markAsDirty();
  6020. return this;
  6021. };
  6022. /**
  6023. * Adds a new control to the current grid
  6024. * @param control defines the control to add
  6025. * @param row defines the row where to add the control (0 by default)
  6026. * @param column defines the column where to add the control (0 by default)
  6027. * @returns the current grid
  6028. */
  6029. Grid.prototype.addControl = function (control, row, column) {
  6030. if (row === void 0) { row = 0; }
  6031. if (column === void 0) { column = 0; }
  6032. if (this._rowDefinitions.length === 0) {
  6033. // Add default row definition
  6034. this.addRowDefinition(1, false);
  6035. }
  6036. if (this._columnDefinitions.length === 0) {
  6037. // Add default column definition
  6038. this.addColumnDefinition(1, false);
  6039. }
  6040. if (this._childControls.indexOf(control) !== -1) {
  6041. 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");
  6042. return this;
  6043. }
  6044. var x = Math.min(row, this._rowDefinitions.length - 1);
  6045. var y = Math.min(column, this._columnDefinitions.length - 1);
  6046. var key = x + ":" + y;
  6047. var goodContainer = this._cells[key];
  6048. if (!goodContainer) {
  6049. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6050. this._cells[key] = goodContainer;
  6051. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6052. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6053. _super.prototype.addControl.call(this, goodContainer);
  6054. }
  6055. goodContainer.addControl(control);
  6056. this._childControls.push(control);
  6057. control._tag = key;
  6058. control.parent = this;
  6059. this._markAsDirty();
  6060. return this;
  6061. };
  6062. /**
  6063. * Removes a control from the current container
  6064. * @param control defines the control to remove
  6065. * @returns the current container
  6066. */
  6067. Grid.prototype.removeControl = function (control) {
  6068. var index = this._childControls.indexOf(control);
  6069. if (index !== -1) {
  6070. this._childControls.splice(index, 1);
  6071. }
  6072. var cell = this._cells[control._tag];
  6073. if (cell) {
  6074. cell.removeControl(control);
  6075. control._tag = null;
  6076. }
  6077. this._markAsDirty();
  6078. return this;
  6079. };
  6080. Grid.prototype._getTypeName = function () {
  6081. return "Grid";
  6082. };
  6083. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6084. var widths = [];
  6085. var heights = [];
  6086. var lefts = [];
  6087. var tops = [];
  6088. var availableWidth = this._currentMeasure.width;
  6089. var globalWidthPercentage = 0;
  6090. var availableHeight = this._currentMeasure.height;
  6091. var globalHeightPercentage = 0;
  6092. // Heights
  6093. var index = 0;
  6094. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6095. var value = _a[_i];
  6096. if (value.isPixel) {
  6097. var height = value.getValue(this._host);
  6098. availableHeight -= height;
  6099. heights[index] = height;
  6100. }
  6101. else {
  6102. globalHeightPercentage += value.internalValue;
  6103. }
  6104. index++;
  6105. }
  6106. var top = 0;
  6107. index = 0;
  6108. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6109. var value = _c[_b];
  6110. tops.push(top);
  6111. if (!value.isPixel) {
  6112. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6113. top += height;
  6114. heights[index] = height;
  6115. }
  6116. else {
  6117. top += value.getValue(this._host);
  6118. }
  6119. index++;
  6120. }
  6121. // Widths
  6122. index = 0;
  6123. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6124. var value = _e[_d];
  6125. if (value.isPixel) {
  6126. var width = value.getValue(this._host);
  6127. availableWidth -= width;
  6128. widths[index] = width;
  6129. }
  6130. else {
  6131. globalWidthPercentage += value.internalValue;
  6132. }
  6133. index++;
  6134. }
  6135. var left = 0;
  6136. index = 0;
  6137. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6138. var value = _g[_f];
  6139. lefts.push(left);
  6140. if (!value.isPixel) {
  6141. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6142. left += width;
  6143. widths[index] = width;
  6144. }
  6145. else {
  6146. left += value.getValue(this._host);
  6147. }
  6148. index++;
  6149. }
  6150. definitionCallback(lefts, tops, widths, heights);
  6151. };
  6152. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6153. var _this = this;
  6154. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6155. // Setting child sizes
  6156. for (var key in _this._cells) {
  6157. if (!_this._cells.hasOwnProperty(key)) {
  6158. continue;
  6159. }
  6160. var split = key.split(":");
  6161. var x = parseInt(split[0]);
  6162. var y = parseInt(split[1]);
  6163. var cell = _this._cells[key];
  6164. cell.left = lefts[y] + "px";
  6165. cell.top = tops[x] + "px";
  6166. cell.width = widths[y] + "px";
  6167. cell.height = heights[x] + "px";
  6168. cell._left.ignoreAdaptiveScaling = true;
  6169. cell._top.ignoreAdaptiveScaling = true;
  6170. cell._width.ignoreAdaptiveScaling = true;
  6171. cell._height.ignoreAdaptiveScaling = true;
  6172. }
  6173. });
  6174. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6175. };
  6176. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6177. for (var key in this._cells) {
  6178. if (!this._cells.hasOwnProperty(key)) {
  6179. continue;
  6180. }
  6181. var child = this._cells[key];
  6182. child._markMatrixAsDirty();
  6183. }
  6184. };
  6185. Grid.prototype._renderHighlightSpecific = function (context) {
  6186. var _this = this;
  6187. _super.prototype._renderHighlightSpecific.call(this, context);
  6188. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6189. // Columns
  6190. for (var index = 0; index < lefts.length; index++) {
  6191. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6192. context.beginPath();
  6193. context.moveTo(left, _this._currentMeasure.top);
  6194. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6195. context.stroke();
  6196. }
  6197. // Rows
  6198. for (var index = 0; index < tops.length; index++) {
  6199. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6200. context.beginPath();
  6201. context.moveTo(_this._currentMeasure.left, top_1);
  6202. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6203. context.stroke();
  6204. }
  6205. });
  6206. context.restore();
  6207. };
  6208. /** Releases associated resources */
  6209. Grid.prototype.dispose = function () {
  6210. _super.prototype.dispose.call(this);
  6211. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6212. var control = _a[_i];
  6213. control.dispose();
  6214. }
  6215. this._childControls = [];
  6216. };
  6217. return Grid;
  6218. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6219. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6220. /***/ }),
  6221. /***/ "./2D/controls/image.ts":
  6222. /*!******************************!*\
  6223. !*** ./2D/controls/image.ts ***!
  6224. \******************************/
  6225. /*! exports provided: Image */
  6226. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6227. "use strict";
  6228. __webpack_require__.r(__webpack_exports__);
  6229. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6230. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6231. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6232. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6233. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6234. /**
  6235. * Class used to create 2D images
  6236. */
  6237. var Image = /** @class */ (function (_super) {
  6238. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6239. /**
  6240. * Creates a new Image
  6241. * @param name defines the control name
  6242. * @param url defines the image url
  6243. */
  6244. function Image(name, url) {
  6245. if (url === void 0) { url = null; }
  6246. var _this = _super.call(this, name) || this;
  6247. _this.name = name;
  6248. _this._workingCanvas = null;
  6249. _this._loaded = false;
  6250. _this._stretch = Image.STRETCH_FILL;
  6251. _this._autoScale = false;
  6252. _this._sourceLeft = 0;
  6253. _this._sourceTop = 0;
  6254. _this._sourceWidth = 0;
  6255. _this._sourceHeight = 0;
  6256. _this._svgAttributesComputationCompleted = false;
  6257. _this._isSVG = false;
  6258. _this._cellWidth = 0;
  6259. _this._cellHeight = 0;
  6260. _this._cellId = -1;
  6261. _this._populateNinePatchSlicesFromImage = false;
  6262. /**
  6263. * Observable notified when the content is loaded
  6264. */
  6265. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6266. /**
  6267. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6268. */
  6269. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6270. _this.source = url;
  6271. return _this;
  6272. }
  6273. Object.defineProperty(Image.prototype, "isLoaded", {
  6274. /**
  6275. * Gets a boolean indicating that the content is loaded
  6276. */
  6277. get: function () {
  6278. return this._loaded;
  6279. },
  6280. enumerable: true,
  6281. configurable: true
  6282. });
  6283. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6284. /**
  6285. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6286. */
  6287. get: function () {
  6288. return this._populateNinePatchSlicesFromImage;
  6289. },
  6290. set: function (value) {
  6291. if (this._populateNinePatchSlicesFromImage === value) {
  6292. return;
  6293. }
  6294. this._populateNinePatchSlicesFromImage = value;
  6295. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6296. this._extractNinePatchSliceDataFromImage();
  6297. }
  6298. },
  6299. enumerable: true,
  6300. configurable: true
  6301. });
  6302. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6303. /**
  6304. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6305. * Beware using this as this will comsume more memory as the image has to be stored twice
  6306. */
  6307. get: function () {
  6308. return this._detectPointerOnOpaqueOnly;
  6309. },
  6310. set: function (value) {
  6311. if (this._detectPointerOnOpaqueOnly === value) {
  6312. return;
  6313. }
  6314. this._detectPointerOnOpaqueOnly = value;
  6315. },
  6316. enumerable: true,
  6317. configurable: true
  6318. });
  6319. Object.defineProperty(Image.prototype, "sliceLeft", {
  6320. /**
  6321. * Gets or sets the left value for slicing (9-patch)
  6322. */
  6323. get: function () {
  6324. return this._sliceLeft;
  6325. },
  6326. set: function (value) {
  6327. if (this._sliceLeft === value) {
  6328. return;
  6329. }
  6330. this._sliceLeft = value;
  6331. this._markAsDirty();
  6332. },
  6333. enumerable: true,
  6334. configurable: true
  6335. });
  6336. Object.defineProperty(Image.prototype, "sliceRight", {
  6337. /**
  6338. * Gets or sets the right value for slicing (9-patch)
  6339. */
  6340. get: function () {
  6341. return this._sliceRight;
  6342. },
  6343. set: function (value) {
  6344. if (this._sliceRight === value) {
  6345. return;
  6346. }
  6347. this._sliceRight = value;
  6348. this._markAsDirty();
  6349. },
  6350. enumerable: true,
  6351. configurable: true
  6352. });
  6353. Object.defineProperty(Image.prototype, "sliceTop", {
  6354. /**
  6355. * Gets or sets the top value for slicing (9-patch)
  6356. */
  6357. get: function () {
  6358. return this._sliceTop;
  6359. },
  6360. set: function (value) {
  6361. if (this._sliceTop === value) {
  6362. return;
  6363. }
  6364. this._sliceTop = value;
  6365. this._markAsDirty();
  6366. },
  6367. enumerable: true,
  6368. configurable: true
  6369. });
  6370. Object.defineProperty(Image.prototype, "sliceBottom", {
  6371. /**
  6372. * Gets or sets the bottom value for slicing (9-patch)
  6373. */
  6374. get: function () {
  6375. return this._sliceBottom;
  6376. },
  6377. set: function (value) {
  6378. if (this._sliceBottom === value) {
  6379. return;
  6380. }
  6381. this._sliceBottom = value;
  6382. this._markAsDirty();
  6383. },
  6384. enumerable: true,
  6385. configurable: true
  6386. });
  6387. Object.defineProperty(Image.prototype, "sourceLeft", {
  6388. /**
  6389. * Gets or sets the left coordinate in the source image
  6390. */
  6391. get: function () {
  6392. return this._sourceLeft;
  6393. },
  6394. set: function (value) {
  6395. if (this._sourceLeft === value) {
  6396. return;
  6397. }
  6398. this._sourceLeft = value;
  6399. this._markAsDirty();
  6400. },
  6401. enumerable: true,
  6402. configurable: true
  6403. });
  6404. Object.defineProperty(Image.prototype, "sourceTop", {
  6405. /**
  6406. * Gets or sets the top coordinate in the source image
  6407. */
  6408. get: function () {
  6409. return this._sourceTop;
  6410. },
  6411. set: function (value) {
  6412. if (this._sourceTop === value) {
  6413. return;
  6414. }
  6415. this._sourceTop = value;
  6416. this._markAsDirty();
  6417. },
  6418. enumerable: true,
  6419. configurable: true
  6420. });
  6421. Object.defineProperty(Image.prototype, "sourceWidth", {
  6422. /**
  6423. * Gets or sets the width to capture in the source image
  6424. */
  6425. get: function () {
  6426. return this._sourceWidth;
  6427. },
  6428. set: function (value) {
  6429. if (this._sourceWidth === value) {
  6430. return;
  6431. }
  6432. this._sourceWidth = value;
  6433. this._markAsDirty();
  6434. },
  6435. enumerable: true,
  6436. configurable: true
  6437. });
  6438. Object.defineProperty(Image.prototype, "sourceHeight", {
  6439. /**
  6440. * Gets or sets the height to capture in the source image
  6441. */
  6442. get: function () {
  6443. return this._sourceHeight;
  6444. },
  6445. set: function (value) {
  6446. if (this._sourceHeight === value) {
  6447. return;
  6448. }
  6449. this._sourceHeight = value;
  6450. this._markAsDirty();
  6451. },
  6452. enumerable: true,
  6453. configurable: true
  6454. });
  6455. Object.defineProperty(Image.prototype, "isSVG", {
  6456. /** Indicates if the format of the image is SVG */
  6457. get: function () {
  6458. return this._isSVG;
  6459. },
  6460. enumerable: true,
  6461. configurable: true
  6462. });
  6463. Object.defineProperty(Image.prototype, "svgAttributesComputationCompleted", {
  6464. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  6465. get: function () {
  6466. return this._svgAttributesComputationCompleted;
  6467. },
  6468. enumerable: true,
  6469. configurable: true
  6470. });
  6471. Object.defineProperty(Image.prototype, "autoScale", {
  6472. /**
  6473. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6474. * @see http://doc.babylonjs.com/how_to/gui#image
  6475. */
  6476. get: function () {
  6477. return this._autoScale;
  6478. },
  6479. set: function (value) {
  6480. if (this._autoScale === value) {
  6481. return;
  6482. }
  6483. this._autoScale = value;
  6484. if (value && this._loaded) {
  6485. this.synchronizeSizeWithContent();
  6486. }
  6487. },
  6488. enumerable: true,
  6489. configurable: true
  6490. });
  6491. Object.defineProperty(Image.prototype, "stretch", {
  6492. /** Gets or sets the streching mode used by the image */
  6493. get: function () {
  6494. return this._stretch;
  6495. },
  6496. set: function (value) {
  6497. if (this._stretch === value) {
  6498. return;
  6499. }
  6500. this._stretch = value;
  6501. this._markAsDirty();
  6502. },
  6503. enumerable: true,
  6504. configurable: true
  6505. });
  6506. /** @hidden */
  6507. Image.prototype._rotate90 = function (n, preserveProperties) {
  6508. if (preserveProperties === void 0) { preserveProperties = false; }
  6509. var canvas = document.createElement('canvas');
  6510. var context = canvas.getContext('2d');
  6511. var width = this._domImage.width;
  6512. var height = this._domImage.height;
  6513. canvas.width = height;
  6514. canvas.height = width;
  6515. context.translate(canvas.width / 2, canvas.height / 2);
  6516. context.rotate(n * Math.PI / 2);
  6517. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  6518. var dataUrl = canvas.toDataURL("image/jpg");
  6519. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  6520. if (preserveProperties) {
  6521. rotatedImage._stretch = this._stretch;
  6522. rotatedImage._autoScale = this._autoScale;
  6523. rotatedImage._cellId = this._cellId;
  6524. rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;
  6525. rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;
  6526. }
  6527. this._handleRotationForSVGImage(this, rotatedImage, n);
  6528. return rotatedImage;
  6529. };
  6530. Image.prototype._handleRotationForSVGImage = function (srcImage, dstImage, n) {
  6531. var _this = this;
  6532. if (!srcImage._isSVG) {
  6533. return;
  6534. }
  6535. if (srcImage._svgAttributesComputationCompleted) {
  6536. this._rotate90SourceProperties(srcImage, dstImage, n);
  6537. this._markAsDirty();
  6538. }
  6539. else {
  6540. srcImage.onSVGAttributesComputedObservable.addOnce(function () {
  6541. _this._rotate90SourceProperties(srcImage, dstImage, n);
  6542. _this._markAsDirty();
  6543. });
  6544. }
  6545. };
  6546. Image.prototype._rotate90SourceProperties = function (srcImage, dstImage, n) {
  6547. var _a, _b;
  6548. var srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
  6549. var dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
  6550. if (n != 0) {
  6551. var mult = n < 0 ? -1 : 1;
  6552. n = n % 4;
  6553. for (var i = 0; i < Math.abs(n); ++i) {
  6554. dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;
  6555. dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;
  6556. _a = [dstHeight, dstWidth], dstWidth = _a[0], dstHeight = _a[1];
  6557. if (n < 0) {
  6558. dstTop -= dstHeight;
  6559. }
  6560. else {
  6561. dstLeft -= dstWidth;
  6562. }
  6563. srcLeft = dstLeft;
  6564. srcTop = dstTop;
  6565. _b = [srcHeight, srcWidth], srcWidth = _b[0], srcHeight = _b[1];
  6566. }
  6567. }
  6568. dstImage.sourceLeft = dstLeft;
  6569. dstImage.sourceTop = dstTop;
  6570. dstImage.sourceWidth = dstWidth;
  6571. dstImage.sourceHeight = dstHeight;
  6572. };
  6573. Object.defineProperty(Image.prototype, "domImage", {
  6574. get: function () {
  6575. return this._domImage;
  6576. },
  6577. /**
  6578. * Gets or sets the internal DOM image used to render the control
  6579. */
  6580. set: function (value) {
  6581. var _this = this;
  6582. this._domImage = value;
  6583. this._loaded = false;
  6584. if (this._domImage.width) {
  6585. this._onImageLoaded();
  6586. }
  6587. else {
  6588. this._domImage.onload = function () {
  6589. _this._onImageLoaded();
  6590. };
  6591. }
  6592. },
  6593. enumerable: true,
  6594. configurable: true
  6595. });
  6596. Image.prototype._onImageLoaded = function () {
  6597. this._imageWidth = this._domImage.width;
  6598. this._imageHeight = this._domImage.height;
  6599. this._loaded = true;
  6600. if (this._populateNinePatchSlicesFromImage) {
  6601. this._extractNinePatchSliceDataFromImage();
  6602. }
  6603. if (this._autoScale) {
  6604. this.synchronizeSizeWithContent();
  6605. }
  6606. this.onImageLoadedObservable.notifyObservers(this);
  6607. this._markAsDirty();
  6608. };
  6609. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6610. if (!this._workingCanvas) {
  6611. this._workingCanvas = document.createElement('canvas');
  6612. }
  6613. var canvas = this._workingCanvas;
  6614. var context = canvas.getContext('2d');
  6615. var width = this._domImage.width;
  6616. var height = this._domImage.height;
  6617. canvas.width = width;
  6618. canvas.height = height;
  6619. context.drawImage(this._domImage, 0, 0, width, height);
  6620. var imageData = context.getImageData(0, 0, width, height);
  6621. // Left and right
  6622. this._sliceLeft = -1;
  6623. this._sliceRight = -1;
  6624. for (var x = 0; x < width; x++) {
  6625. var alpha = imageData.data[x * 4 + 3];
  6626. if (alpha > 127 && this._sliceLeft === -1) {
  6627. this._sliceLeft = x;
  6628. continue;
  6629. }
  6630. if (alpha < 127 && this._sliceLeft > -1) {
  6631. this._sliceRight = x;
  6632. break;
  6633. }
  6634. }
  6635. // top and bottom
  6636. this._sliceTop = -1;
  6637. this._sliceBottom = -1;
  6638. for (var y = 0; y < height; y++) {
  6639. var alpha = imageData.data[y * width * 4 + 3];
  6640. if (alpha > 127 && this._sliceTop === -1) {
  6641. this._sliceTop = y;
  6642. continue;
  6643. }
  6644. if (alpha < 127 && this._sliceTop > -1) {
  6645. this._sliceBottom = y;
  6646. break;
  6647. }
  6648. }
  6649. };
  6650. Object.defineProperty(Image.prototype, "source", {
  6651. /**
  6652. * Gets or sets image source url
  6653. */
  6654. set: function (value) {
  6655. var _this = this;
  6656. if (this._source === value) {
  6657. return;
  6658. }
  6659. this._loaded = false;
  6660. this._source = value;
  6661. if (value) {
  6662. value = this._svgCheck(value);
  6663. }
  6664. this._domImage = document.createElement("img");
  6665. this._domImage.onload = function () {
  6666. _this._onImageLoaded();
  6667. };
  6668. if (value) {
  6669. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6670. this._domImage.src = value;
  6671. }
  6672. },
  6673. enumerable: true,
  6674. configurable: true
  6675. });
  6676. /**
  6677. * Checks for svg document with icon id present
  6678. */
  6679. Image.prototype._svgCheck = function (value) {
  6680. var _this = this;
  6681. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6682. this._isSVG = true;
  6683. var svgsrc = value.split('#')[0];
  6684. var elemid = value.split('#')[1];
  6685. // check if object alr exist in document
  6686. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6687. if (svgExist) {
  6688. var svgDoc = svgExist.contentDocument;
  6689. // get viewbox width and height, get svg document width and height in px
  6690. if (svgDoc && svgDoc.documentElement) {
  6691. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6692. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6693. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6694. var elem = svgDoc.getElementById(elemid);
  6695. if (elem && vb && docwidth && docheight) {
  6696. this._getSVGAttribs(svgExist, elemid);
  6697. return value;
  6698. }
  6699. }
  6700. // wait for object to load
  6701. svgExist.addEventListener("load", function () {
  6702. _this._getSVGAttribs(svgExist, elemid);
  6703. });
  6704. }
  6705. else {
  6706. // create document object
  6707. var svgImage = document.createElement("object");
  6708. svgImage.data = svgsrc;
  6709. svgImage.type = "image/svg+xml";
  6710. svgImage.width = "0%";
  6711. svgImage.height = "0%";
  6712. document.body.appendChild(svgImage);
  6713. // when the object has loaded, get the element attribs
  6714. svgImage.onload = function () {
  6715. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6716. if (svgobj) {
  6717. _this._getSVGAttribs(svgobj, elemid);
  6718. }
  6719. };
  6720. }
  6721. return svgsrc;
  6722. }
  6723. else {
  6724. return value;
  6725. }
  6726. };
  6727. /**
  6728. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6729. * given external svg file and icon id
  6730. */
  6731. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6732. var svgDoc = svgsrc.contentDocument;
  6733. // get viewbox width and height, get svg document width and height in px
  6734. if (svgDoc && svgDoc.documentElement) {
  6735. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6736. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6737. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6738. // get element bbox and matrix transform
  6739. var elem = svgDoc.getElementById(elemid);
  6740. if (vb && docwidth && docheight && elem) {
  6741. var vb_width = Number(vb.split(" ")[2]);
  6742. var vb_height = Number(vb.split(" ")[3]);
  6743. var elem_bbox = elem.getBBox();
  6744. var elem_matrix_a = 1;
  6745. var elem_matrix_d = 1;
  6746. var elem_matrix_e = 0;
  6747. var elem_matrix_f = 0;
  6748. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6749. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6750. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6751. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6752. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6753. }
  6754. // compute source coordinates and dimensions
  6755. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6756. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6757. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6758. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6759. this._svgAttributesComputationCompleted = true;
  6760. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6761. }
  6762. }
  6763. };
  6764. Object.defineProperty(Image.prototype, "cellWidth", {
  6765. /**
  6766. * Gets or sets the cell width to use when animation sheet is enabled
  6767. * @see http://doc.babylonjs.com/how_to/gui#image
  6768. */
  6769. get: function () {
  6770. return this._cellWidth;
  6771. },
  6772. set: function (value) {
  6773. if (this._cellWidth === value) {
  6774. return;
  6775. }
  6776. this._cellWidth = value;
  6777. this._markAsDirty();
  6778. },
  6779. enumerable: true,
  6780. configurable: true
  6781. });
  6782. Object.defineProperty(Image.prototype, "cellHeight", {
  6783. /**
  6784. * Gets or sets the cell height to use when animation sheet is enabled
  6785. * @see http://doc.babylonjs.com/how_to/gui#image
  6786. */
  6787. get: function () {
  6788. return this._cellHeight;
  6789. },
  6790. set: function (value) {
  6791. if (this._cellHeight === value) {
  6792. return;
  6793. }
  6794. this._cellHeight = value;
  6795. this._markAsDirty();
  6796. },
  6797. enumerable: true,
  6798. configurable: true
  6799. });
  6800. Object.defineProperty(Image.prototype, "cellId", {
  6801. /**
  6802. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6803. * @see http://doc.babylonjs.com/how_to/gui#image
  6804. */
  6805. get: function () {
  6806. return this._cellId;
  6807. },
  6808. set: function (value) {
  6809. if (this._cellId === value) {
  6810. return;
  6811. }
  6812. this._cellId = value;
  6813. this._markAsDirty();
  6814. },
  6815. enumerable: true,
  6816. configurable: true
  6817. });
  6818. /**
  6819. * Tests if a given coordinates belong to the current control
  6820. * @param x defines x coordinate to test
  6821. * @param y defines y coordinate to test
  6822. * @returns true if the coordinates are inside the control
  6823. */
  6824. Image.prototype.contains = function (x, y) {
  6825. if (!_super.prototype.contains.call(this, x, y)) {
  6826. return false;
  6827. }
  6828. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6829. return true;
  6830. }
  6831. var canvas = this._workingCanvas;
  6832. var context = canvas.getContext("2d");
  6833. var width = this._currentMeasure.width | 0;
  6834. var height = this._currentMeasure.height | 0;
  6835. var imageData = context.getImageData(0, 0, width, height).data;
  6836. x = (x - this._currentMeasure.left) | 0;
  6837. y = (y - this._currentMeasure.top) | 0;
  6838. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6839. return pickedPixel > 0;
  6840. };
  6841. Image.prototype._getTypeName = function () {
  6842. return "Image";
  6843. };
  6844. /** Force the control to synchronize with its content */
  6845. Image.prototype.synchronizeSizeWithContent = function () {
  6846. if (!this._loaded) {
  6847. return;
  6848. }
  6849. this.width = this._domImage.width + "px";
  6850. this.height = this._domImage.height + "px";
  6851. };
  6852. Image.prototype._processMeasures = function (parentMeasure, context) {
  6853. if (this._loaded) {
  6854. switch (this._stretch) {
  6855. case Image.STRETCH_NONE:
  6856. break;
  6857. case Image.STRETCH_FILL:
  6858. break;
  6859. case Image.STRETCH_UNIFORM:
  6860. break;
  6861. case Image.STRETCH_NINE_PATCH:
  6862. break;
  6863. case Image.STRETCH_EXTEND:
  6864. if (this._autoScale) {
  6865. this.synchronizeSizeWithContent();
  6866. }
  6867. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6868. this.parent.adaptWidthToChildren = true;
  6869. this.parent.adaptHeightToChildren = true;
  6870. }
  6871. break;
  6872. }
  6873. }
  6874. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6875. };
  6876. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6877. if (!this._detectPointerOnOpaqueOnly) {
  6878. return;
  6879. }
  6880. if (!this._workingCanvas) {
  6881. this._workingCanvas = document.createElement('canvas');
  6882. }
  6883. var canvas = this._workingCanvas;
  6884. var width = this._currentMeasure.width;
  6885. var height = this._currentMeasure.height;
  6886. var context = canvas.getContext("2d");
  6887. canvas.width = width;
  6888. canvas.height = height;
  6889. context.clearRect(0, 0, width, height);
  6890. };
  6891. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6892. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6893. if (!this._detectPointerOnOpaqueOnly) {
  6894. return;
  6895. }
  6896. var canvas = this._workingCanvas;
  6897. context = canvas.getContext("2d");
  6898. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6899. };
  6900. Image.prototype._draw = function (context) {
  6901. context.save();
  6902. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6903. context.shadowColor = this.shadowColor;
  6904. context.shadowBlur = this.shadowBlur;
  6905. context.shadowOffsetX = this.shadowOffsetX;
  6906. context.shadowOffsetY = this.shadowOffsetY;
  6907. }
  6908. var x, y, width, height;
  6909. if (this.cellId == -1) {
  6910. x = this._sourceLeft;
  6911. y = this._sourceTop;
  6912. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6913. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6914. }
  6915. else {
  6916. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6917. var column = (this.cellId / rowCount) >> 0;
  6918. var row = this.cellId % rowCount;
  6919. x = this.cellWidth * row;
  6920. y = this.cellHeight * column;
  6921. width = this.cellWidth;
  6922. height = this.cellHeight;
  6923. }
  6924. this._prepareWorkingCanvasForOpaqueDetection();
  6925. this._applyStates(context);
  6926. if (this._loaded) {
  6927. switch (this._stretch) {
  6928. case Image.STRETCH_NONE:
  6929. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6930. break;
  6931. case Image.STRETCH_FILL:
  6932. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6933. break;
  6934. case Image.STRETCH_UNIFORM:
  6935. var hRatio = this._currentMeasure.width / width;
  6936. var vRatio = this._currentMeasure.height / height;
  6937. var ratio = Math.min(hRatio, vRatio);
  6938. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6939. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6940. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6941. break;
  6942. case Image.STRETCH_EXTEND:
  6943. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6944. break;
  6945. case Image.STRETCH_NINE_PATCH:
  6946. this._renderNinePatch(context);
  6947. break;
  6948. }
  6949. }
  6950. context.restore();
  6951. };
  6952. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6953. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6954. };
  6955. Image.prototype._renderNinePatch = function (context) {
  6956. var height = this._imageHeight;
  6957. var leftWidth = this._sliceLeft;
  6958. var topHeight = this._sliceTop;
  6959. var bottomHeight = this._imageHeight - this._sliceBottom;
  6960. var rightWidth = this._imageWidth - this._sliceRight;
  6961. var left = 0;
  6962. var top = 0;
  6963. if (this._populateNinePatchSlicesFromImage) {
  6964. left = 1;
  6965. top = 1;
  6966. height -= 2;
  6967. leftWidth -= 1;
  6968. topHeight -= 1;
  6969. bottomHeight -= 1;
  6970. rightWidth -= 1;
  6971. }
  6972. var centerWidth = this._sliceRight - this._sliceLeft;
  6973. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft;
  6974. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6975. // Corners
  6976. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6977. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6978. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6979. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6980. // Center
  6981. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight);
  6982. // Borders
  6983. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6984. 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);
  6985. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6986. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6987. };
  6988. Image.prototype.dispose = function () {
  6989. _super.prototype.dispose.call(this);
  6990. this.onImageLoadedObservable.clear();
  6991. this.onSVGAttributesComputedObservable.clear();
  6992. };
  6993. // Static
  6994. /** STRETCH_NONE */
  6995. Image.STRETCH_NONE = 0;
  6996. /** STRETCH_FILL */
  6997. Image.STRETCH_FILL = 1;
  6998. /** STRETCH_UNIFORM */
  6999. Image.STRETCH_UNIFORM = 2;
  7000. /** STRETCH_EXTEND */
  7001. Image.STRETCH_EXTEND = 3;
  7002. /** NINE_PATCH */
  7003. Image.STRETCH_NINE_PATCH = 4;
  7004. return Image;
  7005. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7006. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  7007. /***/ }),
  7008. /***/ "./2D/controls/index.ts":
  7009. /*!******************************!*\
  7010. !*** ./2D/controls/index.ts ***!
  7011. \******************************/
  7012. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  7013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7014. "use strict";
  7015. __webpack_require__.r(__webpack_exports__);
  7016. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  7017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  7018. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  7019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  7020. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  7021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  7022. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  7023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  7024. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  7026. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  7027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  7028. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  7029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  7030. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  7031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  7032. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  7034. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  7035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  7036. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  7037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  7038. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  7039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  7040. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  7041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  7042. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  7043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  7044. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  7045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  7046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  7047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  7048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  7049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  7050. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  7051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  7052. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  7053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  7054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  7055. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  7056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  7057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  7058. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  7059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  7060. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  7061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  7062. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  7063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  7064. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  7065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  7066. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  7067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  7068. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  7069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  7070. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  7071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__["ImageScrollBar"]; });
  7072. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  7073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_25__["name"]; });
  7074. /***/ }),
  7075. /***/ "./2D/controls/inputPassword.ts":
  7076. /*!**************************************!*\
  7077. !*** ./2D/controls/inputPassword.ts ***!
  7078. \**************************************/
  7079. /*! exports provided: InputPassword */
  7080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7081. "use strict";
  7082. __webpack_require__.r(__webpack_exports__);
  7083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  7084. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7085. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7086. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  7087. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  7088. /**
  7089. * Class used to create a password control
  7090. */
  7091. var InputPassword = /** @class */ (function (_super) {
  7092. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  7093. function InputPassword() {
  7094. return _super !== null && _super.apply(this, arguments) || this;
  7095. }
  7096. InputPassword.prototype._beforeRenderText = function (text) {
  7097. var txt = "";
  7098. for (var i = 0; i < text.length; i++) {
  7099. txt += "\u2022";
  7100. }
  7101. return txt;
  7102. };
  7103. return InputPassword;
  7104. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  7105. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  7106. /***/ }),
  7107. /***/ "./2D/controls/inputText.ts":
  7108. /*!**********************************!*\
  7109. !*** ./2D/controls/inputText.ts ***!
  7110. \**********************************/
  7111. /*! exports provided: InputText */
  7112. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7113. "use strict";
  7114. __webpack_require__.r(__webpack_exports__);
  7115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  7116. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7117. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  7118. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  7119. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7120. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7121. /**
  7122. * Class used to create input text control
  7123. */
  7124. var InputText = /** @class */ (function (_super) {
  7125. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7126. /**
  7127. * Creates a new InputText
  7128. * @param name defines the control name
  7129. * @param text defines the text of the control
  7130. */
  7131. function InputText(name, text) {
  7132. if (text === void 0) { text = ""; }
  7133. var _this = _super.call(this, name) || this;
  7134. _this.name = name;
  7135. _this._text = "";
  7136. _this._placeholderText = "";
  7137. _this._background = "#222222";
  7138. _this._focusedBackground = "#000000";
  7139. _this._focusedColor = "white";
  7140. _this._placeholderColor = "gray";
  7141. _this._thickness = 1;
  7142. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7143. _this._autoStretchWidth = true;
  7144. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7145. _this._isFocused = false;
  7146. _this._blinkIsEven = false;
  7147. _this._cursorOffset = 0;
  7148. _this._deadKey = false;
  7149. _this._addKey = true;
  7150. _this._currentKey = "";
  7151. _this._isTextHighlightOn = false;
  7152. _this._textHighlightColor = "#d5e0ff";
  7153. _this._highligherOpacity = 0.4;
  7154. _this._highlightedText = "";
  7155. _this._startHighlightIndex = 0;
  7156. _this._endHighlightIndex = 0;
  7157. _this._cursorIndex = -1;
  7158. _this._onFocusSelectAll = false;
  7159. _this._isPointerDown = false;
  7160. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7161. _this.promptMessage = "Please enter text:";
  7162. /** Force disable prompt on mobile device */
  7163. _this.disableMobilePrompt = false;
  7164. /** Observable raised when the text changes */
  7165. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7166. /** Observable raised just before an entered character is to be added */
  7167. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7168. /** Observable raised when the control gets the focus */
  7169. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7170. /** Observable raised when the control loses the focus */
  7171. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7172. /**Observable raised when the text is highlighted */
  7173. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7174. /**Observable raised when copy event is triggered */
  7175. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7176. /** Observable raised when cut event is triggered */
  7177. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7178. /** Observable raised when paste event is triggered */
  7179. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7180. /** Observable raised when a key event was processed */
  7181. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7182. _this.text = text;
  7183. _this.isPointerBlocker = true;
  7184. return _this;
  7185. }
  7186. Object.defineProperty(InputText.prototype, "maxWidth", {
  7187. /** Gets or sets the maximum width allowed by the control */
  7188. get: function () {
  7189. return this._maxWidth.toString(this._host);
  7190. },
  7191. set: function (value) {
  7192. if (this._maxWidth.toString(this._host) === value) {
  7193. return;
  7194. }
  7195. if (this._maxWidth.fromString(value)) {
  7196. this._markAsDirty();
  7197. }
  7198. },
  7199. enumerable: true,
  7200. configurable: true
  7201. });
  7202. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7203. /** Gets the maximum width allowed by the control in pixels */
  7204. get: function () {
  7205. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7206. },
  7207. enumerable: true,
  7208. configurable: true
  7209. });
  7210. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7211. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7212. get: function () {
  7213. return this._highligherOpacity;
  7214. },
  7215. set: function (value) {
  7216. if (this._highligherOpacity === value) {
  7217. return;
  7218. }
  7219. this._highligherOpacity = value;
  7220. this._markAsDirty();
  7221. },
  7222. enumerable: true,
  7223. configurable: true
  7224. });
  7225. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7226. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7227. get: function () {
  7228. return this._onFocusSelectAll;
  7229. },
  7230. set: function (value) {
  7231. if (this._onFocusSelectAll === value) {
  7232. return;
  7233. }
  7234. this._onFocusSelectAll = value;
  7235. this._markAsDirty();
  7236. },
  7237. enumerable: true,
  7238. configurable: true
  7239. });
  7240. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7241. /** Gets or sets the text hightlight color */
  7242. get: function () {
  7243. return this._textHighlightColor;
  7244. },
  7245. set: function (value) {
  7246. if (this._textHighlightColor === value) {
  7247. return;
  7248. }
  7249. this._textHighlightColor = value;
  7250. this._markAsDirty();
  7251. },
  7252. enumerable: true,
  7253. configurable: true
  7254. });
  7255. Object.defineProperty(InputText.prototype, "margin", {
  7256. /** Gets or sets control margin */
  7257. get: function () {
  7258. return this._margin.toString(this._host);
  7259. },
  7260. set: function (value) {
  7261. if (this._margin.toString(this._host) === value) {
  7262. return;
  7263. }
  7264. if (this._margin.fromString(value)) {
  7265. this._markAsDirty();
  7266. }
  7267. },
  7268. enumerable: true,
  7269. configurable: true
  7270. });
  7271. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7272. /** Gets control margin in pixels */
  7273. get: function () {
  7274. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7275. },
  7276. enumerable: true,
  7277. configurable: true
  7278. });
  7279. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7280. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7281. get: function () {
  7282. return this._autoStretchWidth;
  7283. },
  7284. set: function (value) {
  7285. if (this._autoStretchWidth === value) {
  7286. return;
  7287. }
  7288. this._autoStretchWidth = value;
  7289. this._markAsDirty();
  7290. },
  7291. enumerable: true,
  7292. configurable: true
  7293. });
  7294. Object.defineProperty(InputText.prototype, "thickness", {
  7295. /** Gets or sets border thickness */
  7296. get: function () {
  7297. return this._thickness;
  7298. },
  7299. set: function (value) {
  7300. if (this._thickness === value) {
  7301. return;
  7302. }
  7303. this._thickness = value;
  7304. this._markAsDirty();
  7305. },
  7306. enumerable: true,
  7307. configurable: true
  7308. });
  7309. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7310. /** Gets or sets the background color when focused */
  7311. get: function () {
  7312. return this._focusedBackground;
  7313. },
  7314. set: function (value) {
  7315. if (this._focusedBackground === value) {
  7316. return;
  7317. }
  7318. this._focusedBackground = value;
  7319. this._markAsDirty();
  7320. },
  7321. enumerable: true,
  7322. configurable: true
  7323. });
  7324. Object.defineProperty(InputText.prototype, "focusedColor", {
  7325. /** Gets or sets the background color when focused */
  7326. get: function () {
  7327. return this._focusedColor;
  7328. },
  7329. set: function (value) {
  7330. if (this._focusedColor === value) {
  7331. return;
  7332. }
  7333. this._focusedColor = value;
  7334. this._markAsDirty();
  7335. },
  7336. enumerable: true,
  7337. configurable: true
  7338. });
  7339. Object.defineProperty(InputText.prototype, "background", {
  7340. /** Gets or sets the background color */
  7341. get: function () {
  7342. return this._background;
  7343. },
  7344. set: function (value) {
  7345. if (this._background === value) {
  7346. return;
  7347. }
  7348. this._background = value;
  7349. this._markAsDirty();
  7350. },
  7351. enumerable: true,
  7352. configurable: true
  7353. });
  7354. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7355. /** Gets or sets the placeholder color */
  7356. get: function () {
  7357. return this._placeholderColor;
  7358. },
  7359. set: function (value) {
  7360. if (this._placeholderColor === value) {
  7361. return;
  7362. }
  7363. this._placeholderColor = value;
  7364. this._markAsDirty();
  7365. },
  7366. enumerable: true,
  7367. configurable: true
  7368. });
  7369. Object.defineProperty(InputText.prototype, "placeholderText", {
  7370. /** Gets or sets the text displayed when the control is empty */
  7371. get: function () {
  7372. return this._placeholderText;
  7373. },
  7374. set: function (value) {
  7375. if (this._placeholderText === value) {
  7376. return;
  7377. }
  7378. this._placeholderText = value;
  7379. this._markAsDirty();
  7380. },
  7381. enumerable: true,
  7382. configurable: true
  7383. });
  7384. Object.defineProperty(InputText.prototype, "deadKey", {
  7385. /** Gets or sets the dead key flag */
  7386. get: function () {
  7387. return this._deadKey;
  7388. },
  7389. set: function (flag) {
  7390. this._deadKey = flag;
  7391. },
  7392. enumerable: true,
  7393. configurable: true
  7394. });
  7395. Object.defineProperty(InputText.prototype, "highlightedText", {
  7396. /** Gets or sets the highlight text */
  7397. get: function () {
  7398. return this._highlightedText;
  7399. },
  7400. set: function (text) {
  7401. if (this._highlightedText === text) {
  7402. return;
  7403. }
  7404. this._highlightedText = text;
  7405. this._markAsDirty();
  7406. },
  7407. enumerable: true,
  7408. configurable: true
  7409. });
  7410. Object.defineProperty(InputText.prototype, "addKey", {
  7411. /** Gets or sets if the current key should be added */
  7412. get: function () {
  7413. return this._addKey;
  7414. },
  7415. set: function (flag) {
  7416. this._addKey = flag;
  7417. },
  7418. enumerable: true,
  7419. configurable: true
  7420. });
  7421. Object.defineProperty(InputText.prototype, "currentKey", {
  7422. /** Gets or sets the value of the current key being entered */
  7423. get: function () {
  7424. return this._currentKey;
  7425. },
  7426. set: function (key) {
  7427. this._currentKey = key;
  7428. },
  7429. enumerable: true,
  7430. configurable: true
  7431. });
  7432. Object.defineProperty(InputText.prototype, "text", {
  7433. /** Gets or sets the text displayed in the control */
  7434. get: function () {
  7435. return this._text;
  7436. },
  7437. set: function (value) {
  7438. var valueAsString = value.toString(); // Forcing convertion
  7439. if (this._text === valueAsString) {
  7440. return;
  7441. }
  7442. this._text = valueAsString;
  7443. this._markAsDirty();
  7444. this.onTextChangedObservable.notifyObservers(this);
  7445. },
  7446. enumerable: true,
  7447. configurable: true
  7448. });
  7449. Object.defineProperty(InputText.prototype, "width", {
  7450. /** Gets or sets control width */
  7451. get: function () {
  7452. return this._width.toString(this._host);
  7453. },
  7454. set: function (value) {
  7455. if (this._width.toString(this._host) === value) {
  7456. return;
  7457. }
  7458. if (this._width.fromString(value)) {
  7459. this._markAsDirty();
  7460. }
  7461. this.autoStretchWidth = false;
  7462. },
  7463. enumerable: true,
  7464. configurable: true
  7465. });
  7466. /** @hidden */
  7467. InputText.prototype.onBlur = function () {
  7468. this._isFocused = false;
  7469. this._scrollLeft = null;
  7470. this._cursorOffset = 0;
  7471. clearTimeout(this._blinkTimeout);
  7472. this._markAsDirty();
  7473. this.onBlurObservable.notifyObservers(this);
  7474. this._host.unRegisterClipboardEvents();
  7475. if (this._onClipboardObserver) {
  7476. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7477. }
  7478. var scene = this._host.getScene();
  7479. if (this._onPointerDblTapObserver && scene) {
  7480. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7481. }
  7482. };
  7483. /** @hidden */
  7484. InputText.prototype.onFocus = function () {
  7485. var _this = this;
  7486. if (!this._isEnabled) {
  7487. return;
  7488. }
  7489. this._scrollLeft = null;
  7490. this._isFocused = true;
  7491. this._blinkIsEven = false;
  7492. this._cursorOffset = 0;
  7493. this._markAsDirty();
  7494. this.onFocusObservable.notifyObservers(this);
  7495. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7496. var value = prompt(this.promptMessage);
  7497. if (value !== null) {
  7498. this.text = value;
  7499. }
  7500. this._host.focusedControl = null;
  7501. return;
  7502. }
  7503. this._host.registerClipboardEvents();
  7504. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7505. // process clipboard event, can be configured.
  7506. switch (clipboardInfo.type) {
  7507. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7508. _this._onCopyText(clipboardInfo.event);
  7509. _this.onTextCopyObservable.notifyObservers(_this);
  7510. break;
  7511. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7512. _this._onCutText(clipboardInfo.event);
  7513. _this.onTextCutObservable.notifyObservers(_this);
  7514. break;
  7515. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7516. _this._onPasteText(clipboardInfo.event);
  7517. _this.onTextPasteObservable.notifyObservers(_this);
  7518. break;
  7519. default: return;
  7520. }
  7521. });
  7522. var scene = this._host.getScene();
  7523. if (scene) {
  7524. //register the pointer double tap event
  7525. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7526. if (!_this._isFocused) {
  7527. return;
  7528. }
  7529. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7530. _this._processDblClick(pointerInfo);
  7531. }
  7532. });
  7533. }
  7534. if (this._onFocusSelectAll) {
  7535. this._selectAllText();
  7536. }
  7537. };
  7538. InputText.prototype._getTypeName = function () {
  7539. return "InputText";
  7540. };
  7541. /**
  7542. * Function called to get the list of controls that should not steal the focus from this control
  7543. * @returns an array of controls
  7544. */
  7545. InputText.prototype.keepsFocusWith = function () {
  7546. if (!this._connectedVirtualKeyboard) {
  7547. return null;
  7548. }
  7549. return [this._connectedVirtualKeyboard];
  7550. };
  7551. /** @hidden */
  7552. InputText.prototype.processKey = function (keyCode, key, evt) {
  7553. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7554. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7555. return;
  7556. }
  7557. //select all
  7558. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7559. this._selectAllText();
  7560. evt.preventDefault();
  7561. return;
  7562. }
  7563. // Specific cases
  7564. switch (keyCode) {
  7565. case 32: //SPACE
  7566. key = " "; //ie11 key for space is "Spacebar"
  7567. break;
  7568. case 191: //SLASH
  7569. if (evt) {
  7570. evt.preventDefault();
  7571. }
  7572. break;
  7573. case 8: // BACKSPACE
  7574. if (this._text && this._text.length > 0) {
  7575. //delete the highlighted text
  7576. if (this._isTextHighlightOn) {
  7577. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7578. this._isTextHighlightOn = false;
  7579. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7580. this._blinkIsEven = false;
  7581. if (evt) {
  7582. evt.preventDefault();
  7583. }
  7584. return;
  7585. }
  7586. //delete single character
  7587. if (this._cursorOffset === 0) {
  7588. this.text = this._text.substr(0, this._text.length - 1);
  7589. }
  7590. else {
  7591. var deletePosition = this._text.length - this._cursorOffset;
  7592. if (deletePosition > 0) {
  7593. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7594. }
  7595. }
  7596. }
  7597. if (evt) {
  7598. evt.preventDefault();
  7599. }
  7600. return;
  7601. case 46: // DELETE
  7602. if (this._isTextHighlightOn) {
  7603. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7604. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7605. while (decrementor > 0 && this._cursorOffset > 0) {
  7606. this._cursorOffset--;
  7607. }
  7608. this._isTextHighlightOn = false;
  7609. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7610. if (evt) {
  7611. evt.preventDefault();
  7612. }
  7613. return;
  7614. }
  7615. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7616. var deletePosition = this._text.length - this._cursorOffset;
  7617. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7618. this._cursorOffset--;
  7619. }
  7620. if (evt) {
  7621. evt.preventDefault();
  7622. }
  7623. return;
  7624. case 13: // RETURN
  7625. this._host.focusedControl = null;
  7626. this._isTextHighlightOn = false;
  7627. return;
  7628. case 35: // END
  7629. this._cursorOffset = 0;
  7630. this._blinkIsEven = false;
  7631. this._isTextHighlightOn = false;
  7632. this._markAsDirty();
  7633. return;
  7634. case 36: // HOME
  7635. this._cursorOffset = this._text.length;
  7636. this._blinkIsEven = false;
  7637. this._isTextHighlightOn = false;
  7638. this._markAsDirty();
  7639. return;
  7640. case 37: // LEFT
  7641. this._cursorOffset++;
  7642. if (this._cursorOffset > this._text.length) {
  7643. this._cursorOffset = this._text.length;
  7644. }
  7645. if (evt && evt.shiftKey) {
  7646. // update the cursor
  7647. this._blinkIsEven = false;
  7648. // shift + ctrl/cmd + <-
  7649. if (evt.ctrlKey || evt.metaKey) {
  7650. if (!this._isTextHighlightOn) {
  7651. if (this._text.length === this._cursorOffset) {
  7652. return;
  7653. }
  7654. else {
  7655. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7656. }
  7657. }
  7658. this._startHighlightIndex = 0;
  7659. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7660. this._cursorOffset = this._text.length;
  7661. this._isTextHighlightOn = true;
  7662. this._markAsDirty();
  7663. return;
  7664. }
  7665. //store the starting point
  7666. if (!this._isTextHighlightOn) {
  7667. this._isTextHighlightOn = true;
  7668. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7669. }
  7670. //if text is already highlighted
  7671. else if (this._cursorIndex === -1) {
  7672. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7673. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7674. }
  7675. //set the highlight indexes
  7676. if (this._cursorIndex < this._cursorOffset) {
  7677. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7678. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7679. }
  7680. else if (this._cursorIndex > this._cursorOffset) {
  7681. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7682. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7683. }
  7684. else {
  7685. this._isTextHighlightOn = false;
  7686. }
  7687. this._markAsDirty();
  7688. return;
  7689. }
  7690. if (this._isTextHighlightOn) {
  7691. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7692. this._isTextHighlightOn = false;
  7693. }
  7694. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7695. this._cursorOffset = this.text.length;
  7696. evt.preventDefault();
  7697. }
  7698. this._blinkIsEven = false;
  7699. this._isTextHighlightOn = false;
  7700. this._cursorIndex = -1;
  7701. this._markAsDirty();
  7702. return;
  7703. case 39: // RIGHT
  7704. this._cursorOffset--;
  7705. if (this._cursorOffset < 0) {
  7706. this._cursorOffset = 0;
  7707. }
  7708. if (evt && evt.shiftKey) {
  7709. //update the cursor
  7710. this._blinkIsEven = false;
  7711. //shift + ctrl/cmd + ->
  7712. if (evt.ctrlKey || evt.metaKey) {
  7713. if (!this._isTextHighlightOn) {
  7714. if (this._cursorOffset === 0) {
  7715. return;
  7716. }
  7717. else {
  7718. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7719. }
  7720. }
  7721. this._endHighlightIndex = this._text.length;
  7722. this._isTextHighlightOn = true;
  7723. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7724. this._cursorOffset = 0;
  7725. this._markAsDirty();
  7726. return;
  7727. }
  7728. if (!this._isTextHighlightOn) {
  7729. this._isTextHighlightOn = true;
  7730. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7731. }
  7732. //if text is already highlighted
  7733. else if (this._cursorIndex === -1) {
  7734. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7735. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7736. }
  7737. //set the highlight indexes
  7738. if (this._cursorIndex < this._cursorOffset) {
  7739. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7740. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7741. }
  7742. else if (this._cursorIndex > this._cursorOffset) {
  7743. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7744. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7745. }
  7746. else {
  7747. this._isTextHighlightOn = false;
  7748. }
  7749. this._markAsDirty();
  7750. return;
  7751. }
  7752. if (this._isTextHighlightOn) {
  7753. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7754. this._isTextHighlightOn = false;
  7755. }
  7756. //ctr + ->
  7757. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7758. this._cursorOffset = 0;
  7759. evt.preventDefault();
  7760. }
  7761. this._blinkIsEven = false;
  7762. this._isTextHighlightOn = false;
  7763. this._cursorIndex = -1;
  7764. this._markAsDirty();
  7765. return;
  7766. case 222: // Dead
  7767. if (evt) {
  7768. evt.preventDefault();
  7769. }
  7770. this._cursorIndex = -1;
  7771. this.deadKey = true;
  7772. break;
  7773. }
  7774. // Printable characters
  7775. if (key &&
  7776. ((keyCode === -1) || // Direct access
  7777. (keyCode === 32) || // Space
  7778. (keyCode > 47 && keyCode < 64) || // Numbers
  7779. (keyCode > 64 && keyCode < 91) || // Letters
  7780. (keyCode > 159 && keyCode < 193) || // Special characters
  7781. (keyCode > 218 && keyCode < 223) || // Special characters
  7782. (keyCode > 95 && keyCode < 112))) { // Numpad
  7783. this._currentKey = key;
  7784. this.onBeforeKeyAddObservable.notifyObservers(this);
  7785. key = this._currentKey;
  7786. if (this._addKey) {
  7787. if (this._isTextHighlightOn) {
  7788. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7789. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7790. this._isTextHighlightOn = false;
  7791. this._blinkIsEven = false;
  7792. this._markAsDirty();
  7793. }
  7794. else if (this._cursorOffset === 0) {
  7795. this.text += key;
  7796. }
  7797. else {
  7798. var insertPosition = this._text.length - this._cursorOffset;
  7799. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7800. }
  7801. }
  7802. }
  7803. };
  7804. /** @hidden */
  7805. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7806. //update the cursor
  7807. this._blinkIsEven = false;
  7808. if (this._cursorIndex === -1) {
  7809. this._cursorIndex = offset;
  7810. }
  7811. else {
  7812. if (this._cursorIndex < this._cursorOffset) {
  7813. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7814. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7815. }
  7816. else if (this._cursorIndex > this._cursorOffset) {
  7817. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7818. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7819. }
  7820. else {
  7821. this._isTextHighlightOn = false;
  7822. this._markAsDirty();
  7823. return;
  7824. }
  7825. }
  7826. this._isTextHighlightOn = true;
  7827. this._markAsDirty();
  7828. };
  7829. /** @hidden */
  7830. InputText.prototype._processDblClick = function (evt) {
  7831. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7832. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7833. this._endHighlightIndex = this._startHighlightIndex;
  7834. var rWord = /\w+/g, moveLeft, moveRight;
  7835. do {
  7836. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7837. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7838. } while (moveLeft || moveRight);
  7839. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7840. this.onTextHighlightObservable.notifyObservers(this);
  7841. this._isTextHighlightOn = true;
  7842. this._clickedCoordinate = null;
  7843. this._blinkIsEven = true;
  7844. this._cursorIndex = -1;
  7845. this._markAsDirty();
  7846. };
  7847. /** @hidden */
  7848. InputText.prototype._selectAllText = function () {
  7849. this._blinkIsEven = true;
  7850. this._isTextHighlightOn = true;
  7851. this._startHighlightIndex = 0;
  7852. this._endHighlightIndex = this._text.length;
  7853. this._cursorOffset = this._text.length;
  7854. this._cursorIndex = -1;
  7855. this._markAsDirty();
  7856. };
  7857. /**
  7858. * Handles the keyboard event
  7859. * @param evt Defines the KeyboardEvent
  7860. */
  7861. InputText.prototype.processKeyboard = function (evt) {
  7862. // process pressed key
  7863. this.processKey(evt.keyCode, evt.key, evt);
  7864. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7865. };
  7866. /** @hidden */
  7867. InputText.prototype._onCopyText = function (ev) {
  7868. this._isTextHighlightOn = false;
  7869. //when write permission to clipbaord data is denied
  7870. try {
  7871. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7872. }
  7873. catch (_a) { } //pass
  7874. this._host.clipboardData = this._highlightedText;
  7875. };
  7876. /** @hidden */
  7877. InputText.prototype._onCutText = function (ev) {
  7878. if (!this._highlightedText) {
  7879. return;
  7880. }
  7881. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7882. this._isTextHighlightOn = false;
  7883. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7884. //when write permission to clipbaord data is denied
  7885. try {
  7886. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7887. }
  7888. catch (_a) { } //pass
  7889. this._host.clipboardData = this._highlightedText;
  7890. this._highlightedText = "";
  7891. };
  7892. /** @hidden */
  7893. InputText.prototype._onPasteText = function (ev) {
  7894. var data = "";
  7895. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7896. data = ev.clipboardData.getData("text/plain");
  7897. }
  7898. else {
  7899. //get the cached data; returns blank string by default
  7900. data = this._host.clipboardData;
  7901. }
  7902. var insertPosition = this._text.length - this._cursorOffset;
  7903. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7904. };
  7905. InputText.prototype._draw = function (context, invalidatedRectangle) {
  7906. var _this = this;
  7907. context.save();
  7908. this._applyStates(context);
  7909. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7910. context.shadowColor = this.shadowColor;
  7911. context.shadowBlur = this.shadowBlur;
  7912. context.shadowOffsetX = this.shadowOffsetX;
  7913. context.shadowOffsetY = this.shadowOffsetY;
  7914. }
  7915. // Background
  7916. if (this._isFocused) {
  7917. if (this._focusedBackground) {
  7918. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7919. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7920. }
  7921. }
  7922. else if (this._background) {
  7923. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7924. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7925. }
  7926. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7927. context.shadowBlur = 0;
  7928. context.shadowOffsetX = 0;
  7929. context.shadowOffsetY = 0;
  7930. }
  7931. if (!this._fontOffset) {
  7932. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7933. }
  7934. // Text
  7935. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7936. if (this.color) {
  7937. context.fillStyle = this.color;
  7938. }
  7939. var text = this._beforeRenderText(this._text);
  7940. if (!this._isFocused && !this._text && this._placeholderText) {
  7941. text = this._placeholderText;
  7942. if (this._placeholderColor) {
  7943. context.fillStyle = this._placeholderColor;
  7944. }
  7945. }
  7946. this._textWidth = context.measureText(text).width;
  7947. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7948. if (this._autoStretchWidth) {
  7949. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7950. }
  7951. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7952. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7953. context.save();
  7954. context.beginPath();
  7955. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7956. context.clip();
  7957. if (this._isFocused && this._textWidth > availableWidth) {
  7958. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7959. if (!this._scrollLeft) {
  7960. this._scrollLeft = textLeft;
  7961. }
  7962. }
  7963. else {
  7964. this._scrollLeft = clipTextLeft;
  7965. }
  7966. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7967. // Cursor
  7968. if (this._isFocused) {
  7969. // Need to move cursor
  7970. if (this._clickedCoordinate) {
  7971. var rightPosition = this._scrollLeft + this._textWidth;
  7972. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7973. var currentSize = 0;
  7974. this._cursorOffset = 0;
  7975. var previousDist = 0;
  7976. do {
  7977. if (this._cursorOffset) {
  7978. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7979. }
  7980. this._cursorOffset++;
  7981. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7982. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7983. // Find closest move
  7984. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7985. this._cursorOffset--;
  7986. }
  7987. this._blinkIsEven = false;
  7988. this._clickedCoordinate = null;
  7989. }
  7990. // Render cursor
  7991. if (!this._blinkIsEven) {
  7992. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7993. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7994. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7995. if (cursorLeft < clipTextLeft) {
  7996. this._scrollLeft += (clipTextLeft - cursorLeft);
  7997. cursorLeft = clipTextLeft;
  7998. this._markAsDirty();
  7999. }
  8000. else if (cursorLeft > clipTextLeft + availableWidth) {
  8001. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  8002. cursorLeft = clipTextLeft + availableWidth;
  8003. this._markAsDirty();
  8004. }
  8005. if (!this._isTextHighlightOn) {
  8006. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  8007. }
  8008. }
  8009. clearTimeout(this._blinkTimeout);
  8010. this._blinkTimeout = setTimeout(function () {
  8011. _this._blinkIsEven = !_this._blinkIsEven;
  8012. _this._markAsDirty();
  8013. }, 500);
  8014. //show the highlighted text
  8015. if (this._isTextHighlightOn) {
  8016. clearTimeout(this._blinkTimeout);
  8017. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  8018. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  8019. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  8020. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  8021. if (highlightCursorLeft < clipTextLeft) {
  8022. width = width - (clipTextLeft - highlightCursorLeft);
  8023. if (!width) {
  8024. // when using left arrow on text.length > availableWidth;
  8025. // assigns the width of the first letter after clipTextLeft
  8026. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  8027. }
  8028. highlightCursorLeft = clipTextLeft;
  8029. }
  8030. //for transparancy
  8031. context.globalAlpha = this._highligherOpacity;
  8032. context.fillStyle = this._textHighlightColor;
  8033. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  8034. context.globalAlpha = 1.0;
  8035. }
  8036. }
  8037. context.restore();
  8038. // Border
  8039. if (this._thickness) {
  8040. if (this._isFocused) {
  8041. if (this.focusedColor) {
  8042. context.strokeStyle = this.focusedColor;
  8043. }
  8044. }
  8045. else {
  8046. if (this.color) {
  8047. context.strokeStyle = this.color;
  8048. }
  8049. }
  8050. context.lineWidth = this._thickness;
  8051. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8052. }
  8053. context.restore();
  8054. };
  8055. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8056. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8057. return false;
  8058. }
  8059. this._clickedCoordinate = coordinates.x;
  8060. this._isTextHighlightOn = false;
  8061. this._highlightedText = "";
  8062. this._cursorIndex = -1;
  8063. this._isPointerDown = true;
  8064. this._host._capturingControl[pointerId] = this;
  8065. if (this._host.focusedControl === this) {
  8066. // Move cursor
  8067. clearTimeout(this._blinkTimeout);
  8068. this._markAsDirty();
  8069. return true;
  8070. }
  8071. if (!this._isEnabled) {
  8072. return false;
  8073. }
  8074. this._host.focusedControl = this;
  8075. return true;
  8076. };
  8077. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  8078. if (this._host.focusedControl === this && this._isPointerDown) {
  8079. this._clickedCoordinate = coordinates.x;
  8080. this._markAsDirty();
  8081. this._updateValueFromCursorIndex(this._cursorOffset);
  8082. }
  8083. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  8084. };
  8085. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  8086. this._isPointerDown = false;
  8087. delete this._host._capturingControl[pointerId];
  8088. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  8089. };
  8090. InputText.prototype._beforeRenderText = function (text) {
  8091. return text;
  8092. };
  8093. InputText.prototype.dispose = function () {
  8094. _super.prototype.dispose.call(this);
  8095. this.onBlurObservable.clear();
  8096. this.onFocusObservable.clear();
  8097. this.onTextChangedObservable.clear();
  8098. this.onTextCopyObservable.clear();
  8099. this.onTextCutObservable.clear();
  8100. this.onTextPasteObservable.clear();
  8101. this.onTextHighlightObservable.clear();
  8102. this.onKeyboardEventProcessedObservable.clear();
  8103. };
  8104. return InputText;
  8105. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8106. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  8107. /***/ }),
  8108. /***/ "./2D/controls/line.ts":
  8109. /*!*****************************!*\
  8110. !*** ./2D/controls/line.ts ***!
  8111. \*****************************/
  8112. /*! exports provided: Line */
  8113. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8114. "use strict";
  8115. __webpack_require__.r(__webpack_exports__);
  8116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  8117. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8118. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  8119. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  8120. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8121. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  8122. /** Class used to render 2D lines */
  8123. var Line = /** @class */ (function (_super) {
  8124. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8125. /**
  8126. * Creates a new Line
  8127. * @param name defines the control name
  8128. */
  8129. function Line(name) {
  8130. var _this = _super.call(this, name) || this;
  8131. _this.name = name;
  8132. _this._lineWidth = 1;
  8133. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8134. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8135. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8136. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8137. _this._dash = new Array();
  8138. _this._automaticSize = true;
  8139. _this.isHitTestVisible = false;
  8140. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8141. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8142. return _this;
  8143. }
  8144. Object.defineProperty(Line.prototype, "dash", {
  8145. /** Gets or sets the dash pattern */
  8146. get: function () {
  8147. return this._dash;
  8148. },
  8149. set: function (value) {
  8150. if (this._dash === value) {
  8151. return;
  8152. }
  8153. this._dash = value;
  8154. this._markAsDirty();
  8155. },
  8156. enumerable: true,
  8157. configurable: true
  8158. });
  8159. Object.defineProperty(Line.prototype, "connectedControl", {
  8160. /** Gets or sets the control connected with the line end */
  8161. get: function () {
  8162. return this._connectedControl;
  8163. },
  8164. set: function (value) {
  8165. var _this = this;
  8166. if (this._connectedControl === value) {
  8167. return;
  8168. }
  8169. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8170. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8171. this._connectedControlDirtyObserver = null;
  8172. }
  8173. if (value) {
  8174. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8175. }
  8176. this._connectedControl = value;
  8177. this._markAsDirty();
  8178. },
  8179. enumerable: true,
  8180. configurable: true
  8181. });
  8182. Object.defineProperty(Line.prototype, "x1", {
  8183. /** Gets or sets start coordinates on X axis */
  8184. get: function () {
  8185. return this._x1.toString(this._host);
  8186. },
  8187. set: function (value) {
  8188. if (this._x1.toString(this._host) === value) {
  8189. return;
  8190. }
  8191. if (this._x1.fromString(value)) {
  8192. this._markAsDirty();
  8193. }
  8194. },
  8195. enumerable: true,
  8196. configurable: true
  8197. });
  8198. Object.defineProperty(Line.prototype, "y1", {
  8199. /** Gets or sets start coordinates on Y axis */
  8200. get: function () {
  8201. return this._y1.toString(this._host);
  8202. },
  8203. set: function (value) {
  8204. if (this._y1.toString(this._host) === value) {
  8205. return;
  8206. }
  8207. if (this._y1.fromString(value)) {
  8208. this._markAsDirty();
  8209. }
  8210. },
  8211. enumerable: true,
  8212. configurable: true
  8213. });
  8214. Object.defineProperty(Line.prototype, "x2", {
  8215. /** Gets or sets end coordinates on X axis */
  8216. get: function () {
  8217. return this._x2.toString(this._host);
  8218. },
  8219. set: function (value) {
  8220. if (this._x2.toString(this._host) === value) {
  8221. return;
  8222. }
  8223. if (this._x2.fromString(value)) {
  8224. this._markAsDirty();
  8225. }
  8226. },
  8227. enumerable: true,
  8228. configurable: true
  8229. });
  8230. Object.defineProperty(Line.prototype, "y2", {
  8231. /** Gets or sets end coordinates on Y axis */
  8232. get: function () {
  8233. return this._y2.toString(this._host);
  8234. },
  8235. set: function (value) {
  8236. if (this._y2.toString(this._host) === value) {
  8237. return;
  8238. }
  8239. if (this._y2.fromString(value)) {
  8240. this._markAsDirty();
  8241. }
  8242. },
  8243. enumerable: true,
  8244. configurable: true
  8245. });
  8246. Object.defineProperty(Line.prototype, "lineWidth", {
  8247. /** Gets or sets line width */
  8248. get: function () {
  8249. return this._lineWidth;
  8250. },
  8251. set: function (value) {
  8252. if (this._lineWidth === value) {
  8253. return;
  8254. }
  8255. this._lineWidth = value;
  8256. this._markAsDirty();
  8257. },
  8258. enumerable: true,
  8259. configurable: true
  8260. });
  8261. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8262. /** Gets or sets horizontal alignment */
  8263. set: function (value) {
  8264. return;
  8265. },
  8266. enumerable: true,
  8267. configurable: true
  8268. });
  8269. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8270. /** Gets or sets vertical alignment */
  8271. set: function (value) {
  8272. return;
  8273. },
  8274. enumerable: true,
  8275. configurable: true
  8276. });
  8277. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8278. get: function () {
  8279. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8280. },
  8281. enumerable: true,
  8282. configurable: true
  8283. });
  8284. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8285. get: function () {
  8286. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8287. },
  8288. enumerable: true,
  8289. configurable: true
  8290. });
  8291. Line.prototype._getTypeName = function () {
  8292. return "Line";
  8293. };
  8294. Line.prototype._draw = function (context) {
  8295. context.save();
  8296. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8297. context.shadowColor = this.shadowColor;
  8298. context.shadowBlur = this.shadowBlur;
  8299. context.shadowOffsetX = this.shadowOffsetX;
  8300. context.shadowOffsetY = this.shadowOffsetY;
  8301. }
  8302. this._applyStates(context);
  8303. context.strokeStyle = this.color;
  8304. context.lineWidth = this._lineWidth;
  8305. context.setLineDash(this._dash);
  8306. context.beginPath();
  8307. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8308. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8309. context.stroke();
  8310. context.restore();
  8311. };
  8312. Line.prototype._measure = function () {
  8313. // Width / Height
  8314. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8315. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8316. };
  8317. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8318. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8319. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8320. };
  8321. /**
  8322. * Move one end of the line given 3D cartesian coordinates.
  8323. * @param position Targeted world position
  8324. * @param scene Scene
  8325. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8326. */
  8327. Line.prototype.moveToVector3 = function (position, scene, end) {
  8328. if (end === void 0) { end = false; }
  8329. if (!this._host || this.parent !== this._host._rootContainer) {
  8330. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8331. return;
  8332. }
  8333. var globalViewport = this._host._getGlobalViewport(scene);
  8334. var projectedPosition = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8335. this._moveToProjectedPosition(projectedPosition, end);
  8336. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8337. this.notRenderable = true;
  8338. return;
  8339. }
  8340. this.notRenderable = false;
  8341. };
  8342. /**
  8343. * Move one end of the line to a position in screen absolute space.
  8344. * @param projectedPosition Position in screen absolute space (X, Y)
  8345. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8346. */
  8347. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8348. if (end === void 0) { end = false; }
  8349. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8350. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8351. if (end) {
  8352. this.x2 = x;
  8353. this.y2 = y;
  8354. this._x2.ignoreAdaptiveScaling = true;
  8355. this._y2.ignoreAdaptiveScaling = true;
  8356. }
  8357. else {
  8358. this.x1 = x;
  8359. this.y1 = y;
  8360. this._x1.ignoreAdaptiveScaling = true;
  8361. this._y1.ignoreAdaptiveScaling = true;
  8362. }
  8363. };
  8364. return Line;
  8365. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8366. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8367. /***/ }),
  8368. /***/ "./2D/controls/multiLine.ts":
  8369. /*!**********************************!*\
  8370. !*** ./2D/controls/multiLine.ts ***!
  8371. \**********************************/
  8372. /*! exports provided: MultiLine */
  8373. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8374. "use strict";
  8375. __webpack_require__.r(__webpack_exports__);
  8376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8377. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8378. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/perfCounter");
  8379. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8380. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8381. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8382. /**
  8383. * Class used to create multi line control
  8384. */
  8385. var MultiLine = /** @class */ (function (_super) {
  8386. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8387. /**
  8388. * Creates a new MultiLine
  8389. * @param name defines the control name
  8390. */
  8391. function MultiLine(name) {
  8392. var _this = _super.call(this, name) || this;
  8393. _this.name = name;
  8394. _this._lineWidth = 1;
  8395. /** Function called when a point is updated */
  8396. _this.onPointUpdate = function () {
  8397. _this._markAsDirty();
  8398. };
  8399. _this._automaticSize = true;
  8400. _this.isHitTestVisible = false;
  8401. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8402. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8403. _this._dash = [];
  8404. _this._points = [];
  8405. return _this;
  8406. }
  8407. Object.defineProperty(MultiLine.prototype, "dash", {
  8408. /** Gets or sets dash pattern */
  8409. get: function () {
  8410. return this._dash;
  8411. },
  8412. set: function (value) {
  8413. if (this._dash === value) {
  8414. return;
  8415. }
  8416. this._dash = value;
  8417. this._markAsDirty();
  8418. },
  8419. enumerable: true,
  8420. configurable: true
  8421. });
  8422. /**
  8423. * Gets point stored at specified index
  8424. * @param index defines the index to look for
  8425. * @returns the requested point if found
  8426. */
  8427. MultiLine.prototype.getAt = function (index) {
  8428. if (!this._points[index]) {
  8429. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8430. }
  8431. return this._points[index];
  8432. };
  8433. /**
  8434. * Adds new points to the point collection
  8435. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8436. * @returns the list of created MultiLinePoint
  8437. */
  8438. MultiLine.prototype.add = function () {
  8439. var _this = this;
  8440. var items = [];
  8441. for (var _i = 0; _i < arguments.length; _i++) {
  8442. items[_i] = arguments[_i];
  8443. }
  8444. return items.map(function (item) { return _this.push(item); });
  8445. };
  8446. /**
  8447. * Adds a new point to the point collection
  8448. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8449. * @returns the created MultiLinePoint
  8450. */
  8451. MultiLine.prototype.push = function (item) {
  8452. var point = this.getAt(this._points.length);
  8453. if (item == null) {
  8454. return point;
  8455. }
  8456. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8457. point.mesh = item;
  8458. }
  8459. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8460. point.control = item;
  8461. }
  8462. else if (item.x != null && item.y != null) {
  8463. point.x = item.x;
  8464. point.y = item.y;
  8465. }
  8466. return point;
  8467. };
  8468. /**
  8469. * Remove a specific value or point from the active point collection
  8470. * @param value defines the value or point to remove
  8471. */
  8472. MultiLine.prototype.remove = function (value) {
  8473. var index;
  8474. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8475. index = this._points.indexOf(value);
  8476. if (index === -1) {
  8477. return;
  8478. }
  8479. }
  8480. else {
  8481. index = value;
  8482. }
  8483. var point = this._points[index];
  8484. if (!point) {
  8485. return;
  8486. }
  8487. point.dispose();
  8488. this._points.splice(index, 1);
  8489. };
  8490. /**
  8491. * Resets this object to initial state (no point)
  8492. */
  8493. MultiLine.prototype.reset = function () {
  8494. while (this._points.length > 0) {
  8495. this.remove(this._points.length - 1);
  8496. }
  8497. };
  8498. /**
  8499. * Resets all links
  8500. */
  8501. MultiLine.prototype.resetLinks = function () {
  8502. this._points.forEach(function (point) {
  8503. if (point != null) {
  8504. point.resetLinks();
  8505. }
  8506. });
  8507. };
  8508. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8509. /** Gets or sets line width */
  8510. get: function () {
  8511. return this._lineWidth;
  8512. },
  8513. set: function (value) {
  8514. if (this._lineWidth === value) {
  8515. return;
  8516. }
  8517. this._lineWidth = value;
  8518. this._markAsDirty();
  8519. },
  8520. enumerable: true,
  8521. configurable: true
  8522. });
  8523. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8524. set: function (value) {
  8525. return;
  8526. },
  8527. enumerable: true,
  8528. configurable: true
  8529. });
  8530. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8531. set: function (value) {
  8532. return;
  8533. },
  8534. enumerable: true,
  8535. configurable: true
  8536. });
  8537. MultiLine.prototype._getTypeName = function () {
  8538. return "MultiLine";
  8539. };
  8540. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8541. context.save();
  8542. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8543. context.shadowColor = this.shadowColor;
  8544. context.shadowBlur = this.shadowBlur;
  8545. context.shadowOffsetX = this.shadowOffsetX;
  8546. context.shadowOffsetY = this.shadowOffsetY;
  8547. }
  8548. this._applyStates(context);
  8549. context.strokeStyle = this.color;
  8550. context.lineWidth = this._lineWidth;
  8551. context.setLineDash(this._dash);
  8552. context.beginPath();
  8553. var first = true; //first index is not necessarily 0
  8554. this._points.forEach(function (point) {
  8555. if (!point) {
  8556. return;
  8557. }
  8558. if (first) {
  8559. context.moveTo(point._point.x, point._point.y);
  8560. first = false;
  8561. }
  8562. else {
  8563. context.lineTo(point._point.x, point._point.y);
  8564. }
  8565. });
  8566. context.stroke();
  8567. context.restore();
  8568. };
  8569. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8570. var _this = this;
  8571. this._minX = null;
  8572. this._minY = null;
  8573. this._maxX = null;
  8574. this._maxY = null;
  8575. this._points.forEach(function (point, index) {
  8576. if (!point) {
  8577. return;
  8578. }
  8579. point.translate();
  8580. if (_this._minX == null || point._point.x < _this._minX) {
  8581. _this._minX = point._point.x;
  8582. }
  8583. if (_this._minY == null || point._point.y < _this._minY) {
  8584. _this._minY = point._point.y;
  8585. }
  8586. if (_this._maxX == null || point._point.x > _this._maxX) {
  8587. _this._maxX = point._point.x;
  8588. }
  8589. if (_this._maxY == null || point._point.y > _this._maxY) {
  8590. _this._maxY = point._point.y;
  8591. }
  8592. });
  8593. if (this._minX == null) {
  8594. this._minX = 0;
  8595. }
  8596. if (this._minY == null) {
  8597. this._minY = 0;
  8598. }
  8599. if (this._maxX == null) {
  8600. this._maxX = 0;
  8601. }
  8602. if (this._maxY == null) {
  8603. this._maxY = 0;
  8604. }
  8605. };
  8606. MultiLine.prototype._measure = function () {
  8607. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8608. return;
  8609. }
  8610. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8611. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8612. };
  8613. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8614. if (this._minX == null || this._minY == null) {
  8615. return;
  8616. }
  8617. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8618. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8619. };
  8620. MultiLine.prototype.dispose = function () {
  8621. this.reset();
  8622. _super.prototype.dispose.call(this);
  8623. };
  8624. return MultiLine;
  8625. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8626. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8627. /***/ }),
  8628. /***/ "./2D/controls/radioButton.ts":
  8629. /*!************************************!*\
  8630. !*** ./2D/controls/radioButton.ts ***!
  8631. \************************************/
  8632. /*! exports provided: RadioButton */
  8633. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8634. "use strict";
  8635. __webpack_require__.r(__webpack_exports__);
  8636. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8637. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8638. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  8639. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8640. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8641. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8642. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8643. /**
  8644. * Class used to create radio button controls
  8645. */
  8646. var RadioButton = /** @class */ (function (_super) {
  8647. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8648. /**
  8649. * Creates a new RadioButton
  8650. * @param name defines the control name
  8651. */
  8652. function RadioButton(name) {
  8653. var _this = _super.call(this, name) || this;
  8654. _this.name = name;
  8655. _this._isChecked = false;
  8656. _this._background = "black";
  8657. _this._checkSizeRatio = 0.8;
  8658. _this._thickness = 1;
  8659. /** Gets or sets group name */
  8660. _this.group = "";
  8661. /** Observable raised when isChecked is changed */
  8662. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8663. _this.isPointerBlocker = true;
  8664. return _this;
  8665. }
  8666. Object.defineProperty(RadioButton.prototype, "thickness", {
  8667. /** Gets or sets border thickness */
  8668. get: function () {
  8669. return this._thickness;
  8670. },
  8671. set: function (value) {
  8672. if (this._thickness === value) {
  8673. return;
  8674. }
  8675. this._thickness = value;
  8676. this._markAsDirty();
  8677. },
  8678. enumerable: true,
  8679. configurable: true
  8680. });
  8681. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8682. /** Gets or sets a value indicating the ratio between overall size and check size */
  8683. get: function () {
  8684. return this._checkSizeRatio;
  8685. },
  8686. set: function (value) {
  8687. value = Math.max(Math.min(1, value), 0);
  8688. if (this._checkSizeRatio === value) {
  8689. return;
  8690. }
  8691. this._checkSizeRatio = value;
  8692. this._markAsDirty();
  8693. },
  8694. enumerable: true,
  8695. configurable: true
  8696. });
  8697. Object.defineProperty(RadioButton.prototype, "background", {
  8698. /** Gets or sets background color */
  8699. get: function () {
  8700. return this._background;
  8701. },
  8702. set: function (value) {
  8703. if (this._background === value) {
  8704. return;
  8705. }
  8706. this._background = value;
  8707. this._markAsDirty();
  8708. },
  8709. enumerable: true,
  8710. configurable: true
  8711. });
  8712. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8713. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8714. get: function () {
  8715. return this._isChecked;
  8716. },
  8717. set: function (value) {
  8718. var _this = this;
  8719. if (this._isChecked === value) {
  8720. return;
  8721. }
  8722. this._isChecked = value;
  8723. this._markAsDirty();
  8724. this.onIsCheckedChangedObservable.notifyObservers(value);
  8725. if (this._isChecked && this._host) {
  8726. // Update all controls from same group
  8727. this._host.executeOnAllControls(function (control) {
  8728. if (control === _this) {
  8729. return;
  8730. }
  8731. if (control.group === undefined) {
  8732. return;
  8733. }
  8734. var childRadio = control;
  8735. if (childRadio.group === _this.group) {
  8736. childRadio.isChecked = false;
  8737. }
  8738. });
  8739. }
  8740. },
  8741. enumerable: true,
  8742. configurable: true
  8743. });
  8744. RadioButton.prototype._getTypeName = function () {
  8745. return "RadioButton";
  8746. };
  8747. RadioButton.prototype._draw = function (context) {
  8748. context.save();
  8749. this._applyStates(context);
  8750. var actualWidth = this._currentMeasure.width - this._thickness;
  8751. var actualHeight = this._currentMeasure.height - this._thickness;
  8752. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8753. context.shadowColor = this.shadowColor;
  8754. context.shadowBlur = this.shadowBlur;
  8755. context.shadowOffsetX = this.shadowOffsetX;
  8756. context.shadowOffsetY = this.shadowOffsetY;
  8757. }
  8758. // Outer
  8759. _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);
  8760. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8761. context.fill();
  8762. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8763. context.shadowBlur = 0;
  8764. context.shadowOffsetX = 0;
  8765. context.shadowOffsetY = 0;
  8766. }
  8767. context.strokeStyle = this.color;
  8768. context.lineWidth = this._thickness;
  8769. context.stroke();
  8770. // Inner
  8771. if (this._isChecked) {
  8772. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8773. var offsetWidth = actualWidth * this._checkSizeRatio;
  8774. var offseHeight = actualHeight * this._checkSizeRatio;
  8775. _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);
  8776. context.fill();
  8777. }
  8778. context.restore();
  8779. };
  8780. // Events
  8781. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8782. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8783. return false;
  8784. }
  8785. if (!this.isChecked) {
  8786. this.isChecked = true;
  8787. }
  8788. return true;
  8789. };
  8790. /**
  8791. * Utility function to easily create a radio button with a header
  8792. * @param title defines the label to use for the header
  8793. * @param group defines the group to use for the radio button
  8794. * @param isChecked defines the initial state of the radio button
  8795. * @param onValueChanged defines the callback to call when value changes
  8796. * @returns a StackPanel containing the radio button and a textBlock
  8797. */
  8798. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8799. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8800. panel.isVertical = false;
  8801. panel.height = "30px";
  8802. var radio = new RadioButton();
  8803. radio.width = "20px";
  8804. radio.height = "20px";
  8805. radio.isChecked = isChecked;
  8806. radio.color = "green";
  8807. radio.group = group;
  8808. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8809. panel.addControl(radio);
  8810. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8811. header.text = title;
  8812. header.width = "180px";
  8813. header.paddingLeft = "5px";
  8814. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8815. header.color = "white";
  8816. panel.addControl(header);
  8817. return panel;
  8818. };
  8819. return RadioButton;
  8820. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8821. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8822. /***/ }),
  8823. /***/ "./2D/controls/rectangle.ts":
  8824. /*!**********************************!*\
  8825. !*** ./2D/controls/rectangle.ts ***!
  8826. \**********************************/
  8827. /*! exports provided: Rectangle */
  8828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8829. "use strict";
  8830. __webpack_require__.r(__webpack_exports__);
  8831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8832. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8833. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8834. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  8835. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8836. /** Class used to create rectangle container */
  8837. var Rectangle = /** @class */ (function (_super) {
  8838. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8839. /**
  8840. * Creates a new Rectangle
  8841. * @param name defines the control name
  8842. */
  8843. function Rectangle(name) {
  8844. var _this = _super.call(this, name) || this;
  8845. _this.name = name;
  8846. _this._thickness = 1;
  8847. _this._cornerRadius = 0;
  8848. return _this;
  8849. }
  8850. Object.defineProperty(Rectangle.prototype, "thickness", {
  8851. /** Gets or sets border thickness */
  8852. get: function () {
  8853. return this._thickness;
  8854. },
  8855. set: function (value) {
  8856. if (this._thickness === value) {
  8857. return;
  8858. }
  8859. this._thickness = value;
  8860. this._markAsDirty();
  8861. },
  8862. enumerable: true,
  8863. configurable: true
  8864. });
  8865. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8866. /** Gets or sets the corner radius angle */
  8867. get: function () {
  8868. return this._cornerRadius;
  8869. },
  8870. set: function (value) {
  8871. if (value < 0) {
  8872. value = 0;
  8873. }
  8874. if (this._cornerRadius === value) {
  8875. return;
  8876. }
  8877. this._cornerRadius = value;
  8878. this._markAsDirty();
  8879. },
  8880. enumerable: true,
  8881. configurable: true
  8882. });
  8883. Rectangle.prototype._getTypeName = function () {
  8884. return "Rectangle";
  8885. };
  8886. Rectangle.prototype._localDraw = function (context) {
  8887. context.save();
  8888. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8889. context.shadowColor = this.shadowColor;
  8890. context.shadowBlur = this.shadowBlur;
  8891. context.shadowOffsetX = this.shadowOffsetX;
  8892. context.shadowOffsetY = this.shadowOffsetY;
  8893. }
  8894. if (this._background) {
  8895. context.fillStyle = this._background;
  8896. if (this._cornerRadius) {
  8897. this._drawRoundedRect(context, this._thickness / 2);
  8898. context.fill();
  8899. }
  8900. else {
  8901. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8902. }
  8903. }
  8904. if (this._thickness) {
  8905. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8906. context.shadowBlur = 0;
  8907. context.shadowOffsetX = 0;
  8908. context.shadowOffsetY = 0;
  8909. }
  8910. if (this.color) {
  8911. context.strokeStyle = this.color;
  8912. }
  8913. context.lineWidth = this._thickness;
  8914. if (this._cornerRadius) {
  8915. this._drawRoundedRect(context, this._thickness / 2);
  8916. context.stroke();
  8917. }
  8918. else {
  8919. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8920. }
  8921. }
  8922. context.restore();
  8923. };
  8924. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8925. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8926. this._measureForChildren.width -= 2 * this._thickness;
  8927. this._measureForChildren.height -= 2 * this._thickness;
  8928. this._measureForChildren.left += this._thickness;
  8929. this._measureForChildren.top += this._thickness;
  8930. };
  8931. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8932. if (offset === void 0) { offset = 0; }
  8933. var x = this._currentMeasure.left + offset;
  8934. var y = this._currentMeasure.top + offset;
  8935. var width = this._currentMeasure.width - offset * 2;
  8936. var height = this._currentMeasure.height - offset * 2;
  8937. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8938. context.beginPath();
  8939. context.moveTo(x + radius, y);
  8940. context.lineTo(x + width - radius, y);
  8941. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8942. context.lineTo(x + width, y + height - radius);
  8943. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8944. context.lineTo(x + radius, y + height);
  8945. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8946. context.lineTo(x, y + radius);
  8947. context.quadraticCurveTo(x, y, x + radius, y);
  8948. context.closePath();
  8949. };
  8950. Rectangle.prototype._clipForChildren = function (context) {
  8951. if (this._cornerRadius) {
  8952. this._drawRoundedRect(context, this._thickness);
  8953. context.clip();
  8954. }
  8955. };
  8956. return Rectangle;
  8957. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8958. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  8959. /***/ }),
  8960. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8961. /*!***************************************************!*\
  8962. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8963. \***************************************************/
  8964. /*! exports provided: ScrollViewer */
  8965. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8966. "use strict";
  8967. __webpack_require__.r(__webpack_exports__);
  8968. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8969. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8970. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8971. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8972. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8973. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8974. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8975. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  8976. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  8977. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__);
  8978. /**
  8979. * Class used to hold a viewer window and sliders in a grid
  8980. */
  8981. var ScrollViewer = /** @class */ (function (_super) {
  8982. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  8983. /**
  8984. * Creates a new ScrollViewer
  8985. * @param name of ScrollViewer
  8986. */
  8987. function ScrollViewer(name, isImageBased) {
  8988. var _this = _super.call(this, name) || this;
  8989. _this._barSize = 20;
  8990. _this._pointerIsOver = false;
  8991. _this._wheelPrecision = 0.05;
  8992. _this._thumbLength = 0.5;
  8993. _this._thumbHeight = 1;
  8994. _this._barImageHeight = 1;
  8995. _this._horizontalBarImageHeight = 1;
  8996. _this._verticalBarImageHeight = 1;
  8997. _this._forceHorizontalBar = false;
  8998. _this._forceVerticalBar = false;
  8999. _this._useImageBar = isImageBased ? isImageBased : false;
  9000. _this.onDirtyObservable.add(function () {
  9001. _this._horizontalBarSpace.color = _this.color;
  9002. _this._verticalBarSpace.color = _this.color;
  9003. _this._dragSpace.color = _this.color;
  9004. });
  9005. _this.onPointerEnterObservable.add(function () {
  9006. _this._pointerIsOver = true;
  9007. });
  9008. _this.onPointerOutObservable.add(function () {
  9009. _this._pointerIsOver = false;
  9010. });
  9011. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_2__["Grid"]();
  9012. if (_this._useImageBar) {
  9013. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9014. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9015. }
  9016. else {
  9017. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9018. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9019. }
  9020. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__["_ScrollViewerWindow"]("scrollViewer_window");
  9021. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9022. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9023. _this._grid.addColumnDefinition(1);
  9024. _this._grid.addColumnDefinition(0, true);
  9025. _this._grid.addRowDefinition(1);
  9026. _this._grid.addRowDefinition(0, true);
  9027. _super.prototype.addControl.call(_this, _this._grid);
  9028. _this._grid.addControl(_this._window, 0, 0);
  9029. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9030. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9031. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9032. _this._verticalBarSpace.thickness = 1;
  9033. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  9034. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  9035. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9036. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9037. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9038. _this._horizontalBarSpace.thickness = 1;
  9039. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  9040. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  9041. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9042. _this._dragSpace.thickness = 1;
  9043. _this._grid.addControl(_this._dragSpace, 1, 1);
  9044. // Colors
  9045. if (!_this._useImageBar) {
  9046. _this.barColor = "grey";
  9047. _this.barBackground = "transparent";
  9048. }
  9049. return _this;
  9050. }
  9051. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  9052. /**
  9053. * Gets the horizontal scrollbar
  9054. */
  9055. get: function () {
  9056. return this._horizontalBar;
  9057. },
  9058. enumerable: true,
  9059. configurable: true
  9060. });
  9061. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  9062. /**
  9063. * Gets the vertical scrollbar
  9064. */
  9065. get: function () {
  9066. return this._verticalBar;
  9067. },
  9068. enumerable: true,
  9069. configurable: true
  9070. });
  9071. /**
  9072. * Adds a new control to the current container
  9073. * @param control defines the control to add
  9074. * @returns the current container
  9075. */
  9076. ScrollViewer.prototype.addControl = function (control) {
  9077. if (!control) {
  9078. return this;
  9079. }
  9080. this._window.addControl(control);
  9081. return this;
  9082. };
  9083. /**
  9084. * Removes a control from the current container
  9085. * @param control defines the control to remove
  9086. * @returns the current container
  9087. */
  9088. ScrollViewer.prototype.removeControl = function (control) {
  9089. this._window.removeControl(control);
  9090. return this;
  9091. };
  9092. Object.defineProperty(ScrollViewer.prototype, "children", {
  9093. /** Gets the list of children */
  9094. get: function () {
  9095. return this._window.children;
  9096. },
  9097. enumerable: true,
  9098. configurable: true
  9099. });
  9100. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  9101. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9102. var child = _a[_i];
  9103. child._markMatrixAsDirty();
  9104. }
  9105. };
  9106. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  9107. /**
  9108. * Freezes or unfreezes the controls in the window.
  9109. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  9110. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  9111. */
  9112. get: function () {
  9113. return this._window.freezeControls;
  9114. },
  9115. set: function (value) {
  9116. this._window.freezeControls = value;
  9117. },
  9118. enumerable: true,
  9119. configurable: true
  9120. });
  9121. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  9122. /** Gets the bucket width */
  9123. get: function () {
  9124. return this._window.bucketWidth;
  9125. },
  9126. enumerable: true,
  9127. configurable: true
  9128. });
  9129. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9130. /** Gets the bucket height */
  9131. get: function () {
  9132. return this._window.bucketHeight;
  9133. },
  9134. enumerable: true,
  9135. configurable: true
  9136. });
  9137. /**
  9138. * Sets the bucket sizes.
  9139. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9140. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9141. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9142. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9143. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9144. * used), that's why it is not enabled by default.
  9145. * @param width width of the bucket
  9146. * @param height height of the bucket
  9147. */
  9148. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9149. this._window.setBucketSizes(width, height);
  9150. };
  9151. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9152. /**
  9153. * Forces the horizontal scroll bar to be displayed
  9154. */
  9155. get: function () {
  9156. return this._forceHorizontalBar;
  9157. },
  9158. set: function (value) {
  9159. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9160. this._horizontalBar.isVisible = value;
  9161. this._forceHorizontalBar = value;
  9162. },
  9163. enumerable: true,
  9164. configurable: true
  9165. });
  9166. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9167. /**
  9168. * Forces the vertical scroll bar to be displayed
  9169. */
  9170. get: function () {
  9171. return this._forceVerticalBar;
  9172. },
  9173. set: function (value) {
  9174. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9175. this._verticalBar.isVisible = value;
  9176. this._forceVerticalBar = value;
  9177. },
  9178. enumerable: true,
  9179. configurable: true
  9180. });
  9181. /** Reset the scroll viewer window to initial size */
  9182. ScrollViewer.prototype.resetWindow = function () {
  9183. this._window.width = "100%";
  9184. this._window.height = "100%";
  9185. };
  9186. ScrollViewer.prototype._getTypeName = function () {
  9187. return "ScrollViewer";
  9188. };
  9189. ScrollViewer.prototype._buildClientSizes = function () {
  9190. var ratio = this.host.idealRatio;
  9191. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9192. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9193. this._clientWidth = this._window.parentClientWidth;
  9194. this._clientHeight = this._window.parentClientHeight;
  9195. };
  9196. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  9197. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9198. this._buildClientSizes();
  9199. };
  9200. ScrollViewer.prototype._postMeasure = function () {
  9201. _super.prototype._postMeasure.call(this);
  9202. this._updateScroller();
  9203. };
  9204. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  9205. /**
  9206. * Gets or sets the mouse wheel precision
  9207. * from 0 to 1 with a default value of 0.05
  9208. * */
  9209. get: function () {
  9210. return this._wheelPrecision;
  9211. },
  9212. set: function (value) {
  9213. if (this._wheelPrecision === value) {
  9214. return;
  9215. }
  9216. if (value < 0) {
  9217. value = 0;
  9218. }
  9219. if (value > 1) {
  9220. value = 1;
  9221. }
  9222. this._wheelPrecision = value;
  9223. },
  9224. enumerable: true,
  9225. configurable: true
  9226. });
  9227. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  9228. /** Gets or sets the scroll bar container background color */
  9229. get: function () {
  9230. return this._horizontalBarSpace.background;
  9231. },
  9232. set: function (color) {
  9233. if (this._horizontalBarSpace.background === color) {
  9234. return;
  9235. }
  9236. this._horizontalBarSpace.background = color;
  9237. this._verticalBarSpace.background = color;
  9238. },
  9239. enumerable: true,
  9240. configurable: true
  9241. });
  9242. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9243. /** Gets or sets the bar color */
  9244. get: function () {
  9245. return this._barColor;
  9246. },
  9247. set: function (color) {
  9248. if (this._barColor === color) {
  9249. return;
  9250. }
  9251. this._barColor = color;
  9252. this._horizontalBar.color = color;
  9253. this._verticalBar.color = color;
  9254. },
  9255. enumerable: true,
  9256. configurable: true
  9257. });
  9258. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9259. /** Gets or sets the bar image */
  9260. get: function () {
  9261. return this._barImage;
  9262. },
  9263. set: function (value) {
  9264. if (this._barImage === value) {
  9265. return;
  9266. }
  9267. this._barImage = value;
  9268. var hb = this._horizontalBar;
  9269. var vb = this._verticalBar;
  9270. hb.thumbImage = value;
  9271. vb.thumbImage = value;
  9272. },
  9273. enumerable: true,
  9274. configurable: true
  9275. });
  9276. Object.defineProperty(ScrollViewer.prototype, "horizontalThumbImage", {
  9277. /** Gets or sets the horizontal bar image */
  9278. get: function () {
  9279. return this._horizontalBarImage;
  9280. },
  9281. set: function (value) {
  9282. if (this._horizontalBarImage === value) {
  9283. return;
  9284. }
  9285. this._horizontalBarImage = value;
  9286. var hb = this._horizontalBar;
  9287. hb.thumbImage = value;
  9288. },
  9289. enumerable: true,
  9290. configurable: true
  9291. });
  9292. Object.defineProperty(ScrollViewer.prototype, "verticalThumbImage", {
  9293. /** Gets or sets the vertical bar image */
  9294. get: function () {
  9295. return this._verticalBarImage;
  9296. },
  9297. set: function (value) {
  9298. if (this._verticalBarImage === value) {
  9299. return;
  9300. }
  9301. this._verticalBarImage = value;
  9302. var vb = this._verticalBar;
  9303. vb.thumbImage = value;
  9304. },
  9305. enumerable: true,
  9306. configurable: true
  9307. });
  9308. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9309. /** Gets or sets the size of the bar */
  9310. get: function () {
  9311. return this._barSize;
  9312. },
  9313. set: function (value) {
  9314. if (this._barSize === value) {
  9315. return;
  9316. }
  9317. this._barSize = value;
  9318. this._markAsDirty();
  9319. if (this._horizontalBar.isVisible) {
  9320. this._grid.setRowDefinition(1, this._barSize, true);
  9321. }
  9322. if (this._verticalBar.isVisible) {
  9323. this._grid.setColumnDefinition(1, this._barSize, true);
  9324. }
  9325. },
  9326. enumerable: true,
  9327. configurable: true
  9328. });
  9329. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9330. /** Gets or sets the length of the thumb */
  9331. get: function () {
  9332. return this._thumbLength;
  9333. },
  9334. set: function (value) {
  9335. if (this._thumbLength === value) {
  9336. return;
  9337. }
  9338. if (value <= 0) {
  9339. value = 0.1;
  9340. }
  9341. if (value > 1) {
  9342. value = 1;
  9343. }
  9344. this._thumbLength = value;
  9345. var hb = this._horizontalBar;
  9346. var vb = this._verticalBar;
  9347. hb.thumbLength = value;
  9348. vb.thumbLength = value;
  9349. this._markAsDirty();
  9350. },
  9351. enumerable: true,
  9352. configurable: true
  9353. });
  9354. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9355. /** Gets or sets the height of the thumb */
  9356. get: function () {
  9357. return this._thumbHeight;
  9358. },
  9359. set: function (value) {
  9360. if (this._thumbHeight === value) {
  9361. return;
  9362. }
  9363. if (value <= 0) {
  9364. value = 0.1;
  9365. }
  9366. if (value > 1) {
  9367. value = 1;
  9368. }
  9369. this._thumbHeight = value;
  9370. var hb = this._horizontalBar;
  9371. var vb = this._verticalBar;
  9372. hb.thumbHeight = value;
  9373. vb.thumbHeight = value;
  9374. this._markAsDirty();
  9375. },
  9376. enumerable: true,
  9377. configurable: true
  9378. });
  9379. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9380. /** Gets or sets the height of the bar image */
  9381. get: function () {
  9382. return this._barImageHeight;
  9383. },
  9384. set: function (value) {
  9385. if (this._barImageHeight === value) {
  9386. return;
  9387. }
  9388. if (value <= 0) {
  9389. value = 0.1;
  9390. }
  9391. if (value > 1) {
  9392. value = 1;
  9393. }
  9394. this._barImageHeight = value;
  9395. var hb = this._horizontalBar;
  9396. var vb = this._verticalBar;
  9397. hb.barImageHeight = value;
  9398. vb.barImageHeight = value;
  9399. this._markAsDirty();
  9400. },
  9401. enumerable: true,
  9402. configurable: true
  9403. });
  9404. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImageHeight", {
  9405. /** Gets or sets the height of the horizontal bar image */
  9406. get: function () {
  9407. return this._horizontalBarImageHeight;
  9408. },
  9409. set: function (value) {
  9410. if (this._horizontalBarImageHeight === value) {
  9411. return;
  9412. }
  9413. if (value <= 0) {
  9414. value = 0.1;
  9415. }
  9416. if (value > 1) {
  9417. value = 1;
  9418. }
  9419. this._horizontalBarImageHeight = value;
  9420. var hb = this._horizontalBar;
  9421. hb.barImageHeight = value;
  9422. this._markAsDirty();
  9423. },
  9424. enumerable: true,
  9425. configurable: true
  9426. });
  9427. Object.defineProperty(ScrollViewer.prototype, "verticalBarImageHeight", {
  9428. /** Gets or sets the height of the vertical bar image */
  9429. get: function () {
  9430. return this._verticalBarImageHeight;
  9431. },
  9432. set: function (value) {
  9433. if (this._verticalBarImageHeight === value) {
  9434. return;
  9435. }
  9436. if (value <= 0) {
  9437. value = 0.1;
  9438. }
  9439. if (value > 1) {
  9440. value = 1;
  9441. }
  9442. this._verticalBarImageHeight = value;
  9443. var vb = this._verticalBar;
  9444. vb.barImageHeight = value;
  9445. this._markAsDirty();
  9446. },
  9447. enumerable: true,
  9448. configurable: true
  9449. });
  9450. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9451. /** Gets or sets the bar background */
  9452. get: function () {
  9453. return this._barBackground;
  9454. },
  9455. set: function (color) {
  9456. if (this._barBackground === color) {
  9457. return;
  9458. }
  9459. this._barBackground = color;
  9460. var hb = this._horizontalBar;
  9461. var vb = this._verticalBar;
  9462. hb.background = color;
  9463. vb.background = color;
  9464. this._dragSpace.background = color;
  9465. },
  9466. enumerable: true,
  9467. configurable: true
  9468. });
  9469. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9470. /** Gets or sets the bar background image */
  9471. get: function () {
  9472. return this._barBackgroundImage;
  9473. },
  9474. set: function (value) {
  9475. if (this._barBackgroundImage === value) {
  9476. }
  9477. this._barBackgroundImage = value;
  9478. var hb = this._horizontalBar;
  9479. var vb = this._verticalBar;
  9480. hb.backgroundImage = value;
  9481. vb.backgroundImage = value;
  9482. },
  9483. enumerable: true,
  9484. configurable: true
  9485. });
  9486. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImage", {
  9487. /** Gets or sets the horizontal bar background image */
  9488. get: function () {
  9489. return this._horizontalBarBackgroundImage;
  9490. },
  9491. set: function (value) {
  9492. if (this._horizontalBarBackgroundImage === value) {
  9493. }
  9494. this._horizontalBarBackgroundImage = value;
  9495. var hb = this._horizontalBar;
  9496. hb.backgroundImage = value;
  9497. },
  9498. enumerable: true,
  9499. configurable: true
  9500. });
  9501. Object.defineProperty(ScrollViewer.prototype, "verticalBarImage", {
  9502. /** Gets or sets the vertical bar background image */
  9503. get: function () {
  9504. return this._verticalBarBackgroundImage;
  9505. },
  9506. set: function (value) {
  9507. if (this._verticalBarBackgroundImage === value) {
  9508. }
  9509. this._verticalBarBackgroundImage = value;
  9510. var vb = this._verticalBar;
  9511. vb.backgroundImage = value;
  9512. },
  9513. enumerable: true,
  9514. configurable: true
  9515. });
  9516. ScrollViewer.prototype._setWindowPosition = function () {
  9517. var ratio = this.host.idealRatio;
  9518. var windowContentsWidth = this._window._currentMeasure.width;
  9519. var windowContentsHeight = this._window._currentMeasure.height;
  9520. var _endLeft = this._clientWidth - windowContentsWidth;
  9521. var _endTop = this._clientHeight - windowContentsHeight;
  9522. var newLeft = (this._horizontalBar.value / ratio) * _endLeft + "px";
  9523. var newTop = (this._verticalBar.value / ratio) * _endTop + "px";
  9524. if (newLeft !== this._window.left) {
  9525. this._window.left = newLeft;
  9526. if (!this.freezeControls) {
  9527. this._rebuildLayout = true;
  9528. }
  9529. }
  9530. if (newTop !== this._window.top) {
  9531. this._window.top = newTop;
  9532. if (!this.freezeControls) {
  9533. this._rebuildLayout = true;
  9534. }
  9535. }
  9536. };
  9537. /** @hidden */
  9538. ScrollViewer.prototype._updateScroller = function () {
  9539. var windowContentsWidth = this._window._currentMeasure.width;
  9540. var windowContentsHeight = this._window._currentMeasure.height;
  9541. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  9542. this._grid.setRowDefinition(1, 0, true);
  9543. this._horizontalBar.isVisible = false;
  9544. this._horizontalBar.value = 0;
  9545. this._rebuildLayout = true;
  9546. }
  9547. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  9548. this._grid.setRowDefinition(1, this._barSize, true);
  9549. this._horizontalBar.isVisible = true;
  9550. this._rebuildLayout = true;
  9551. }
  9552. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  9553. this._grid.setColumnDefinition(1, 0, true);
  9554. this._verticalBar.isVisible = false;
  9555. this._verticalBar.value = 0;
  9556. this._rebuildLayout = true;
  9557. }
  9558. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  9559. this._grid.setColumnDefinition(1, this._barSize, true);
  9560. this._verticalBar.isVisible = true;
  9561. this._rebuildLayout = true;
  9562. }
  9563. this._buildClientSizes();
  9564. var ratio = this.host.idealRatio;
  9565. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientWidth / ratio) + "px";
  9566. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientHeight / ratio) + "px";
  9567. };
  9568. ScrollViewer.prototype._link = function (host) {
  9569. _super.prototype._link.call(this, host);
  9570. this._attachWheel();
  9571. };
  9572. /** @hidden */
  9573. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9574. var _this = this;
  9575. barControl.paddingLeft = 0;
  9576. barControl.width = "100%";
  9577. barControl.height = "100%";
  9578. barControl.barOffset = 0;
  9579. barControl.value = 0;
  9580. barControl.maximum = 1;
  9581. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9582. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9583. barControl.isVertical = isVertical;
  9584. barControl.rotation = rotation;
  9585. barControl.isVisible = false;
  9586. barContainer.addControl(barControl);
  9587. barControl.onValueChangedObservable.add(function (value) {
  9588. _this._setWindowPosition();
  9589. });
  9590. };
  9591. /** @hidden */
  9592. ScrollViewer.prototype._attachWheel = function () {
  9593. var _this = this;
  9594. if (!this._host || this._onWheelObserver) {
  9595. return;
  9596. }
  9597. this._onWheelObserver = this.onWheelObservable.add(function (pi) {
  9598. if (!_this._pointerIsOver) {
  9599. return;
  9600. }
  9601. if (_this._verticalBar.isVisible == true) {
  9602. if (pi.y < 0 && _this._verticalBar.value > 0) {
  9603. _this._verticalBar.value -= _this._wheelPrecision;
  9604. }
  9605. else if (pi.y > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9606. _this._verticalBar.value += _this._wheelPrecision;
  9607. }
  9608. }
  9609. if (_this._horizontalBar.isVisible == true) {
  9610. if (pi.x < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9611. _this._horizontalBar.value += _this._wheelPrecision;
  9612. }
  9613. else if (pi.x > 0 && _this._horizontalBar.value > 0) {
  9614. _this._horizontalBar.value -= _this._wheelPrecision;
  9615. }
  9616. }
  9617. });
  9618. };
  9619. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9620. if (!this.isHighlighted) {
  9621. return;
  9622. }
  9623. _super.prototype._renderHighlightSpecific.call(this, context);
  9624. this._grid._renderHighlightSpecific(context);
  9625. context.restore();
  9626. };
  9627. /** Releases associated resources */
  9628. ScrollViewer.prototype.dispose = function () {
  9629. this.onWheelObservable.remove(this._onWheelObserver);
  9630. this._onWheelObserver = null;
  9631. _super.prototype.dispose.call(this);
  9632. };
  9633. return ScrollViewer;
  9634. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9635. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9636. /***/ }),
  9637. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9638. /*!*********************************************************!*\
  9639. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9640. \*********************************************************/
  9641. /*! exports provided: _ScrollViewerWindow */
  9642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9643. "use strict";
  9644. __webpack_require__.r(__webpack_exports__);
  9645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9646. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9647. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9648. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9649. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9650. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9651. /**
  9652. * Class used to hold a the container for ScrollViewer
  9653. * @hidden
  9654. */
  9655. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9656. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9657. /**
  9658. * Creates a new ScrollViewerWindow
  9659. * @param name of ScrollViewerWindow
  9660. */
  9661. function _ScrollViewerWindow(name) {
  9662. var _this = _super.call(this, name) || this;
  9663. _this._freezeControls = false;
  9664. _this._bucketWidth = 0;
  9665. _this._bucketHeight = 0;
  9666. _this._buckets = {};
  9667. return _this;
  9668. }
  9669. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  9670. get: function () {
  9671. return this._freezeControls;
  9672. },
  9673. set: function (value) {
  9674. if (this._freezeControls === value) {
  9675. return;
  9676. }
  9677. // trigger a full normal layout calculation to be sure all children have their measures up to date
  9678. this._freezeControls = false;
  9679. var textureSize = this.host.getSize();
  9680. var renderWidth = textureSize.width;
  9681. var renderHeight = textureSize.height;
  9682. var context = this.host.getContext();
  9683. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  9684. this.host._numLayoutCalls = 0;
  9685. this.host._rootContainer._layout(measure, context);
  9686. // in freeze mode, prepare children measures accordingly
  9687. if (value) {
  9688. this._updateMeasures();
  9689. if (this._useBuckets()) {
  9690. this._makeBuckets();
  9691. }
  9692. }
  9693. this._freezeControls = value;
  9694. this.host.markAsDirty(); // redraw with the (new) current settings
  9695. },
  9696. enumerable: true,
  9697. configurable: true
  9698. });
  9699. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  9700. get: function () {
  9701. return this._bucketWidth;
  9702. },
  9703. enumerable: true,
  9704. configurable: true
  9705. });
  9706. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  9707. get: function () {
  9708. return this._bucketHeight;
  9709. },
  9710. enumerable: true,
  9711. configurable: true
  9712. });
  9713. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  9714. this._bucketWidth = width;
  9715. this._bucketHeight = height;
  9716. if (this._useBuckets()) {
  9717. if (this._freezeControls) {
  9718. this._makeBuckets();
  9719. }
  9720. }
  9721. else {
  9722. this._buckets = {};
  9723. }
  9724. };
  9725. _ScrollViewerWindow.prototype._useBuckets = function () {
  9726. return this._bucketWidth > 0 && this._bucketHeight > 0;
  9727. };
  9728. _ScrollViewerWindow.prototype._makeBuckets = function () {
  9729. this._buckets = {};
  9730. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  9731. this._dispatchInBuckets(this._children);
  9732. };
  9733. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  9734. for (var i = 0; i < children.length; ++i) {
  9735. var child = children[i];
  9736. var bStartX = Math.max(0, Math.floor((child._currentMeasure.left - this._currentMeasure.left) / this._bucketWidth)), bEndX = Math.floor((child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width - 1) / this._bucketWidth), bStartY = Math.max(0, Math.floor((child._currentMeasure.top - this._currentMeasure.top) / this._bucketHeight)), bEndY = Math.floor((child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height - 1) / this._bucketHeight);
  9737. while (bStartY <= bEndY) {
  9738. for (var x = bStartX; x <= bEndX; ++x) {
  9739. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9740. if (!lstc) {
  9741. lstc = [];
  9742. this._buckets[bucket] = lstc;
  9743. }
  9744. lstc.push(child);
  9745. }
  9746. bStartY++;
  9747. }
  9748. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9749. this._dispatchInBuckets(child._children);
  9750. }
  9751. }
  9752. };
  9753. // reset left and top measures for the window and all its children
  9754. _ScrollViewerWindow.prototype._updateMeasures = function () {
  9755. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9756. this._measureForChildren.left -= left;
  9757. this._measureForChildren.top -= top;
  9758. this._currentMeasure.left -= left;
  9759. this._currentMeasure.top -= top;
  9760. this._updateChildrenMeasures(this._children, left, top);
  9761. };
  9762. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  9763. for (var i = 0; i < children.length; ++i) {
  9764. var child = children[i];
  9765. child._currentMeasure.left -= left;
  9766. child._currentMeasure.top -= top;
  9767. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  9768. child._customData._origTop = child._currentMeasure.top;
  9769. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9770. this._updateChildrenMeasures(child._children, left, top);
  9771. }
  9772. }
  9773. };
  9774. _ScrollViewerWindow.prototype._getTypeName = function () {
  9775. return "ScrollViewerWindow";
  9776. };
  9777. /** @hidden */
  9778. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9779. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9780. this._parentMeasure = parentMeasure;
  9781. this._measureForChildren.left = this._currentMeasure.left;
  9782. this._measureForChildren.top = this._currentMeasure.top;
  9783. this._measureForChildren.width = parentMeasure.width;
  9784. this._measureForChildren.height = parentMeasure.height;
  9785. };
  9786. /** @hidden */
  9787. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  9788. if (this._freezeControls) {
  9789. this.invalidateRect(); // will trigger a redraw of the window
  9790. return false;
  9791. }
  9792. return _super.prototype._layout.call(this, parentMeasure, context);
  9793. };
  9794. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  9795. for (var i = 0; i < children.length; ++i) {
  9796. var child = children[i];
  9797. child._currentMeasure.left = child._customData._origLeft + left;
  9798. child._currentMeasure.top = child._customData._origTop + top;
  9799. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9800. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9801. this._scrollChildren(child._children, left, top);
  9802. }
  9803. }
  9804. };
  9805. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  9806. var bStartX = Math.max(0, Math.floor(-left / this._bucketWidth)), bEndX = Math.floor((-left + this._parentMeasure.width - 1) / this._bucketWidth), bStartY = Math.max(0, Math.floor(-top / this._bucketHeight)), bEndY = Math.floor((-top + this._parentMeasure.height - 1) / this._bucketHeight);
  9807. while (bStartY <= bEndY) {
  9808. for (var x = bStartX; x <= bEndX; ++x) {
  9809. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9810. if (lstc) {
  9811. for (var i = 0; i < lstc.length; ++i) {
  9812. var child = lstc[i];
  9813. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  9814. child._currentMeasure.top = child._customData._origTop + scrollTop;
  9815. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9816. }
  9817. }
  9818. }
  9819. bStartY++;
  9820. }
  9821. };
  9822. /** @hidden */
  9823. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  9824. if (!this._freezeControls) {
  9825. _super.prototype._draw.call(this, context, invalidatedRectangle);
  9826. return;
  9827. }
  9828. this._localDraw(context);
  9829. if (this.clipChildren) {
  9830. this._clipForChildren(context);
  9831. }
  9832. var left = this.leftInPixels, top = this.topInPixels;
  9833. if (this._useBuckets()) {
  9834. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  9835. this._scrollChildrenWithBuckets(left, top, left, top);
  9836. }
  9837. else {
  9838. this._scrollChildren(this._children, left, top);
  9839. }
  9840. this._oldLeft = left;
  9841. this._oldTop = top;
  9842. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9843. var child = _a[_i];
  9844. if (!child._intersectsRect(this._parentMeasure)) {
  9845. continue;
  9846. }
  9847. child._render(context, this._parentMeasure);
  9848. }
  9849. };
  9850. _ScrollViewerWindow.prototype._postMeasure = function () {
  9851. if (this._freezeControls) {
  9852. _super.prototype._postMeasure.call(this);
  9853. return;
  9854. }
  9855. var maxWidth = this.parentClientWidth;
  9856. var maxHeight = this.parentClientHeight;
  9857. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9858. var child = _a[_i];
  9859. if (!child.isVisible || child.notRenderable) {
  9860. continue;
  9861. }
  9862. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9863. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9864. }
  9865. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9866. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9867. }
  9868. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9869. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9870. }
  9871. if (this._currentMeasure.width !== maxWidth) {
  9872. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9873. this._currentMeasure.width = maxWidth;
  9874. this._rebuildLayout = true;
  9875. this._isDirty = true;
  9876. }
  9877. if (this._currentMeasure.height !== maxHeight) {
  9878. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9879. this._currentMeasure.height = maxHeight;
  9880. this._rebuildLayout = true;
  9881. this._isDirty = true;
  9882. }
  9883. _super.prototype._postMeasure.call(this);
  9884. };
  9885. return _ScrollViewerWindow;
  9886. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  9887. /***/ }),
  9888. /***/ "./2D/controls/selector.ts":
  9889. /*!*********************************!*\
  9890. !*** ./2D/controls/selector.ts ***!
  9891. \*********************************/
  9892. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9893. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9894. "use strict";
  9895. __webpack_require__.r(__webpack_exports__);
  9896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9900. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9901. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9902. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9903. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9904. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9905. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9906. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9907. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9908. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9909. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9910. /** Class used to create a RadioGroup
  9911. * which contains groups of radio buttons
  9912. */
  9913. var SelectorGroup = /** @class */ (function () {
  9914. /**
  9915. * Creates a new SelectorGroup
  9916. * @param name of group, used as a group heading
  9917. */
  9918. function SelectorGroup(
  9919. /** name of SelectorGroup */
  9920. name) {
  9921. this.name = name;
  9922. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9923. this._selectors = new Array();
  9924. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9925. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9926. this._groupHeader = this._addGroupHeader(name);
  9927. }
  9928. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9929. /** Gets the groupPanel of the SelectorGroup */
  9930. get: function () {
  9931. return this._groupPanel;
  9932. },
  9933. enumerable: true,
  9934. configurable: true
  9935. });
  9936. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9937. /** Gets the selectors array */
  9938. get: function () {
  9939. return this._selectors;
  9940. },
  9941. enumerable: true,
  9942. configurable: true
  9943. });
  9944. Object.defineProperty(SelectorGroup.prototype, "header", {
  9945. /** Gets and sets the group header */
  9946. get: function () {
  9947. return this._groupHeader.text;
  9948. },
  9949. set: function (label) {
  9950. if (this._groupHeader.text === "label") {
  9951. return;
  9952. }
  9953. this._groupHeader.text = label;
  9954. },
  9955. enumerable: true,
  9956. configurable: true
  9957. });
  9958. /** @hidden */
  9959. SelectorGroup.prototype._addGroupHeader = function (text) {
  9960. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9961. groupHeading.width = 0.9;
  9962. groupHeading.height = "30px";
  9963. groupHeading.textWrapping = true;
  9964. groupHeading.color = "black";
  9965. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9966. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9967. groupHeading.left = "2px";
  9968. this._groupPanel.addControl(groupHeading);
  9969. return groupHeading;
  9970. };
  9971. /** @hidden*/
  9972. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9973. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9974. return;
  9975. }
  9976. return this._selectors[selectorNb];
  9977. };
  9978. /** Removes the selector at the given position
  9979. * @param selectorNb the position of the selector within the group
  9980. */
  9981. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9982. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9983. return;
  9984. }
  9985. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9986. this._selectors.splice(selectorNb, 1);
  9987. };
  9988. return SelectorGroup;
  9989. }());
  9990. /** Class used to create a CheckboxGroup
  9991. * which contains groups of checkbox buttons
  9992. */
  9993. var CheckboxGroup = /** @class */ (function (_super) {
  9994. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  9995. function CheckboxGroup() {
  9996. return _super !== null && _super.apply(this, arguments) || this;
  9997. }
  9998. /** Adds a checkbox as a control
  9999. * @param text is the label for the selector
  10000. * @param func is the function called when the Selector is checked
  10001. * @param checked is true when Selector is checked
  10002. */
  10003. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  10004. if (func === void 0) { func = function (s) { }; }
  10005. if (checked === void 0) { checked = false; }
  10006. var checked = checked || false;
  10007. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  10008. button.width = "20px";
  10009. button.height = "20px";
  10010. button.color = "#364249";
  10011. button.background = "#CCCCCC";
  10012. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10013. button.onIsCheckedChangedObservable.add(function (state) {
  10014. func(state);
  10015. });
  10016. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  10017. _selector.height = "30px";
  10018. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10019. _selector.left = "4px";
  10020. this.groupPanel.addControl(_selector);
  10021. this.selectors.push(_selector);
  10022. button.isChecked = checked;
  10023. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10024. button.color = this.groupPanel.parent.parent.buttonColor;
  10025. button.background = this.groupPanel.parent.parent.buttonBackground;
  10026. }
  10027. };
  10028. /** @hidden */
  10029. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10030. this.selectors[selectorNb].children[1].text = label;
  10031. };
  10032. /** @hidden */
  10033. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10034. this.selectors[selectorNb].children[1].color = color;
  10035. };
  10036. /** @hidden */
  10037. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10038. this.selectors[selectorNb].children[0].color = color;
  10039. };
  10040. /** @hidden */
  10041. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10042. this.selectors[selectorNb].children[0].background = color;
  10043. };
  10044. return CheckboxGroup;
  10045. }(SelectorGroup));
  10046. /** Class used to create a RadioGroup
  10047. * which contains groups of radio buttons
  10048. */
  10049. var RadioGroup = /** @class */ (function (_super) {
  10050. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  10051. function RadioGroup() {
  10052. var _this = _super !== null && _super.apply(this, arguments) || this;
  10053. _this._selectNb = 0;
  10054. return _this;
  10055. }
  10056. /** Adds a radio button as a control
  10057. * @param label is the label for the selector
  10058. * @param func is the function called when the Selector is checked
  10059. * @param checked is true when Selector is checked
  10060. */
  10061. RadioGroup.prototype.addRadio = function (label, func, checked) {
  10062. if (func === void 0) { func = function (n) { }; }
  10063. if (checked === void 0) { checked = false; }
  10064. var nb = this._selectNb++;
  10065. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  10066. button.name = label;
  10067. button.width = "20px";
  10068. button.height = "20px";
  10069. button.color = "#364249";
  10070. button.background = "#CCCCCC";
  10071. button.group = this.name;
  10072. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10073. button.onIsCheckedChangedObservable.add(function (state) {
  10074. if (state) {
  10075. func(nb);
  10076. }
  10077. });
  10078. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  10079. _selector.height = "30px";
  10080. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10081. _selector.left = "4px";
  10082. this.groupPanel.addControl(_selector);
  10083. this.selectors.push(_selector);
  10084. button.isChecked = checked;
  10085. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10086. button.color = this.groupPanel.parent.parent.buttonColor;
  10087. button.background = this.groupPanel.parent.parent.buttonBackground;
  10088. }
  10089. };
  10090. /** @hidden */
  10091. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10092. this.selectors[selectorNb].children[1].text = label;
  10093. };
  10094. /** @hidden */
  10095. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10096. this.selectors[selectorNb].children[1].color = color;
  10097. };
  10098. /** @hidden */
  10099. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10100. this.selectors[selectorNb].children[0].color = color;
  10101. };
  10102. /** @hidden */
  10103. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10104. this.selectors[selectorNb].children[0].background = color;
  10105. };
  10106. return RadioGroup;
  10107. }(SelectorGroup));
  10108. /** Class used to create a SliderGroup
  10109. * which contains groups of slider buttons
  10110. */
  10111. var SliderGroup = /** @class */ (function (_super) {
  10112. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  10113. function SliderGroup() {
  10114. return _super !== null && _super.apply(this, arguments) || this;
  10115. }
  10116. /**
  10117. * Adds a slider to the SelectorGroup
  10118. * @param label is the label for the SliderBar
  10119. * @param func is the function called when the Slider moves
  10120. * @param unit is a string describing the units used, eg degrees or metres
  10121. * @param min is the minimum value for the Slider
  10122. * @param max is the maximum value for the Slider
  10123. * @param value is the start value for the Slider between min and max
  10124. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  10125. */
  10126. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  10127. if (func === void 0) { func = function (v) { }; }
  10128. if (unit === void 0) { unit = "Units"; }
  10129. if (min === void 0) { min = 0; }
  10130. if (max === void 0) { max = 0; }
  10131. if (value === void 0) { value = 0; }
  10132. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  10133. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  10134. button.name = unit;
  10135. button.value = value;
  10136. button.minimum = min;
  10137. button.maximum = max;
  10138. button.width = 0.9;
  10139. button.height = "20px";
  10140. button.color = "#364249";
  10141. button.background = "#CCCCCC";
  10142. button.borderColor = "black";
  10143. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10144. button.left = "4px";
  10145. button.paddingBottom = "4px";
  10146. button.onValueChangedObservable.add(function (value) {
  10147. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  10148. func(value);
  10149. });
  10150. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  10151. _selector.height = "60px";
  10152. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10153. _selector.left = "4px";
  10154. _selector.children[0].name = label;
  10155. this.groupPanel.addControl(_selector);
  10156. this.selectors.push(_selector);
  10157. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10158. button.color = this.groupPanel.parent.parent.buttonColor;
  10159. button.background = this.groupPanel.parent.parent.buttonBackground;
  10160. }
  10161. };
  10162. /** @hidden */
  10163. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10164. this.selectors[selectorNb].children[0].name = label;
  10165. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  10166. };
  10167. /** @hidden */
  10168. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10169. this.selectors[selectorNb].children[0].color = color;
  10170. };
  10171. /** @hidden */
  10172. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10173. this.selectors[selectorNb].children[1].color = color;
  10174. };
  10175. /** @hidden */
  10176. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10177. this.selectors[selectorNb].children[1].background = color;
  10178. };
  10179. return SliderGroup;
  10180. }(SelectorGroup));
  10181. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  10182. * @see http://doc.babylonjs.com/how_to/selector
  10183. */
  10184. var SelectionPanel = /** @class */ (function (_super) {
  10185. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  10186. /**
  10187. * Creates a new SelectionPanel
  10188. * @param name of SelectionPanel
  10189. * @param groups is an array of SelectionGroups
  10190. */
  10191. function SelectionPanel(
  10192. /** name of SelectionPanel */
  10193. name,
  10194. /** an array of SelectionGroups */
  10195. groups) {
  10196. if (groups === void 0) { groups = []; }
  10197. var _this = _super.call(this, name) || this;
  10198. _this.name = name;
  10199. _this.groups = groups;
  10200. _this._buttonColor = "#364249";
  10201. _this._buttonBackground = "#CCCCCC";
  10202. _this._headerColor = "black";
  10203. _this._barColor = "white";
  10204. _this._barHeight = "2px";
  10205. _this._spacerHeight = "20px";
  10206. _this._bars = new Array();
  10207. _this._groups = groups;
  10208. _this.thickness = 2;
  10209. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10210. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10211. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10212. _this._panel.top = 5;
  10213. _this._panel.left = 5;
  10214. _this._panel.width = 0.95;
  10215. if (groups.length > 0) {
  10216. for (var i = 0; i < groups.length - 1; i++) {
  10217. _this._panel.addControl(groups[i].groupPanel);
  10218. _this._addSpacer();
  10219. }
  10220. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  10221. }
  10222. _this.addControl(_this._panel);
  10223. return _this;
  10224. }
  10225. SelectionPanel.prototype._getTypeName = function () {
  10226. return "SelectionPanel";
  10227. };
  10228. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  10229. /** Gets or sets the headerColor */
  10230. get: function () {
  10231. return this._headerColor;
  10232. },
  10233. set: function (color) {
  10234. if (this._headerColor === color) {
  10235. return;
  10236. }
  10237. this._headerColor = color;
  10238. this._setHeaderColor();
  10239. },
  10240. enumerable: true,
  10241. configurable: true
  10242. });
  10243. SelectionPanel.prototype._setHeaderColor = function () {
  10244. for (var i = 0; i < this._groups.length; i++) {
  10245. this._groups[i].groupPanel.children[0].color = this._headerColor;
  10246. }
  10247. };
  10248. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  10249. /** Gets or sets the button color */
  10250. get: function () {
  10251. return this._buttonColor;
  10252. },
  10253. set: function (color) {
  10254. if (this._buttonColor === color) {
  10255. return;
  10256. }
  10257. this._buttonColor = color;
  10258. this._setbuttonColor();
  10259. },
  10260. enumerable: true,
  10261. configurable: true
  10262. });
  10263. SelectionPanel.prototype._setbuttonColor = function () {
  10264. for (var i = 0; i < this._groups.length; i++) {
  10265. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10266. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  10267. }
  10268. }
  10269. };
  10270. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  10271. /** Gets or sets the label color */
  10272. get: function () {
  10273. return this._labelColor;
  10274. },
  10275. set: function (color) {
  10276. if (this._labelColor === color) {
  10277. return;
  10278. }
  10279. this._labelColor = color;
  10280. this._setLabelColor();
  10281. },
  10282. enumerable: true,
  10283. configurable: true
  10284. });
  10285. SelectionPanel.prototype._setLabelColor = function () {
  10286. for (var i = 0; i < this._groups.length; i++) {
  10287. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10288. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  10289. }
  10290. }
  10291. };
  10292. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  10293. /** Gets or sets the button background */
  10294. get: function () {
  10295. return this._buttonBackground;
  10296. },
  10297. set: function (color) {
  10298. if (this._buttonBackground === color) {
  10299. return;
  10300. }
  10301. this._buttonBackground = color;
  10302. this._setButtonBackground();
  10303. },
  10304. enumerable: true,
  10305. configurable: true
  10306. });
  10307. SelectionPanel.prototype._setButtonBackground = function () {
  10308. for (var i = 0; i < this._groups.length; i++) {
  10309. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10310. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  10311. }
  10312. }
  10313. };
  10314. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  10315. /** Gets or sets the color of separator bar */
  10316. get: function () {
  10317. return this._barColor;
  10318. },
  10319. set: function (color) {
  10320. if (this._barColor === color) {
  10321. return;
  10322. }
  10323. this._barColor = color;
  10324. this._setBarColor();
  10325. },
  10326. enumerable: true,
  10327. configurable: true
  10328. });
  10329. SelectionPanel.prototype._setBarColor = function () {
  10330. for (var i = 0; i < this._bars.length; i++) {
  10331. this._bars[i].children[0].background = this._barColor;
  10332. }
  10333. };
  10334. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  10335. /** Gets or sets the height of separator bar */
  10336. get: function () {
  10337. return this._barHeight;
  10338. },
  10339. set: function (value) {
  10340. if (this._barHeight === value) {
  10341. return;
  10342. }
  10343. this._barHeight = value;
  10344. this._setBarHeight();
  10345. },
  10346. enumerable: true,
  10347. configurable: true
  10348. });
  10349. SelectionPanel.prototype._setBarHeight = function () {
  10350. for (var i = 0; i < this._bars.length; i++) {
  10351. this._bars[i].children[0].height = this._barHeight;
  10352. }
  10353. };
  10354. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  10355. /** Gets or sets the height of spacers*/
  10356. get: function () {
  10357. return this._spacerHeight;
  10358. },
  10359. set: function (value) {
  10360. if (this._spacerHeight === value) {
  10361. return;
  10362. }
  10363. this._spacerHeight = value;
  10364. this._setSpacerHeight();
  10365. },
  10366. enumerable: true,
  10367. configurable: true
  10368. });
  10369. SelectionPanel.prototype._setSpacerHeight = function () {
  10370. for (var i = 0; i < this._bars.length; i++) {
  10371. this._bars[i].height = this._spacerHeight;
  10372. }
  10373. };
  10374. /** Adds a bar between groups */
  10375. SelectionPanel.prototype._addSpacer = function () {
  10376. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  10377. separator.width = 1;
  10378. separator.height = this._spacerHeight;
  10379. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10380. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  10381. bar.width = 1;
  10382. bar.height = this._barHeight;
  10383. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10384. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10385. bar.background = this._barColor;
  10386. bar.color = "transparent";
  10387. separator.addControl(bar);
  10388. this._panel.addControl(separator);
  10389. this._bars.push(separator);
  10390. };
  10391. /** Add a group to the selection panel
  10392. * @param group is the selector group to add
  10393. */
  10394. SelectionPanel.prototype.addGroup = function (group) {
  10395. if (this._groups.length > 0) {
  10396. this._addSpacer();
  10397. }
  10398. this._panel.addControl(group.groupPanel);
  10399. this._groups.push(group);
  10400. group.groupPanel.children[0].color = this._headerColor;
  10401. for (var j = 0; j < group.selectors.length; j++) {
  10402. group._setSelectorButtonColor(j, this._buttonColor);
  10403. group._setSelectorButtonBackground(j, this._buttonBackground);
  10404. }
  10405. };
  10406. /** Remove the group from the given position
  10407. * @param groupNb is the position of the group in the list
  10408. */
  10409. SelectionPanel.prototype.removeGroup = function (groupNb) {
  10410. if (groupNb < 0 || groupNb >= this._groups.length) {
  10411. return;
  10412. }
  10413. var group = this._groups[groupNb];
  10414. this._panel.removeControl(group.groupPanel);
  10415. this._groups.splice(groupNb, 1);
  10416. if (groupNb < this._bars.length) {
  10417. this._panel.removeControl(this._bars[groupNb]);
  10418. this._bars.splice(groupNb, 1);
  10419. }
  10420. };
  10421. /** Change a group header label
  10422. * @param label is the new group header label
  10423. * @param groupNb is the number of the group to relabel
  10424. * */
  10425. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  10426. if (groupNb < 0 || groupNb >= this._groups.length) {
  10427. return;
  10428. }
  10429. var group = this._groups[groupNb];
  10430. group.groupPanel.children[0].text = label;
  10431. };
  10432. /** Change selector label to the one given
  10433. * @param label is the new selector label
  10434. * @param groupNb is the number of the groupcontaining the selector
  10435. * @param selectorNb is the number of the selector within a group to relabel
  10436. * */
  10437. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  10438. if (groupNb < 0 || groupNb >= this._groups.length) {
  10439. return;
  10440. }
  10441. var group = this._groups[groupNb];
  10442. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10443. return;
  10444. }
  10445. group._setSelectorLabel(selectorNb, label);
  10446. };
  10447. /** For a given group position remove the selector at the given position
  10448. * @param groupNb is the number of the group to remove the selector from
  10449. * @param selectorNb is the number of the selector within the group
  10450. */
  10451. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  10452. if (groupNb < 0 || groupNb >= this._groups.length) {
  10453. return;
  10454. }
  10455. var group = this._groups[groupNb];
  10456. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10457. return;
  10458. }
  10459. group.removeSelector(selectorNb);
  10460. };
  10461. /** For a given group position of correct type add a checkbox button
  10462. * @param groupNb is the number of the group to remove the selector from
  10463. * @param label is the label for the selector
  10464. * @param func is the function called when the Selector is checked
  10465. * @param checked is true when Selector is checked
  10466. */
  10467. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  10468. if (func === void 0) { func = function () { }; }
  10469. if (checked === void 0) { checked = false; }
  10470. if (groupNb < 0 || groupNb >= this._groups.length) {
  10471. return;
  10472. }
  10473. var group = this._groups[groupNb];
  10474. group.addCheckbox(label, func, checked);
  10475. };
  10476. /** For a given group position of correct type add a radio button
  10477. * @param groupNb is the number of the group to remove the selector from
  10478. * @param label is the label for the selector
  10479. * @param func is the function called when the Selector is checked
  10480. * @param checked is true when Selector is checked
  10481. */
  10482. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  10483. if (func === void 0) { func = function () { }; }
  10484. if (checked === void 0) { checked = false; }
  10485. if (groupNb < 0 || groupNb >= this._groups.length) {
  10486. return;
  10487. }
  10488. var group = this._groups[groupNb];
  10489. group.addRadio(label, func, checked);
  10490. };
  10491. /**
  10492. * For a given slider group add a slider
  10493. * @param groupNb is the number of the group to add the slider to
  10494. * @param label is the label for the Slider
  10495. * @param func is the function called when the Slider moves
  10496. * @param unit is a string describing the units used, eg degrees or metres
  10497. * @param min is the minimum value for the Slider
  10498. * @param max is the maximum value for the Slider
  10499. * @param value is the start value for the Slider between min and max
  10500. * @param onVal is the function used to format the value displayed, eg radians to degrees
  10501. */
  10502. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  10503. if (func === void 0) { func = function () { }; }
  10504. if (unit === void 0) { unit = "Units"; }
  10505. if (min === void 0) { min = 0; }
  10506. if (max === void 0) { max = 0; }
  10507. if (value === void 0) { value = 0; }
  10508. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  10509. if (groupNb < 0 || groupNb >= this._groups.length) {
  10510. return;
  10511. }
  10512. var group = this._groups[groupNb];
  10513. group.addSlider(label, func, unit, min, max, value, onVal);
  10514. };
  10515. return SelectionPanel;
  10516. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10517. /***/ }),
  10518. /***/ "./2D/controls/sliders/baseSlider.ts":
  10519. /*!*******************************************!*\
  10520. !*** ./2D/controls/sliders/baseSlider.ts ***!
  10521. \*******************************************/
  10522. /*! exports provided: BaseSlider */
  10523. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10524. "use strict";
  10525. __webpack_require__.r(__webpack_exports__);
  10526. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  10527. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10528. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  10529. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10530. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10531. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10532. /**
  10533. * Class used to create slider controls
  10534. */
  10535. var BaseSlider = /** @class */ (function (_super) {
  10536. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  10537. /**
  10538. * Creates a new BaseSlider
  10539. * @param name defines the control name
  10540. */
  10541. function BaseSlider(name) {
  10542. var _this = _super.call(this, name) || this;
  10543. _this.name = name;
  10544. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10545. _this._minimum = 0;
  10546. _this._maximum = 100;
  10547. _this._value = 50;
  10548. _this._isVertical = false;
  10549. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10550. _this._isThumbClamped = false;
  10551. _this._displayThumb = true;
  10552. _this._step = 0;
  10553. _this._lastPointerDownID = -1;
  10554. // Shared rendering info
  10555. _this._effectiveBarOffset = 0;
  10556. /** Observable raised when the sldier value changes */
  10557. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10558. // Events
  10559. _this._pointerIsDown = false;
  10560. _this.isPointerBlocker = true;
  10561. return _this;
  10562. }
  10563. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10564. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10565. get: function () {
  10566. return this._displayThumb;
  10567. },
  10568. set: function (value) {
  10569. if (this._displayThumb === value) {
  10570. return;
  10571. }
  10572. this._displayThumb = value;
  10573. this._markAsDirty();
  10574. },
  10575. enumerable: true,
  10576. configurable: true
  10577. });
  10578. Object.defineProperty(BaseSlider.prototype, "step", {
  10579. /** Gets or sets a step to apply to values (0 by default) */
  10580. get: function () {
  10581. return this._step;
  10582. },
  10583. set: function (value) {
  10584. if (this._step === value) {
  10585. return;
  10586. }
  10587. this._step = value;
  10588. this._markAsDirty();
  10589. },
  10590. enumerable: true,
  10591. configurable: true
  10592. });
  10593. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10594. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10595. get: function () {
  10596. return this._barOffset.toString(this._host);
  10597. },
  10598. set: function (value) {
  10599. if (this._barOffset.toString(this._host) === value) {
  10600. return;
  10601. }
  10602. if (this._barOffset.fromString(value)) {
  10603. this._markAsDirty();
  10604. }
  10605. },
  10606. enumerable: true,
  10607. configurable: true
  10608. });
  10609. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10610. /** Gets main bar offset in pixels*/
  10611. get: function () {
  10612. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10613. },
  10614. enumerable: true,
  10615. configurable: true
  10616. });
  10617. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10618. /** Gets or sets thumb width */
  10619. get: function () {
  10620. return this._thumbWidth.toString(this._host);
  10621. },
  10622. set: function (value) {
  10623. if (this._thumbWidth.toString(this._host) === value) {
  10624. return;
  10625. }
  10626. if (this._thumbWidth.fromString(value)) {
  10627. this._markAsDirty();
  10628. }
  10629. },
  10630. enumerable: true,
  10631. configurable: true
  10632. });
  10633. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10634. /** Gets thumb width in pixels */
  10635. get: function () {
  10636. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10637. },
  10638. enumerable: true,
  10639. configurable: true
  10640. });
  10641. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10642. /** Gets or sets minimum value */
  10643. get: function () {
  10644. return this._minimum;
  10645. },
  10646. set: function (value) {
  10647. if (this._minimum === value) {
  10648. return;
  10649. }
  10650. this._minimum = value;
  10651. this._markAsDirty();
  10652. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10653. },
  10654. enumerable: true,
  10655. configurable: true
  10656. });
  10657. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10658. /** Gets or sets maximum value */
  10659. get: function () {
  10660. return this._maximum;
  10661. },
  10662. set: function (value) {
  10663. if (this._maximum === value) {
  10664. return;
  10665. }
  10666. this._maximum = value;
  10667. this._markAsDirty();
  10668. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10669. },
  10670. enumerable: true,
  10671. configurable: true
  10672. });
  10673. Object.defineProperty(BaseSlider.prototype, "value", {
  10674. /** Gets or sets current value */
  10675. get: function () {
  10676. return this._value;
  10677. },
  10678. set: function (value) {
  10679. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10680. if (this._value === value) {
  10681. return;
  10682. }
  10683. this._value = value;
  10684. this._markAsDirty();
  10685. this.onValueChangedObservable.notifyObservers(this._value);
  10686. },
  10687. enumerable: true,
  10688. configurable: true
  10689. });
  10690. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10691. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10692. get: function () {
  10693. return this._isVertical;
  10694. },
  10695. set: function (value) {
  10696. if (this._isVertical === value) {
  10697. return;
  10698. }
  10699. this._isVertical = value;
  10700. this._markAsDirty();
  10701. },
  10702. enumerable: true,
  10703. configurable: true
  10704. });
  10705. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10706. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10707. get: function () {
  10708. return this._isThumbClamped;
  10709. },
  10710. set: function (value) {
  10711. if (this._isThumbClamped === value) {
  10712. return;
  10713. }
  10714. this._isThumbClamped = value;
  10715. this._markAsDirty();
  10716. },
  10717. enumerable: true,
  10718. configurable: true
  10719. });
  10720. BaseSlider.prototype._getTypeName = function () {
  10721. return "BaseSlider";
  10722. };
  10723. BaseSlider.prototype._getThumbPosition = function () {
  10724. if (this.isVertical) {
  10725. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10726. }
  10727. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10728. };
  10729. BaseSlider.prototype._getThumbThickness = function (type) {
  10730. var thumbThickness = 0;
  10731. switch (type) {
  10732. case "circle":
  10733. if (this._thumbWidth.isPixel) {
  10734. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10735. }
  10736. else {
  10737. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10738. }
  10739. break;
  10740. case "rectangle":
  10741. if (this._thumbWidth.isPixel) {
  10742. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10743. }
  10744. else {
  10745. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10746. }
  10747. }
  10748. return thumbThickness;
  10749. };
  10750. BaseSlider.prototype._prepareRenderingData = function (type) {
  10751. // Main bar
  10752. this._effectiveBarOffset = 0;
  10753. this._renderLeft = this._currentMeasure.left;
  10754. this._renderTop = this._currentMeasure.top;
  10755. this._renderWidth = this._currentMeasure.width;
  10756. this._renderHeight = this._currentMeasure.height;
  10757. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10758. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10759. this._effectiveThumbThickness = this._getThumbThickness(type);
  10760. if (this.displayThumb) {
  10761. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10762. }
  10763. //throw error when height is less than width for vertical slider
  10764. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10765. console.error("Height should be greater than width");
  10766. return;
  10767. }
  10768. if (this._barOffset.isPixel) {
  10769. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10770. }
  10771. else {
  10772. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10773. }
  10774. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10775. if (this.isVertical) {
  10776. this._renderLeft += this._effectiveBarOffset;
  10777. if (!this.isThumbClamped && this.displayThumb) {
  10778. this._renderTop += (this._effectiveThumbThickness / 2);
  10779. }
  10780. this._renderHeight = this._backgroundBoxLength;
  10781. this._renderWidth = this._backgroundBoxThickness;
  10782. }
  10783. else {
  10784. this._renderTop += this._effectiveBarOffset;
  10785. if (!this.isThumbClamped && this.displayThumb) {
  10786. this._renderLeft += (this._effectiveThumbThickness / 2);
  10787. }
  10788. this._renderHeight = this._backgroundBoxThickness;
  10789. this._renderWidth = this._backgroundBoxLength;
  10790. }
  10791. };
  10792. /** @hidden */
  10793. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10794. if (this.rotation != 0) {
  10795. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10796. x = this._transformedPosition.x;
  10797. y = this._transformedPosition.y;
  10798. }
  10799. var value;
  10800. if (this._isVertical) {
  10801. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10802. }
  10803. else {
  10804. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10805. }
  10806. var mult = (1 / this._step) | 0;
  10807. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10808. };
  10809. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10810. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10811. return false;
  10812. }
  10813. this._pointerIsDown = true;
  10814. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10815. this._host._capturingControl[pointerId] = this;
  10816. this._lastPointerDownID = pointerId;
  10817. return true;
  10818. };
  10819. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10820. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10821. if (pointerId != this._lastPointerDownID) {
  10822. return;
  10823. }
  10824. if (this._pointerIsDown) {
  10825. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10826. }
  10827. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10828. };
  10829. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10830. this._pointerIsDown = false;
  10831. delete this._host._capturingControl[pointerId];
  10832. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10833. };
  10834. return BaseSlider;
  10835. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10836. /***/ }),
  10837. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10838. /*!*************************************************!*\
  10839. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10840. \*************************************************/
  10841. /*! exports provided: ImageBasedSlider */
  10842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10843. "use strict";
  10844. __webpack_require__.r(__webpack_exports__);
  10845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10846. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10847. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10848. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10849. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  10850. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10851. /**
  10852. * Class used to create slider controls based on images
  10853. */
  10854. var ImageBasedSlider = /** @class */ (function (_super) {
  10855. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  10856. /**
  10857. * Creates a new ImageBasedSlider
  10858. * @param name defines the control name
  10859. */
  10860. function ImageBasedSlider(name) {
  10861. var _this = _super.call(this, name) || this;
  10862. _this.name = name;
  10863. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10864. return _this;
  10865. }
  10866. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10867. get: function () {
  10868. return this._displayThumb && this.thumbImage != null;
  10869. },
  10870. set: function (value) {
  10871. if (this._displayThumb === value) {
  10872. return;
  10873. }
  10874. this._displayThumb = value;
  10875. this._markAsDirty();
  10876. },
  10877. enumerable: true,
  10878. configurable: true
  10879. });
  10880. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10881. /**
  10882. * Gets or sets the image used to render the background
  10883. */
  10884. get: function () {
  10885. return this._backgroundImage;
  10886. },
  10887. set: function (value) {
  10888. var _this = this;
  10889. if (this._backgroundImage === value) {
  10890. return;
  10891. }
  10892. this._backgroundImage = value;
  10893. if (value && !value.isLoaded) {
  10894. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10895. }
  10896. this._markAsDirty();
  10897. },
  10898. enumerable: true,
  10899. configurable: true
  10900. });
  10901. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10902. /**
  10903. * Gets or sets the image used to render the value bar
  10904. */
  10905. get: function () {
  10906. return this._valueBarImage;
  10907. },
  10908. set: function (value) {
  10909. var _this = this;
  10910. if (this._valueBarImage === value) {
  10911. return;
  10912. }
  10913. this._valueBarImage = value;
  10914. if (value && !value.isLoaded) {
  10915. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10916. }
  10917. this._markAsDirty();
  10918. },
  10919. enumerable: true,
  10920. configurable: true
  10921. });
  10922. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10923. /**
  10924. * Gets or sets the image used to render the thumb
  10925. */
  10926. get: function () {
  10927. return this._thumbImage;
  10928. },
  10929. set: function (value) {
  10930. var _this = this;
  10931. if (this._thumbImage === value) {
  10932. return;
  10933. }
  10934. this._thumbImage = value;
  10935. if (value && !value.isLoaded) {
  10936. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10937. }
  10938. this._markAsDirty();
  10939. },
  10940. enumerable: true,
  10941. configurable: true
  10942. });
  10943. ImageBasedSlider.prototype._getTypeName = function () {
  10944. return "ImageBasedSlider";
  10945. };
  10946. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  10947. context.save();
  10948. this._applyStates(context);
  10949. this._prepareRenderingData("rectangle");
  10950. var thumbPosition = this._getThumbPosition();
  10951. var left = this._renderLeft;
  10952. var top = this._renderTop;
  10953. var width = this._renderWidth;
  10954. var height = this._renderHeight;
  10955. // Background
  10956. if (this._backgroundImage) {
  10957. this._tempMeasure.copyFromFloats(left, top, width, height);
  10958. if (this.isThumbClamped && this.displayThumb) {
  10959. if (this.isVertical) {
  10960. this._tempMeasure.height += this._effectiveThumbThickness;
  10961. }
  10962. else {
  10963. this._tempMeasure.width += this._effectiveThumbThickness;
  10964. }
  10965. }
  10966. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10967. this._backgroundImage._draw(context);
  10968. }
  10969. // Bar
  10970. if (this._valueBarImage) {
  10971. if (this.isVertical) {
  10972. if (this.isThumbClamped && this.displayThumb) {
  10973. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10974. }
  10975. else {
  10976. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10977. }
  10978. }
  10979. else {
  10980. if (this.isThumbClamped && this.displayThumb) {
  10981. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10982. }
  10983. else {
  10984. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10985. }
  10986. }
  10987. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10988. this._valueBarImage._draw(context);
  10989. }
  10990. // Thumb
  10991. if (this.displayThumb) {
  10992. if (this.isVertical) {
  10993. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10994. }
  10995. else {
  10996. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10997. }
  10998. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10999. this._thumbImage._draw(context);
  11000. }
  11001. context.restore();
  11002. };
  11003. return ImageBasedSlider;
  11004. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11005. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  11006. /***/ }),
  11007. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  11008. /*!***********************************************!*\
  11009. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  11010. \***********************************************/
  11011. /*! exports provided: ImageScrollBar */
  11012. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11013. "use strict";
  11014. __webpack_require__.r(__webpack_exports__);
  11015. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  11016. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11017. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11018. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11019. /**
  11020. * Class used to create slider controls
  11021. */
  11022. var ImageScrollBar = /** @class */ (function (_super) {
  11023. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  11024. /**
  11025. * Creates a new ImageScrollBar
  11026. * @param name defines the control name
  11027. */
  11028. function ImageScrollBar(name) {
  11029. var _this = _super.call(this, name) || this;
  11030. _this.name = name;
  11031. _this._thumbLength = 0.5;
  11032. _this._thumbHeight = 1;
  11033. _this._barImageHeight = 1;
  11034. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11035. /** Number of 90° rotation to apply on the images when in vertical mode */
  11036. _this.num90RotationInVerticalMode = 1;
  11037. return _this;
  11038. }
  11039. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  11040. /**
  11041. * Gets or sets the image used to render the background for horizontal bar
  11042. */
  11043. get: function () {
  11044. return this._backgroundBaseImage;
  11045. },
  11046. set: function (value) {
  11047. var _this = this;
  11048. if (this._backgroundBaseImage === value) {
  11049. return;
  11050. }
  11051. this._backgroundBaseImage = value;
  11052. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11053. if (!value.isLoaded) {
  11054. value.onImageLoadedObservable.addOnce(function () {
  11055. var rotatedValue = value._rotate90(_this.num90RotationInVerticalMode, true);
  11056. _this._backgroundImage = rotatedValue;
  11057. if (!rotatedValue.isLoaded) {
  11058. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11059. _this._markAsDirty();
  11060. });
  11061. }
  11062. _this._markAsDirty();
  11063. });
  11064. }
  11065. else {
  11066. this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);
  11067. this._markAsDirty();
  11068. }
  11069. }
  11070. else {
  11071. this._backgroundImage = value;
  11072. if (value && !value.isLoaded) {
  11073. value.onImageLoadedObservable.addOnce(function () {
  11074. _this._markAsDirty();
  11075. });
  11076. }
  11077. this._markAsDirty();
  11078. }
  11079. },
  11080. enumerable: true,
  11081. configurable: true
  11082. });
  11083. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  11084. /**
  11085. * Gets or sets the image used to render the thumb
  11086. */
  11087. get: function () {
  11088. return this._thumbBaseImage;
  11089. },
  11090. set: function (value) {
  11091. var _this = this;
  11092. if (this._thumbBaseImage === value) {
  11093. return;
  11094. }
  11095. this._thumbBaseImage = value;
  11096. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11097. if (!value.isLoaded) {
  11098. value.onImageLoadedObservable.addOnce(function () {
  11099. var rotatedValue = value._rotate90(-_this.num90RotationInVerticalMode, true);
  11100. _this._thumbImage = rotatedValue;
  11101. if (!rotatedValue.isLoaded) {
  11102. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11103. _this._markAsDirty();
  11104. });
  11105. }
  11106. _this._markAsDirty();
  11107. });
  11108. }
  11109. else {
  11110. this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);
  11111. this._markAsDirty();
  11112. }
  11113. }
  11114. else {
  11115. this._thumbImage = value;
  11116. if (value && !value.isLoaded) {
  11117. value.onImageLoadedObservable.addOnce(function () {
  11118. _this._markAsDirty();
  11119. });
  11120. }
  11121. this._markAsDirty();
  11122. }
  11123. },
  11124. enumerable: true,
  11125. configurable: true
  11126. });
  11127. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  11128. /**
  11129. * Gets or sets the length of the thumb
  11130. */
  11131. get: function () {
  11132. return this._thumbLength;
  11133. },
  11134. set: function (value) {
  11135. if (this._thumbLength === value) {
  11136. return;
  11137. }
  11138. this._thumbLength = value;
  11139. this._markAsDirty();
  11140. },
  11141. enumerable: true,
  11142. configurable: true
  11143. });
  11144. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  11145. /**
  11146. * Gets or sets the height of the thumb
  11147. */
  11148. get: function () {
  11149. return this._thumbHeight;
  11150. },
  11151. set: function (value) {
  11152. if (this._thumbLength === value) {
  11153. return;
  11154. }
  11155. this._thumbHeight = value;
  11156. this._markAsDirty();
  11157. },
  11158. enumerable: true,
  11159. configurable: true
  11160. });
  11161. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  11162. /**
  11163. * Gets or sets the height of the bar image
  11164. */
  11165. get: function () {
  11166. return this._barImageHeight;
  11167. },
  11168. set: function (value) {
  11169. if (this._barImageHeight === value) {
  11170. return;
  11171. }
  11172. this._barImageHeight = value;
  11173. this._markAsDirty();
  11174. },
  11175. enumerable: true,
  11176. configurable: true
  11177. });
  11178. ImageScrollBar.prototype._getTypeName = function () {
  11179. return "ImageScrollBar";
  11180. };
  11181. ImageScrollBar.prototype._getThumbThickness = function () {
  11182. var thumbThickness = 0;
  11183. if (this._thumbWidth.isPixel) {
  11184. thumbThickness = this._thumbWidth.getValue(this._host);
  11185. }
  11186. else {
  11187. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11188. }
  11189. return thumbThickness;
  11190. };
  11191. ImageScrollBar.prototype._draw = function (context) {
  11192. context.save();
  11193. this._applyStates(context);
  11194. this._prepareRenderingData("rectangle");
  11195. var thumbPosition = this._getThumbPosition();
  11196. var left = this._renderLeft;
  11197. var top = this._renderTop;
  11198. var width = this._renderWidth;
  11199. var height = this._renderHeight;
  11200. // Background
  11201. if (this._backgroundImage) {
  11202. this._tempMeasure.copyFromFloats(left, top, width, height);
  11203. if (this.isVertical) {
  11204. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  11205. this._tempMeasure.height += this._effectiveThumbThickness;
  11206. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11207. }
  11208. else {
  11209. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  11210. this._tempMeasure.width += this._effectiveThumbThickness;
  11211. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11212. }
  11213. this._backgroundImage._draw(context);
  11214. }
  11215. // Thumb
  11216. if (this.isVertical) {
  11217. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset + this._currentMeasure.width * (1 - this._thumbHeight) * 0.5, this._currentMeasure.top + thumbPosition, this._currentMeasure.width * this._thumbHeight, this._effectiveThumbThickness);
  11218. }
  11219. else {
  11220. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top + this._currentMeasure.height * (1 - this._thumbHeight) * 0.5, this._effectiveThumbThickness, this._currentMeasure.height * this._thumbHeight);
  11221. }
  11222. if (this._thumbImage) {
  11223. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11224. this._thumbImage._draw(context);
  11225. }
  11226. context.restore();
  11227. };
  11228. /** @hidden */
  11229. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11230. if (this.rotation != 0) {
  11231. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11232. x = this._transformedPosition.x;
  11233. y = this._transformedPosition.y;
  11234. }
  11235. if (this._first) {
  11236. this._first = false;
  11237. this._originX = x;
  11238. this._originY = y;
  11239. // Check if move is required
  11240. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11241. if (this.isVertical) {
  11242. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11243. }
  11244. else {
  11245. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11246. }
  11247. }
  11248. }
  11249. // Delta mode
  11250. var delta = 0;
  11251. if (this.isVertical) {
  11252. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11253. }
  11254. else {
  11255. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11256. }
  11257. this.value += delta * (this.maximum - this.minimum);
  11258. this._originX = x;
  11259. this._originY = y;
  11260. };
  11261. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11262. this._first = true;
  11263. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11264. };
  11265. return ImageScrollBar;
  11266. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11267. /***/ }),
  11268. /***/ "./2D/controls/sliders/scrollBar.ts":
  11269. /*!******************************************!*\
  11270. !*** ./2D/controls/sliders/scrollBar.ts ***!
  11271. \******************************************/
  11272. /*! exports provided: ScrollBar */
  11273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11274. "use strict";
  11275. __webpack_require__.r(__webpack_exports__);
  11276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  11277. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11278. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11279. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11280. /**
  11281. * Class used to create slider controls
  11282. */
  11283. var ScrollBar = /** @class */ (function (_super) {
  11284. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  11285. /**
  11286. * Creates a new Slider
  11287. * @param name defines the control name
  11288. */
  11289. function ScrollBar(name) {
  11290. var _this = _super.call(this, name) || this;
  11291. _this.name = name;
  11292. _this._background = "black";
  11293. _this._borderColor = "white";
  11294. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11295. return _this;
  11296. }
  11297. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  11298. /** Gets or sets border color */
  11299. get: function () {
  11300. return this._borderColor;
  11301. },
  11302. set: function (value) {
  11303. if (this._borderColor === value) {
  11304. return;
  11305. }
  11306. this._borderColor = value;
  11307. this._markAsDirty();
  11308. },
  11309. enumerable: true,
  11310. configurable: true
  11311. });
  11312. Object.defineProperty(ScrollBar.prototype, "background", {
  11313. /** Gets or sets background color */
  11314. get: function () {
  11315. return this._background;
  11316. },
  11317. set: function (value) {
  11318. if (this._background === value) {
  11319. return;
  11320. }
  11321. this._background = value;
  11322. this._markAsDirty();
  11323. },
  11324. enumerable: true,
  11325. configurable: true
  11326. });
  11327. ScrollBar.prototype._getTypeName = function () {
  11328. return "Scrollbar";
  11329. };
  11330. ScrollBar.prototype._getThumbThickness = function () {
  11331. var thumbThickness = 0;
  11332. if (this._thumbWidth.isPixel) {
  11333. thumbThickness = this._thumbWidth.getValue(this._host);
  11334. }
  11335. else {
  11336. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11337. }
  11338. return thumbThickness;
  11339. };
  11340. ScrollBar.prototype._draw = function (context) {
  11341. context.save();
  11342. this._applyStates(context);
  11343. this._prepareRenderingData("rectangle");
  11344. var left = this._renderLeft;
  11345. var thumbPosition = this._getThumbPosition();
  11346. context.fillStyle = this._background;
  11347. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  11348. // Value bar
  11349. context.fillStyle = this.color;
  11350. // Thumb
  11351. if (this.isVertical) {
  11352. this._tempMeasure.left = left - this._effectiveBarOffset;
  11353. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  11354. this._tempMeasure.width = this._currentMeasure.width;
  11355. this._tempMeasure.height = this._effectiveThumbThickness;
  11356. }
  11357. else {
  11358. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  11359. this._tempMeasure.top = this._currentMeasure.top;
  11360. this._tempMeasure.width = this._effectiveThumbThickness;
  11361. this._tempMeasure.height = this._currentMeasure.height;
  11362. }
  11363. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  11364. context.restore();
  11365. };
  11366. /** @hidden */
  11367. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11368. if (this.rotation != 0) {
  11369. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11370. x = this._transformedPosition.x;
  11371. y = this._transformedPosition.y;
  11372. }
  11373. if (this._first) {
  11374. this._first = false;
  11375. this._originX = x;
  11376. this._originY = y;
  11377. // Check if move is required
  11378. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11379. if (this.isVertical) {
  11380. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11381. }
  11382. else {
  11383. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11384. }
  11385. }
  11386. }
  11387. // Delta mode
  11388. var delta = 0;
  11389. if (this.isVertical) {
  11390. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11391. }
  11392. else {
  11393. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11394. }
  11395. this.value += delta * (this.maximum - this.minimum);
  11396. this._originX = x;
  11397. this._originY = y;
  11398. };
  11399. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11400. this._first = true;
  11401. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11402. };
  11403. return ScrollBar;
  11404. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11405. /***/ }),
  11406. /***/ "./2D/controls/sliders/slider.ts":
  11407. /*!***************************************!*\
  11408. !*** ./2D/controls/sliders/slider.ts ***!
  11409. \***************************************/
  11410. /*! exports provided: Slider */
  11411. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11412. "use strict";
  11413. __webpack_require__.r(__webpack_exports__);
  11414. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  11415. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11416. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11417. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  11418. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  11419. /**
  11420. * Class used to create slider controls
  11421. */
  11422. var Slider = /** @class */ (function (_super) {
  11423. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  11424. /**
  11425. * Creates a new Slider
  11426. * @param name defines the control name
  11427. */
  11428. function Slider(name) {
  11429. var _this = _super.call(this, name) || this;
  11430. _this.name = name;
  11431. _this._background = "black";
  11432. _this._borderColor = "white";
  11433. _this._isThumbCircle = false;
  11434. _this._displayValueBar = true;
  11435. return _this;
  11436. }
  11437. Object.defineProperty(Slider.prototype, "displayValueBar", {
  11438. /** Gets or sets a boolean indicating if the value bar must be rendered */
  11439. get: function () {
  11440. return this._displayValueBar;
  11441. },
  11442. set: function (value) {
  11443. if (this._displayValueBar === value) {
  11444. return;
  11445. }
  11446. this._displayValueBar = value;
  11447. this._markAsDirty();
  11448. },
  11449. enumerable: true,
  11450. configurable: true
  11451. });
  11452. Object.defineProperty(Slider.prototype, "borderColor", {
  11453. /** Gets or sets border color */
  11454. get: function () {
  11455. return this._borderColor;
  11456. },
  11457. set: function (value) {
  11458. if (this._borderColor === value) {
  11459. return;
  11460. }
  11461. this._borderColor = value;
  11462. this._markAsDirty();
  11463. },
  11464. enumerable: true,
  11465. configurable: true
  11466. });
  11467. Object.defineProperty(Slider.prototype, "background", {
  11468. /** Gets or sets background color */
  11469. get: function () {
  11470. return this._background;
  11471. },
  11472. set: function (value) {
  11473. if (this._background === value) {
  11474. return;
  11475. }
  11476. this._background = value;
  11477. this._markAsDirty();
  11478. },
  11479. enumerable: true,
  11480. configurable: true
  11481. });
  11482. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  11483. /** Gets or sets a boolean indicating if the thumb should be round or square */
  11484. get: function () {
  11485. return this._isThumbCircle;
  11486. },
  11487. set: function (value) {
  11488. if (this._isThumbCircle === value) {
  11489. return;
  11490. }
  11491. this._isThumbCircle = value;
  11492. this._markAsDirty();
  11493. },
  11494. enumerable: true,
  11495. configurable: true
  11496. });
  11497. Slider.prototype._getTypeName = function () {
  11498. return "Slider";
  11499. };
  11500. Slider.prototype._draw = function (context, invalidatedRectangle) {
  11501. context.save();
  11502. this._applyStates(context);
  11503. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  11504. var left = this._renderLeft;
  11505. var top = this._renderTop;
  11506. var width = this._renderWidth;
  11507. var height = this._renderHeight;
  11508. var radius = 0;
  11509. if (this.isThumbClamped && this.isThumbCircle) {
  11510. if (this.isVertical) {
  11511. top += (this._effectiveThumbThickness / 2);
  11512. }
  11513. else {
  11514. left += (this._effectiveThumbThickness / 2);
  11515. }
  11516. radius = this._backgroundBoxThickness / 2;
  11517. }
  11518. else {
  11519. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  11520. }
  11521. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11522. context.shadowColor = this.shadowColor;
  11523. context.shadowBlur = this.shadowBlur;
  11524. context.shadowOffsetX = this.shadowOffsetX;
  11525. context.shadowOffsetY = this.shadowOffsetY;
  11526. }
  11527. var thumbPosition = this._getThumbPosition();
  11528. context.fillStyle = this._background;
  11529. if (this.isVertical) {
  11530. if (this.isThumbClamped) {
  11531. if (this.isThumbCircle) {
  11532. context.beginPath();
  11533. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  11534. context.fill();
  11535. context.fillRect(left, top, width, height);
  11536. }
  11537. else {
  11538. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  11539. }
  11540. }
  11541. else {
  11542. context.fillRect(left, top, width, height);
  11543. }
  11544. }
  11545. else {
  11546. if (this.isThumbClamped) {
  11547. if (this.isThumbCircle) {
  11548. context.beginPath();
  11549. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11550. context.fill();
  11551. context.fillRect(left, top, width, height);
  11552. }
  11553. else {
  11554. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  11555. }
  11556. }
  11557. else {
  11558. context.fillRect(left, top, width, height);
  11559. }
  11560. }
  11561. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11562. context.shadowBlur = 0;
  11563. context.shadowOffsetX = 0;
  11564. context.shadowOffsetY = 0;
  11565. }
  11566. // Value bar
  11567. context.fillStyle = this.color;
  11568. if (this._displayValueBar) {
  11569. if (this.isVertical) {
  11570. if (this.isThumbClamped) {
  11571. if (this.isThumbCircle) {
  11572. context.beginPath();
  11573. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  11574. context.fill();
  11575. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11576. }
  11577. else {
  11578. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11579. }
  11580. }
  11581. else {
  11582. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11583. }
  11584. }
  11585. else {
  11586. if (this.isThumbClamped) {
  11587. if (this.isThumbCircle) {
  11588. context.beginPath();
  11589. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  11590. context.fill();
  11591. context.fillRect(left, top, thumbPosition, height);
  11592. }
  11593. else {
  11594. context.fillRect(left, top, thumbPosition, height);
  11595. }
  11596. }
  11597. else {
  11598. context.fillRect(left, top, thumbPosition, height);
  11599. }
  11600. }
  11601. }
  11602. // Thumb
  11603. if (this.displayThumb) {
  11604. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11605. context.shadowColor = this.shadowColor;
  11606. context.shadowBlur = this.shadowBlur;
  11607. context.shadowOffsetX = this.shadowOffsetX;
  11608. context.shadowOffsetY = this.shadowOffsetY;
  11609. }
  11610. if (this._isThumbCircle) {
  11611. context.beginPath();
  11612. if (this.isVertical) {
  11613. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11614. }
  11615. else {
  11616. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11617. }
  11618. context.fill();
  11619. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11620. context.shadowBlur = 0;
  11621. context.shadowOffsetX = 0;
  11622. context.shadowOffsetY = 0;
  11623. }
  11624. context.strokeStyle = this._borderColor;
  11625. context.stroke();
  11626. }
  11627. else {
  11628. if (this.isVertical) {
  11629. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11630. }
  11631. else {
  11632. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11633. }
  11634. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11635. context.shadowBlur = 0;
  11636. context.shadowOffsetX = 0;
  11637. context.shadowOffsetY = 0;
  11638. }
  11639. context.strokeStyle = this._borderColor;
  11640. if (this.isVertical) {
  11641. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11642. }
  11643. else {
  11644. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11645. }
  11646. }
  11647. }
  11648. context.restore();
  11649. };
  11650. return Slider;
  11651. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11652. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11653. /***/ }),
  11654. /***/ "./2D/controls/stackPanel.ts":
  11655. /*!***********************************!*\
  11656. !*** ./2D/controls/stackPanel.ts ***!
  11657. \***********************************/
  11658. /*! exports provided: StackPanel */
  11659. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11660. "use strict";
  11661. __webpack_require__.r(__webpack_exports__);
  11662. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11663. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11664. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  11665. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11666. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11667. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11668. /**
  11669. * Class used to create a 2D stack panel container
  11670. */
  11671. var StackPanel = /** @class */ (function (_super) {
  11672. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11673. /**
  11674. * Creates a new StackPanel
  11675. * @param name defines control name
  11676. */
  11677. function StackPanel(name) {
  11678. var _this = _super.call(this, name) || this;
  11679. _this.name = name;
  11680. _this._isVertical = true;
  11681. _this._manualWidth = false;
  11682. _this._manualHeight = false;
  11683. _this._doNotTrackManualChanges = false;
  11684. /**
  11685. * Gets or sets a boolean indicating that layou warnings should be ignored
  11686. */
  11687. _this.ignoreLayoutWarnings = false;
  11688. return _this;
  11689. }
  11690. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11691. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11692. get: function () {
  11693. return this._isVertical;
  11694. },
  11695. set: function (value) {
  11696. if (this._isVertical === value) {
  11697. return;
  11698. }
  11699. this._isVertical = value;
  11700. this._markAsDirty();
  11701. },
  11702. enumerable: true,
  11703. configurable: true
  11704. });
  11705. Object.defineProperty(StackPanel.prototype, "width", {
  11706. get: function () {
  11707. return this._width.toString(this._host);
  11708. },
  11709. /**
  11710. * Gets or sets panel width.
  11711. * This value should not be set when in horizontal mode as it will be computed automatically
  11712. */
  11713. set: function (value) {
  11714. if (!this._doNotTrackManualChanges) {
  11715. this._manualWidth = true;
  11716. }
  11717. if (this._width.toString(this._host) === value) {
  11718. return;
  11719. }
  11720. if (this._width.fromString(value)) {
  11721. this._markAsDirty();
  11722. }
  11723. },
  11724. enumerable: true,
  11725. configurable: true
  11726. });
  11727. Object.defineProperty(StackPanel.prototype, "height", {
  11728. get: function () {
  11729. return this._height.toString(this._host);
  11730. },
  11731. /**
  11732. * Gets or sets panel height.
  11733. * This value should not be set when in vertical mode as it will be computed automatically
  11734. */
  11735. set: function (value) {
  11736. if (!this._doNotTrackManualChanges) {
  11737. this._manualHeight = true;
  11738. }
  11739. if (this._height.toString(this._host) === value) {
  11740. return;
  11741. }
  11742. if (this._height.fromString(value)) {
  11743. this._markAsDirty();
  11744. }
  11745. },
  11746. enumerable: true,
  11747. configurable: true
  11748. });
  11749. StackPanel.prototype._getTypeName = function () {
  11750. return "StackPanel";
  11751. };
  11752. /** @hidden */
  11753. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11754. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11755. var child = _a[_i];
  11756. if (this._isVertical) {
  11757. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11758. }
  11759. else {
  11760. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11761. }
  11762. }
  11763. _super.prototype._preMeasure.call(this, parentMeasure, context);
  11764. };
  11765. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  11766. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  11767. this._measureForChildren.copyFrom(parentMeasure);
  11768. this._measureForChildren.left = this._currentMeasure.left;
  11769. this._measureForChildren.top = this._currentMeasure.top;
  11770. if (!this.isVertical || this._manualWidth) {
  11771. this._measureForChildren.width = this._currentMeasure.width;
  11772. }
  11773. if (this.isVertical || this._manualHeight) {
  11774. this._measureForChildren.height = this._currentMeasure.height;
  11775. }
  11776. };
  11777. StackPanel.prototype._postMeasure = function () {
  11778. var stackWidth = 0;
  11779. var stackHeight = 0;
  11780. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11781. var child = _a[_i];
  11782. if (!child.isVisible || child.notRenderable) {
  11783. continue;
  11784. }
  11785. if (this._isVertical) {
  11786. if (child.top !== stackHeight + "px") {
  11787. child.top = stackHeight + "px";
  11788. this._rebuildLayout = true;
  11789. child._top.ignoreAdaptiveScaling = true;
  11790. }
  11791. if (child._height.isPercentage && !child._automaticSize) {
  11792. if (!this.ignoreLayoutWarnings) {
  11793. 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");
  11794. }
  11795. }
  11796. else {
  11797. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  11798. }
  11799. }
  11800. else {
  11801. if (child.left !== stackWidth + "px") {
  11802. child.left = stackWidth + "px";
  11803. this._rebuildLayout = true;
  11804. child._left.ignoreAdaptiveScaling = true;
  11805. }
  11806. if (child._width.isPercentage && !child._automaticSize) {
  11807. if (!this.ignoreLayoutWarnings) {
  11808. 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");
  11809. }
  11810. }
  11811. else {
  11812. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  11813. }
  11814. }
  11815. }
  11816. this._doNotTrackManualChanges = true;
  11817. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  11818. // User can now define their own height and width for stack panel.
  11819. var panelWidthChanged = false;
  11820. var panelHeightChanged = false;
  11821. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  11822. var previousHeight = this.height;
  11823. this.height = stackHeight + "px";
  11824. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  11825. }
  11826. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  11827. var previousWidth = this.width;
  11828. this.width = stackWidth + "px";
  11829. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  11830. }
  11831. if (panelHeightChanged) {
  11832. this._height.ignoreAdaptiveScaling = true;
  11833. }
  11834. if (panelWidthChanged) {
  11835. this._width.ignoreAdaptiveScaling = true;
  11836. }
  11837. this._doNotTrackManualChanges = false;
  11838. if (panelWidthChanged || panelHeightChanged) {
  11839. this._rebuildLayout = true;
  11840. }
  11841. _super.prototype._postMeasure.call(this);
  11842. };
  11843. return StackPanel;
  11844. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  11845. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  11846. /***/ }),
  11847. /***/ "./2D/controls/statics.ts":
  11848. /*!********************************!*\
  11849. !*** ./2D/controls/statics.ts ***!
  11850. \********************************/
  11851. /*! exports provided: name */
  11852. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11853. "use strict";
  11854. __webpack_require__.r(__webpack_exports__);
  11855. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  11856. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11857. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11858. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  11859. /**
  11860. * Forcing an export so that this code will execute
  11861. * @hidden
  11862. */
  11863. var name = "Statics";
  11864. /**
  11865. * Creates a stack panel that can be used to render headers
  11866. * @param control defines the control to associate with the header
  11867. * @param text defines the text of the header
  11868. * @param size defines the size of the header
  11869. * @param options defines options used to configure the header
  11870. * @returns a new StackPanel
  11871. */
  11872. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  11873. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  11874. var isHorizontal = options ? options.isHorizontal : true;
  11875. var controlFirst = options ? options.controlFirst : true;
  11876. panel.isVertical = !isHorizontal;
  11877. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  11878. header.text = text;
  11879. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11880. if (isHorizontal) {
  11881. header.width = size;
  11882. }
  11883. else {
  11884. header.height = size;
  11885. }
  11886. if (controlFirst) {
  11887. panel.addControl(control);
  11888. panel.addControl(header);
  11889. header.paddingLeft = "5px";
  11890. }
  11891. else {
  11892. panel.addControl(header);
  11893. panel.addControl(control);
  11894. header.paddingRight = "5px";
  11895. }
  11896. header.shadowBlur = control.shadowBlur;
  11897. header.shadowColor = control.shadowColor;
  11898. header.shadowOffsetX = control.shadowOffsetX;
  11899. header.shadowOffsetY = control.shadowOffsetY;
  11900. return panel;
  11901. };
  11902. /***/ }),
  11903. /***/ "./2D/controls/textBlock.ts":
  11904. /*!**********************************!*\
  11905. !*** ./2D/controls/textBlock.ts ***!
  11906. \**********************************/
  11907. /*! exports provided: TextWrapping, TextBlock */
  11908. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11909. "use strict";
  11910. __webpack_require__.r(__webpack_exports__);
  11911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  11912. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  11913. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11914. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  11915. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11916. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  11917. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11918. /**
  11919. * Enum that determines the text-wrapping mode to use.
  11920. */
  11921. var TextWrapping;
  11922. (function (TextWrapping) {
  11923. /**
  11924. * Clip the text when it's larger than Control.width; this is the default mode.
  11925. */
  11926. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  11927. /**
  11928. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  11929. */
  11930. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  11931. /**
  11932. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  11933. */
  11934. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  11935. })(TextWrapping || (TextWrapping = {}));
  11936. /**
  11937. * Class used to create text block control
  11938. */
  11939. var TextBlock = /** @class */ (function (_super) {
  11940. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  11941. /**
  11942. * Creates a new TextBlock object
  11943. * @param name defines the name of the control
  11944. * @param text defines the text to display (emptry string by default)
  11945. */
  11946. function TextBlock(
  11947. /**
  11948. * Defines the name of the control
  11949. */
  11950. name, text) {
  11951. if (text === void 0) { text = ""; }
  11952. var _this = _super.call(this, name) || this;
  11953. _this.name = name;
  11954. _this._text = "";
  11955. _this._textWrapping = TextWrapping.Clip;
  11956. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  11957. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  11958. _this._resizeToFit = false;
  11959. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  11960. _this._outlineWidth = 0;
  11961. _this._outlineColor = "white";
  11962. /**
  11963. * An event triggered after the text is changed
  11964. */
  11965. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11966. /**
  11967. * An event triggered after the text was broken up into lines
  11968. */
  11969. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11970. _this.text = text;
  11971. return _this;
  11972. }
  11973. Object.defineProperty(TextBlock.prototype, "lines", {
  11974. /**
  11975. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  11976. */
  11977. get: function () {
  11978. return this._lines;
  11979. },
  11980. enumerable: true,
  11981. configurable: true
  11982. });
  11983. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  11984. /**
  11985. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11986. */
  11987. get: function () {
  11988. return this._resizeToFit;
  11989. },
  11990. /**
  11991. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11992. */
  11993. set: function (value) {
  11994. if (this._resizeToFit === value) {
  11995. return;
  11996. }
  11997. this._resizeToFit = value;
  11998. if (this._resizeToFit) {
  11999. this._width.ignoreAdaptiveScaling = true;
  12000. this._height.ignoreAdaptiveScaling = true;
  12001. }
  12002. this._markAsDirty();
  12003. },
  12004. enumerable: true,
  12005. configurable: true
  12006. });
  12007. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  12008. /**
  12009. * Gets or sets a boolean indicating if text must be wrapped
  12010. */
  12011. get: function () {
  12012. return this._textWrapping;
  12013. },
  12014. /**
  12015. * Gets or sets a boolean indicating if text must be wrapped
  12016. */
  12017. set: function (value) {
  12018. if (this._textWrapping === value) {
  12019. return;
  12020. }
  12021. this._textWrapping = +value;
  12022. this._markAsDirty();
  12023. },
  12024. enumerable: true,
  12025. configurable: true
  12026. });
  12027. Object.defineProperty(TextBlock.prototype, "text", {
  12028. /**
  12029. * Gets or sets text to display
  12030. */
  12031. get: function () {
  12032. return this._text;
  12033. },
  12034. /**
  12035. * Gets or sets text to display
  12036. */
  12037. set: function (value) {
  12038. if (this._text === value) {
  12039. return;
  12040. }
  12041. this._text = value;
  12042. this._markAsDirty();
  12043. this.onTextChangedObservable.notifyObservers(this);
  12044. },
  12045. enumerable: true,
  12046. configurable: true
  12047. });
  12048. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  12049. /**
  12050. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12051. */
  12052. get: function () {
  12053. return this._textHorizontalAlignment;
  12054. },
  12055. /**
  12056. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12057. */
  12058. set: function (value) {
  12059. if (this._textHorizontalAlignment === value) {
  12060. return;
  12061. }
  12062. this._textHorizontalAlignment = value;
  12063. this._markAsDirty();
  12064. },
  12065. enumerable: true,
  12066. configurable: true
  12067. });
  12068. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  12069. /**
  12070. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12071. */
  12072. get: function () {
  12073. return this._textVerticalAlignment;
  12074. },
  12075. /**
  12076. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12077. */
  12078. set: function (value) {
  12079. if (this._textVerticalAlignment === value) {
  12080. return;
  12081. }
  12082. this._textVerticalAlignment = value;
  12083. this._markAsDirty();
  12084. },
  12085. enumerable: true,
  12086. configurable: true
  12087. });
  12088. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  12089. /**
  12090. * Gets or sets line spacing value
  12091. */
  12092. get: function () {
  12093. return this._lineSpacing.toString(this._host);
  12094. },
  12095. /**
  12096. * Gets or sets line spacing value
  12097. */
  12098. set: function (value) {
  12099. if (this._lineSpacing.fromString(value)) {
  12100. this._markAsDirty();
  12101. }
  12102. },
  12103. enumerable: true,
  12104. configurable: true
  12105. });
  12106. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  12107. /**
  12108. * Gets or sets outlineWidth of the text to display
  12109. */
  12110. get: function () {
  12111. return this._outlineWidth;
  12112. },
  12113. /**
  12114. * Gets or sets outlineWidth of the text to display
  12115. */
  12116. set: function (value) {
  12117. if (this._outlineWidth === value) {
  12118. return;
  12119. }
  12120. this._outlineWidth = value;
  12121. this._markAsDirty();
  12122. },
  12123. enumerable: true,
  12124. configurable: true
  12125. });
  12126. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  12127. /**
  12128. * Gets or sets outlineColor of the text to display
  12129. */
  12130. get: function () {
  12131. return this._outlineColor;
  12132. },
  12133. /**
  12134. * Gets or sets outlineColor of the text to display
  12135. */
  12136. set: function (value) {
  12137. if (this._outlineColor === value) {
  12138. return;
  12139. }
  12140. this._outlineColor = value;
  12141. this._markAsDirty();
  12142. },
  12143. enumerable: true,
  12144. configurable: true
  12145. });
  12146. TextBlock.prototype._getTypeName = function () {
  12147. return "TextBlock";
  12148. };
  12149. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  12150. if (!this._fontOffset) {
  12151. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  12152. }
  12153. _super.prototype._processMeasures.call(this, parentMeasure, context);
  12154. // Prepare lines
  12155. this._lines = this._breakLines(this._currentMeasure.width, context);
  12156. this.onLinesReadyObservable.notifyObservers(this);
  12157. var maxLineWidth = 0;
  12158. for (var i = 0; i < this._lines.length; i++) {
  12159. var line = this._lines[i];
  12160. if (line.width > maxLineWidth) {
  12161. maxLineWidth = line.width;
  12162. }
  12163. }
  12164. if (this._resizeToFit) {
  12165. if (this._textWrapping === TextWrapping.Clip) {
  12166. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  12167. if (newWidth !== this._width.internalValue) {
  12168. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12169. this._rebuildLayout = true;
  12170. }
  12171. }
  12172. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  12173. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12174. var lineSpacing = 0;
  12175. if (this._lineSpacing.isPixel) {
  12176. lineSpacing = this._lineSpacing.getValue(this._host);
  12177. }
  12178. else {
  12179. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12180. }
  12181. newHeight += (this._lines.length - 1) * lineSpacing;
  12182. }
  12183. if (newHeight !== this._height.internalValue) {
  12184. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12185. this._rebuildLayout = true;
  12186. }
  12187. }
  12188. };
  12189. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  12190. var width = this._currentMeasure.width;
  12191. var x = 0;
  12192. switch (this._textHorizontalAlignment) {
  12193. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  12194. x = 0;
  12195. break;
  12196. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  12197. x = width - textWidth;
  12198. break;
  12199. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  12200. x = (width - textWidth) / 2;
  12201. break;
  12202. }
  12203. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12204. context.shadowColor = this.shadowColor;
  12205. context.shadowBlur = this.shadowBlur;
  12206. context.shadowOffsetX = this.shadowOffsetX;
  12207. context.shadowOffsetY = this.shadowOffsetY;
  12208. }
  12209. if (this.outlineWidth) {
  12210. context.strokeText(text, this._currentMeasure.left + x, y);
  12211. }
  12212. context.fillText(text, this._currentMeasure.left + x, y);
  12213. };
  12214. /** @hidden */
  12215. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  12216. context.save();
  12217. this._applyStates(context);
  12218. // Render lines
  12219. this._renderLines(context);
  12220. context.restore();
  12221. };
  12222. TextBlock.prototype._applyStates = function (context) {
  12223. _super.prototype._applyStates.call(this, context);
  12224. if (this.outlineWidth) {
  12225. context.lineWidth = this.outlineWidth;
  12226. context.strokeStyle = this.outlineColor;
  12227. }
  12228. };
  12229. TextBlock.prototype._breakLines = function (refWidth, context) {
  12230. var lines = [];
  12231. var _lines = this.text.split("\n");
  12232. if (this._textWrapping === TextWrapping.Ellipsis) {
  12233. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  12234. var _line = _lines_1[_i];
  12235. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  12236. }
  12237. }
  12238. else if (this._textWrapping === TextWrapping.WordWrap) {
  12239. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  12240. var _line = _lines_2[_a];
  12241. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  12242. }
  12243. }
  12244. else {
  12245. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  12246. var _line = _lines_3[_b];
  12247. lines.push(this._parseLine(_line, context));
  12248. }
  12249. }
  12250. return lines;
  12251. };
  12252. TextBlock.prototype._parseLine = function (line, context) {
  12253. if (line === void 0) { line = ''; }
  12254. return { text: line, width: context.measureText(line).width };
  12255. };
  12256. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  12257. if (line === void 0) { line = ''; }
  12258. var lineWidth = context.measureText(line).width;
  12259. if (lineWidth > width) {
  12260. line += '…';
  12261. }
  12262. while (line.length > 2 && lineWidth > width) {
  12263. line = line.slice(0, -2) + '…';
  12264. lineWidth = context.measureText(line).width;
  12265. }
  12266. return { text: line, width: lineWidth };
  12267. };
  12268. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  12269. if (line === void 0) { line = ''; }
  12270. var lines = [];
  12271. var words = line.split(' ');
  12272. var lineWidth = 0;
  12273. for (var n = 0; n < words.length; n++) {
  12274. var testLine = n > 0 ? line + " " + words[n] : words[0];
  12275. var metrics = context.measureText(testLine);
  12276. var testWidth = metrics.width;
  12277. if (testWidth > width && n > 0) {
  12278. lines.push({ text: line, width: lineWidth });
  12279. line = words[n];
  12280. lineWidth = context.measureText(line).width;
  12281. }
  12282. else {
  12283. lineWidth = testWidth;
  12284. line = testLine;
  12285. }
  12286. }
  12287. lines.push({ text: line, width: lineWidth });
  12288. return lines;
  12289. };
  12290. TextBlock.prototype._renderLines = function (context) {
  12291. var height = this._currentMeasure.height;
  12292. var rootY = 0;
  12293. switch (this._textVerticalAlignment) {
  12294. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  12295. rootY = this._fontOffset.ascent;
  12296. break;
  12297. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  12298. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  12299. break;
  12300. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  12301. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  12302. break;
  12303. }
  12304. rootY += this._currentMeasure.top;
  12305. for (var i = 0; i < this._lines.length; i++) {
  12306. var line = this._lines[i];
  12307. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  12308. if (this._lineSpacing.isPixel) {
  12309. rootY += this._lineSpacing.getValue(this._host);
  12310. }
  12311. else {
  12312. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12313. }
  12314. }
  12315. this._drawText(line.text, line.width, rootY, context);
  12316. rootY += this._fontOffset.height;
  12317. }
  12318. };
  12319. /**
  12320. * Given a width constraint applied on the text block, find the expected height
  12321. * @returns expected height
  12322. */
  12323. TextBlock.prototype.computeExpectedHeight = function () {
  12324. if (this.text && this.widthInPixels) {
  12325. var context_1 = document.createElement('canvas').getContext('2d');
  12326. if (context_1) {
  12327. this._applyStates(context_1);
  12328. if (!this._fontOffset) {
  12329. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  12330. }
  12331. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  12332. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  12333. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12334. var lineSpacing = 0;
  12335. if (this._lineSpacing.isPixel) {
  12336. lineSpacing = this._lineSpacing.getValue(this._host);
  12337. }
  12338. else {
  12339. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12340. }
  12341. newHeight += (lines.length - 1) * lineSpacing;
  12342. }
  12343. return newHeight;
  12344. }
  12345. }
  12346. return 0;
  12347. };
  12348. TextBlock.prototype.dispose = function () {
  12349. _super.prototype.dispose.call(this);
  12350. this.onTextChangedObservable.clear();
  12351. };
  12352. return TextBlock;
  12353. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  12354. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  12355. /***/ }),
  12356. /***/ "./2D/controls/virtualKeyboard.ts":
  12357. /*!****************************************!*\
  12358. !*** ./2D/controls/virtualKeyboard.ts ***!
  12359. \****************************************/
  12360. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  12361. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12362. "use strict";
  12363. __webpack_require__.r(__webpack_exports__);
  12364. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  12365. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  12366. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12367. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12368. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12369. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12370. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  12371. /**
  12372. * Class used to store key control properties
  12373. */
  12374. var KeyPropertySet = /** @class */ (function () {
  12375. function KeyPropertySet() {
  12376. }
  12377. return KeyPropertySet;
  12378. }());
  12379. /**
  12380. * Class used to create virtual keyboard
  12381. */
  12382. var VirtualKeyboard = /** @class */ (function (_super) {
  12383. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  12384. function VirtualKeyboard() {
  12385. var _this = _super !== null && _super.apply(this, arguments) || this;
  12386. /** Observable raised when a key is pressed */
  12387. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12388. /** Gets or sets default key button width */
  12389. _this.defaultButtonWidth = "40px";
  12390. /** Gets or sets default key button height */
  12391. _this.defaultButtonHeight = "40px";
  12392. /** Gets or sets default key button left padding */
  12393. _this.defaultButtonPaddingLeft = "2px";
  12394. /** Gets or sets default key button right padding */
  12395. _this.defaultButtonPaddingRight = "2px";
  12396. /** Gets or sets default key button top padding */
  12397. _this.defaultButtonPaddingTop = "2px";
  12398. /** Gets or sets default key button bottom padding */
  12399. _this.defaultButtonPaddingBottom = "2px";
  12400. /** Gets or sets default key button foreground color */
  12401. _this.defaultButtonColor = "#DDD";
  12402. /** Gets or sets default key button background color */
  12403. _this.defaultButtonBackground = "#070707";
  12404. /** Gets or sets shift button foreground color */
  12405. _this.shiftButtonColor = "#7799FF";
  12406. /** Gets or sets shift button thickness*/
  12407. _this.selectedShiftThickness = 1;
  12408. /** Gets shift key state */
  12409. _this.shiftState = 0;
  12410. _this._currentlyConnectedInputText = null;
  12411. _this._connectedInputTexts = [];
  12412. _this._onKeyPressObserver = null;
  12413. return _this;
  12414. }
  12415. VirtualKeyboard.prototype._getTypeName = function () {
  12416. return "VirtualKeyboard";
  12417. };
  12418. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  12419. var _this = this;
  12420. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  12421. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  12422. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  12423. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  12424. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  12425. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  12426. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  12427. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  12428. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  12429. button.thickness = 0;
  12430. button.isFocusInvisible = true;
  12431. button.shadowColor = this.shadowColor;
  12432. button.shadowBlur = this.shadowBlur;
  12433. button.shadowOffsetX = this.shadowOffsetX;
  12434. button.shadowOffsetY = this.shadowOffsetY;
  12435. button.onPointerUpObservable.add(function () {
  12436. _this.onKeyPressObservable.notifyObservers(key);
  12437. });
  12438. return button;
  12439. };
  12440. /**
  12441. * Adds a new row of keys
  12442. * @param keys defines the list of keys to add
  12443. * @param propertySets defines the associated property sets
  12444. */
  12445. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  12446. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  12447. panel.isVertical = false;
  12448. panel.isFocusInvisible = true;
  12449. var maxKey = null;
  12450. for (var i = 0; i < keys.length; i++) {
  12451. var properties = null;
  12452. if (propertySets && propertySets.length === keys.length) {
  12453. properties = propertySets[i];
  12454. }
  12455. var key = this._createKey(keys[i], properties);
  12456. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  12457. maxKey = key;
  12458. }
  12459. panel.addControl(key);
  12460. }
  12461. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  12462. this.addControl(panel);
  12463. };
  12464. /**
  12465. * Set the shift key to a specific state
  12466. * @param shiftState defines the new shift state
  12467. */
  12468. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  12469. if (!this.children) {
  12470. return;
  12471. }
  12472. for (var i = 0; i < this.children.length; i++) {
  12473. var row = this.children[i];
  12474. if (!row || !row.children) {
  12475. continue;
  12476. }
  12477. var rowContainer = row;
  12478. for (var j = 0; j < rowContainer.children.length; j++) {
  12479. var button = rowContainer.children[j];
  12480. if (!button || !button.children[0]) {
  12481. continue;
  12482. }
  12483. var button_tblock = button.children[0];
  12484. if (button_tblock.text === "\u21E7") {
  12485. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  12486. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  12487. }
  12488. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  12489. }
  12490. }
  12491. };
  12492. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  12493. /** Gets the input text control currently attached to the keyboard */
  12494. get: function () {
  12495. return this._currentlyConnectedInputText;
  12496. },
  12497. enumerable: true,
  12498. configurable: true
  12499. });
  12500. /**
  12501. * Connects the keyboard with an input text control
  12502. *
  12503. * @param input defines the target control
  12504. */
  12505. VirtualKeyboard.prototype.connect = function (input) {
  12506. var _this = this;
  12507. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  12508. if (inputTextAlreadyConnected) {
  12509. return;
  12510. }
  12511. if (this._onKeyPressObserver === null) {
  12512. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  12513. if (!_this._currentlyConnectedInputText) {
  12514. return;
  12515. }
  12516. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  12517. switch (key) {
  12518. case "\u21E7":
  12519. _this.shiftState++;
  12520. if (_this.shiftState > 2) {
  12521. _this.shiftState = 0;
  12522. }
  12523. _this.applyShiftState(_this.shiftState);
  12524. return;
  12525. case "\u2190":
  12526. _this._currentlyConnectedInputText.processKey(8);
  12527. return;
  12528. case "\u21B5":
  12529. _this._currentlyConnectedInputText.processKey(13);
  12530. return;
  12531. }
  12532. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  12533. if (_this.shiftState === 1) {
  12534. _this.shiftState = 0;
  12535. _this.applyShiftState(_this.shiftState);
  12536. }
  12537. });
  12538. }
  12539. this.isVisible = false;
  12540. this._currentlyConnectedInputText = input;
  12541. input._connectedVirtualKeyboard = this;
  12542. // Events hooking
  12543. var onFocusObserver = input.onFocusObservable.add(function () {
  12544. _this._currentlyConnectedInputText = input;
  12545. input._connectedVirtualKeyboard = _this;
  12546. _this.isVisible = true;
  12547. });
  12548. var onBlurObserver = input.onBlurObservable.add(function () {
  12549. input._connectedVirtualKeyboard = null;
  12550. _this._currentlyConnectedInputText = null;
  12551. _this.isVisible = false;
  12552. });
  12553. this._connectedInputTexts.push({
  12554. input: input,
  12555. onBlurObserver: onBlurObserver,
  12556. onFocusObserver: onFocusObserver
  12557. });
  12558. };
  12559. /**
  12560. * Disconnects the keyboard from connected InputText controls
  12561. *
  12562. * @param input optionally defines a target control, otherwise all are disconnected
  12563. */
  12564. VirtualKeyboard.prototype.disconnect = function (input) {
  12565. var _this = this;
  12566. if (input) {
  12567. // .find not available on IE
  12568. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  12569. if (filtered.length === 1) {
  12570. this._removeConnectedInputObservables(filtered[0]);
  12571. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  12572. if (this._currentlyConnectedInputText === input) {
  12573. this._currentlyConnectedInputText = null;
  12574. }
  12575. }
  12576. }
  12577. else {
  12578. this._connectedInputTexts.forEach(function (connectedInputText) {
  12579. _this._removeConnectedInputObservables(connectedInputText);
  12580. });
  12581. this._connectedInputTexts = [];
  12582. }
  12583. if (this._connectedInputTexts.length === 0) {
  12584. this._currentlyConnectedInputText = null;
  12585. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  12586. this._onKeyPressObserver = null;
  12587. }
  12588. };
  12589. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  12590. connectedInputText.input._connectedVirtualKeyboard = null;
  12591. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  12592. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  12593. };
  12594. /**
  12595. * Release all resources
  12596. */
  12597. VirtualKeyboard.prototype.dispose = function () {
  12598. _super.prototype.dispose.call(this);
  12599. this.disconnect();
  12600. };
  12601. // Statics
  12602. /**
  12603. * Creates a new keyboard using a default layout
  12604. *
  12605. * @param name defines control name
  12606. * @returns a new VirtualKeyboard
  12607. */
  12608. VirtualKeyboard.CreateDefaultLayout = function (name) {
  12609. var returnValue = new VirtualKeyboard(name);
  12610. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  12611. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  12612. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  12613. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  12614. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  12615. return returnValue;
  12616. };
  12617. return VirtualKeyboard;
  12618. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  12619. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  12620. /***/ }),
  12621. /***/ "./2D/index.ts":
  12622. /*!*********************!*\
  12623. !*** ./2D/index.ts ***!
  12624. \*********************/
  12625. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  12626. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12627. "use strict";
  12628. __webpack_require__.r(__webpack_exports__);
  12629. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  12630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  12631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  12632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  12633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  12634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  12635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  12636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  12637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  12638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  12639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  12640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  12641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  12642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  12643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  12644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  12645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  12646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  12647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  12648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  12649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  12650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  12651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  12652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  12653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  12654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  12655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  12656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  12657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  12658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  12659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  12660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  12661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  12662. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  12664. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  12665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  12666. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  12667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  12668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  12669. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  12670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  12671. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  12672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  12673. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  12674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  12675. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  12677. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  12678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  12679. /***/ }),
  12680. /***/ "./2D/math2D.ts":
  12681. /*!**********************!*\
  12682. !*** ./2D/math2D.ts ***!
  12683. \**********************/
  12684. /*! exports provided: Vector2WithInfo, Matrix2D */
  12685. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12686. "use strict";
  12687. __webpack_require__.r(__webpack_exports__);
  12688. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  12689. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  12690. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12691. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  12692. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  12693. /**
  12694. * Class used to transport Vector2 information for pointer events
  12695. */
  12696. var Vector2WithInfo = /** @class */ (function (_super) {
  12697. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  12698. /**
  12699. * Creates a new Vector2WithInfo
  12700. * @param source defines the vector2 data to transport
  12701. * @param buttonIndex defines the current mouse button index
  12702. */
  12703. function Vector2WithInfo(source,
  12704. /** defines the current mouse button index */
  12705. buttonIndex) {
  12706. if (buttonIndex === void 0) { buttonIndex = 0; }
  12707. var _this = _super.call(this, source.x, source.y) || this;
  12708. _this.buttonIndex = buttonIndex;
  12709. return _this;
  12710. }
  12711. return Vector2WithInfo;
  12712. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  12713. /** Class used to provide 2D matrix features */
  12714. var Matrix2D = /** @class */ (function () {
  12715. /**
  12716. * Creates a new matrix
  12717. * @param m00 defines value for (0, 0)
  12718. * @param m01 defines value for (0, 1)
  12719. * @param m10 defines value for (1, 0)
  12720. * @param m11 defines value for (1, 1)
  12721. * @param m20 defines value for (2, 0)
  12722. * @param m21 defines value for (2, 1)
  12723. */
  12724. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  12725. /** Gets the internal array of 6 floats used to store matrix data */
  12726. this.m = new Float32Array(6);
  12727. this.fromValues(m00, m01, m10, m11, m20, m21);
  12728. }
  12729. /**
  12730. * Fills the matrix from direct values
  12731. * @param m00 defines value for (0, 0)
  12732. * @param m01 defines value for (0, 1)
  12733. * @param m10 defines value for (1, 0)
  12734. * @param m11 defines value for (1, 1)
  12735. * @param m20 defines value for (2, 0)
  12736. * @param m21 defines value for (2, 1)
  12737. * @returns the current modified matrix
  12738. */
  12739. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  12740. this.m[0] = m00;
  12741. this.m[1] = m01;
  12742. this.m[2] = m10;
  12743. this.m[3] = m11;
  12744. this.m[4] = m20;
  12745. this.m[5] = m21;
  12746. return this;
  12747. };
  12748. /**
  12749. * Gets matrix determinant
  12750. * @returns the determinant
  12751. */
  12752. Matrix2D.prototype.determinant = function () {
  12753. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  12754. };
  12755. /**
  12756. * Inverses the matrix and stores it in a target matrix
  12757. * @param result defines the target matrix
  12758. * @returns the current matrix
  12759. */
  12760. Matrix2D.prototype.invertToRef = function (result) {
  12761. var l0 = this.m[0];
  12762. var l1 = this.m[1];
  12763. var l2 = this.m[2];
  12764. var l3 = this.m[3];
  12765. var l4 = this.m[4];
  12766. var l5 = this.m[5];
  12767. var det = this.determinant();
  12768. if (det < (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  12769. result.m[0] = 0;
  12770. result.m[1] = 0;
  12771. result.m[2] = 0;
  12772. result.m[3] = 0;
  12773. result.m[4] = 0;
  12774. result.m[5] = 0;
  12775. return this;
  12776. }
  12777. var detDiv = 1 / det;
  12778. var det4 = l2 * l5 - l3 * l4;
  12779. var det5 = l1 * l4 - l0 * l5;
  12780. result.m[0] = l3 * detDiv;
  12781. result.m[1] = -l1 * detDiv;
  12782. result.m[2] = -l2 * detDiv;
  12783. result.m[3] = l0 * detDiv;
  12784. result.m[4] = det4 * detDiv;
  12785. result.m[5] = det5 * detDiv;
  12786. return this;
  12787. };
  12788. /**
  12789. * Multiplies the current matrix with another one
  12790. * @param other defines the second operand
  12791. * @param result defines the target matrix
  12792. * @returns the current matrix
  12793. */
  12794. Matrix2D.prototype.multiplyToRef = function (other, result) {
  12795. var l0 = this.m[0];
  12796. var l1 = this.m[1];
  12797. var l2 = this.m[2];
  12798. var l3 = this.m[3];
  12799. var l4 = this.m[4];
  12800. var l5 = this.m[5];
  12801. var r0 = other.m[0];
  12802. var r1 = other.m[1];
  12803. var r2 = other.m[2];
  12804. var r3 = other.m[3];
  12805. var r4 = other.m[4];
  12806. var r5 = other.m[5];
  12807. result.m[0] = l0 * r0 + l1 * r2;
  12808. result.m[1] = l0 * r1 + l1 * r3;
  12809. result.m[2] = l2 * r0 + l3 * r2;
  12810. result.m[3] = l2 * r1 + l3 * r3;
  12811. result.m[4] = l4 * r0 + l5 * r2 + r4;
  12812. result.m[5] = l4 * r1 + l5 * r3 + r5;
  12813. return this;
  12814. };
  12815. /**
  12816. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  12817. * @param x defines the x coordinate to transform
  12818. * @param y defines the x coordinate to transform
  12819. * @param result defines the target vector2
  12820. * @returns the current matrix
  12821. */
  12822. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  12823. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  12824. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  12825. return this;
  12826. };
  12827. // Statics
  12828. /**
  12829. * Creates an identity matrix
  12830. * @returns a new matrix
  12831. */
  12832. Matrix2D.Identity = function () {
  12833. return new Matrix2D(1, 0, 0, 1, 0, 0);
  12834. };
  12835. /**
  12836. * Creates a translation matrix and stores it in a target matrix
  12837. * @param x defines the x coordinate of the translation
  12838. * @param y defines the y coordinate of the translation
  12839. * @param result defines the target matrix
  12840. */
  12841. Matrix2D.TranslationToRef = function (x, y, result) {
  12842. result.fromValues(1, 0, 0, 1, x, y);
  12843. };
  12844. /**
  12845. * Creates a scaling matrix and stores it in a target matrix
  12846. * @param x defines the x coordinate of the scaling
  12847. * @param y defines the y coordinate of the scaling
  12848. * @param result defines the target matrix
  12849. */
  12850. Matrix2D.ScalingToRef = function (x, y, result) {
  12851. result.fromValues(x, 0, 0, y, 0, 0);
  12852. };
  12853. /**
  12854. * Creates a rotation matrix and stores it in a target matrix
  12855. * @param angle defines the rotation angle
  12856. * @param result defines the target matrix
  12857. */
  12858. Matrix2D.RotationToRef = function (angle, result) {
  12859. var s = Math.sin(angle);
  12860. var c = Math.cos(angle);
  12861. result.fromValues(c, s, -s, c, 0, 0);
  12862. };
  12863. /**
  12864. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  12865. * @param tx defines the x coordinate of the translation
  12866. * @param ty defines the y coordinate of the translation
  12867. * @param angle defines the rotation angle
  12868. * @param scaleX defines the x coordinate of the scaling
  12869. * @param scaleY defines the y coordinate of the scaling
  12870. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  12871. * @param result defines the target matrix
  12872. */
  12873. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  12874. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  12875. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  12876. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  12877. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  12878. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  12879. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  12880. if (parentMatrix) {
  12881. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  12882. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  12883. }
  12884. else {
  12885. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  12886. }
  12887. };
  12888. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  12889. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  12890. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  12891. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  12892. Matrix2D._TempCompose0 = Matrix2D.Identity();
  12893. Matrix2D._TempCompose1 = Matrix2D.Identity();
  12894. Matrix2D._TempCompose2 = Matrix2D.Identity();
  12895. return Matrix2D;
  12896. }());
  12897. /***/ }),
  12898. /***/ "./2D/measure.ts":
  12899. /*!***********************!*\
  12900. !*** ./2D/measure.ts ***!
  12901. \***********************/
  12902. /*! exports provided: Measure */
  12903. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12904. "use strict";
  12905. __webpack_require__.r(__webpack_exports__);
  12906. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  12907. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  12908. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  12909. var tmpRect = [
  12910. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12911. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12912. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12913. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12914. ];
  12915. var tmpRect2 = [
  12916. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12917. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12918. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12919. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12920. ];
  12921. var tmpV1 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12922. var tmpV2 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12923. /**
  12924. * Class used to store 2D control sizes
  12925. */
  12926. var Measure = /** @class */ (function () {
  12927. /**
  12928. * Creates a new measure
  12929. * @param left defines left coordinate
  12930. * @param top defines top coordinate
  12931. * @param width defines width dimension
  12932. * @param height defines height dimension
  12933. */
  12934. function Measure(
  12935. /** defines left coordinate */
  12936. left,
  12937. /** defines top coordinate */
  12938. top,
  12939. /** defines width dimension */
  12940. width,
  12941. /** defines height dimension */
  12942. height) {
  12943. this.left = left;
  12944. this.top = top;
  12945. this.width = width;
  12946. this.height = height;
  12947. }
  12948. /**
  12949. * Copy from another measure
  12950. * @param other defines the other measure to copy from
  12951. */
  12952. Measure.prototype.copyFrom = function (other) {
  12953. this.left = other.left;
  12954. this.top = other.top;
  12955. this.width = other.width;
  12956. this.height = other.height;
  12957. };
  12958. /**
  12959. * Copy from a group of 4 floats
  12960. * @param left defines left coordinate
  12961. * @param top defines top coordinate
  12962. * @param width defines width dimension
  12963. * @param height defines height dimension
  12964. */
  12965. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  12966. this.left = left;
  12967. this.top = top;
  12968. this.width = width;
  12969. this.height = height;
  12970. };
  12971. /**
  12972. * Computes the axis aligned bounding box measure for two given measures
  12973. * @param a Input measure
  12974. * @param b Input measure
  12975. * @param result the resulting bounding measure
  12976. */
  12977. Measure.CombineToRef = function (a, b, result) {
  12978. var left = Math.min(a.left, b.left);
  12979. var top = Math.min(a.top, b.top);
  12980. var right = Math.max(a.left + a.width, b.left + b.width);
  12981. var bottom = Math.max(a.top + a.height, b.top + b.height);
  12982. result.left = left;
  12983. result.top = top;
  12984. result.width = right - left;
  12985. result.height = bottom - top;
  12986. };
  12987. /**
  12988. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  12989. * @param transform the matrix to transform the measure before computing the AABB
  12990. * @param result the resulting AABB
  12991. */
  12992. Measure.prototype.transformToRef = function (transform, result) {
  12993. tmpRect[0].copyFromFloats(this.left, this.top);
  12994. tmpRect[1].copyFromFloats(this.left + this.width, this.top);
  12995. tmpRect[2].copyFromFloats(this.left + this.width, this.top + this.height);
  12996. tmpRect[3].copyFromFloats(this.left, this.top + this.height);
  12997. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  12998. tmpV2.copyFromFloats(0, 0);
  12999. for (var i = 0; i < 4; i++) {
  13000. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  13001. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  13002. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  13003. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  13004. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  13005. }
  13006. result.left = tmpV1.x;
  13007. result.top = tmpV1.y;
  13008. result.width = tmpV2.x - tmpV1.x;
  13009. result.height = tmpV2.y - tmpV1.y;
  13010. };
  13011. /**
  13012. * Check equality between this measure and another one
  13013. * @param other defines the other measures
  13014. * @returns true if both measures are equals
  13015. */
  13016. Measure.prototype.isEqualsTo = function (other) {
  13017. if (this.left !== other.left) {
  13018. return false;
  13019. }
  13020. if (this.top !== other.top) {
  13021. return false;
  13022. }
  13023. if (this.width !== other.width) {
  13024. return false;
  13025. }
  13026. if (this.height !== other.height) {
  13027. return false;
  13028. }
  13029. return true;
  13030. };
  13031. /**
  13032. * Creates an empty measure
  13033. * @returns a new measure
  13034. */
  13035. Measure.Empty = function () {
  13036. return new Measure(0, 0, 0, 0);
  13037. };
  13038. return Measure;
  13039. }());
  13040. /***/ }),
  13041. /***/ "./2D/multiLinePoint.ts":
  13042. /*!******************************!*\
  13043. !*** ./2D/multiLinePoint.ts ***!
  13044. \******************************/
  13045. /*! exports provided: MultiLinePoint */
  13046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13047. "use strict";
  13048. __webpack_require__.r(__webpack_exports__);
  13049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  13050. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  13051. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13052. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13053. /**
  13054. * Class used to store a point for a MultiLine object.
  13055. * The point can be pure 2D coordinates, a mesh or a control
  13056. */
  13057. var MultiLinePoint = /** @class */ (function () {
  13058. /**
  13059. * Creates a new MultiLinePoint
  13060. * @param multiLine defines the source MultiLine object
  13061. */
  13062. function MultiLinePoint(multiLine) {
  13063. this._multiLine = multiLine;
  13064. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13065. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13066. this._point = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13067. }
  13068. Object.defineProperty(MultiLinePoint.prototype, "x", {
  13069. /** Gets or sets x coordinate */
  13070. get: function () {
  13071. return this._x.toString(this._multiLine._host);
  13072. },
  13073. set: function (value) {
  13074. if (this._x.toString(this._multiLine._host) === value) {
  13075. return;
  13076. }
  13077. if (this._x.fromString(value)) {
  13078. this._multiLine._markAsDirty();
  13079. }
  13080. },
  13081. enumerable: true,
  13082. configurable: true
  13083. });
  13084. Object.defineProperty(MultiLinePoint.prototype, "y", {
  13085. /** Gets or sets y coordinate */
  13086. get: function () {
  13087. return this._y.toString(this._multiLine._host);
  13088. },
  13089. set: function (value) {
  13090. if (this._y.toString(this._multiLine._host) === value) {
  13091. return;
  13092. }
  13093. if (this._y.fromString(value)) {
  13094. this._multiLine._markAsDirty();
  13095. }
  13096. },
  13097. enumerable: true,
  13098. configurable: true
  13099. });
  13100. Object.defineProperty(MultiLinePoint.prototype, "control", {
  13101. /** Gets or sets the control associated with this point */
  13102. get: function () {
  13103. return this._control;
  13104. },
  13105. set: function (value) {
  13106. if (this._control === value) {
  13107. return;
  13108. }
  13109. if (this._control && this._controlObserver) {
  13110. this._control.onDirtyObservable.remove(this._controlObserver);
  13111. this._controlObserver = null;
  13112. }
  13113. this._control = value;
  13114. if (this._control) {
  13115. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  13116. }
  13117. this._multiLine._markAsDirty();
  13118. },
  13119. enumerable: true,
  13120. configurable: true
  13121. });
  13122. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  13123. /** Gets or sets the mesh associated with this point */
  13124. get: function () {
  13125. return this._mesh;
  13126. },
  13127. set: function (value) {
  13128. if (this._mesh === value) {
  13129. return;
  13130. }
  13131. if (this._mesh && this._meshObserver) {
  13132. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  13133. }
  13134. this._mesh = value;
  13135. if (this._mesh) {
  13136. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  13137. }
  13138. this._multiLine._markAsDirty();
  13139. },
  13140. enumerable: true,
  13141. configurable: true
  13142. });
  13143. /** Resets links */
  13144. MultiLinePoint.prototype.resetLinks = function () {
  13145. this.control = null;
  13146. this.mesh = null;
  13147. };
  13148. /**
  13149. * Gets a translation vector
  13150. * @returns the translation vector
  13151. */
  13152. MultiLinePoint.prototype.translate = function () {
  13153. this._point = this._translatePoint();
  13154. return this._point;
  13155. };
  13156. MultiLinePoint.prototype._translatePoint = function () {
  13157. if (this._mesh != null) {
  13158. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  13159. }
  13160. else if (this._control != null) {
  13161. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  13162. }
  13163. else {
  13164. var host = this._multiLine._host;
  13165. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  13166. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  13167. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  13168. }
  13169. };
  13170. /** Release associated resources */
  13171. MultiLinePoint.prototype.dispose = function () {
  13172. this.resetLinks();
  13173. };
  13174. return MultiLinePoint;
  13175. }());
  13176. /***/ }),
  13177. /***/ "./2D/style.ts":
  13178. /*!*********************!*\
  13179. !*** ./2D/style.ts ***!
  13180. \*********************/
  13181. /*! exports provided: Style */
  13182. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13183. "use strict";
  13184. __webpack_require__.r(__webpack_exports__);
  13185. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  13186. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  13187. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13188. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13189. /**
  13190. * Define a style used by control to automatically setup properties based on a template.
  13191. * Only support font related properties so far
  13192. */
  13193. var Style = /** @class */ (function () {
  13194. /**
  13195. * Creates a new style object
  13196. * @param host defines the AdvancedDynamicTexture which hosts this style
  13197. */
  13198. function Style(host) {
  13199. this._fontFamily = "Arial";
  13200. this._fontStyle = "";
  13201. this._fontWeight = "";
  13202. /** @hidden */
  13203. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  13204. /**
  13205. * Observable raised when the style values are changed
  13206. */
  13207. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13208. this._host = host;
  13209. }
  13210. Object.defineProperty(Style.prototype, "fontSize", {
  13211. /**
  13212. * Gets or sets the font size
  13213. */
  13214. get: function () {
  13215. return this._fontSize.toString(this._host);
  13216. },
  13217. set: function (value) {
  13218. if (this._fontSize.toString(this._host) === value) {
  13219. return;
  13220. }
  13221. if (this._fontSize.fromString(value)) {
  13222. this.onChangedObservable.notifyObservers(this);
  13223. }
  13224. },
  13225. enumerable: true,
  13226. configurable: true
  13227. });
  13228. Object.defineProperty(Style.prototype, "fontFamily", {
  13229. /**
  13230. * Gets or sets the font family
  13231. */
  13232. get: function () {
  13233. return this._fontFamily;
  13234. },
  13235. set: function (value) {
  13236. if (this._fontFamily === value) {
  13237. return;
  13238. }
  13239. this._fontFamily = value;
  13240. this.onChangedObservable.notifyObservers(this);
  13241. },
  13242. enumerable: true,
  13243. configurable: true
  13244. });
  13245. Object.defineProperty(Style.prototype, "fontStyle", {
  13246. /**
  13247. * Gets or sets the font style
  13248. */
  13249. get: function () {
  13250. return this._fontStyle;
  13251. },
  13252. set: function (value) {
  13253. if (this._fontStyle === value) {
  13254. return;
  13255. }
  13256. this._fontStyle = value;
  13257. this.onChangedObservable.notifyObservers(this);
  13258. },
  13259. enumerable: true,
  13260. configurable: true
  13261. });
  13262. Object.defineProperty(Style.prototype, "fontWeight", {
  13263. /** Gets or sets font weight */
  13264. get: function () {
  13265. return this._fontWeight;
  13266. },
  13267. set: function (value) {
  13268. if (this._fontWeight === value) {
  13269. return;
  13270. }
  13271. this._fontWeight = value;
  13272. this.onChangedObservable.notifyObservers(this);
  13273. },
  13274. enumerable: true,
  13275. configurable: true
  13276. });
  13277. /** Dispose all associated resources */
  13278. Style.prototype.dispose = function () {
  13279. this.onChangedObservable.clear();
  13280. };
  13281. return Style;
  13282. }());
  13283. /***/ }),
  13284. /***/ "./2D/valueAndUnit.ts":
  13285. /*!****************************!*\
  13286. !*** ./2D/valueAndUnit.ts ***!
  13287. \****************************/
  13288. /*! exports provided: ValueAndUnit */
  13289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13290. "use strict";
  13291. __webpack_require__.r(__webpack_exports__);
  13292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  13293. /**
  13294. * Class used to specific a value and its associated unit
  13295. */
  13296. var ValueAndUnit = /** @class */ (function () {
  13297. /**
  13298. * Creates a new ValueAndUnit
  13299. * @param value defines the value to store
  13300. * @param unit defines the unit to store
  13301. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  13302. */
  13303. function ValueAndUnit(value,
  13304. /** defines the unit to store */
  13305. unit,
  13306. /** defines a boolean indicating if the value can be negative */
  13307. negativeValueAllowed) {
  13308. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13309. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  13310. this.unit = unit;
  13311. this.negativeValueAllowed = negativeValueAllowed;
  13312. this._value = 1;
  13313. /**
  13314. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  13315. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  13316. */
  13317. this.ignoreAdaptiveScaling = false;
  13318. this._value = value;
  13319. this._originalUnit = unit;
  13320. }
  13321. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  13322. /** Gets a boolean indicating if the value is a percentage */
  13323. get: function () {
  13324. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  13325. },
  13326. enumerable: true,
  13327. configurable: true
  13328. });
  13329. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  13330. /** Gets a boolean indicating if the value is store as pixel */
  13331. get: function () {
  13332. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  13333. },
  13334. enumerable: true,
  13335. configurable: true
  13336. });
  13337. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  13338. /** Gets direct internal value */
  13339. get: function () {
  13340. return this._value;
  13341. },
  13342. enumerable: true,
  13343. configurable: true
  13344. });
  13345. /**
  13346. * Gets value as pixel
  13347. * @param host defines the root host
  13348. * @param refValue defines the reference value for percentages
  13349. * @returns the value as pixel
  13350. */
  13351. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  13352. if (this.isPixel) {
  13353. return this.getValue(host);
  13354. }
  13355. return this.getValue(host) * refValue;
  13356. };
  13357. /**
  13358. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  13359. * @param value defines the value to store
  13360. * @param unit defines the unit to store
  13361. * @returns the current ValueAndUnit
  13362. */
  13363. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  13364. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13365. this._value = value;
  13366. this.unit = unit;
  13367. return this;
  13368. };
  13369. /**
  13370. * Gets the value accordingly to its unit
  13371. * @param host defines the root host
  13372. * @returns the value
  13373. */
  13374. ValueAndUnit.prototype.getValue = function (host) {
  13375. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  13376. var width = 0;
  13377. var height = 0;
  13378. if (host.idealWidth) {
  13379. width = (this._value * host.getSize().width) / host.idealWidth;
  13380. }
  13381. if (host.idealHeight) {
  13382. height = (this._value * host.getSize().height) / host.idealHeight;
  13383. }
  13384. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  13385. return window.innerWidth < window.innerHeight ? width : height;
  13386. }
  13387. if (host.idealWidth) { // horizontal
  13388. return width;
  13389. }
  13390. if (host.idealHeight) { // vertical
  13391. return height;
  13392. }
  13393. }
  13394. return this._value;
  13395. };
  13396. /**
  13397. * Gets a string representation of the value
  13398. * @param host defines the root host
  13399. * @param decimals defines an optional number of decimals to display
  13400. * @returns a string
  13401. */
  13402. ValueAndUnit.prototype.toString = function (host, decimals) {
  13403. switch (this.unit) {
  13404. case ValueAndUnit.UNITMODE_PERCENTAGE:
  13405. var percentage = this.getValue(host) * 100;
  13406. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  13407. case ValueAndUnit.UNITMODE_PIXEL:
  13408. var pixels = this.getValue(host);
  13409. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  13410. }
  13411. return this.unit.toString();
  13412. };
  13413. /**
  13414. * Store a value parsed from a string
  13415. * @param source defines the source string
  13416. * @returns true if the value was successfully parsed
  13417. */
  13418. ValueAndUnit.prototype.fromString = function (source) {
  13419. var match = ValueAndUnit._Regex.exec(source.toString());
  13420. if (!match || match.length === 0) {
  13421. return false;
  13422. }
  13423. var sourceValue = parseFloat(match[1]);
  13424. var sourceUnit = this._originalUnit;
  13425. if (!this.negativeValueAllowed) {
  13426. if (sourceValue < 0) {
  13427. sourceValue = 0;
  13428. }
  13429. }
  13430. if (match.length === 4) {
  13431. switch (match[3]) {
  13432. case "px":
  13433. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  13434. break;
  13435. case "%":
  13436. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  13437. sourceValue /= 100.0;
  13438. break;
  13439. }
  13440. }
  13441. if (sourceValue === this._value && sourceUnit === this.unit) {
  13442. return false;
  13443. }
  13444. this._value = sourceValue;
  13445. this.unit = sourceUnit;
  13446. return true;
  13447. };
  13448. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  13449. /** UNITMODE_PERCENTAGE */
  13450. get: function () {
  13451. return ValueAndUnit._UNITMODE_PERCENTAGE;
  13452. },
  13453. enumerable: true,
  13454. configurable: true
  13455. });
  13456. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  13457. /** UNITMODE_PIXEL */
  13458. get: function () {
  13459. return ValueAndUnit._UNITMODE_PIXEL;
  13460. },
  13461. enumerable: true,
  13462. configurable: true
  13463. });
  13464. // Static
  13465. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  13466. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  13467. ValueAndUnit._UNITMODE_PIXEL = 1;
  13468. return ValueAndUnit;
  13469. }());
  13470. /***/ }),
  13471. /***/ "./2D/xmlLoader.ts":
  13472. /*!*************************!*\
  13473. !*** ./2D/xmlLoader.ts ***!
  13474. \*************************/
  13475. /*! exports provided: XmlLoader */
  13476. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13477. "use strict";
  13478. __webpack_require__.r(__webpack_exports__);
  13479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  13480. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  13481. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  13482. /**
  13483. * Class used to load GUI via XML.
  13484. */
  13485. var XmlLoader = /** @class */ (function () {
  13486. /**
  13487. * Create a new xml loader
  13488. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  13489. */
  13490. function XmlLoader(parentClass) {
  13491. if (parentClass === void 0) { parentClass = null; }
  13492. this._nodes = {};
  13493. this._nodeTypes = {
  13494. element: 1,
  13495. attribute: 2,
  13496. text: 3
  13497. };
  13498. this._isLoaded = false;
  13499. this._objectAttributes = {
  13500. "textHorizontalAlignment": 1,
  13501. "textVerticalAlignment": 2,
  13502. "horizontalAlignment": 3,
  13503. "verticalAlignment": 4,
  13504. "stretch": 5,
  13505. };
  13506. if (parentClass) {
  13507. this._parentClass = parentClass;
  13508. }
  13509. }
  13510. XmlLoader.prototype._getChainElement = function (attributeValue) {
  13511. var element = window;
  13512. if (this._parentClass) {
  13513. element = this._parentClass;
  13514. }
  13515. var value = attributeValue;
  13516. value = value.split(".");
  13517. for (var i = 0; i < value.length; i++) {
  13518. element = element[value[i]];
  13519. }
  13520. return element;
  13521. };
  13522. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  13523. var attribute = attributeName.split(".");
  13524. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  13525. return className[attribute[1]];
  13526. };
  13527. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  13528. if (linkParent === void 0) { linkParent = true; }
  13529. try {
  13530. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  13531. var guiNode = new className();
  13532. if (parent && linkParent) {
  13533. parent.addControl(guiNode);
  13534. }
  13535. for (var i = 0; i < node.attributes.length; i++) {
  13536. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  13537. continue;
  13538. }
  13539. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  13540. var element = this._getChainElement(node.attributes[i].value);
  13541. guiNode[node.attributes[i].name].add(element);
  13542. continue;
  13543. }
  13544. else if (node.attributes[i].name == "linkWithMesh") {
  13545. if (this._parentClass) {
  13546. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  13547. }
  13548. else {
  13549. guiNode.linkWithMesh(window[node.attributes[i].value]);
  13550. }
  13551. }
  13552. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  13553. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  13554. guiNode[node.attributes[i].name] = element;
  13555. }
  13556. else if (!this._objectAttributes[node.attributes[i].name]) {
  13557. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  13558. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  13559. }
  13560. else {
  13561. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  13562. }
  13563. }
  13564. else {
  13565. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  13566. }
  13567. }
  13568. if (!node.attributes.getNamedItem("id")) {
  13569. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  13570. return guiNode;
  13571. }
  13572. var id = node.attributes.getNamedItem("id").value;
  13573. if (id.startsWith("{{") && id.endsWith("}}")) {
  13574. id = this._getChainElement(id.substring(2, id.length - 2));
  13575. }
  13576. if (!this._nodes[id]) {
  13577. this._nodes[id] = guiNode;
  13578. }
  13579. else {
  13580. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  13581. }
  13582. return guiNode;
  13583. }
  13584. catch (e) {
  13585. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  13586. }
  13587. };
  13588. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  13589. var width;
  13590. var height;
  13591. var columns;
  13592. var rows = node.children;
  13593. var cells;
  13594. var isPixel = false;
  13595. var cellNode;
  13596. var rowNumber = -1;
  13597. var columnNumber = -1;
  13598. var totalColumnsNumber = 0;
  13599. for (var i = 0; i < rows.length; i++) {
  13600. if (rows[i].nodeType != this._nodeTypes.element) {
  13601. continue;
  13602. }
  13603. if (rows[i].nodeName != "Row") {
  13604. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  13605. }
  13606. rowNumber += 1;
  13607. columns = rows[i].children;
  13608. if (!rows[i].attributes.getNamedItem("height")) {
  13609. throw "XmlLoader Exception : Height must be defined for grid rows";
  13610. }
  13611. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  13612. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  13613. guiNode.addRowDefinition(height, isPixel);
  13614. for (var j = 0; j < columns.length; j++) {
  13615. if (columns[j].nodeType != this._nodeTypes.element) {
  13616. continue;
  13617. }
  13618. if (columns[j].nodeName != "Column") {
  13619. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  13620. }
  13621. columnNumber += 1;
  13622. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  13623. 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.";
  13624. }
  13625. if (rowNumber == 0) {
  13626. if (!columns[j].attributes.getNamedItem("width")) {
  13627. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  13628. }
  13629. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  13630. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  13631. guiNode.addColumnDefinition(width, isPixel);
  13632. }
  13633. cells = columns[j].children;
  13634. for (var k = 0; k < cells.length; k++) {
  13635. if (cells[k].nodeType != this._nodeTypes.element) {
  13636. continue;
  13637. }
  13638. cellNode = this._createGuiElement(cells[k], guiNode, false);
  13639. guiNode.addControl(cellNode, rowNumber, columnNumber);
  13640. if (cells[k].firstChild) {
  13641. this._parseXml(cells[k].firstChild, cellNode);
  13642. }
  13643. }
  13644. }
  13645. if (rowNumber == 0) {
  13646. totalColumnsNumber = columnNumber;
  13647. }
  13648. columnNumber = -1;
  13649. }
  13650. if (node.nextSibling) {
  13651. this._parseXml(node.nextSibling, parent);
  13652. }
  13653. };
  13654. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  13655. if (node.firstChild) {
  13656. this._parseXml(node.firstChild, guiNode);
  13657. }
  13658. if (node.nextSibling) {
  13659. this._parseXml(node.nextSibling, parent);
  13660. }
  13661. };
  13662. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  13663. if (this._parentClass) {
  13664. this._parentClass[variable] = source[iterator];
  13665. }
  13666. else {
  13667. window[variable] = source[iterator];
  13668. }
  13669. if (node.firstChild) {
  13670. this._parseXml(node.firstChild, guiNode, true);
  13671. }
  13672. };
  13673. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  13674. var dataSource = node.attributes.getNamedItem("dataSource").value;
  13675. if (!dataSource.includes(" in ")) {
  13676. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  13677. }
  13678. else {
  13679. var isArray = true;
  13680. var splittedSource = dataSource.split(" in ");
  13681. if (splittedSource.length < 2) {
  13682. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  13683. }
  13684. var source = splittedSource[1];
  13685. if (source.startsWith("{") && source.endsWith("}")) {
  13686. isArray = false;
  13687. }
  13688. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  13689. source = source.substring(1, source.length - 1);
  13690. }
  13691. if (this._parentClass) {
  13692. source = this._parentClass[source];
  13693. }
  13694. else {
  13695. source = window[source];
  13696. }
  13697. if (isArray) {
  13698. for (var i = 0; i < source.length; i++) {
  13699. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13700. }
  13701. }
  13702. else {
  13703. for (var i in source) {
  13704. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13705. }
  13706. }
  13707. if (node.nextSibling) {
  13708. this._parseXml(node.nextSibling, parent);
  13709. }
  13710. }
  13711. };
  13712. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  13713. if (generated === void 0) { generated = false; }
  13714. if (node.nodeType != this._nodeTypes.element) {
  13715. if (node.nextSibling) {
  13716. this._parseXml(node.nextSibling, parent, generated);
  13717. }
  13718. return;
  13719. }
  13720. if (generated) {
  13721. node.setAttribute("id", parent.id + (parent._children.length + 1));
  13722. }
  13723. var guiNode = this._createGuiElement(node, parent);
  13724. if (node.nodeName == "Grid") {
  13725. this._parseGrid(node, guiNode, parent);
  13726. }
  13727. else if (!node.attributes.getNamedItem("dataSource")) {
  13728. this._parseElement(node, guiNode, parent);
  13729. }
  13730. else {
  13731. this._parseElementsFromSource(node, guiNode, parent);
  13732. }
  13733. };
  13734. /**
  13735. * Gets if the loading has finished.
  13736. * @returns whether the loading has finished or not
  13737. */
  13738. XmlLoader.prototype.isLoaded = function () {
  13739. return this._isLoaded;
  13740. };
  13741. /**
  13742. * Gets a loaded node / control by id.
  13743. * @param id the Controls id set in the xml
  13744. * @returns element of type Control
  13745. */
  13746. XmlLoader.prototype.getNodeById = function (id) {
  13747. return this._nodes[id];
  13748. };
  13749. /**
  13750. * Gets all loaded nodes / controls
  13751. * @returns Array of controls
  13752. */
  13753. XmlLoader.prototype.getNodes = function () {
  13754. return this._nodes;
  13755. };
  13756. /**
  13757. * Initiates the xml layout loading
  13758. * @param xmlFile defines the xml layout to load
  13759. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  13760. * @param callback defines the callback called on layout load.
  13761. */
  13762. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  13763. var xhttp = new XMLHttpRequest();
  13764. xhttp.onreadystatechange = function () {
  13765. if (xhttp.readyState == 4 && xhttp.status == 200) {
  13766. if (!xhttp.responseXML) {
  13767. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  13768. }
  13769. var xmlDoc = xhttp.responseXML.documentElement;
  13770. this._parseXml(xmlDoc.firstChild, rootNode);
  13771. this._isLoaded = true;
  13772. if (callback) {
  13773. callback();
  13774. }
  13775. }
  13776. }.bind(this);
  13777. xhttp.open("GET", xmlFile, true);
  13778. xhttp.send();
  13779. };
  13780. return XmlLoader;
  13781. }());
  13782. /***/ }),
  13783. /***/ "./3D/controls/abstractButton3D.ts":
  13784. /*!*****************************************!*\
  13785. !*** ./3D/controls/abstractButton3D.ts ***!
  13786. \*****************************************/
  13787. /*! exports provided: AbstractButton3D */
  13788. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13789. "use strict";
  13790. __webpack_require__.r(__webpack_exports__);
  13791. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  13792. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13793. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  13794. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13795. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13796. /**
  13797. * Class used as a root to all buttons
  13798. */
  13799. var AbstractButton3D = /** @class */ (function (_super) {
  13800. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  13801. /**
  13802. * Creates a new button
  13803. * @param name defines the control name
  13804. */
  13805. function AbstractButton3D(name) {
  13806. return _super.call(this, name) || this;
  13807. }
  13808. AbstractButton3D.prototype._getTypeName = function () {
  13809. return "AbstractButton3D";
  13810. };
  13811. // Mesh association
  13812. AbstractButton3D.prototype._createNode = function (scene) {
  13813. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  13814. };
  13815. return AbstractButton3D;
  13816. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13817. /***/ }),
  13818. /***/ "./3D/controls/button3D.ts":
  13819. /*!*********************************!*\
  13820. !*** ./3D/controls/button3D.ts ***!
  13821. \*********************************/
  13822. /*! exports provided: Button3D */
  13823. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13824. "use strict";
  13825. __webpack_require__.r(__webpack_exports__);
  13826. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  13827. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13828. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  13829. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  13830. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13831. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13832. /**
  13833. * Class used to create a button in 3D
  13834. */
  13835. var Button3D = /** @class */ (function (_super) {
  13836. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  13837. /**
  13838. * Creates a new button
  13839. * @param name defines the control name
  13840. */
  13841. function Button3D(name) {
  13842. var _this = _super.call(this, name) || this;
  13843. _this._contentResolution = 512;
  13844. _this._contentScaleRatio = 2;
  13845. // Default animations
  13846. _this.pointerEnterAnimation = function () {
  13847. if (!_this.mesh) {
  13848. return;
  13849. }
  13850. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  13851. };
  13852. _this.pointerOutAnimation = function () {
  13853. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13854. };
  13855. _this.pointerDownAnimation = function () {
  13856. if (!_this.mesh) {
  13857. return;
  13858. }
  13859. _this.mesh.scaling.scaleInPlace(0.95);
  13860. };
  13861. _this.pointerUpAnimation = function () {
  13862. if (!_this.mesh) {
  13863. return;
  13864. }
  13865. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13866. };
  13867. return _this;
  13868. }
  13869. Object.defineProperty(Button3D.prototype, "contentResolution", {
  13870. /**
  13871. * Gets or sets the texture resolution used to render content (512 by default)
  13872. */
  13873. get: function () {
  13874. return this._contentResolution;
  13875. },
  13876. set: function (value) {
  13877. if (this._contentResolution === value) {
  13878. return;
  13879. }
  13880. this._contentResolution = value;
  13881. this._resetContent();
  13882. },
  13883. enumerable: true,
  13884. configurable: true
  13885. });
  13886. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  13887. /**
  13888. * Gets or sets the texture scale ratio used to render content (2 by default)
  13889. */
  13890. get: function () {
  13891. return this._contentScaleRatio;
  13892. },
  13893. set: function (value) {
  13894. if (this._contentScaleRatio === value) {
  13895. return;
  13896. }
  13897. this._contentScaleRatio = value;
  13898. this._resetContent();
  13899. },
  13900. enumerable: true,
  13901. configurable: true
  13902. });
  13903. Button3D.prototype._disposeFacadeTexture = function () {
  13904. if (this._facadeTexture) {
  13905. this._facadeTexture.dispose();
  13906. this._facadeTexture = null;
  13907. }
  13908. };
  13909. Button3D.prototype._resetContent = function () {
  13910. this._disposeFacadeTexture();
  13911. this.content = this._content;
  13912. };
  13913. Object.defineProperty(Button3D.prototype, "content", {
  13914. /**
  13915. * Gets or sets the GUI 2D content used to display the button's facade
  13916. */
  13917. get: function () {
  13918. return this._content;
  13919. },
  13920. set: function (value) {
  13921. this._content = value;
  13922. if (!this._host || !this._host.utilityLayer) {
  13923. return;
  13924. }
  13925. if (!this._facadeTexture) {
  13926. this._facadeTexture = new _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__["AdvancedDynamicTexture"]("Facade", this._contentResolution, this._contentResolution, this._host.utilityLayer.utilityLayerScene, true, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  13927. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  13928. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  13929. this._facadeTexture.premulAlpha = true;
  13930. }
  13931. else {
  13932. this._facadeTexture.rootContainer.clearControls();
  13933. }
  13934. this._facadeTexture.addControl(value);
  13935. this._applyFacade(this._facadeTexture);
  13936. },
  13937. enumerable: true,
  13938. configurable: true
  13939. });
  13940. /**
  13941. * Apply the facade texture (created from the content property).
  13942. * This function can be overloaded by child classes
  13943. * @param facadeTexture defines the AdvancedDynamicTexture to use
  13944. */
  13945. Button3D.prototype._applyFacade = function (facadeTexture) {
  13946. this._currentMaterial.emissiveTexture = facadeTexture;
  13947. };
  13948. Button3D.prototype._getTypeName = function () {
  13949. return "Button3D";
  13950. };
  13951. // Mesh association
  13952. Button3D.prototype._createNode = function (scene) {
  13953. var faceUV = new Array(6);
  13954. for (var i = 0; i < 6; i++) {
  13955. faceUV[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  13956. }
  13957. faceUV[1] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  13958. var mesh = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  13959. width: 1.0,
  13960. height: 1.0,
  13961. depth: 0.08,
  13962. faceUV: faceUV
  13963. }, scene);
  13964. return mesh;
  13965. };
  13966. Button3D.prototype._affectMaterial = function (mesh) {
  13967. var material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  13968. material.specularColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13969. mesh.material = material;
  13970. this._currentMaterial = material;
  13971. this._resetContent();
  13972. };
  13973. /**
  13974. * Releases all associated resources
  13975. */
  13976. Button3D.prototype.dispose = function () {
  13977. _super.prototype.dispose.call(this);
  13978. this._disposeFacadeTexture();
  13979. if (this._currentMaterial) {
  13980. this._currentMaterial.dispose();
  13981. }
  13982. };
  13983. return Button3D;
  13984. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  13985. /***/ }),
  13986. /***/ "./3D/controls/container3D.ts":
  13987. /*!************************************!*\
  13988. !*** ./3D/controls/container3D.ts ***!
  13989. \************************************/
  13990. /*! exports provided: Container3D */
  13991. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13992. "use strict";
  13993. __webpack_require__.r(__webpack_exports__);
  13994. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  13995. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13996. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  13997. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13998. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13999. /**
  14000. * Class used to create containers for controls
  14001. */
  14002. var Container3D = /** @class */ (function (_super) {
  14003. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  14004. /**
  14005. * Creates a new container
  14006. * @param name defines the container name
  14007. */
  14008. function Container3D(name) {
  14009. var _this = _super.call(this, name) || this;
  14010. _this._blockLayout = false;
  14011. /**
  14012. * Gets the list of child controls
  14013. */
  14014. _this._children = new Array();
  14015. return _this;
  14016. }
  14017. Object.defineProperty(Container3D.prototype, "children", {
  14018. /**
  14019. * Gets the list of child controls
  14020. */
  14021. get: function () {
  14022. return this._children;
  14023. },
  14024. enumerable: true,
  14025. configurable: true
  14026. });
  14027. Object.defineProperty(Container3D.prototype, "blockLayout", {
  14028. /**
  14029. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  14030. * This is helpful to optimize layout operation when adding multiple children in a row
  14031. */
  14032. get: function () {
  14033. return this._blockLayout;
  14034. },
  14035. set: function (value) {
  14036. if (this._blockLayout === value) {
  14037. return;
  14038. }
  14039. this._blockLayout = value;
  14040. if (!this._blockLayout) {
  14041. this._arrangeChildren();
  14042. }
  14043. },
  14044. enumerable: true,
  14045. configurable: true
  14046. });
  14047. /**
  14048. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  14049. * @returns the current container
  14050. */
  14051. Container3D.prototype.updateLayout = function () {
  14052. this._arrangeChildren();
  14053. return this;
  14054. };
  14055. /**
  14056. * Gets a boolean indicating if the given control is in the children of this control
  14057. * @param control defines the control to check
  14058. * @returns true if the control is in the child list
  14059. */
  14060. Container3D.prototype.containsControl = function (control) {
  14061. return this._children.indexOf(control) !== -1;
  14062. };
  14063. /**
  14064. * Adds a control to the children of this control
  14065. * @param control defines the control to add
  14066. * @returns the current container
  14067. */
  14068. Container3D.prototype.addControl = function (control) {
  14069. var index = this._children.indexOf(control);
  14070. if (index !== -1) {
  14071. return this;
  14072. }
  14073. control.parent = this;
  14074. control._host = this._host;
  14075. this._children.push(control);
  14076. if (this._host.utilityLayer) {
  14077. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  14078. if (control.node) {
  14079. control.node.parent = this.node;
  14080. }
  14081. if (!this.blockLayout) {
  14082. this._arrangeChildren();
  14083. }
  14084. }
  14085. return this;
  14086. };
  14087. /**
  14088. * This function will be called everytime a new control is added
  14089. */
  14090. Container3D.prototype._arrangeChildren = function () {
  14091. };
  14092. Container3D.prototype._createNode = function (scene) {
  14093. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  14094. };
  14095. /**
  14096. * Removes a control from the children of this control
  14097. * @param control defines the control to remove
  14098. * @returns the current container
  14099. */
  14100. Container3D.prototype.removeControl = function (control) {
  14101. var index = this._children.indexOf(control);
  14102. if (index !== -1) {
  14103. this._children.splice(index, 1);
  14104. control.parent = null;
  14105. control._disposeNode();
  14106. }
  14107. return this;
  14108. };
  14109. Container3D.prototype._getTypeName = function () {
  14110. return "Container3D";
  14111. };
  14112. /**
  14113. * Releases all associated resources
  14114. */
  14115. Container3D.prototype.dispose = function () {
  14116. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14117. var control = _a[_i];
  14118. control.dispose();
  14119. }
  14120. this._children = [];
  14121. _super.prototype.dispose.call(this);
  14122. };
  14123. /** Control rotation will remain unchanged */
  14124. Container3D.UNSET_ORIENTATION = 0;
  14125. /** Control will rotate to make it look at sphere central axis */
  14126. Container3D.FACEORIGIN_ORIENTATION = 1;
  14127. /** Control will rotate to make it look back at sphere central axis */
  14128. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  14129. /** Control will rotate to look at z axis (0, 0, 1) */
  14130. Container3D.FACEFORWARD_ORIENTATION = 3;
  14131. /** Control will rotate to look at negative z axis (0, 0, -1) */
  14132. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  14133. return Container3D;
  14134. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14135. /***/ }),
  14136. /***/ "./3D/controls/control3D.ts":
  14137. /*!**********************************!*\
  14138. !*** ./3D/controls/control3D.ts ***!
  14139. \**********************************/
  14140. /*! exports provided: Control3D */
  14141. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14142. "use strict";
  14143. __webpack_require__.r(__webpack_exports__);
  14144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  14145. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  14146. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14147. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14148. /**
  14149. * Class used as base class for controls
  14150. */
  14151. var Control3D = /** @class */ (function () {
  14152. /**
  14153. * Creates a new control
  14154. * @param name defines the control name
  14155. */
  14156. function Control3D(
  14157. /** Defines the control name */
  14158. name) {
  14159. this.name = name;
  14160. this._downCount = 0;
  14161. this._enterCount = -1;
  14162. this._downPointerIds = {};
  14163. this._isVisible = true;
  14164. /**
  14165. * An event triggered when the pointer move over the control
  14166. */
  14167. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14168. /**
  14169. * An event triggered when the pointer move out of the control
  14170. */
  14171. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14172. /**
  14173. * An event triggered when the pointer taps the control
  14174. */
  14175. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14176. /**
  14177. * An event triggered when pointer is up
  14178. */
  14179. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14180. /**
  14181. * An event triggered when a control is clicked on (with a mouse)
  14182. */
  14183. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14184. /**
  14185. * An event triggered when pointer enters the control
  14186. */
  14187. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14188. // Behaviors
  14189. this._behaviors = new Array();
  14190. }
  14191. Object.defineProperty(Control3D.prototype, "position", {
  14192. /** Gets or sets the control position in world space */
  14193. get: function () {
  14194. if (!this._node) {
  14195. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  14196. }
  14197. return this._node.position;
  14198. },
  14199. set: function (value) {
  14200. if (!this._node) {
  14201. return;
  14202. }
  14203. this._node.position = value;
  14204. },
  14205. enumerable: true,
  14206. configurable: true
  14207. });
  14208. Object.defineProperty(Control3D.prototype, "scaling", {
  14209. /** Gets or sets the control scaling in world space */
  14210. get: function () {
  14211. if (!this._node) {
  14212. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  14213. }
  14214. return this._node.scaling;
  14215. },
  14216. set: function (value) {
  14217. if (!this._node) {
  14218. return;
  14219. }
  14220. this._node.scaling = value;
  14221. },
  14222. enumerable: true,
  14223. configurable: true
  14224. });
  14225. Object.defineProperty(Control3D.prototype, "behaviors", {
  14226. /**
  14227. * Gets the list of attached behaviors
  14228. * @see http://doc.babylonjs.com/features/behaviour
  14229. */
  14230. get: function () {
  14231. return this._behaviors;
  14232. },
  14233. enumerable: true,
  14234. configurable: true
  14235. });
  14236. /**
  14237. * Attach a behavior to the control
  14238. * @see http://doc.babylonjs.com/features/behaviour
  14239. * @param behavior defines the behavior to attach
  14240. * @returns the current control
  14241. */
  14242. Control3D.prototype.addBehavior = function (behavior) {
  14243. var _this = this;
  14244. var index = this._behaviors.indexOf(behavior);
  14245. if (index !== -1) {
  14246. return this;
  14247. }
  14248. behavior.init();
  14249. var scene = this._host.scene;
  14250. if (scene.isLoading) {
  14251. // We defer the attach when the scene will be loaded
  14252. scene.onDataLoadedObservable.addOnce(function () {
  14253. behavior.attach(_this);
  14254. });
  14255. }
  14256. else {
  14257. behavior.attach(this);
  14258. }
  14259. this._behaviors.push(behavior);
  14260. return this;
  14261. };
  14262. /**
  14263. * Remove an attached behavior
  14264. * @see http://doc.babylonjs.com/features/behaviour
  14265. * @param behavior defines the behavior to attach
  14266. * @returns the current control
  14267. */
  14268. Control3D.prototype.removeBehavior = function (behavior) {
  14269. var index = this._behaviors.indexOf(behavior);
  14270. if (index === -1) {
  14271. return this;
  14272. }
  14273. this._behaviors[index].detach();
  14274. this._behaviors.splice(index, 1);
  14275. return this;
  14276. };
  14277. /**
  14278. * Gets an attached behavior by name
  14279. * @param name defines the name of the behavior to look for
  14280. * @see http://doc.babylonjs.com/features/behaviour
  14281. * @returns null if behavior was not found else the requested behavior
  14282. */
  14283. Control3D.prototype.getBehaviorByName = function (name) {
  14284. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14285. var behavior = _a[_i];
  14286. if (behavior.name === name) {
  14287. return behavior;
  14288. }
  14289. }
  14290. return null;
  14291. };
  14292. Object.defineProperty(Control3D.prototype, "isVisible", {
  14293. /** Gets or sets a boolean indicating if the control is visible */
  14294. get: function () {
  14295. return this._isVisible;
  14296. },
  14297. set: function (value) {
  14298. if (this._isVisible === value) {
  14299. return;
  14300. }
  14301. this._isVisible = value;
  14302. var mesh = this.mesh;
  14303. if (mesh) {
  14304. mesh.setEnabled(value);
  14305. }
  14306. },
  14307. enumerable: true,
  14308. configurable: true
  14309. });
  14310. Object.defineProperty(Control3D.prototype, "typeName", {
  14311. /**
  14312. * Gets a string representing the class name
  14313. */
  14314. get: function () {
  14315. return this._getTypeName();
  14316. },
  14317. enumerable: true,
  14318. configurable: true
  14319. });
  14320. /**
  14321. * Get the current class name of the control.
  14322. * @returns current class name
  14323. */
  14324. Control3D.prototype.getClassName = function () {
  14325. return this._getTypeName();
  14326. };
  14327. Control3D.prototype._getTypeName = function () {
  14328. return "Control3D";
  14329. };
  14330. Object.defineProperty(Control3D.prototype, "node", {
  14331. /**
  14332. * Gets the transform node used by this control
  14333. */
  14334. get: function () {
  14335. return this._node;
  14336. },
  14337. enumerable: true,
  14338. configurable: true
  14339. });
  14340. Object.defineProperty(Control3D.prototype, "mesh", {
  14341. /**
  14342. * Gets the mesh used to render this control
  14343. */
  14344. get: function () {
  14345. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  14346. return this._node;
  14347. }
  14348. return null;
  14349. },
  14350. enumerable: true,
  14351. configurable: true
  14352. });
  14353. /**
  14354. * Link the control as child of the given node
  14355. * @param node defines the node to link to. Use null to unlink the control
  14356. * @returns the current control
  14357. */
  14358. Control3D.prototype.linkToTransformNode = function (node) {
  14359. if (this._node) {
  14360. this._node.parent = node;
  14361. }
  14362. return this;
  14363. };
  14364. /** @hidden **/
  14365. Control3D.prototype._prepareNode = function (scene) {
  14366. if (!this._node) {
  14367. this._node = this._createNode(scene);
  14368. if (!this.node) {
  14369. return;
  14370. }
  14371. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  14372. this._node.position = this.position;
  14373. this._node.scaling = this.scaling;
  14374. var mesh = this.mesh;
  14375. if (mesh) {
  14376. mesh.isPickable = true;
  14377. this._affectMaterial(mesh);
  14378. }
  14379. }
  14380. };
  14381. /**
  14382. * Node creation.
  14383. * Can be overriden by children
  14384. * @param scene defines the scene where the node must be attached
  14385. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  14386. */
  14387. Control3D.prototype._createNode = function (scene) {
  14388. // Do nothing by default
  14389. return null;
  14390. };
  14391. /**
  14392. * Affect a material to the given mesh
  14393. * @param mesh defines the mesh which will represent the control
  14394. */
  14395. Control3D.prototype._affectMaterial = function (mesh) {
  14396. mesh.material = null;
  14397. };
  14398. // Pointers
  14399. /** @hidden */
  14400. Control3D.prototype._onPointerMove = function (target, coordinates) {
  14401. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  14402. };
  14403. /** @hidden */
  14404. Control3D.prototype._onPointerEnter = function (target) {
  14405. if (this._enterCount > 0) {
  14406. return false;
  14407. }
  14408. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  14409. this._enterCount = 0;
  14410. }
  14411. this._enterCount++;
  14412. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  14413. if (this.pointerEnterAnimation) {
  14414. this.pointerEnterAnimation();
  14415. }
  14416. return true;
  14417. };
  14418. /** @hidden */
  14419. Control3D.prototype._onPointerOut = function (target) {
  14420. this._enterCount = 0;
  14421. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  14422. if (this.pointerOutAnimation) {
  14423. this.pointerOutAnimation();
  14424. }
  14425. };
  14426. /** @hidden */
  14427. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  14428. if (this._downCount !== 0) {
  14429. this._downCount++;
  14430. return false;
  14431. }
  14432. this._downCount++;
  14433. this._downPointerIds[pointerId] = true;
  14434. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14435. if (this.pointerDownAnimation) {
  14436. this.pointerDownAnimation();
  14437. }
  14438. return true;
  14439. };
  14440. /** @hidden */
  14441. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  14442. this._downCount--;
  14443. delete this._downPointerIds[pointerId];
  14444. if (this._downCount < 0) {
  14445. // Handle if forcePointerUp was called prior to this
  14446. this._downCount = 0;
  14447. return;
  14448. }
  14449. if (this._downCount == 0) {
  14450. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  14451. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14452. }
  14453. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14454. if (this.pointerUpAnimation) {
  14455. this.pointerUpAnimation();
  14456. }
  14457. }
  14458. };
  14459. /** @hidden */
  14460. Control3D.prototype.forcePointerUp = function (pointerId) {
  14461. if (pointerId === void 0) { pointerId = null; }
  14462. if (pointerId !== null) {
  14463. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  14464. }
  14465. else {
  14466. for (var key in this._downPointerIds) {
  14467. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  14468. }
  14469. if (this._downCount > 0) {
  14470. this._downCount = 1;
  14471. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  14472. }
  14473. }
  14474. };
  14475. /** @hidden */
  14476. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  14477. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14478. this._onPointerMove(this, pickedPoint);
  14479. var previousControlOver = this._host._lastControlOver[pointerId];
  14480. if (previousControlOver && previousControlOver !== this) {
  14481. previousControlOver._onPointerOut(this);
  14482. }
  14483. if (previousControlOver !== this) {
  14484. this._onPointerEnter(this);
  14485. }
  14486. this._host._lastControlOver[pointerId] = this;
  14487. return true;
  14488. }
  14489. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  14490. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  14491. this._host._lastControlDown[pointerId] = this;
  14492. this._host._lastPickedControl = this;
  14493. return true;
  14494. }
  14495. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14496. if (this._host._lastControlDown[pointerId]) {
  14497. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  14498. }
  14499. delete this._host._lastControlDown[pointerId];
  14500. return true;
  14501. }
  14502. return false;
  14503. };
  14504. /** @hidden */
  14505. Control3D.prototype._disposeNode = function () {
  14506. if (this._node) {
  14507. this._node.dispose();
  14508. this._node = null;
  14509. }
  14510. };
  14511. /**
  14512. * Releases all associated resources
  14513. */
  14514. Control3D.prototype.dispose = function () {
  14515. this.onPointerDownObservable.clear();
  14516. this.onPointerEnterObservable.clear();
  14517. this.onPointerMoveObservable.clear();
  14518. this.onPointerOutObservable.clear();
  14519. this.onPointerUpObservable.clear();
  14520. this.onPointerClickObservable.clear();
  14521. this._disposeNode();
  14522. // Behaviors
  14523. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14524. var behavior = _a[_i];
  14525. behavior.detach();
  14526. }
  14527. };
  14528. return Control3D;
  14529. }());
  14530. /***/ }),
  14531. /***/ "./3D/controls/cylinderPanel.ts":
  14532. /*!**************************************!*\
  14533. !*** ./3D/controls/cylinderPanel.ts ***!
  14534. \**************************************/
  14535. /*! exports provided: CylinderPanel */
  14536. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14537. "use strict";
  14538. __webpack_require__.r(__webpack_exports__);
  14539. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  14540. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14541. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  14542. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14543. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14544. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14545. /**
  14546. * Class used to create a container panel deployed on the surface of a cylinder
  14547. */
  14548. var CylinderPanel = /** @class */ (function (_super) {
  14549. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  14550. function CylinderPanel() {
  14551. var _this = _super !== null && _super.apply(this, arguments) || this;
  14552. _this._radius = 5.0;
  14553. return _this;
  14554. }
  14555. Object.defineProperty(CylinderPanel.prototype, "radius", {
  14556. /**
  14557. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  14558. */
  14559. get: function () {
  14560. return this._radius;
  14561. },
  14562. set: function (value) {
  14563. var _this = this;
  14564. if (this._radius === value) {
  14565. return;
  14566. }
  14567. this._radius = value;
  14568. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14569. _this._arrangeChildren();
  14570. });
  14571. },
  14572. enumerable: true,
  14573. configurable: true
  14574. });
  14575. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  14576. var mesh = control.mesh;
  14577. if (!mesh) {
  14578. return;
  14579. }
  14580. var newPos = this._cylindricalMapping(nodePosition);
  14581. control.position = newPos;
  14582. switch (this.orientation) {
  14583. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14584. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  14585. break;
  14586. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14587. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  14588. break;
  14589. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14590. break;
  14591. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14592. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14593. break;
  14594. }
  14595. };
  14596. CylinderPanel.prototype._cylindricalMapping = function (source) {
  14597. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  14598. var yAngle = (source.x / this._radius);
  14599. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14600. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14601. };
  14602. return CylinderPanel;
  14603. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14604. /***/ }),
  14605. /***/ "./3D/controls/holographicButton.ts":
  14606. /*!******************************************!*\
  14607. !*** ./3D/controls/holographicButton.ts ***!
  14608. \******************************************/
  14609. /*! exports provided: HolographicButton */
  14610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14611. "use strict";
  14612. __webpack_require__.r(__webpack_exports__);
  14613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  14614. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14615. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14616. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Materials/standardMaterial */ "babylonjs/Misc/perfCounter");
  14617. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__);
  14618. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14619. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  14620. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  14621. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  14622. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14623. /**
  14624. * Class used to create a holographic button in 3D
  14625. */
  14626. var HolographicButton = /** @class */ (function (_super) {
  14627. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  14628. /**
  14629. * Creates a new button
  14630. * @param name defines the control name
  14631. */
  14632. function HolographicButton(name, shareMaterials) {
  14633. if (shareMaterials === void 0) { shareMaterials = true; }
  14634. var _this = _super.call(this, name) || this;
  14635. _this._shareMaterials = true;
  14636. _this._shareMaterials = shareMaterials;
  14637. // Default animations
  14638. _this.pointerEnterAnimation = function () {
  14639. if (!_this.mesh) {
  14640. return;
  14641. }
  14642. _this._frontPlate.setEnabled(true);
  14643. };
  14644. _this.pointerOutAnimation = function () {
  14645. if (!_this.mesh) {
  14646. return;
  14647. }
  14648. _this._frontPlate.setEnabled(false);
  14649. };
  14650. return _this;
  14651. }
  14652. HolographicButton.prototype._disposeTooltip = function () {
  14653. this._tooltipFade = null;
  14654. if (this._tooltipTextBlock) {
  14655. this._tooltipTextBlock.dispose();
  14656. }
  14657. if (this._tooltipTexture) {
  14658. this._tooltipTexture.dispose();
  14659. }
  14660. if (this._tooltipMesh) {
  14661. this._tooltipMesh.dispose();
  14662. }
  14663. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  14664. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  14665. };
  14666. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  14667. get: function () {
  14668. return this._backPlate.renderingGroupId;
  14669. },
  14670. /**
  14671. * Rendering ground id of all the mesh in the button
  14672. */
  14673. set: function (id) {
  14674. this._backPlate.renderingGroupId = id;
  14675. this._textPlate.renderingGroupId = id;
  14676. this._frontPlate.renderingGroupId = id;
  14677. if (this._tooltipMesh) {
  14678. this._tooltipMesh.renderingGroupId = id;
  14679. }
  14680. },
  14681. enumerable: true,
  14682. configurable: true
  14683. });
  14684. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  14685. get: function () {
  14686. if (this._tooltipTextBlock) {
  14687. return this._tooltipTextBlock.text;
  14688. }
  14689. return null;
  14690. },
  14691. /**
  14692. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  14693. */
  14694. set: function (text) {
  14695. var _this = this;
  14696. if (!text) {
  14697. this._disposeTooltip();
  14698. return;
  14699. }
  14700. if (!this._tooltipFade) {
  14701. // Create tooltip with mesh and text
  14702. this._tooltipMesh = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  14703. var tooltipBackground = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1, sideOrientation: babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Mesh"].DOUBLESIDE }, this._backPlate._scene);
  14704. var mat = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  14705. mat.diffuseColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  14706. tooltipBackground.material = mat;
  14707. tooltipBackground.isPickable = false;
  14708. this._tooltipMesh.addChild(tooltipBackground);
  14709. tooltipBackground.position.z = 0.05;
  14710. this._tooltipMesh.scaling.y = 1 / 3;
  14711. this._tooltipMesh.position.y = 0.7;
  14712. this._tooltipMesh.position.z = -0.15;
  14713. this._tooltipMesh.isPickable = false;
  14714. this._tooltipMesh.parent = this._backPlate;
  14715. // Create text texture for the tooltip
  14716. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  14717. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14718. this._tooltipTextBlock.scaleY = 3;
  14719. this._tooltipTextBlock.color = "white";
  14720. this._tooltipTextBlock.fontSize = 130;
  14721. this._tooltipTexture.addControl(this._tooltipTextBlock);
  14722. // Add hover action to tooltip
  14723. this._tooltipFade = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  14724. this._tooltipFade.delay = 500;
  14725. this._tooltipMesh.addBehavior(this._tooltipFade);
  14726. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  14727. if (_this._tooltipFade) {
  14728. _this._tooltipFade.fadeIn(true);
  14729. }
  14730. });
  14731. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  14732. if (_this._tooltipFade) {
  14733. _this._tooltipFade.fadeIn(false);
  14734. }
  14735. });
  14736. }
  14737. if (this._tooltipTextBlock) {
  14738. this._tooltipTextBlock.text = text;
  14739. }
  14740. },
  14741. enumerable: true,
  14742. configurable: true
  14743. });
  14744. Object.defineProperty(HolographicButton.prototype, "text", {
  14745. /**
  14746. * Gets or sets text for the button
  14747. */
  14748. get: function () {
  14749. return this._text;
  14750. },
  14751. set: function (value) {
  14752. if (this._text === value) {
  14753. return;
  14754. }
  14755. this._text = value;
  14756. this._rebuildContent();
  14757. },
  14758. enumerable: true,
  14759. configurable: true
  14760. });
  14761. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  14762. /**
  14763. * Gets or sets the image url for the button
  14764. */
  14765. get: function () {
  14766. return this._imageUrl;
  14767. },
  14768. set: function (value) {
  14769. if (this._imageUrl === value) {
  14770. return;
  14771. }
  14772. this._imageUrl = value;
  14773. this._rebuildContent();
  14774. },
  14775. enumerable: true,
  14776. configurable: true
  14777. });
  14778. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  14779. /**
  14780. * Gets the back material used by this button
  14781. */
  14782. get: function () {
  14783. return this._backMaterial;
  14784. },
  14785. enumerable: true,
  14786. configurable: true
  14787. });
  14788. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  14789. /**
  14790. * Gets the front material used by this button
  14791. */
  14792. get: function () {
  14793. return this._frontMaterial;
  14794. },
  14795. enumerable: true,
  14796. configurable: true
  14797. });
  14798. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  14799. /**
  14800. * Gets the plate material used by this button
  14801. */
  14802. get: function () {
  14803. return this._plateMaterial;
  14804. },
  14805. enumerable: true,
  14806. configurable: true
  14807. });
  14808. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  14809. /**
  14810. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  14811. */
  14812. get: function () {
  14813. return this._shareMaterials;
  14814. },
  14815. enumerable: true,
  14816. configurable: true
  14817. });
  14818. HolographicButton.prototype._getTypeName = function () {
  14819. return "HolographicButton";
  14820. };
  14821. HolographicButton.prototype._rebuildContent = function () {
  14822. this._disposeFacadeTexture();
  14823. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  14824. panel.isVertical = true;
  14825. if (this._imageUrl) {
  14826. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  14827. image.source = this._imageUrl;
  14828. image.paddingTop = "40px";
  14829. image.height = "180px";
  14830. image.width = "100px";
  14831. image.paddingBottom = "40px";
  14832. panel.addControl(image);
  14833. }
  14834. if (this._text) {
  14835. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14836. text.text = this._text;
  14837. text.color = "white";
  14838. text.height = "30px";
  14839. text.fontSize = 24;
  14840. panel.addControl(text);
  14841. }
  14842. if (this._frontPlate) {
  14843. this.content = panel;
  14844. }
  14845. };
  14846. // Mesh association
  14847. HolographicButton.prototype._createNode = function (scene) {
  14848. this._backPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  14849. width: 1.0,
  14850. height: 1.0,
  14851. depth: 0.08
  14852. }, scene);
  14853. this._frontPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  14854. width: 1.0,
  14855. height: 1.0,
  14856. depth: 0.08
  14857. }, scene);
  14858. this._frontPlate.parent = this._backPlate;
  14859. this._frontPlate.position.z = -0.08;
  14860. this._frontPlate.isPickable = false;
  14861. this._frontPlate.setEnabled(false);
  14862. this._textPlate = _super.prototype._createNode.call(this, scene);
  14863. this._textPlate.parent = this._backPlate;
  14864. this._textPlate.position.z = -0.08;
  14865. this._textPlate.isPickable = false;
  14866. return this._backPlate;
  14867. };
  14868. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  14869. this._plateMaterial.emissiveTexture = facadeTexture;
  14870. this._plateMaterial.opacityTexture = facadeTexture;
  14871. };
  14872. HolographicButton.prototype._createBackMaterial = function (mesh) {
  14873. var _this = this;
  14874. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  14875. this._backMaterial.renderHoverLight = true;
  14876. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  14877. if (pickedPoint) {
  14878. _this._backMaterial.hoverPosition = pickedPoint;
  14879. _this._backMaterial.hoverColor.a = 1.0;
  14880. }
  14881. else {
  14882. _this._backMaterial.hoverColor.a = 0;
  14883. }
  14884. });
  14885. };
  14886. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  14887. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  14888. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  14889. this._frontMaterial.alpha = 0.5; // Additive
  14890. this._frontMaterial.renderBorders = true;
  14891. };
  14892. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  14893. this._plateMaterial = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  14894. this._plateMaterial.specularColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  14895. };
  14896. HolographicButton.prototype._affectMaterial = function (mesh) {
  14897. // Back
  14898. if (this._shareMaterials) {
  14899. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  14900. this._createBackMaterial(mesh);
  14901. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  14902. }
  14903. else {
  14904. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  14905. }
  14906. // Front
  14907. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  14908. this._createFrontMaterial(mesh);
  14909. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  14910. }
  14911. else {
  14912. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  14913. }
  14914. }
  14915. else {
  14916. this._createBackMaterial(mesh);
  14917. this._createFrontMaterial(mesh);
  14918. }
  14919. this._createPlateMaterial(mesh);
  14920. this._backPlate.material = this._backMaterial;
  14921. this._frontPlate.material = this._frontMaterial;
  14922. this._textPlate.material = this._plateMaterial;
  14923. this._rebuildContent();
  14924. };
  14925. /**
  14926. * Releases all associated resources
  14927. */
  14928. HolographicButton.prototype.dispose = function () {
  14929. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  14930. this._disposeTooltip();
  14931. if (!this.shareMaterials) {
  14932. this._backMaterial.dispose();
  14933. this._frontMaterial.dispose();
  14934. this._plateMaterial.dispose();
  14935. if (this._pickedPointObserver) {
  14936. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  14937. this._pickedPointObserver = null;
  14938. }
  14939. }
  14940. };
  14941. return HolographicButton;
  14942. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14943. /***/ }),
  14944. /***/ "./3D/controls/index.ts":
  14945. /*!******************************!*\
  14946. !*** ./3D/controls/index.ts ***!
  14947. \******************************/
  14948. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  14949. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14950. "use strict";
  14951. __webpack_require__.r(__webpack_exports__);
  14952. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  14953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14954. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14956. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  14958. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  14960. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  14961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  14962. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  14963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  14964. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  14965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  14966. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  14967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  14968. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  14969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  14970. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  14971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  14972. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  14973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  14974. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  14976. /***/ }),
  14977. /***/ "./3D/controls/meshButton3D.ts":
  14978. /*!*************************************!*\
  14979. !*** ./3D/controls/meshButton3D.ts ***!
  14980. \*************************************/
  14981. /*! exports provided: MeshButton3D */
  14982. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14983. "use strict";
  14984. __webpack_require__.r(__webpack_exports__);
  14985. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  14986. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14987. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14988. /**
  14989. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  14990. */
  14991. var MeshButton3D = /** @class */ (function (_super) {
  14992. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  14993. /**
  14994. * Creates a new 3D button based on a mesh
  14995. * @param mesh mesh to become a 3D button
  14996. * @param name defines the control name
  14997. */
  14998. function MeshButton3D(mesh, name) {
  14999. var _this = _super.call(this, name) || this;
  15000. _this._currentMesh = mesh;
  15001. /**
  15002. * Provides a default behavior on hover/out & up/down
  15003. * Override those function to create your own desired behavior specific to your mesh
  15004. */
  15005. _this.pointerEnterAnimation = function () {
  15006. if (!_this.mesh) {
  15007. return;
  15008. }
  15009. _this.mesh.scaling.scaleInPlace(1.1);
  15010. };
  15011. _this.pointerOutAnimation = function () {
  15012. if (!_this.mesh) {
  15013. return;
  15014. }
  15015. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  15016. };
  15017. _this.pointerDownAnimation = function () {
  15018. if (!_this.mesh) {
  15019. return;
  15020. }
  15021. _this.mesh.scaling.scaleInPlace(0.95);
  15022. };
  15023. _this.pointerUpAnimation = function () {
  15024. if (!_this.mesh) {
  15025. return;
  15026. }
  15027. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  15028. };
  15029. return _this;
  15030. }
  15031. MeshButton3D.prototype._getTypeName = function () {
  15032. return "MeshButton3D";
  15033. };
  15034. // Mesh association
  15035. MeshButton3D.prototype._createNode = function (scene) {
  15036. var _this = this;
  15037. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  15038. mesh.metadata = _this;
  15039. });
  15040. return this._currentMesh;
  15041. };
  15042. MeshButton3D.prototype._affectMaterial = function (mesh) {
  15043. };
  15044. return MeshButton3D;
  15045. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15046. /***/ }),
  15047. /***/ "./3D/controls/planePanel.ts":
  15048. /*!***********************************!*\
  15049. !*** ./3D/controls/planePanel.ts ***!
  15050. \***********************************/
  15051. /*! exports provided: PlanePanel */
  15052. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15053. "use strict";
  15054. __webpack_require__.r(__webpack_exports__);
  15055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  15056. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15057. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  15058. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  15059. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15060. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15061. /**
  15062. * Class used to create a container panel deployed on the surface of a plane
  15063. */
  15064. var PlanePanel = /** @class */ (function (_super) {
  15065. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  15066. function PlanePanel() {
  15067. return _super !== null && _super.apply(this, arguments) || this;
  15068. }
  15069. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  15070. var mesh = control.mesh;
  15071. if (!mesh) {
  15072. return;
  15073. }
  15074. control.position = nodePosition.clone();
  15075. var target = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15076. target.copyFrom(nodePosition);
  15077. switch (this.orientation) {
  15078. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  15079. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  15080. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15081. mesh.lookAt(target);
  15082. break;
  15083. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15084. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15085. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15086. mesh.lookAt(target);
  15087. break;
  15088. }
  15089. };
  15090. return PlanePanel;
  15091. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  15092. /***/ }),
  15093. /***/ "./3D/controls/scatterPanel.ts":
  15094. /*!*************************************!*\
  15095. !*** ./3D/controls/scatterPanel.ts ***!
  15096. \*************************************/
  15097. /*! exports provided: ScatterPanel */
  15098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15099. "use strict";
  15100. __webpack_require__.r(__webpack_exports__);
  15101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  15102. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15103. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15104. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15105. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15106. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15107. /**
  15108. * Class used to create a container panel where items get randomized planar mapping
  15109. */
  15110. var ScatterPanel = /** @class */ (function (_super) {
  15111. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  15112. function ScatterPanel() {
  15113. var _this = _super !== null && _super.apply(this, arguments) || this;
  15114. _this._iteration = 100.0;
  15115. return _this;
  15116. }
  15117. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  15118. /**
  15119. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  15120. */
  15121. get: function () {
  15122. return this._iteration;
  15123. },
  15124. set: function (value) {
  15125. var _this = this;
  15126. if (this._iteration === value) {
  15127. return;
  15128. }
  15129. this._iteration = value;
  15130. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15131. _this._arrangeChildren();
  15132. });
  15133. },
  15134. enumerable: true,
  15135. configurable: true
  15136. });
  15137. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  15138. var mesh = control.mesh;
  15139. var newPos = this._scatterMapping(nodePosition);
  15140. if (!mesh) {
  15141. return;
  15142. }
  15143. switch (this.orientation) {
  15144. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15145. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15146. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15147. break;
  15148. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15149. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15150. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15151. break;
  15152. }
  15153. control.position = newPos;
  15154. };
  15155. ScatterPanel.prototype._scatterMapping = function (source) {
  15156. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  15157. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  15158. return source;
  15159. };
  15160. ScatterPanel.prototype._finalProcessing = function () {
  15161. var meshes = [];
  15162. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15163. var child = _a[_i];
  15164. if (!child.mesh) {
  15165. continue;
  15166. }
  15167. meshes.push(child.mesh);
  15168. }
  15169. for (var count = 0; count < this._iteration; count++) {
  15170. meshes.sort(function (a, b) {
  15171. var distance1 = a.position.lengthSquared();
  15172. var distance2 = b.position.lengthSquared();
  15173. if (distance1 < distance2) {
  15174. return 1;
  15175. }
  15176. else if (distance1 > distance2) {
  15177. return -1;
  15178. }
  15179. return 0;
  15180. });
  15181. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  15182. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  15183. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  15184. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15185. for (var i = 0; i < meshes.length - 1; i++) {
  15186. for (var j = i + 1; j < meshes.length; j++) {
  15187. if (i != j) {
  15188. meshes[j].position.subtractToRef(meshes[i].position, difference);
  15189. // Ignore Z axis
  15190. difference2D.x = difference.x;
  15191. difference2D.y = difference.y;
  15192. var combinedRadius = cellSize;
  15193. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  15194. var minSeparation = Math.min(distance, radiusPaddingSquared);
  15195. distance -= minSeparation;
  15196. if (distance < (Math.pow(combinedRadius, 2.0))) {
  15197. difference2D.normalize();
  15198. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  15199. meshes[j].position.addInPlace(difference);
  15200. meshes[i].position.subtractInPlace(difference);
  15201. }
  15202. }
  15203. }
  15204. }
  15205. }
  15206. };
  15207. return ScatterPanel;
  15208. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15209. /***/ }),
  15210. /***/ "./3D/controls/spherePanel.ts":
  15211. /*!************************************!*\
  15212. !*** ./3D/controls/spherePanel.ts ***!
  15213. \************************************/
  15214. /*! exports provided: SpherePanel */
  15215. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15216. "use strict";
  15217. __webpack_require__.r(__webpack_exports__);
  15218. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  15219. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15220. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15221. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15222. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15223. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15224. /**
  15225. * Class used to create a container panel deployed on the surface of a sphere
  15226. */
  15227. var SpherePanel = /** @class */ (function (_super) {
  15228. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  15229. function SpherePanel() {
  15230. var _this = _super !== null && _super.apply(this, arguments) || this;
  15231. _this._radius = 5.0;
  15232. return _this;
  15233. }
  15234. Object.defineProperty(SpherePanel.prototype, "radius", {
  15235. /**
  15236. * Gets or sets the radius of the sphere where to project controls (5 by default)
  15237. */
  15238. get: function () {
  15239. return this._radius;
  15240. },
  15241. set: function (value) {
  15242. var _this = this;
  15243. if (this._radius === value) {
  15244. return;
  15245. }
  15246. this._radius = value;
  15247. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15248. _this._arrangeChildren();
  15249. });
  15250. },
  15251. enumerable: true,
  15252. configurable: true
  15253. });
  15254. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  15255. var mesh = control.mesh;
  15256. if (!mesh) {
  15257. return;
  15258. }
  15259. var newPos = this._sphericalMapping(nodePosition);
  15260. control.position = newPos;
  15261. switch (this.orientation) {
  15262. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15263. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  15264. break;
  15265. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15266. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  15267. break;
  15268. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15269. break;
  15270. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15271. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  15272. break;
  15273. }
  15274. };
  15275. SpherePanel.prototype._sphericalMapping = function (source) {
  15276. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  15277. var xAngle = (source.y / this._radius);
  15278. var yAngle = -(source.x / this._radius);
  15279. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15280. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15281. };
  15282. return SpherePanel;
  15283. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15284. /***/ }),
  15285. /***/ "./3D/controls/stackPanel3D.ts":
  15286. /*!*************************************!*\
  15287. !*** ./3D/controls/stackPanel3D.ts ***!
  15288. \*************************************/
  15289. /*! exports provided: StackPanel3D */
  15290. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15291. "use strict";
  15292. __webpack_require__.r(__webpack_exports__);
  15293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  15294. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15295. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15296. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15297. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15298. /**
  15299. * Class used to create a stack panel in 3D on XY plane
  15300. */
  15301. var StackPanel3D = /** @class */ (function (_super) {
  15302. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  15303. /**
  15304. * Creates new StackPanel
  15305. * @param isVertical
  15306. */
  15307. function StackPanel3D(isVertical) {
  15308. if (isVertical === void 0) { isVertical = false; }
  15309. var _this = _super.call(this) || this;
  15310. _this._isVertical = false;
  15311. /**
  15312. * Gets or sets the distance between elements
  15313. */
  15314. _this.margin = 0.1;
  15315. _this._isVertical = isVertical;
  15316. return _this;
  15317. }
  15318. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  15319. /**
  15320. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  15321. */
  15322. get: function () {
  15323. return this._isVertical;
  15324. },
  15325. set: function (value) {
  15326. var _this = this;
  15327. if (this._isVertical === value) {
  15328. return;
  15329. }
  15330. this._isVertical = value;
  15331. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15332. _this._arrangeChildren();
  15333. });
  15334. },
  15335. enumerable: true,
  15336. configurable: true
  15337. });
  15338. StackPanel3D.prototype._arrangeChildren = function () {
  15339. var width = 0;
  15340. var height = 0;
  15341. var controlCount = 0;
  15342. var extendSizes = [];
  15343. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15344. // Measure
  15345. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15346. var child = _a[_i];
  15347. if (!child.mesh) {
  15348. continue;
  15349. }
  15350. controlCount++;
  15351. child.mesh.computeWorldMatrix(true);
  15352. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15353. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  15354. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15355. extendSizes.push(extendSize);
  15356. if (this._isVertical) {
  15357. height += extendSize.y;
  15358. }
  15359. else {
  15360. width += extendSize.x;
  15361. }
  15362. }
  15363. if (this._isVertical) {
  15364. height += (controlCount - 1) * this.margin / 2;
  15365. }
  15366. else {
  15367. width += (controlCount - 1) * this.margin / 2;
  15368. }
  15369. // Arrange
  15370. var offset;
  15371. if (this._isVertical) {
  15372. offset = -height;
  15373. }
  15374. else {
  15375. offset = -width;
  15376. }
  15377. var index = 0;
  15378. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15379. var child = _c[_b];
  15380. if (!child.mesh) {
  15381. continue;
  15382. }
  15383. controlCount--;
  15384. var extendSize = extendSizes[index++];
  15385. if (this._isVertical) {
  15386. child.position.y = offset + extendSize.y;
  15387. child.position.x = 0;
  15388. offset += extendSize.y * 2;
  15389. }
  15390. else {
  15391. child.position.x = offset + extendSize.x;
  15392. child.position.y = 0;
  15393. offset += extendSize.x * 2;
  15394. }
  15395. offset += (controlCount > 0 ? this.margin : 0);
  15396. }
  15397. };
  15398. return StackPanel3D;
  15399. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15400. /***/ }),
  15401. /***/ "./3D/controls/volumeBasedPanel.ts":
  15402. /*!*****************************************!*\
  15403. !*** ./3D/controls/volumeBasedPanel.ts ***!
  15404. \*****************************************/
  15405. /*! exports provided: VolumeBasedPanel */
  15406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15407. "use strict";
  15408. __webpack_require__.r(__webpack_exports__);
  15409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  15410. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15411. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15412. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15413. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15414. /**
  15415. * Abstract class used to create a container panel deployed on the surface of a volume
  15416. */
  15417. var VolumeBasedPanel = /** @class */ (function (_super) {
  15418. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  15419. /**
  15420. * Creates new VolumeBasedPanel
  15421. */
  15422. function VolumeBasedPanel() {
  15423. var _this = _super.call(this) || this;
  15424. _this._columns = 10;
  15425. _this._rows = 0;
  15426. _this._rowThenColum = true;
  15427. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  15428. /**
  15429. * Gets or sets the distance between elements
  15430. */
  15431. _this.margin = 0;
  15432. return _this;
  15433. }
  15434. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  15435. /**
  15436. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  15437. * | Value | Type | Description |
  15438. * | ----- | ----------------------------------- | ----------- |
  15439. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  15440. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  15441. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  15442. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  15443. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  15444. */
  15445. get: function () {
  15446. return this._orientation;
  15447. },
  15448. set: function (value) {
  15449. var _this = this;
  15450. if (this._orientation === value) {
  15451. return;
  15452. }
  15453. this._orientation = value;
  15454. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15455. _this._arrangeChildren();
  15456. });
  15457. },
  15458. enumerable: true,
  15459. configurable: true
  15460. });
  15461. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  15462. /**
  15463. * Gets or sets the number of columns requested (10 by default).
  15464. * The panel will automatically compute the number of rows based on number of child controls.
  15465. */
  15466. get: function () {
  15467. return this._columns;
  15468. },
  15469. set: function (value) {
  15470. var _this = this;
  15471. if (this._columns === value) {
  15472. return;
  15473. }
  15474. this._columns = value;
  15475. this._rowThenColum = true;
  15476. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15477. _this._arrangeChildren();
  15478. });
  15479. },
  15480. enumerable: true,
  15481. configurable: true
  15482. });
  15483. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  15484. /**
  15485. * Gets or sets a the number of rows requested.
  15486. * The panel will automatically compute the number of columns based on number of child controls.
  15487. */
  15488. get: function () {
  15489. return this._rows;
  15490. },
  15491. set: function (value) {
  15492. var _this = this;
  15493. if (this._rows === value) {
  15494. return;
  15495. }
  15496. this._rows = value;
  15497. this._rowThenColum = false;
  15498. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15499. _this._arrangeChildren();
  15500. });
  15501. },
  15502. enumerable: true,
  15503. configurable: true
  15504. });
  15505. VolumeBasedPanel.prototype._arrangeChildren = function () {
  15506. this._cellWidth = 0;
  15507. this._cellHeight = 0;
  15508. var rows = 0;
  15509. var columns = 0;
  15510. var controlCount = 0;
  15511. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15512. // Measure
  15513. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15514. var child = _a[_i];
  15515. if (!child.mesh) {
  15516. continue;
  15517. }
  15518. controlCount++;
  15519. child.mesh.computeWorldMatrix(true);
  15520. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  15521. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  15522. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15523. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  15524. boundingBox.max.subtractToRef(boundingBox.min, diff);
  15525. diff.scaleInPlace(0.5);
  15526. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  15527. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  15528. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  15529. }
  15530. this._cellWidth += this.margin * 2;
  15531. this._cellHeight += this.margin * 2;
  15532. // Arrange
  15533. if (this._rowThenColum) {
  15534. columns = this._columns;
  15535. rows = Math.ceil(controlCount / this._columns);
  15536. }
  15537. else {
  15538. rows = this._rows;
  15539. columns = Math.ceil(controlCount / this._rows);
  15540. }
  15541. var startOffsetX = (columns * 0.5) * this._cellWidth;
  15542. var startOffsetY = (rows * 0.5) * this._cellHeight;
  15543. var nodeGrid = [];
  15544. var cellCounter = 0;
  15545. if (this._rowThenColum) {
  15546. for (var r = 0; r < rows; r++) {
  15547. for (var c = 0; c < columns; c++) {
  15548. 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));
  15549. cellCounter++;
  15550. if (cellCounter > controlCount) {
  15551. break;
  15552. }
  15553. }
  15554. }
  15555. }
  15556. else {
  15557. for (var c = 0; c < columns; c++) {
  15558. for (var r = 0; r < rows; r++) {
  15559. 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));
  15560. cellCounter++;
  15561. if (cellCounter > controlCount) {
  15562. break;
  15563. }
  15564. }
  15565. }
  15566. }
  15567. cellCounter = 0;
  15568. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15569. var child = _c[_b];
  15570. if (!child.mesh) {
  15571. continue;
  15572. }
  15573. this._mapGridNode(child, nodeGrid[cellCounter]);
  15574. cellCounter++;
  15575. }
  15576. this._finalProcessing();
  15577. };
  15578. /** Child classes can implement this function to provide additional processing */
  15579. VolumeBasedPanel.prototype._finalProcessing = function () {
  15580. };
  15581. return VolumeBasedPanel;
  15582. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15583. /***/ }),
  15584. /***/ "./3D/gui3DManager.ts":
  15585. /*!****************************!*\
  15586. !*** ./3D/gui3DManager.ts ***!
  15587. \****************************/
  15588. /*! exports provided: GUI3DManager */
  15589. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15590. "use strict";
  15591. __webpack_require__.r(__webpack_exports__);
  15592. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  15593. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  15594. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15595. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  15596. /**
  15597. * Class used to manage 3D user interface
  15598. * @see http://doc.babylonjs.com/how_to/gui3d
  15599. */
  15600. var GUI3DManager = /** @class */ (function () {
  15601. /**
  15602. * Creates a new GUI3DManager
  15603. * @param scene
  15604. */
  15605. function GUI3DManager(scene) {
  15606. var _this = this;
  15607. /** @hidden */
  15608. this._lastControlOver = {};
  15609. /** @hidden */
  15610. this._lastControlDown = {};
  15611. /**
  15612. * Observable raised when the point picked by the pointer events changed
  15613. */
  15614. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15615. // Shared resources
  15616. /** @hidden */
  15617. this._sharedMaterials = {};
  15618. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  15619. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  15620. _this._sceneDisposeObserver = null;
  15621. _this._utilityLayer = null;
  15622. _this.dispose();
  15623. });
  15624. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  15625. this._utilityLayer.onlyCheckPointerDownEvents = false;
  15626. this._utilityLayer.pickUtilitySceneFirst = false;
  15627. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  15628. return mesh && mesh.metadata && mesh.metadata._node;
  15629. };
  15630. // Root
  15631. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  15632. this._rootContainer._host = this;
  15633. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  15634. // Events
  15635. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  15636. _this._handlePointerOut(pointerId, true);
  15637. });
  15638. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  15639. _this._doPicking(pi);
  15640. });
  15641. // Scene
  15642. this._utilityLayer.utilityLayerScene.autoClear = false;
  15643. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  15644. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  15645. }
  15646. Object.defineProperty(GUI3DManager.prototype, "scene", {
  15647. /** Gets the hosting scene */
  15648. get: function () {
  15649. return this._scene;
  15650. },
  15651. enumerable: true,
  15652. configurable: true
  15653. });
  15654. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  15655. /** Gets associated utility layer */
  15656. get: function () {
  15657. return this._utilityLayer;
  15658. },
  15659. enumerable: true,
  15660. configurable: true
  15661. });
  15662. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  15663. var previousControlOver = this._lastControlOver[pointerId];
  15664. if (previousControlOver) {
  15665. previousControlOver._onPointerOut(previousControlOver);
  15666. delete this._lastControlOver[pointerId];
  15667. }
  15668. if (isPointerUp) {
  15669. if (this._lastControlDown[pointerId]) {
  15670. this._lastControlDown[pointerId].forcePointerUp();
  15671. delete this._lastControlDown[pointerId];
  15672. }
  15673. }
  15674. this.onPickedPointChangedObservable.notifyObservers(null);
  15675. };
  15676. GUI3DManager.prototype._doPicking = function (pi) {
  15677. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  15678. return false;
  15679. }
  15680. var pointerEvent = (pi.event);
  15681. var pointerId = pointerEvent.pointerId || 0;
  15682. var buttonIndex = pointerEvent.button;
  15683. var pickingInfo = pi.pickInfo;
  15684. if (!pickingInfo || !pickingInfo.hit) {
  15685. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  15686. return false;
  15687. }
  15688. var control = (pickingInfo.pickedMesh.metadata);
  15689. if (pickingInfo.pickedPoint) {
  15690. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  15691. }
  15692. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  15693. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15694. if (this._lastControlOver[pointerId]) {
  15695. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  15696. }
  15697. delete this._lastControlOver[pointerId];
  15698. }
  15699. }
  15700. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  15701. if (this._lastControlDown[pointerEvent.pointerId]) {
  15702. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  15703. delete this._lastControlDown[pointerEvent.pointerId];
  15704. }
  15705. if (pointerEvent.pointerType === "touch") {
  15706. this._handlePointerOut(pointerId, false);
  15707. }
  15708. }
  15709. return true;
  15710. };
  15711. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  15712. /**
  15713. * Gets the root container
  15714. */
  15715. get: function () {
  15716. return this._rootContainer;
  15717. },
  15718. enumerable: true,
  15719. configurable: true
  15720. });
  15721. /**
  15722. * Gets a boolean indicating if the given control is in the root child list
  15723. * @param control defines the control to check
  15724. * @returns true if the control is in the root child list
  15725. */
  15726. GUI3DManager.prototype.containsControl = function (control) {
  15727. return this._rootContainer.containsControl(control);
  15728. };
  15729. /**
  15730. * Adds a control to the root child list
  15731. * @param control defines the control to add
  15732. * @returns the current manager
  15733. */
  15734. GUI3DManager.prototype.addControl = function (control) {
  15735. this._rootContainer.addControl(control);
  15736. return this;
  15737. };
  15738. /**
  15739. * Removes a control from the root child list
  15740. * @param control defines the control to remove
  15741. * @returns the current container
  15742. */
  15743. GUI3DManager.prototype.removeControl = function (control) {
  15744. this._rootContainer.removeControl(control);
  15745. return this;
  15746. };
  15747. /**
  15748. * Releases all associated resources
  15749. */
  15750. GUI3DManager.prototype.dispose = function () {
  15751. this._rootContainer.dispose();
  15752. for (var materialName in this._sharedMaterials) {
  15753. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  15754. continue;
  15755. }
  15756. this._sharedMaterials[materialName].dispose();
  15757. }
  15758. this._sharedMaterials = {};
  15759. if (this._pointerOutObserver && this._utilityLayer) {
  15760. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  15761. this._pointerOutObserver = null;
  15762. }
  15763. this.onPickedPointChangedObservable.clear();
  15764. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  15765. if (utilityLayerScene) {
  15766. if (this._pointerObserver) {
  15767. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  15768. this._pointerObserver = null;
  15769. }
  15770. }
  15771. if (this._scene) {
  15772. if (this._sceneDisposeObserver) {
  15773. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  15774. this._sceneDisposeObserver = null;
  15775. }
  15776. }
  15777. if (this._utilityLayer) {
  15778. this._utilityLayer.dispose();
  15779. }
  15780. };
  15781. return GUI3DManager;
  15782. }());
  15783. /***/ }),
  15784. /***/ "./3D/index.ts":
  15785. /*!*********************!*\
  15786. !*** ./3D/index.ts ***!
  15787. \*********************/
  15788. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15790. "use strict";
  15791. __webpack_require__.r(__webpack_exports__);
  15792. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  15793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15805. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  15806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15808. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  15809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  15810. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  15811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  15812. /***/ }),
  15813. /***/ "./3D/materials/fluentMaterial.ts":
  15814. /*!****************************************!*\
  15815. !*** ./3D/materials/fluentMaterial.ts ***!
  15816. \****************************************/
  15817. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15819. "use strict";
  15820. __webpack_require__.r(__webpack_exports__);
  15821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  15822. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  15823. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15824. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  15825. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  15826. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  15827. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  15828. /** @hidden */
  15829. var FluentMaterialDefines = /** @class */ (function (_super) {
  15830. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  15831. function FluentMaterialDefines() {
  15832. var _this = _super.call(this) || this;
  15833. _this.INNERGLOW = false;
  15834. _this.BORDER = false;
  15835. _this.HOVERLIGHT = false;
  15836. _this.TEXTURE = false;
  15837. _this.rebuild();
  15838. return _this;
  15839. }
  15840. return FluentMaterialDefines;
  15841. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  15842. /**
  15843. * Class used to render controls with fluent desgin
  15844. */
  15845. var FluentMaterial = /** @class */ (function (_super) {
  15846. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  15847. /**
  15848. * Creates a new Fluent material
  15849. * @param name defines the name of the material
  15850. * @param scene defines the hosting scene
  15851. */
  15852. function FluentMaterial(name, scene) {
  15853. var _this = _super.call(this, name, scene) || this;
  15854. /**
  15855. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  15856. */
  15857. _this.innerGlowColorIntensity = 0.5;
  15858. /**
  15859. * Gets or sets the inner glow color (white by default)
  15860. */
  15861. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  15862. /**
  15863. * Gets or sets alpha value (default is 1.0)
  15864. */
  15865. _this.alpha = 1.0;
  15866. /**
  15867. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  15868. */
  15869. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  15870. /**
  15871. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  15872. */
  15873. _this.renderBorders = false;
  15874. /**
  15875. * Gets or sets border width (default is 0.5)
  15876. */
  15877. _this.borderWidth = 0.5;
  15878. /**
  15879. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  15880. */
  15881. _this.edgeSmoothingValue = 0.02;
  15882. /**
  15883. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  15884. */
  15885. _this.borderMinValue = 0.1;
  15886. /**
  15887. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  15888. */
  15889. _this.renderHoverLight = false;
  15890. /**
  15891. * Gets or sets the radius used to render the hover light (default is 1.0)
  15892. */
  15893. _this.hoverRadius = 1.0;
  15894. /**
  15895. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  15896. */
  15897. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  15898. /**
  15899. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  15900. */
  15901. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  15902. return _this;
  15903. }
  15904. FluentMaterial.prototype.needAlphaBlending = function () {
  15905. return this.alpha !== 1.0;
  15906. };
  15907. FluentMaterial.prototype.needAlphaTesting = function () {
  15908. return false;
  15909. };
  15910. FluentMaterial.prototype.getAlphaTestTexture = function () {
  15911. return null;
  15912. };
  15913. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  15914. if (this.isFrozen) {
  15915. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  15916. return true;
  15917. }
  15918. }
  15919. if (!subMesh._materialDefines) {
  15920. subMesh._materialDefines = new FluentMaterialDefines();
  15921. }
  15922. var scene = this.getScene();
  15923. var defines = subMesh._materialDefines;
  15924. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  15925. if (defines._renderId === scene.getRenderId()) {
  15926. return true;
  15927. }
  15928. }
  15929. if (defines._areTexturesDirty) {
  15930. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  15931. defines.BORDER = this.renderBorders;
  15932. defines.HOVERLIGHT = this.renderHoverLight;
  15933. if (this._albedoTexture) {
  15934. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  15935. return false;
  15936. }
  15937. else {
  15938. defines.TEXTURE = true;
  15939. }
  15940. }
  15941. else {
  15942. defines.TEXTURE = false;
  15943. }
  15944. }
  15945. var engine = scene.getEngine();
  15946. // Get correct effect
  15947. if (defines.isDirty) {
  15948. defines.markAsProcessed();
  15949. scene.resetCachedMaterial();
  15950. //Attributes
  15951. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  15952. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  15953. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  15954. var shaderName = "fluent";
  15955. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  15956. "hoverColor", "hoverPosition", "hoverRadius"
  15957. ];
  15958. var samplers = ["albedoSampler"];
  15959. var uniformBuffers = new Array();
  15960. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  15961. uniformsNames: uniforms,
  15962. uniformBuffersNames: uniformBuffers,
  15963. samplers: samplers,
  15964. defines: defines,
  15965. maxSimultaneousLights: 4
  15966. });
  15967. var join = defines.toString();
  15968. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  15969. attributes: attribs,
  15970. uniformsNames: uniforms,
  15971. uniformBuffersNames: uniformBuffers,
  15972. samplers: samplers,
  15973. defines: join,
  15974. fallbacks: null,
  15975. onCompiled: this.onCompiled,
  15976. onError: this.onError,
  15977. indexParameters: { maxSimultaneousLights: 4 }
  15978. }, engine));
  15979. }
  15980. if (!subMesh.effect || !subMesh.effect.isReady()) {
  15981. return false;
  15982. }
  15983. defines._renderId = scene.getRenderId();
  15984. subMesh.effect._wasPreviouslyReady = true;
  15985. return true;
  15986. };
  15987. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  15988. var scene = this.getScene();
  15989. var defines = subMesh._materialDefines;
  15990. if (!defines) {
  15991. return;
  15992. }
  15993. var effect = subMesh.effect;
  15994. if (!effect) {
  15995. return;
  15996. }
  15997. this._activeEffect = effect;
  15998. // Matrices
  15999. this.bindOnlyWorldMatrix(world);
  16000. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  16001. if (this._mustRebind(scene, effect)) {
  16002. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  16003. if (defines.INNERGLOW) {
  16004. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  16005. }
  16006. if (defines.BORDER) {
  16007. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  16008. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  16009. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  16010. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16011. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16012. }
  16013. if (defines.HOVERLIGHT) {
  16014. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  16015. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  16016. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  16017. }
  16018. if (defines.TEXTURE) {
  16019. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  16020. }
  16021. }
  16022. this._afterBind(mesh, this._activeEffect);
  16023. };
  16024. FluentMaterial.prototype.getActiveTextures = function () {
  16025. var activeTextures = _super.prototype.getActiveTextures.call(this);
  16026. return activeTextures;
  16027. };
  16028. FluentMaterial.prototype.hasTexture = function (texture) {
  16029. if (_super.prototype.hasTexture.call(this, texture)) {
  16030. return true;
  16031. }
  16032. return false;
  16033. };
  16034. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  16035. _super.prototype.dispose.call(this, forceDisposeEffect);
  16036. };
  16037. FluentMaterial.prototype.clone = function (name) {
  16038. var _this = this;
  16039. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  16040. };
  16041. FluentMaterial.prototype.serialize = function () {
  16042. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  16043. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  16044. return serializationObject;
  16045. };
  16046. FluentMaterial.prototype.getClassName = function () {
  16047. return "FluentMaterial";
  16048. };
  16049. // Statics
  16050. FluentMaterial.Parse = function (source, scene, rootUrl) {
  16051. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  16052. };
  16053. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16054. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16055. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16056. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  16057. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16058. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16059. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  16060. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16061. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16062. ], FluentMaterial.prototype, "alpha", void 0);
  16063. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16064. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16065. ], FluentMaterial.prototype, "albedoColor", void 0);
  16066. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16067. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16068. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16069. ], FluentMaterial.prototype, "renderBorders", void 0);
  16070. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16071. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16072. ], FluentMaterial.prototype, "borderWidth", void 0);
  16073. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16074. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16075. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  16076. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16077. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16078. ], FluentMaterial.prototype, "borderMinValue", void 0);
  16079. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16080. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16081. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16082. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  16083. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16084. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16085. ], FluentMaterial.prototype, "hoverRadius", void 0);
  16086. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16087. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  16088. ], FluentMaterial.prototype, "hoverColor", void 0);
  16089. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16090. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  16091. ], FluentMaterial.prototype, "hoverPosition", void 0);
  16092. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16093. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  16094. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  16095. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16096. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  16097. ], FluentMaterial.prototype, "albedoTexture", void 0);
  16098. return FluentMaterial;
  16099. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  16100. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  16101. /***/ }),
  16102. /***/ "./3D/materials/index.ts":
  16103. /*!*******************************!*\
  16104. !*** ./3D/materials/index.ts ***!
  16105. \*******************************/
  16106. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16108. "use strict";
  16109. __webpack_require__.r(__webpack_exports__);
  16110. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  16111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16113. /***/ }),
  16114. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  16115. /*!*************************************************!*\
  16116. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  16117. \*************************************************/
  16118. /*! exports provided: fluentPixelShader */
  16119. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16120. "use strict";
  16121. __webpack_require__.r(__webpack_exports__);
  16122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  16123. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  16124. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16125. var name = 'fluentPixelShader';
  16126. 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}";
  16127. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16128. /** @hidden */
  16129. var fluentPixelShader = { name: name, shader: shader };
  16130. /***/ }),
  16131. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  16132. /*!***********************************************!*\
  16133. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  16134. \***********************************************/
  16135. /*! exports provided: fluentVertexShader */
  16136. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16137. "use strict";
  16138. __webpack_require__.r(__webpack_exports__);
  16139. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  16140. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  16141. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16142. var name = 'fluentVertexShader';
  16143. 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";
  16144. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16145. /** @hidden */
  16146. var fluentVertexShader = { name: name, shader: shader };
  16147. /***/ }),
  16148. /***/ "./3D/vector3WithInfo.ts":
  16149. /*!*******************************!*\
  16150. !*** ./3D/vector3WithInfo.ts ***!
  16151. \*******************************/
  16152. /*! exports provided: Vector3WithInfo */
  16153. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16154. "use strict";
  16155. __webpack_require__.r(__webpack_exports__);
  16156. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  16157. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16158. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  16159. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  16160. /**
  16161. * Class used to transport Vector3 information for pointer events
  16162. */
  16163. var Vector3WithInfo = /** @class */ (function (_super) {
  16164. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  16165. /**
  16166. * Creates a new Vector3WithInfo
  16167. * @param source defines the vector3 data to transport
  16168. * @param buttonIndex defines the current mouse button index
  16169. */
  16170. function Vector3WithInfo(source,
  16171. /** defines the current mouse button index */
  16172. buttonIndex) {
  16173. if (buttonIndex === void 0) { buttonIndex = 0; }
  16174. var _this = _super.call(this, source.x, source.y, source.z) || this;
  16175. _this.buttonIndex = buttonIndex;
  16176. return _this;
  16177. }
  16178. return Vector3WithInfo;
  16179. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  16180. /***/ }),
  16181. /***/ "./index.ts":
  16182. /*!******************!*\
  16183. !*** ./index.ts ***!
  16184. \******************/
  16185. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  16186. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16187. "use strict";
  16188. __webpack_require__.r(__webpack_exports__);
  16189. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  16190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16231. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  16232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  16233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  16234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  16235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  16236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  16237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  16238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  16239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  16240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  16241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  16242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  16243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  16244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  16245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  16246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16248. /***/ }),
  16249. /***/ "./legacy/legacy.ts":
  16250. /*!**************************!*\
  16251. !*** ./legacy/legacy.ts ***!
  16252. \**************************/
  16253. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  16254. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16255. "use strict";
  16256. __webpack_require__.r(__webpack_exports__);
  16257. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  16258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  16268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  16269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16315. /**
  16316. * Legacy support, defining window.BABYLON.GUI (global variable).
  16317. *
  16318. * This is the entry point for the UMD module.
  16319. * The entry point for a future ESM package should be index.ts
  16320. */
  16321. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  16322. if (typeof globalObject !== "undefined") {
  16323. globalObject.BABYLON = globalObject.BABYLON || {};
  16324. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  16325. }
  16326. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  16327. /***/ }),
  16328. /***/ "babylonjs/Misc/perfCounter":
  16329. /*!****************************************************************************************************!*\
  16330. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  16331. \****************************************************************************************************/
  16332. /*! no static exports found */
  16333. /***/ (function(module, exports) {
  16334. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__;
  16335. /***/ })
  16336. /******/ });
  16337. });
  16338. //# sourceMappingURL=babylon.gui.js.map