babylon.gui.js 743 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-gui", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-gui"] = factory(require("babylonjs"));
  8. else
  9. root["BABYLON"] = root["BABYLON"] || {}, root["BABYLON"]["GUI"] = factory(root["BABYLON"]);
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!***********************************************************!*\
  100. !*** C:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  126. /*! *****************************************************************************
  127. Copyright (c) Microsoft Corporation. All rights reserved.
  128. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  129. this file except in compliance with the License. You may obtain a copy of the
  130. License at http://www.apache.org/licenses/LICENSE-2.0
  131. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  132. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  133. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  134. MERCHANTABLITY OR NON-INFRINGEMENT.
  135. See the Apache Version 2.0 License for specific language governing permissions
  136. and limitations under the License.
  137. ***************************************************************************** */
  138. /* global Reflect, Promise */
  139. var extendStatics = function(d, b) {
  140. extendStatics = Object.setPrototypeOf ||
  141. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  142. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  143. return extendStatics(d, b);
  144. };
  145. function __extends(d, b) {
  146. extendStatics(d, b);
  147. function __() { this.constructor = d; }
  148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  149. }
  150. var __assign = function() {
  151. __assign = Object.assign || function __assign(t) {
  152. for (var s, i = 1, n = arguments.length; i < n; i++) {
  153. s = arguments[i];
  154. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  155. }
  156. return t;
  157. }
  158. return __assign.apply(this, arguments);
  159. }
  160. function __rest(s, e) {
  161. var t = {};
  162. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  163. t[p] = s[p];
  164. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  165. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  166. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  167. t[p[i]] = s[p[i]];
  168. }
  169. return t;
  170. }
  171. function __decorate(decorators, target, key, desc) {
  172. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  173. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  174. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  175. return c > 3 && r && Object.defineProperty(target, key, r), r;
  176. }
  177. function __param(paramIndex, decorator) {
  178. return function (target, key) { decorator(target, key, paramIndex); }
  179. }
  180. function __metadata(metadataKey, metadataValue) {
  181. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  182. }
  183. function __awaiter(thisArg, _arguments, P, generator) {
  184. return new (P || (P = Promise))(function (resolve, reject) {
  185. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  186. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  187. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  188. step((generator = generator.apply(thisArg, _arguments || [])).next());
  189. });
  190. }
  191. function __generator(thisArg, body) {
  192. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  193. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  194. function verb(n) { return function (v) { return step([n, v]); }; }
  195. function step(op) {
  196. if (f) throw new TypeError("Generator is already executing.");
  197. while (_) try {
  198. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  199. if (y = 0, t) op = [op[0] & 2, t.value];
  200. switch (op[0]) {
  201. case 0: case 1: t = op; break;
  202. case 4: _.label++; return { value: op[1], done: false };
  203. case 5: _.label++; y = op[1]; op = [0]; continue;
  204. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  205. default:
  206. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  207. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  208. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  209. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  210. if (t[2]) _.ops.pop();
  211. _.trys.pop(); continue;
  212. }
  213. op = body.call(thisArg, _);
  214. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  215. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  216. }
  217. }
  218. function __exportStar(m, exports) {
  219. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  220. }
  221. function __values(o) {
  222. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  223. if (m) return m.call(o);
  224. return {
  225. next: function () {
  226. if (o && i >= o.length) o = void 0;
  227. return { value: o && o[i++], done: !o };
  228. }
  229. };
  230. }
  231. function __read(o, n) {
  232. var m = typeof Symbol === "function" && o[Symbol.iterator];
  233. if (!m) return o;
  234. var i = m.call(o), r, ar = [], e;
  235. try {
  236. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  237. }
  238. catch (error) { e = { error: error }; }
  239. finally {
  240. try {
  241. if (r && !r.done && (m = i["return"])) m.call(i);
  242. }
  243. finally { if (e) throw e.error; }
  244. }
  245. return ar;
  246. }
  247. function __spread() {
  248. for (var ar = [], i = 0; i < arguments.length; i++)
  249. ar = ar.concat(__read(arguments[i]));
  250. return ar;
  251. }
  252. function __spreadArrays() {
  253. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  254. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  255. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  256. r[k] = a[j];
  257. return r;
  258. };
  259. function __await(v) {
  260. return this instanceof __await ? (this.v = v, this) : new __await(v);
  261. }
  262. function __asyncGenerator(thisArg, _arguments, generator) {
  263. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  264. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  265. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  266. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  267. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  268. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  269. function fulfill(value) { resume("next", value); }
  270. function reject(value) { resume("throw", value); }
  271. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  272. }
  273. function __asyncDelegator(o) {
  274. var i, p;
  275. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  276. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  277. }
  278. function __asyncValues(o) {
  279. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  280. var m = o[Symbol.asyncIterator], i;
  281. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  282. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  283. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  284. }
  285. function __makeTemplateObject(cooked, raw) {
  286. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  287. return cooked;
  288. };
  289. function __importStar(mod) {
  290. if (mod && mod.__esModule) return mod;
  291. var result = {};
  292. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  293. result.default = mod;
  294. return result;
  295. }
  296. function __importDefault(mod) {
  297. return (mod && mod.__esModule) ? mod : { default: mod };
  298. }
  299. /***/ }),
  300. /***/ "../../node_modules/webpack/buildin/global.js":
  301. /*!***********************************!*\
  302. !*** (webpack)/buildin/global.js ***!
  303. \***********************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports) {
  306. var g;
  307. // This works in non-strict mode
  308. g = (function() {
  309. return this;
  310. })();
  311. try {
  312. // This works if eval is allowed (see CSP)
  313. g = g || new Function("return this")();
  314. } catch (e) {
  315. // This works if the window reference is available
  316. if (typeof window === "object") g = window;
  317. }
  318. // g can still be undefined, but nothing to do about it...
  319. // We return undefined, instead of nothing here, so it's
  320. // easier to handle this case. if(!global) { ...}
  321. module.exports = g;
  322. /***/ }),
  323. /***/ "./2D/adtInstrumentation.ts":
  324. /*!**********************************!*\
  325. !*** ./2D/adtInstrumentation.ts ***!
  326. \**********************************/
  327. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  329. "use strict";
  330. __webpack_require__.r(__webpack_exports__);
  331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  332. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Misc/perfCounter");
  333. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  334. /**
  335. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  336. */
  337. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  338. /**
  339. * Instantiates a new advanced dynamic texture instrumentation.
  340. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  341. * @param texture Defines the AdvancedDynamicTexture to instrument
  342. */
  343. function AdvancedDynamicTextureInstrumentation(
  344. /**
  345. * Define the instrumented AdvancedDynamicTexture.
  346. */
  347. texture) {
  348. this.texture = texture;
  349. this._captureRenderTime = false;
  350. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  351. this._captureLayoutTime = false;
  352. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  353. // Observers
  354. this._onBeginRenderObserver = null;
  355. this._onEndRenderObserver = null;
  356. this._onBeginLayoutObserver = null;
  357. this._onEndLayoutObserver = null;
  358. }
  359. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  360. // Properties
  361. /**
  362. * Gets the perf counter used to capture render time
  363. */
  364. get: function () {
  365. return this._renderTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  371. /**
  372. * Gets the perf counter used to capture layout time
  373. */
  374. get: function () {
  375. return this._layoutTime;
  376. },
  377. enumerable: true,
  378. configurable: true
  379. });
  380. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  381. /**
  382. * Enable or disable the render time capture
  383. */
  384. get: function () {
  385. return this._captureRenderTime;
  386. },
  387. set: function (value) {
  388. var _this = this;
  389. if (value === this._captureRenderTime) {
  390. return;
  391. }
  392. this._captureRenderTime = value;
  393. if (value) {
  394. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  395. _this._renderTime.beginMonitoring();
  396. });
  397. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  398. _this._renderTime.endMonitoring(true);
  399. });
  400. }
  401. else {
  402. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  403. this._onBeginRenderObserver = null;
  404. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  405. this._onEndRenderObserver = null;
  406. }
  407. },
  408. enumerable: true,
  409. configurable: true
  410. });
  411. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  412. /**
  413. * Enable or disable the layout time capture
  414. */
  415. get: function () {
  416. return this._captureLayoutTime;
  417. },
  418. set: function (value) {
  419. var _this = this;
  420. if (value === this._captureLayoutTime) {
  421. return;
  422. }
  423. this._captureLayoutTime = value;
  424. if (value) {
  425. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  426. _this._layoutTime.beginMonitoring();
  427. });
  428. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  429. _this._layoutTime.endMonitoring(true);
  430. });
  431. }
  432. else {
  433. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  434. this._onBeginLayoutObserver = null;
  435. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  436. this._onEndLayoutObserver = null;
  437. }
  438. },
  439. enumerable: true,
  440. configurable: true
  441. });
  442. /**
  443. * Dispose and release associated resources.
  444. */
  445. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  446. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  447. this._onBeginRenderObserver = null;
  448. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  449. this._onEndRenderObserver = null;
  450. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  451. this._onBeginLayoutObserver = null;
  452. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  453. this._onEndLayoutObserver = null;
  454. this.texture = null;
  455. };
  456. return AdvancedDynamicTextureInstrumentation;
  457. }());
  458. /***/ }),
  459. /***/ "./2D/advancedDynamicTexture.ts":
  460. /*!**************************************!*\
  461. !*** ./2D/advancedDynamicTexture.ts ***!
  462. \**************************************/
  463. /*! exports provided: AdvancedDynamicTexture */
  464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  465. "use strict";
  466. __webpack_require__.r(__webpack_exports__);
  467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  469. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  470. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  471. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  472. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  473. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  474. /**
  475. * Class used to create texture to support 2D GUI elements
  476. * @see http://doc.babylonjs.com/how_to/gui
  477. */
  478. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  479. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AdvancedDynamicTexture, _super);
  480. /**
  481. * Creates a new AdvancedDynamicTexture
  482. * @param name defines the name of the texture
  483. * @param width defines the width of the texture
  484. * @param height defines the height of the texture
  485. * @param scene defines the hosting scene
  486. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  487. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  488. */
  489. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  490. if (width === void 0) { width = 0; }
  491. if (height === void 0) { height = 0; }
  492. if (generateMipMaps === void 0) { generateMipMaps = false; }
  493. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  494. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA) || this;
  495. _this._isDirty = false;
  496. /** @hidden */
  497. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  498. /** @hidden */
  499. _this._lastControlOver = {};
  500. /** @hidden */
  501. _this._lastControlDown = {};
  502. /** @hidden */
  503. _this._capturingControl = {};
  504. /** @hidden */
  505. _this._linkedControls = new Array();
  506. _this._isFullscreen = false;
  507. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  508. _this._idealWidth = 0;
  509. _this._idealHeight = 0;
  510. _this._useSmallestIdeal = false;
  511. _this._renderAtIdealSize = false;
  512. _this._blockNextFocusCheck = false;
  513. _this._renderScale = 1;
  514. _this._cursorChanged = false;
  515. /** @hidden */
  516. _this._numLayoutCalls = 0;
  517. /** @hidden */
  518. _this._numRenderCalls = 0;
  519. /**
  520. * Define type to string to ensure compatibility across browsers
  521. * Safari doesn't support DataTransfer constructor
  522. */
  523. _this._clipboardData = "";
  524. /**
  525. * Observable event triggered each time an clipboard event is received from the rendering canvas
  526. */
  527. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  528. /**
  529. * Observable event triggered each time a pointer down is intercepted by a control
  530. */
  531. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  532. /**
  533. * Observable event triggered before layout is evaluated
  534. */
  535. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  536. /**
  537. * Observable event triggered after the layout was evaluated
  538. */
  539. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  540. /**
  541. * Observable event triggered before the texture is rendered
  542. */
  543. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  544. /**
  545. * Observable event triggered after the texture was rendered
  546. */
  547. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  548. /**
  549. * Gets or sets a boolean defining if alpha is stored as premultiplied
  550. */
  551. _this.premulAlpha = false;
  552. _this._useInvalidateRectOptimization = true;
  553. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  554. _this._invalidatedRectangle = null;
  555. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  556. /** @hidden */
  557. _this.onClipboardCopy = function (rawEvt) {
  558. var evt = rawEvt;
  559. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  560. _this.onClipboardObservable.notifyObservers(ev);
  561. evt.preventDefault();
  562. };
  563. /** @hidden */
  564. _this.onClipboardCut = function (rawEvt) {
  565. var evt = rawEvt;
  566. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  567. _this.onClipboardObservable.notifyObservers(ev);
  568. evt.preventDefault();
  569. };
  570. /** @hidden */
  571. _this.onClipboardPaste = function (rawEvt) {
  572. var evt = rawEvt;
  573. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  574. _this.onClipboardObservable.notifyObservers(ev);
  575. evt.preventDefault();
  576. };
  577. scene = _this.getScene();
  578. if (!scene || !_this._texture) {
  579. return _this;
  580. }
  581. _this._rootElement = scene.getEngine().getInputElement();
  582. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  583. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  584. if (!_this._focusedControl) {
  585. return;
  586. }
  587. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  588. _this._focusedControl.processKeyboard(info.event);
  589. }
  590. info.skipOnPointerObservable = true;
  591. });
  592. _this._rootContainer._link(_this);
  593. _this.hasAlpha = true;
  594. if (!width || !height) {
  595. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  596. _this._onResize();
  597. }
  598. _this._texture.isReady = true;
  599. return _this;
  600. }
  601. Object.defineProperty(AdvancedDynamicTexture.prototype, "numLayoutCalls", {
  602. /** Gets the number of layout calls made the last time the ADT has been rendered */
  603. get: function () {
  604. return this._numLayoutCalls;
  605. },
  606. enumerable: true,
  607. configurable: true
  608. });
  609. Object.defineProperty(AdvancedDynamicTexture.prototype, "numRenderCalls", {
  610. /** Gets the number of render calls made the last time the ADT has been rendered */
  611. get: function () {
  612. return this._numRenderCalls;
  613. },
  614. enumerable: true,
  615. configurable: true
  616. });
  617. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  618. /**
  619. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  620. * Useful when you want more antialiasing
  621. */
  622. get: function () {
  623. return this._renderScale;
  624. },
  625. set: function (value) {
  626. if (value === this._renderScale) {
  627. return;
  628. }
  629. this._renderScale = value;
  630. this._onResize();
  631. },
  632. enumerable: true,
  633. configurable: true
  634. });
  635. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  636. /** Gets or sets the background color */
  637. get: function () {
  638. return this._background;
  639. },
  640. set: function (value) {
  641. if (this._background === value) {
  642. return;
  643. }
  644. this._background = value;
  645. this.markAsDirty();
  646. },
  647. enumerable: true,
  648. configurable: true
  649. });
  650. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  651. /**
  652. * Gets or sets the ideal width used to design controls.
  653. * The GUI will then rescale everything accordingly
  654. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  655. */
  656. get: function () {
  657. return this._idealWidth;
  658. },
  659. set: function (value) {
  660. if (this._idealWidth === value) {
  661. return;
  662. }
  663. this._idealWidth = value;
  664. this.markAsDirty();
  665. this._rootContainer._markAllAsDirty();
  666. },
  667. enumerable: true,
  668. configurable: true
  669. });
  670. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  671. /**
  672. * Gets or sets the ideal height used to design controls.
  673. * The GUI will then rescale everything accordingly
  674. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  675. */
  676. get: function () {
  677. return this._idealHeight;
  678. },
  679. set: function (value) {
  680. if (this._idealHeight === value) {
  681. return;
  682. }
  683. this._idealHeight = value;
  684. this.markAsDirty();
  685. this._rootContainer._markAllAsDirty();
  686. },
  687. enumerable: true,
  688. configurable: true
  689. });
  690. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  691. /**
  692. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  693. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  694. */
  695. get: function () {
  696. return this._useSmallestIdeal;
  697. },
  698. set: function (value) {
  699. if (this._useSmallestIdeal === value) {
  700. return;
  701. }
  702. this._useSmallestIdeal = value;
  703. this.markAsDirty();
  704. this._rootContainer._markAllAsDirty();
  705. },
  706. enumerable: true,
  707. configurable: true
  708. });
  709. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  710. /**
  711. * Gets or sets a boolean indicating if adaptive scaling must be used
  712. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  713. */
  714. get: function () {
  715. return this._renderAtIdealSize;
  716. },
  717. set: function (value) {
  718. if (this._renderAtIdealSize === value) {
  719. return;
  720. }
  721. this._renderAtIdealSize = value;
  722. this._onResize();
  723. },
  724. enumerable: true,
  725. configurable: true
  726. });
  727. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealRatio", {
  728. /**
  729. * Gets the ratio used when in "ideal mode"
  730. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  731. * */
  732. get: function () {
  733. var rwidth = 0;
  734. var rheight = 0;
  735. if (this._idealWidth) {
  736. rwidth = (this.getSize().width) / this._idealWidth;
  737. }
  738. if (this._idealHeight) {
  739. rheight = (this.getSize().height) / this._idealHeight;
  740. }
  741. if (this._useSmallestIdeal && this._idealWidth && this._idealHeight) {
  742. return window.innerWidth < window.innerHeight ? rwidth : rheight;
  743. }
  744. if (this._idealWidth) { // horizontal
  745. return rwidth;
  746. }
  747. if (this._idealHeight) { // vertical
  748. return rheight;
  749. }
  750. return 1;
  751. },
  752. enumerable: true,
  753. configurable: true
  754. });
  755. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  756. /**
  757. * Gets the underlying layer used to render the texture when in fullscreen mode
  758. */
  759. get: function () {
  760. return this._layerToDispose;
  761. },
  762. enumerable: true,
  763. configurable: true
  764. });
  765. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  766. /**
  767. * Gets the root container control
  768. */
  769. get: function () {
  770. return this._rootContainer;
  771. },
  772. enumerable: true,
  773. configurable: true
  774. });
  775. /**
  776. * Returns an array containing the root container.
  777. * This is mostly used to let the Inspector introspects the ADT
  778. * @returns an array containing the rootContainer
  779. */
  780. AdvancedDynamicTexture.prototype.getChildren = function () {
  781. return [this._rootContainer];
  782. };
  783. /**
  784. * Will return all controls that are inside this texture
  785. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  786. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  787. * @return all child controls
  788. */
  789. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  790. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  791. };
  792. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  793. /**
  794. * Gets or sets the current focused control
  795. */
  796. get: function () {
  797. return this._focusedControl;
  798. },
  799. set: function (control) {
  800. if (this._focusedControl == control) {
  801. return;
  802. }
  803. if (this._focusedControl) {
  804. this._focusedControl.onBlur();
  805. }
  806. if (control) {
  807. control.onFocus();
  808. }
  809. this._focusedControl = control;
  810. },
  811. enumerable: true,
  812. configurable: true
  813. });
  814. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  815. /**
  816. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  817. */
  818. get: function () {
  819. if (!this.layer) {
  820. return true;
  821. }
  822. return (!this.layer.isBackground);
  823. },
  824. set: function (value) {
  825. if (!this.layer) {
  826. return;
  827. }
  828. if (this.layer.isBackground === !value) {
  829. return;
  830. }
  831. this.layer.isBackground = !value;
  832. },
  833. enumerable: true,
  834. configurable: true
  835. });
  836. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  837. /**
  838. * Gets or set information about clipboardData
  839. */
  840. get: function () {
  841. return this._clipboardData;
  842. },
  843. set: function (value) {
  844. this._clipboardData = value;
  845. },
  846. enumerable: true,
  847. configurable: true
  848. });
  849. /**
  850. * Get the current class name of the texture useful for serialization or dynamic coding.
  851. * @returns "AdvancedDynamicTexture"
  852. */
  853. AdvancedDynamicTexture.prototype.getClassName = function () {
  854. return "AdvancedDynamicTexture";
  855. };
  856. /**
  857. * Function used to execute a function on all controls
  858. * @param func defines the function to execute
  859. * @param container defines the container where controls belong. If null the root container will be used
  860. */
  861. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  862. if (!container) {
  863. container = this._rootContainer;
  864. }
  865. func(container);
  866. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  867. var child = _a[_i];
  868. if (child.children) {
  869. this.executeOnAllControls(func, child);
  870. continue;
  871. }
  872. func(child);
  873. }
  874. };
  875. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  876. /**
  877. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  878. */
  879. get: function () {
  880. return this._useInvalidateRectOptimization;
  881. },
  882. set: function (value) {
  883. this._useInvalidateRectOptimization = value;
  884. },
  885. enumerable: true,
  886. configurable: true
  887. });
  888. /**
  889. * Invalidates a rectangle area on the gui texture
  890. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  891. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  892. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  893. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  894. */
  895. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  896. if (!this._useInvalidateRectOptimization) {
  897. return;
  898. }
  899. if (!this._invalidatedRectangle) {
  900. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  901. }
  902. else {
  903. // Compute intersection
  904. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  905. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  906. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  907. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  908. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  909. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  910. }
  911. };
  912. /**
  913. * Marks the texture as dirty forcing a complete update
  914. */
  915. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  916. this._isDirty = true;
  917. };
  918. /**
  919. * Helper function used to create a new style
  920. * @returns a new style
  921. * @see http://doc.babylonjs.com/how_to/gui#styles
  922. */
  923. AdvancedDynamicTexture.prototype.createStyle = function () {
  924. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  925. };
  926. /**
  927. * Adds a new control to the root container
  928. * @param control defines the control to add
  929. * @returns the current texture
  930. */
  931. AdvancedDynamicTexture.prototype.addControl = function (control) {
  932. this._rootContainer.addControl(control);
  933. return this;
  934. };
  935. /**
  936. * Removes a control from the root container
  937. * @param control defines the control to remove
  938. * @returns the current texture
  939. */
  940. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  941. this._rootContainer.removeControl(control);
  942. return this;
  943. };
  944. /**
  945. * Release all resources
  946. */
  947. AdvancedDynamicTexture.prototype.dispose = function () {
  948. var scene = this.getScene();
  949. if (!scene) {
  950. return;
  951. }
  952. this._rootElement = null;
  953. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  954. if (this._resizeObserver) {
  955. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  956. }
  957. if (this._pointerMoveObserver) {
  958. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  959. }
  960. if (this._pointerObserver) {
  961. scene.onPointerObservable.remove(this._pointerObserver);
  962. }
  963. if (this._preKeyboardObserver) {
  964. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  965. }
  966. if (this._canvasPointerOutObserver) {
  967. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  968. }
  969. if (this._layerToDispose) {
  970. this._layerToDispose.texture = null;
  971. this._layerToDispose.dispose();
  972. this._layerToDispose = null;
  973. }
  974. this._rootContainer.dispose();
  975. this.onClipboardObservable.clear();
  976. this.onControlPickedObservable.clear();
  977. this.onBeginRenderObservable.clear();
  978. this.onEndRenderObservable.clear();
  979. this.onBeginLayoutObservable.clear();
  980. this.onEndLayoutObservable.clear();
  981. _super.prototype.dispose.call(this);
  982. };
  983. AdvancedDynamicTexture.prototype._onResize = function () {
  984. var scene = this.getScene();
  985. if (!scene) {
  986. return;
  987. }
  988. // Check size
  989. var engine = scene.getEngine();
  990. var textureSize = this.getSize();
  991. var renderWidth = engine.getRenderWidth() * this._renderScale;
  992. var renderHeight = engine.getRenderHeight() * this._renderScale;
  993. if (this._renderAtIdealSize) {
  994. if (this._idealWidth) {
  995. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  996. renderWidth = this._idealWidth;
  997. }
  998. else if (this._idealHeight) {
  999. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  1000. renderHeight = this._idealHeight;
  1001. }
  1002. }
  1003. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  1004. this.scaleTo(renderWidth, renderHeight);
  1005. this.markAsDirty();
  1006. if (this._idealWidth || this._idealHeight) {
  1007. this._rootContainer._markAllAsDirty();
  1008. }
  1009. }
  1010. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  1011. };
  1012. /** @hidden */
  1013. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  1014. var engine = scene.getEngine();
  1015. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  1016. };
  1017. /**
  1018. * Get screen coordinates for a vector3
  1019. * @param position defines the position to project
  1020. * @param worldMatrix defines the world matrix to use
  1021. * @returns the projected position
  1022. */
  1023. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  1024. var scene = this.getScene();
  1025. if (!scene) {
  1026. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  1027. }
  1028. var globalViewport = this._getGlobalViewport(scene);
  1029. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1030. projectedPosition.scaleInPlace(this.renderScale);
  1031. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  1032. };
  1033. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  1034. if (this._layerToDispose) {
  1035. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  1036. return;
  1037. }
  1038. }
  1039. if (this._isFullscreen && this._linkedControls.length) {
  1040. var scene = this.getScene();
  1041. if (!scene) {
  1042. return;
  1043. }
  1044. var globalViewport = this._getGlobalViewport(scene);
  1045. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  1046. var control = _a[_i];
  1047. if (!control.isVisible) {
  1048. continue;
  1049. }
  1050. var mesh = control._linkedMesh;
  1051. if (!mesh || mesh.isDisposed()) {
  1052. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1053. control.linkWithMesh(null);
  1054. });
  1055. continue;
  1056. }
  1057. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1058. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1059. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1060. control.notRenderable = true;
  1061. continue;
  1062. }
  1063. control.notRenderable = false;
  1064. // Account for RenderScale.
  1065. projectedPosition.scaleInPlace(this.renderScale);
  1066. control._moveToProjectedPosition(projectedPosition);
  1067. }
  1068. }
  1069. if (!this._isDirty && !this._rootContainer.isDirty) {
  1070. return;
  1071. }
  1072. this._isDirty = false;
  1073. this._render();
  1074. this.update(true, this.premulAlpha);
  1075. };
  1076. AdvancedDynamicTexture.prototype._render = function () {
  1077. var textureSize = this.getSize();
  1078. var renderWidth = textureSize.width;
  1079. var renderHeight = textureSize.height;
  1080. var context = this.getContext();
  1081. context.font = "18px Arial";
  1082. context.strokeStyle = "white";
  1083. // Layout
  1084. this.onBeginLayoutObservable.notifyObservers(this);
  1085. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1086. this._numLayoutCalls = 0;
  1087. this._rootContainer._layout(measure, context);
  1088. this.onEndLayoutObservable.notifyObservers(this);
  1089. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1090. // Clear
  1091. if (this._invalidatedRectangle) {
  1092. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1093. }
  1094. else {
  1095. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1096. }
  1097. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1098. if (this._background) {
  1099. context.save();
  1100. context.fillStyle = this._background;
  1101. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1102. context.restore();
  1103. }
  1104. // Render
  1105. this.onBeginRenderObservable.notifyObservers(this);
  1106. this._numRenderCalls = 0;
  1107. this._rootContainer._render(context, this._invalidatedRectangle);
  1108. this.onEndRenderObservable.notifyObservers(this);
  1109. this._invalidatedRectangle = null;
  1110. };
  1111. /** @hidden */
  1112. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1113. if (this._rootElement) {
  1114. this._rootElement.style.cursor = cursor;
  1115. this._cursorChanged = true;
  1116. }
  1117. };
  1118. /** @hidden */
  1119. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1120. this._lastControlDown[pointerId] = control;
  1121. this.onControlPickedObservable.notifyObservers(control);
  1122. };
  1123. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1124. var scene = this.getScene();
  1125. if (!scene) {
  1126. return;
  1127. }
  1128. var engine = scene.getEngine();
  1129. var textureSize = this.getSize();
  1130. if (this._isFullscreen) {
  1131. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1132. var viewport = camera.viewport;
  1133. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1134. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1135. }
  1136. if (this._capturingControl[pointerId]) {
  1137. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1138. return;
  1139. }
  1140. this._cursorChanged = false;
  1141. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1142. this._changeCursor("");
  1143. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1144. if (this._lastControlOver[pointerId]) {
  1145. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1146. delete this._lastControlOver[pointerId];
  1147. }
  1148. }
  1149. }
  1150. if (!this._cursorChanged) {
  1151. this._changeCursor("");
  1152. }
  1153. this._manageFocus();
  1154. };
  1155. /** @hidden */
  1156. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1157. for (var pointerId in list) {
  1158. if (!list.hasOwnProperty(pointerId)) {
  1159. continue;
  1160. }
  1161. var lastControlOver = list[pointerId];
  1162. if (lastControlOver === control) {
  1163. delete list[pointerId];
  1164. }
  1165. }
  1166. };
  1167. /** @hidden */
  1168. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1169. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1170. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1171. };
  1172. /** Attach to all scene events required to support pointer events */
  1173. AdvancedDynamicTexture.prototype.attach = function () {
  1174. var _this = this;
  1175. var scene = this.getScene();
  1176. if (!scene) {
  1177. return;
  1178. }
  1179. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1180. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1181. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1182. return;
  1183. }
  1184. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1185. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1186. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1187. return;
  1188. }
  1189. if (!scene) {
  1190. return;
  1191. }
  1192. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1193. var engine = scene.getEngine();
  1194. if (!camera) {
  1195. tempViewport.x = 0;
  1196. tempViewport.y = 0;
  1197. tempViewport.width = engine.getRenderWidth();
  1198. tempViewport.height = engine.getRenderHeight();
  1199. }
  1200. else {
  1201. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1202. }
  1203. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1204. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1205. _this._shouldBlockPointer = false;
  1206. // Do picking modifies _shouldBlockPointer
  1207. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1208. // Avoid overwriting a true skipOnPointerObservable to false
  1209. if (_this._shouldBlockPointer) {
  1210. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1211. }
  1212. });
  1213. this._attachToOnPointerOut(scene);
  1214. };
  1215. /**
  1216. * Register the clipboard Events onto the canvas
  1217. */
  1218. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1219. self.addEventListener("copy", this.onClipboardCopy, false);
  1220. self.addEventListener("cut", this.onClipboardCut, false);
  1221. self.addEventListener("paste", this.onClipboardPaste, false);
  1222. };
  1223. /**
  1224. * Unregister the clipboard Events from the canvas
  1225. */
  1226. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1227. self.removeEventListener("copy", this.onClipboardCopy);
  1228. self.removeEventListener("cut", this.onClipboardCut);
  1229. self.removeEventListener("paste", this.onClipboardPaste);
  1230. };
  1231. /**
  1232. * Connect the texture to a hosting mesh to enable interactions
  1233. * @param mesh defines the mesh to attach to
  1234. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1235. */
  1236. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1237. var _this = this;
  1238. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1239. var scene = this.getScene();
  1240. if (!scene) {
  1241. return;
  1242. }
  1243. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1244. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1245. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1246. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1247. return;
  1248. }
  1249. var pointerId = pi.event.pointerId || 0;
  1250. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1251. var uv = pi.pickInfo.getTextureCoordinates();
  1252. if (uv) {
  1253. var size = _this.getSize();
  1254. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1255. }
  1256. }
  1257. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1258. if (_this._lastControlDown[pointerId]) {
  1259. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1260. }
  1261. delete _this._lastControlDown[pointerId];
  1262. if (_this.focusedControl) {
  1263. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1264. var canMoveFocus = true;
  1265. if (friendlyControls) {
  1266. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1267. var control = friendlyControls_1[_i];
  1268. // Same host, no need to keep the focus
  1269. if (_this === control._host) {
  1270. continue;
  1271. }
  1272. // Different hosts
  1273. var otherHost = control._host;
  1274. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1275. canMoveFocus = false;
  1276. break;
  1277. }
  1278. }
  1279. }
  1280. if (canMoveFocus) {
  1281. _this.focusedControl = null;
  1282. }
  1283. }
  1284. }
  1285. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1286. if (_this._lastControlOver[pointerId]) {
  1287. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1288. }
  1289. delete _this._lastControlOver[pointerId];
  1290. }
  1291. });
  1292. mesh.enablePointerMoveEvents = supportPointerMove;
  1293. this._attachToOnPointerOut(scene);
  1294. };
  1295. /**
  1296. * Move the focus to a specific control
  1297. * @param control defines the control which will receive the focus
  1298. */
  1299. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1300. this.focusedControl = control;
  1301. this._lastPickedControl = control;
  1302. this._blockNextFocusCheck = true;
  1303. };
  1304. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1305. if (this._blockNextFocusCheck) {
  1306. this._blockNextFocusCheck = false;
  1307. this._lastPickedControl = this._focusedControl;
  1308. return;
  1309. }
  1310. // Focus management
  1311. if (this._focusedControl) {
  1312. if (this._focusedControl !== this._lastPickedControl) {
  1313. if (this._lastPickedControl.isFocusInvisible) {
  1314. return;
  1315. }
  1316. this.focusedControl = null;
  1317. }
  1318. }
  1319. };
  1320. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1321. var _this = this;
  1322. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1323. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1324. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1325. }
  1326. delete _this._lastControlOver[pointerEvent.pointerId];
  1327. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1328. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1329. delete _this._lastControlDown[pointerEvent.pointerId];
  1330. }
  1331. });
  1332. };
  1333. // Statics
  1334. /**
  1335. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1336. * @param mesh defines the mesh which will receive the texture
  1337. * @param width defines the texture width (1024 by default)
  1338. * @param height defines the texture height (1024 by default)
  1339. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1340. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1341. * @returns a new AdvancedDynamicTexture
  1342. */
  1343. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1344. if (width === void 0) { width = 1024; }
  1345. if (height === void 0) { height = 1024; }
  1346. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1347. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1348. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1349. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1350. material.backFaceCulling = false;
  1351. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1352. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1353. if (onlyAlphaTesting) {
  1354. material.diffuseTexture = result;
  1355. material.emissiveTexture = result;
  1356. result.hasAlpha = true;
  1357. }
  1358. else {
  1359. material.emissiveTexture = result;
  1360. material.opacityTexture = result;
  1361. }
  1362. mesh.material = material;
  1363. result.attachToMesh(mesh, supportPointerMove);
  1364. return result;
  1365. };
  1366. /**
  1367. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1368. * In this mode the texture will rely on a layer for its rendering.
  1369. * This allows it to be treated like any other layer.
  1370. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1371. * LayerMask is set through advancedTexture.layer.layerMask
  1372. * @param name defines name for the texture
  1373. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1374. * @param scene defines the hsoting scene
  1375. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1376. * @returns a new AdvancedDynamicTexture
  1377. */
  1378. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1379. if (foreground === void 0) { foreground = true; }
  1380. if (scene === void 0) { scene = null; }
  1381. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1382. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1383. // Display
  1384. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1385. layer.texture = result;
  1386. result._layerToDispose = layer;
  1387. result._isFullscreen = true;
  1388. // Attach
  1389. result.attach();
  1390. return result;
  1391. };
  1392. return AdvancedDynamicTexture;
  1393. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1394. /***/ }),
  1395. /***/ "./2D/controls/button.ts":
  1396. /*!*******************************!*\
  1397. !*** ./2D/controls/button.ts ***!
  1398. \*******************************/
  1399. /*! exports provided: Button */
  1400. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1401. "use strict";
  1402. __webpack_require__.r(__webpack_exports__);
  1403. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1404. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1405. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1406. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1407. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1408. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1409. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  1410. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1411. /**
  1412. * Class used to create 2D buttons
  1413. */
  1414. var Button = /** @class */ (function (_super) {
  1415. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1416. /**
  1417. * Creates a new Button
  1418. * @param name defines the name of the button
  1419. */
  1420. function Button(name) {
  1421. var _this = _super.call(this, name) || this;
  1422. _this.name = name;
  1423. /**
  1424. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1425. */
  1426. _this.delegatePickingToChildren = false;
  1427. _this.thickness = 1;
  1428. _this.isPointerBlocker = true;
  1429. var alphaStore = null;
  1430. _this.pointerEnterAnimation = function () {
  1431. alphaStore = _this.alpha;
  1432. _this.alpha -= 0.1;
  1433. };
  1434. _this.pointerOutAnimation = function () {
  1435. if (alphaStore !== null) {
  1436. _this.alpha = alphaStore;
  1437. }
  1438. };
  1439. _this.pointerDownAnimation = function () {
  1440. _this.scaleX -= 0.05;
  1441. _this.scaleY -= 0.05;
  1442. };
  1443. _this.pointerUpAnimation = function () {
  1444. _this.scaleX += 0.05;
  1445. _this.scaleY += 0.05;
  1446. };
  1447. return _this;
  1448. }
  1449. Object.defineProperty(Button.prototype, "image", {
  1450. /**
  1451. * Returns the image part of the button (if any)
  1452. */
  1453. get: function () {
  1454. return this._image;
  1455. },
  1456. enumerable: true,
  1457. configurable: true
  1458. });
  1459. Object.defineProperty(Button.prototype, "textBlock", {
  1460. /**
  1461. * Returns the image part of the button (if any)
  1462. */
  1463. get: function () {
  1464. return this._textBlock;
  1465. },
  1466. enumerable: true,
  1467. configurable: true
  1468. });
  1469. Button.prototype._getTypeName = function () {
  1470. return "Button";
  1471. };
  1472. // While being a container, the button behaves like a control.
  1473. /** @hidden */
  1474. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1475. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1476. return false;
  1477. }
  1478. if (!_super.prototype.contains.call(this, x, y)) {
  1479. return false;
  1480. }
  1481. if (this.delegatePickingToChildren) {
  1482. var contains = false;
  1483. for (var index = this._children.length - 1; index >= 0; index--) {
  1484. var child = this._children[index];
  1485. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1486. contains = true;
  1487. break;
  1488. }
  1489. }
  1490. if (!contains) {
  1491. return false;
  1492. }
  1493. }
  1494. this._processObservables(type, x, y, pointerId, buttonIndex);
  1495. return true;
  1496. };
  1497. /** @hidden */
  1498. Button.prototype._onPointerEnter = function (target) {
  1499. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1500. return false;
  1501. }
  1502. if (this.pointerEnterAnimation) {
  1503. this.pointerEnterAnimation();
  1504. }
  1505. return true;
  1506. };
  1507. /** @hidden */
  1508. Button.prototype._onPointerOut = function (target, force) {
  1509. if (force === void 0) { force = false; }
  1510. if (this.pointerOutAnimation) {
  1511. this.pointerOutAnimation();
  1512. }
  1513. _super.prototype._onPointerOut.call(this, target, force);
  1514. };
  1515. /** @hidden */
  1516. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1517. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1518. return false;
  1519. }
  1520. if (this.pointerDownAnimation) {
  1521. this.pointerDownAnimation();
  1522. }
  1523. return true;
  1524. };
  1525. /** @hidden */
  1526. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1527. if (this.pointerUpAnimation) {
  1528. this.pointerUpAnimation();
  1529. }
  1530. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1531. };
  1532. // Statics
  1533. /**
  1534. * Creates a new button made with an image and a text
  1535. * @param name defines the name of the button
  1536. * @param text defines the text of the button
  1537. * @param imageUrl defines the url of the image
  1538. * @returns a new Button
  1539. */
  1540. Button.CreateImageButton = function (name, text, imageUrl) {
  1541. var result = new Button(name);
  1542. // Adding text
  1543. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1544. textBlock.textWrapping = true;
  1545. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1546. textBlock.paddingLeft = "20%";
  1547. result.addControl(textBlock);
  1548. // Adding image
  1549. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1550. iconImage.width = "20%";
  1551. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1552. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1553. result.addControl(iconImage);
  1554. // Store
  1555. result._image = iconImage;
  1556. result._textBlock = textBlock;
  1557. return result;
  1558. };
  1559. /**
  1560. * Creates a new button made with an image
  1561. * @param name defines the name of the button
  1562. * @param imageUrl defines the url of the image
  1563. * @returns a new Button
  1564. */
  1565. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1566. var result = new Button(name);
  1567. // Adding image
  1568. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1569. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1570. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1571. result.addControl(iconImage);
  1572. // Store
  1573. result._image = iconImage;
  1574. return result;
  1575. };
  1576. /**
  1577. * Creates a new button made with a text
  1578. * @param name defines the name of the button
  1579. * @param text defines the text of the button
  1580. * @returns a new Button
  1581. */
  1582. Button.CreateSimpleButton = function (name, text) {
  1583. var result = new Button(name);
  1584. // Adding text
  1585. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1586. textBlock.textWrapping = true;
  1587. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1588. result.addControl(textBlock);
  1589. // Store
  1590. result._textBlock = textBlock;
  1591. return result;
  1592. };
  1593. /**
  1594. * Creates a new button made with an image and a centered text
  1595. * @param name defines the name of the button
  1596. * @param text defines the text of the button
  1597. * @param imageUrl defines the url of the image
  1598. * @returns a new Button
  1599. */
  1600. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1601. var result = new Button(name);
  1602. // Adding image
  1603. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1604. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1605. result.addControl(iconImage);
  1606. // Adding text
  1607. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1608. textBlock.textWrapping = true;
  1609. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1610. result.addControl(textBlock);
  1611. // Store
  1612. result._image = iconImage;
  1613. result._textBlock = textBlock;
  1614. return result;
  1615. };
  1616. return Button;
  1617. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1618. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1619. /***/ }),
  1620. /***/ "./2D/controls/checkbox.ts":
  1621. /*!*********************************!*\
  1622. !*** ./2D/controls/checkbox.ts ***!
  1623. \*********************************/
  1624. /*! exports provided: Checkbox */
  1625. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1626. "use strict";
  1627. __webpack_require__.r(__webpack_exports__);
  1628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1629. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1630. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1631. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1632. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1633. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1634. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1635. /**
  1636. * Class used to represent a 2D checkbox
  1637. */
  1638. var Checkbox = /** @class */ (function (_super) {
  1639. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1640. /**
  1641. * Creates a new CheckBox
  1642. * @param name defines the control name
  1643. */
  1644. function Checkbox(name) {
  1645. var _this = _super.call(this, name) || this;
  1646. _this.name = name;
  1647. _this._isChecked = false;
  1648. _this._background = "black";
  1649. _this._checkSizeRatio = 0.8;
  1650. _this._thickness = 1;
  1651. /**
  1652. * Observable raised when isChecked property changes
  1653. */
  1654. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1655. _this.isPointerBlocker = true;
  1656. return _this;
  1657. }
  1658. Object.defineProperty(Checkbox.prototype, "thickness", {
  1659. /** Gets or sets border thickness */
  1660. get: function () {
  1661. return this._thickness;
  1662. },
  1663. set: function (value) {
  1664. if (this._thickness === value) {
  1665. return;
  1666. }
  1667. this._thickness = value;
  1668. this._markAsDirty();
  1669. },
  1670. enumerable: true,
  1671. configurable: true
  1672. });
  1673. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1674. /** Gets or sets a value indicating the ratio between overall size and check size */
  1675. get: function () {
  1676. return this._checkSizeRatio;
  1677. },
  1678. set: function (value) {
  1679. value = Math.max(Math.min(1, value), 0);
  1680. if (this._checkSizeRatio === value) {
  1681. return;
  1682. }
  1683. this._checkSizeRatio = value;
  1684. this._markAsDirty();
  1685. },
  1686. enumerable: true,
  1687. configurable: true
  1688. });
  1689. Object.defineProperty(Checkbox.prototype, "background", {
  1690. /** Gets or sets background color */
  1691. get: function () {
  1692. return this._background;
  1693. },
  1694. set: function (value) {
  1695. if (this._background === value) {
  1696. return;
  1697. }
  1698. this._background = value;
  1699. this._markAsDirty();
  1700. },
  1701. enumerable: true,
  1702. configurable: true
  1703. });
  1704. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1705. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1706. get: function () {
  1707. return this._isChecked;
  1708. },
  1709. set: function (value) {
  1710. if (this._isChecked === value) {
  1711. return;
  1712. }
  1713. this._isChecked = value;
  1714. this._markAsDirty();
  1715. this.onIsCheckedChangedObservable.notifyObservers(value);
  1716. },
  1717. enumerable: true,
  1718. configurable: true
  1719. });
  1720. Checkbox.prototype._getTypeName = function () {
  1721. return "Checkbox";
  1722. };
  1723. /** @hidden */
  1724. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1725. context.save();
  1726. this._applyStates(context);
  1727. var actualWidth = this._currentMeasure.width - this._thickness;
  1728. var actualHeight = this._currentMeasure.height - this._thickness;
  1729. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1730. context.shadowColor = this.shadowColor;
  1731. context.shadowBlur = this.shadowBlur;
  1732. context.shadowOffsetX = this.shadowOffsetX;
  1733. context.shadowOffsetY = this.shadowOffsetY;
  1734. }
  1735. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1736. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1737. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1738. context.shadowBlur = 0;
  1739. context.shadowOffsetX = 0;
  1740. context.shadowOffsetY = 0;
  1741. }
  1742. if (this._isChecked) {
  1743. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1744. var offsetWidth = actualWidth * this._checkSizeRatio;
  1745. var offseHeight = actualHeight * this._checkSizeRatio;
  1746. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1747. }
  1748. context.strokeStyle = this.color;
  1749. context.lineWidth = this._thickness;
  1750. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1751. context.restore();
  1752. };
  1753. // Events
  1754. /** @hidden */
  1755. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1756. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1757. return false;
  1758. }
  1759. this.isChecked = !this.isChecked;
  1760. return true;
  1761. };
  1762. /**
  1763. * Utility function to easily create a checkbox with a header
  1764. * @param title defines the label to use for the header
  1765. * @param onValueChanged defines the callback to call when value changes
  1766. * @returns a StackPanel containing the checkbox and a textBlock
  1767. */
  1768. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1769. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1770. panel.isVertical = false;
  1771. panel.height = "30px";
  1772. var checkbox = new Checkbox();
  1773. checkbox.width = "20px";
  1774. checkbox.height = "20px";
  1775. checkbox.isChecked = true;
  1776. checkbox.color = "green";
  1777. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1778. panel.addControl(checkbox);
  1779. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1780. header.text = title;
  1781. header.width = "180px";
  1782. header.paddingLeft = "5px";
  1783. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1784. header.color = "white";
  1785. panel.addControl(header);
  1786. return panel;
  1787. };
  1788. return Checkbox;
  1789. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1790. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1791. /***/ }),
  1792. /***/ "./2D/controls/colorpicker.ts":
  1793. /*!************************************!*\
  1794. !*** ./2D/controls/colorpicker.ts ***!
  1795. \************************************/
  1796. /*! exports provided: ColorPicker */
  1797. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1798. "use strict";
  1799. __webpack_require__.r(__webpack_exports__);
  1800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1801. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1802. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1803. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1804. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1805. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1806. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1807. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1808. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1809. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1810. /** Class used to create color pickers */
  1811. var ColorPicker = /** @class */ (function (_super) {
  1812. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1813. /**
  1814. * Creates a new ColorPicker
  1815. * @param name defines the control name
  1816. */
  1817. function ColorPicker(name) {
  1818. var _this = _super.call(this, name) || this;
  1819. _this.name = name;
  1820. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1821. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1822. _this._pointerStartedOnSquare = false;
  1823. _this._pointerStartedOnWheel = false;
  1824. _this._squareLeft = 0;
  1825. _this._squareTop = 0;
  1826. _this._squareSize = 0;
  1827. _this._h = 360;
  1828. _this._s = 1;
  1829. _this._v = 1;
  1830. _this._lastPointerDownID = -1;
  1831. /**
  1832. * Observable raised when the value changes
  1833. */
  1834. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1835. // Events
  1836. _this._pointerIsDown = false;
  1837. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1838. _this.size = "200px";
  1839. _this.isPointerBlocker = true;
  1840. return _this;
  1841. }
  1842. Object.defineProperty(ColorPicker.prototype, "value", {
  1843. /** Gets or sets the color of the color picker */
  1844. get: function () {
  1845. return this._value;
  1846. },
  1847. set: function (value) {
  1848. if (this._value.equals(value)) {
  1849. return;
  1850. }
  1851. this._value.copyFrom(value);
  1852. this._value.toHSVToRef(this._tmpColor);
  1853. this._h = this._tmpColor.r;
  1854. this._s = Math.max(this._tmpColor.g, 0.00001);
  1855. this._v = Math.max(this._tmpColor.b, 0.00001);
  1856. this._markAsDirty();
  1857. if (this._value.r <= ColorPicker._Epsilon) {
  1858. this._value.r = 0;
  1859. }
  1860. if (this._value.g <= ColorPicker._Epsilon) {
  1861. this._value.g = 0;
  1862. }
  1863. if (this._value.b <= ColorPicker._Epsilon) {
  1864. this._value.b = 0;
  1865. }
  1866. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1867. this._value.r = 1.0;
  1868. }
  1869. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1870. this._value.g = 1.0;
  1871. }
  1872. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1873. this._value.b = 1.0;
  1874. }
  1875. this.onValueChangedObservable.notifyObservers(this._value);
  1876. },
  1877. enumerable: true,
  1878. configurable: true
  1879. });
  1880. Object.defineProperty(ColorPicker.prototype, "width", {
  1881. /**
  1882. * Gets or sets control width
  1883. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1884. */
  1885. get: function () {
  1886. return this._width.toString(this._host);
  1887. },
  1888. set: function (value) {
  1889. if (this._width.toString(this._host) === value) {
  1890. return;
  1891. }
  1892. if (this._width.fromString(value)) {
  1893. this._height.fromString(value);
  1894. this._markAsDirty();
  1895. }
  1896. },
  1897. enumerable: true,
  1898. configurable: true
  1899. });
  1900. Object.defineProperty(ColorPicker.prototype, "height", {
  1901. /**
  1902. * Gets or sets control height
  1903. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1904. */
  1905. get: function () {
  1906. return this._height.toString(this._host);
  1907. },
  1908. /** Gets or sets control height */
  1909. set: function (value) {
  1910. if (this._height.toString(this._host) === value) {
  1911. return;
  1912. }
  1913. if (this._height.fromString(value)) {
  1914. this._width.fromString(value);
  1915. this._markAsDirty();
  1916. }
  1917. },
  1918. enumerable: true,
  1919. configurable: true
  1920. });
  1921. Object.defineProperty(ColorPicker.prototype, "size", {
  1922. /** Gets or sets control size */
  1923. get: function () {
  1924. return this.width;
  1925. },
  1926. set: function (value) {
  1927. this.width = value;
  1928. },
  1929. enumerable: true,
  1930. configurable: true
  1931. });
  1932. ColorPicker.prototype._getTypeName = function () {
  1933. return "ColorPicker";
  1934. };
  1935. /** @hidden */
  1936. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1937. if (parentMeasure.width < parentMeasure.height) {
  1938. this._currentMeasure.height = parentMeasure.width;
  1939. }
  1940. else {
  1941. this._currentMeasure.width = parentMeasure.height;
  1942. }
  1943. };
  1944. ColorPicker.prototype._updateSquareProps = function () {
  1945. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1946. var wheelThickness = radius * .2;
  1947. var innerDiameter = (radius - wheelThickness) * 2;
  1948. var squareSize = innerDiameter / (Math.sqrt(2));
  1949. var offset = radius - squareSize * .5;
  1950. this._squareLeft = this._currentMeasure.left + offset;
  1951. this._squareTop = this._currentMeasure.top + offset;
  1952. this._squareSize = squareSize;
  1953. };
  1954. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1955. var lgh = context.createLinearGradient(left, top, width + left, top);
  1956. lgh.addColorStop(0, '#fff');
  1957. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1958. context.fillStyle = lgh;
  1959. context.fillRect(left, top, width, height);
  1960. var lgv = context.createLinearGradient(left, top, left, height + top);
  1961. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1962. lgv.addColorStop(1, '#000');
  1963. context.fillStyle = lgv;
  1964. context.fillRect(left, top, width, height);
  1965. };
  1966. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1967. context.beginPath();
  1968. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1969. context.lineWidth = 3;
  1970. context.strokeStyle = '#333333';
  1971. context.stroke();
  1972. context.beginPath();
  1973. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1974. context.lineWidth = 3;
  1975. context.strokeStyle = '#ffffff';
  1976. context.stroke();
  1977. };
  1978. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1979. var canvas = document.createElement("canvas");
  1980. canvas.width = radius * 2;
  1981. canvas.height = radius * 2;
  1982. var context = canvas.getContext("2d");
  1983. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1984. var data = image.data;
  1985. var color = this._tmpColor;
  1986. var maxDistSq = radius * radius;
  1987. var innerRadius = radius - thickness;
  1988. var minDistSq = innerRadius * innerRadius;
  1989. for (var x = -radius; x < radius; x++) {
  1990. for (var y = -radius; y < radius; y++) {
  1991. var distSq = x * x + y * y;
  1992. if (distSq > maxDistSq || distSq < minDistSq) {
  1993. continue;
  1994. }
  1995. var dist = Math.sqrt(distSq);
  1996. var ang = Math.atan2(y, x);
  1997. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1998. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1999. data[index] = color.r * 255;
  2000. data[index + 1] = color.g * 255;
  2001. data[index + 2] = color.b * 255;
  2002. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2003. //apply less alpha to bigger color pickers
  2004. var alphaAmount = .2;
  2005. var maxAlpha = .2;
  2006. var minAlpha = .04;
  2007. var lowerRadius = 50;
  2008. var upperRadius = 150;
  2009. if (radius < lowerRadius) {
  2010. alphaAmount = maxAlpha;
  2011. }
  2012. else if (radius > upperRadius) {
  2013. alphaAmount = minAlpha;
  2014. }
  2015. else {
  2016. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  2017. }
  2018. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2019. if (alphaRatio < alphaAmount) {
  2020. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  2021. }
  2022. else if (alphaRatio > 1 - alphaAmount) {
  2023. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  2024. }
  2025. else {
  2026. data[index + 3] = 255;
  2027. }
  2028. }
  2029. }
  2030. context.putImageData(image, 0, 0);
  2031. return canvas;
  2032. };
  2033. /** @hidden */
  2034. ColorPicker.prototype._draw = function (context) {
  2035. context.save();
  2036. this._applyStates(context);
  2037. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2038. var wheelThickness = radius * .2;
  2039. var left = this._currentMeasure.left;
  2040. var top = this._currentMeasure.top;
  2041. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2042. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2043. }
  2044. this._updateSquareProps();
  2045. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2046. context.shadowColor = this.shadowColor;
  2047. context.shadowBlur = this.shadowBlur;
  2048. context.shadowOffsetX = this.shadowOffsetX;
  2049. context.shadowOffsetY = this.shadowOffsetY;
  2050. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2051. }
  2052. context.drawImage(this._colorWheelCanvas, left, top);
  2053. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2054. context.shadowBlur = 0;
  2055. context.shadowOffsetX = 0;
  2056. context.shadowOffsetY = 0;
  2057. }
  2058. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2059. var cx = this._squareLeft + this._squareSize * this._s;
  2060. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2061. this._drawCircle(cx, cy, radius * .04, context);
  2062. var dist = radius - wheelThickness * .5;
  2063. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2064. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2065. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2066. context.restore();
  2067. };
  2068. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2069. if (this._pointerStartedOnWheel) {
  2070. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2071. var centerX = radius + this._currentMeasure.left;
  2072. var centerY = radius + this._currentMeasure.top;
  2073. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2074. }
  2075. else if (this._pointerStartedOnSquare) {
  2076. this._updateSquareProps();
  2077. this._s = (x - this._squareLeft) / this._squareSize;
  2078. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2079. this._s = Math.min(this._s, 1);
  2080. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2081. this._v = Math.min(this._v, 1);
  2082. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2083. }
  2084. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2085. this.value = this._tmpColor;
  2086. };
  2087. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2088. this._updateSquareProps();
  2089. var left = this._squareLeft;
  2090. var top = this._squareTop;
  2091. var size = this._squareSize;
  2092. if (x >= left && x <= left + size &&
  2093. y >= top && y <= top + size) {
  2094. return true;
  2095. }
  2096. return false;
  2097. };
  2098. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2099. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2100. var centerX = radius + this._currentMeasure.left;
  2101. var centerY = radius + this._currentMeasure.top;
  2102. var wheelThickness = radius * .2;
  2103. var innerRadius = radius - wheelThickness;
  2104. var radiusSq = radius * radius;
  2105. var innerRadiusSq = innerRadius * innerRadius;
  2106. var dx = x - centerX;
  2107. var dy = y - centerY;
  2108. var distSq = dx * dx + dy * dy;
  2109. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2110. return true;
  2111. }
  2112. return false;
  2113. };
  2114. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2115. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2116. return false;
  2117. }
  2118. this._pointerIsDown = true;
  2119. this._pointerStartedOnSquare = false;
  2120. this._pointerStartedOnWheel = false;
  2121. // Invert transform
  2122. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2123. var x = this._transformedPosition.x;
  2124. var y = this._transformedPosition.y;
  2125. if (this._isPointOnSquare(x, y)) {
  2126. this._pointerStartedOnSquare = true;
  2127. }
  2128. else if (this._isPointOnWheel(x, y)) {
  2129. this._pointerStartedOnWheel = true;
  2130. }
  2131. this._updateValueFromPointer(x, y);
  2132. this._host._capturingControl[pointerId] = this;
  2133. this._lastPointerDownID = pointerId;
  2134. return true;
  2135. };
  2136. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2137. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2138. if (pointerId != this._lastPointerDownID) {
  2139. return;
  2140. }
  2141. // Invert transform
  2142. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2143. var x = this._transformedPosition.x;
  2144. var y = this._transformedPosition.y;
  2145. if (this._pointerIsDown) {
  2146. this._updateValueFromPointer(x, y);
  2147. }
  2148. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2149. };
  2150. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2151. this._pointerIsDown = false;
  2152. delete this._host._capturingControl[pointerId];
  2153. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2154. };
  2155. /**
  2156. * This function expands the color picker by creating a color picker dialog with manual
  2157. * color value input and the ability to save colors into an array to be used later in
  2158. * subsequent launches of the dialogue.
  2159. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2160. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  2161. * @returns picked color as a hex string and the saved colors array as hex strings.
  2162. */
  2163. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2164. return new Promise(function (resolve, reject) {
  2165. // Default options
  2166. options.pickerWidth = options.pickerWidth || "640px";
  2167. options.pickerHeight = options.pickerHeight || "400px";
  2168. options.headerHeight = options.headerHeight || "35px";
  2169. options.lastColor = options.lastColor || "#000000";
  2170. options.swatchLimit = options.swatchLimit || 20;
  2171. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2172. // Window size settings
  2173. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2174. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2175. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2176. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2177. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2178. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2179. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2180. // Button Colors
  2181. var buttonColor = "#c0c0c0";
  2182. var buttonBackgroundColor = "#535353";
  2183. var buttonBackgroundHoverColor = "#414141";
  2184. var buttonBackgroundClickColor = "515151";
  2185. var buttonDisabledColor = "#555555";
  2186. var buttonDisabledBackgroundColor = "#454545";
  2187. var currentSwatchesOutlineColor = "#404040";
  2188. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2189. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2190. var iconColorDark = "#aaaaaa";
  2191. var iconColorLight = "#ffffff";
  2192. var closeIconColor;
  2193. // Button settings
  2194. var buttonFontSize;
  2195. var butEdit;
  2196. var buttonWidth;
  2197. var buttonHeight;
  2198. // Input Text Colors
  2199. var inputFieldLabels = ["R", "G", "B"];
  2200. var inputTextBackgroundColor = "#454545";
  2201. var inputTextColor = "#f0f0f0";
  2202. // This is the current color as set by either the picker or by entering a value
  2203. var currentColor;
  2204. // This int is used for naming swatches and serves as the index for calling them from the list
  2205. var swatchNumber;
  2206. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2207. var swatchDrawer;
  2208. var editSwatchMode = false;
  2209. // Color InputText fields that will be updated upon value change
  2210. var picker;
  2211. var rValInt;
  2212. var gValInt;
  2213. var bValInt;
  2214. var rValDec;
  2215. var gValDec;
  2216. var bValDec;
  2217. var hexVal;
  2218. var newSwatch;
  2219. var lastVal;
  2220. var activeField;
  2221. /**
  2222. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2223. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2224. * are will receive no update. This is to prevent the input from the user being overwritten.
  2225. */
  2226. function updateValues(value, inputField) {
  2227. activeField = inputField;
  2228. var pickedColor = value.toHexString();
  2229. newSwatch.background = pickedColor;
  2230. if (rValInt.name != activeField) {
  2231. rValInt.text = Math.floor(value.r * 255).toString();
  2232. }
  2233. if (gValInt.name != activeField) {
  2234. gValInt.text = Math.floor(value.g * 255).toString();
  2235. }
  2236. if (bValInt.name != activeField) {
  2237. bValInt.text = Math.floor(value.b * 255).toString();
  2238. }
  2239. if (rValDec.name != activeField) {
  2240. rValDec.text = value.r.toString();
  2241. }
  2242. if (gValDec.name != activeField) {
  2243. gValDec.text = value.g.toString();
  2244. }
  2245. if (bValDec.name != activeField) {
  2246. bValDec.text = value.b.toString();
  2247. }
  2248. if (hexVal.name != activeField) {
  2249. var minusPound = pickedColor.split("#");
  2250. hexVal.text = minusPound[1];
  2251. }
  2252. if (picker.name != activeField) {
  2253. picker.value = value;
  2254. }
  2255. }
  2256. // When the user enters an integer for R, G, or B we check to make sure it is a valid number and replace if not.
  2257. function updateInt(field, channel) {
  2258. var newValue = field.text;
  2259. var checkVal = /[^0-9]/g.test(newValue);
  2260. if (checkVal) {
  2261. field.text = lastVal;
  2262. return;
  2263. }
  2264. else {
  2265. if (newValue != "") {
  2266. if (Math.floor(parseInt(newValue)) < 0) {
  2267. newValue = "0";
  2268. }
  2269. else if (Math.floor(parseInt(newValue)) > 255) {
  2270. newValue = "255";
  2271. }
  2272. else if (isNaN(parseInt(newValue))) {
  2273. newValue = "0";
  2274. }
  2275. }
  2276. if (activeField == field.name) {
  2277. lastVal = newValue;
  2278. }
  2279. }
  2280. if (newValue != "") {
  2281. newValue = parseInt(newValue).toString();
  2282. field.text = newValue;
  2283. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2284. if (activeField == field.name) {
  2285. if (channel == "r") {
  2286. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2287. }
  2288. else if (channel == "g") {
  2289. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2290. }
  2291. else {
  2292. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2293. }
  2294. }
  2295. }
  2296. }
  2297. // When the user enters a float for R, G, or B we check to make sure it is a valid number and replace if not.
  2298. function updateFloat(field, channel) {
  2299. var newValue = field.text;
  2300. var checkVal = /[^0-9\.]/g.test(newValue);
  2301. if (checkVal) {
  2302. field.text = lastVal;
  2303. return;
  2304. }
  2305. else {
  2306. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2307. if (parseFloat(newValue) < 0.0) {
  2308. newValue = "0.0";
  2309. }
  2310. else if (parseFloat(newValue) > 1.0) {
  2311. newValue = "1.0";
  2312. }
  2313. else if (isNaN(parseFloat(newValue))) {
  2314. newValue = "0.0";
  2315. }
  2316. }
  2317. if (activeField == field.name) {
  2318. lastVal = newValue;
  2319. }
  2320. }
  2321. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2322. newValue = parseFloat(newValue).toString();
  2323. field.text = newValue;
  2324. }
  2325. else {
  2326. newValue = "0.0";
  2327. }
  2328. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2329. if (activeField == field.name) {
  2330. if (channel == "r") {
  2331. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2332. }
  2333. else if (channel == "g") {
  2334. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2335. }
  2336. else {
  2337. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2338. }
  2339. }
  2340. }
  2341. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2342. function deleteSwatch(index) {
  2343. if (options.savedColors) {
  2344. options.savedColors.splice(index, 1);
  2345. }
  2346. if (options.savedColors && options.savedColors.length == 0) {
  2347. setEditButtonVisibility(false);
  2348. editSwatchMode = false;
  2349. }
  2350. }
  2351. // Creates and styles an individual swatch when updateSwatches is called.
  2352. function createSwatch() {
  2353. if (options.savedColors && options.savedColors[swatchNumber]) {
  2354. if (editSwatchMode) {
  2355. var icon = "b";
  2356. }
  2357. else {
  2358. var icon = "";
  2359. }
  2360. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2361. swatch.fontFamily = "BabylonJSglyphs";
  2362. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2363. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2364. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2365. if (swatchLuminence > luminanceLimit) {
  2366. swatch.color = iconColorDark;
  2367. }
  2368. else {
  2369. swatch.color = iconColorLight;
  2370. }
  2371. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2372. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2373. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2374. swatch.background = options.savedColors[swatchNumber];
  2375. swatch.thickness = 2;
  2376. var metadata_1 = swatchNumber;
  2377. swatch.pointerDownAnimation = function () {
  2378. swatch.thickness = 4;
  2379. };
  2380. swatch.pointerUpAnimation = function () {
  2381. swatch.thickness = 3;
  2382. };
  2383. swatch.pointerEnterAnimation = function () {
  2384. swatch.thickness = 3;
  2385. };
  2386. swatch.pointerOutAnimation = function () {
  2387. swatch.thickness = 2;
  2388. };
  2389. swatch.onPointerClickObservable.add(function () {
  2390. if (!editSwatchMode) {
  2391. if (options.savedColors) {
  2392. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2393. }
  2394. }
  2395. else {
  2396. deleteSwatch(metadata_1);
  2397. updateSwatches("", butSave);
  2398. }
  2399. });
  2400. return swatch;
  2401. }
  2402. else {
  2403. return null;
  2404. }
  2405. }
  2406. // Mode switch to render button text and close symbols on swatch controls
  2407. function editSwatches(mode) {
  2408. if (mode !== undefined) {
  2409. editSwatchMode = mode;
  2410. }
  2411. if (editSwatchMode) {
  2412. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2413. var thisButton = swatchDrawer.children[i];
  2414. thisButton.textBlock.text = "b";
  2415. }
  2416. if (butEdit !== undefined) {
  2417. butEdit.textBlock.text = "Done";
  2418. }
  2419. }
  2420. else {
  2421. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2422. var thisButton = swatchDrawer.children[i];
  2423. thisButton.textBlock.text = "";
  2424. }
  2425. if (butEdit !== undefined) {
  2426. butEdit.textBlock.text = "Edit";
  2427. }
  2428. }
  2429. }
  2430. /**
  2431. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2432. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2433. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2434. * saved colors there are and how many can be stored per row.
  2435. */
  2436. function updateSwatches(color, button) {
  2437. if (options.savedColors) {
  2438. if (color != "") {
  2439. options.savedColors.push(color);
  2440. }
  2441. swatchNumber = 0;
  2442. swatchDrawer.clearControls();
  2443. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2444. if (rowCount == 0) {
  2445. var gutterCount = 0;
  2446. }
  2447. else {
  2448. var gutterCount = rowCount + 1;
  2449. }
  2450. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2451. var currentRows = swatchDrawer.rowCount;
  2452. for (var i = 0; i < currentRows; i++) {
  2453. swatchDrawer.removeRowDefinition(0);
  2454. }
  2455. for (var i = 0; i < rowCount + gutterCount; i++) {
  2456. if (i % 2) {
  2457. swatchDrawer.addRowDefinition(swatchSize, true);
  2458. }
  2459. else {
  2460. swatchDrawer.addRowDefinition(gutterSize, true);
  2461. }
  2462. }
  2463. }
  2464. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2465. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2466. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2467. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2468. var totalButtonsThisRow = options.numSwatchesPerLine;
  2469. }
  2470. else {
  2471. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2472. }
  2473. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2474. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2475. if (x > options.numSwatchesPerLine) {
  2476. continue;
  2477. }
  2478. var swatch = createSwatch();
  2479. if (swatch != null) {
  2480. swatchDrawer.addControl(swatch, y, w);
  2481. w += 2;
  2482. swatchNumber++;
  2483. }
  2484. else {
  2485. continue;
  2486. }
  2487. }
  2488. }
  2489. if (options.savedColors.length >= options.swatchLimit) {
  2490. disableButton(button, true);
  2491. }
  2492. else {
  2493. disableButton(button, false);
  2494. }
  2495. }
  2496. }
  2497. // Shows or hides edit swatches button depending on if there are saved swatches
  2498. function setEditButtonVisibility(enableButton) {
  2499. if (enableButton) {
  2500. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2501. butEdit.width = buttonWidth;
  2502. butEdit.height = buttonHeight;
  2503. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2504. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2505. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2506. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2507. butEdit.thickness = 2;
  2508. butEdit.color = buttonColor;
  2509. butEdit.fontSize = buttonFontSize;
  2510. butEdit.background = buttonBackgroundColor;
  2511. butEdit.onPointerEnterObservable.add(function () {
  2512. butEdit.background = buttonBackgroundHoverColor;
  2513. });
  2514. butEdit.onPointerOutObservable.add(function () {
  2515. butEdit.background = buttonBackgroundColor;
  2516. });
  2517. butEdit.pointerDownAnimation = function () {
  2518. butEdit.background = buttonBackgroundClickColor;
  2519. };
  2520. butEdit.pointerUpAnimation = function () {
  2521. butEdit.background = buttonBackgroundHoverColor;
  2522. };
  2523. butEdit.onPointerClickObservable.add(function () {
  2524. if (editSwatchMode) {
  2525. editSwatchMode = false;
  2526. }
  2527. else {
  2528. editSwatchMode = true;
  2529. }
  2530. editSwatches();
  2531. });
  2532. pickerGrid.addControl(butEdit, 1, 0);
  2533. }
  2534. else {
  2535. pickerGrid.removeControl(butEdit);
  2536. }
  2537. }
  2538. // Called when the user hits the limit of saved colors in the drawer.
  2539. function disableButton(button, disabled) {
  2540. if (disabled) {
  2541. button.color = buttonDisabledColor;
  2542. button.background = buttonDisabledBackgroundColor;
  2543. }
  2544. else {
  2545. button.color = buttonColor;
  2546. button.background = buttonBackgroundColor;
  2547. }
  2548. }
  2549. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2550. function closePicker(color) {
  2551. if (options.savedColors && options.savedColors.length > 0) {
  2552. resolve({
  2553. savedColors: options.savedColors,
  2554. pickedColor: color
  2555. });
  2556. }
  2557. else {
  2558. resolve({
  2559. pickedColor: color
  2560. });
  2561. }
  2562. advancedTexture.removeControl(dialogContainer);
  2563. }
  2564. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2565. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2566. dialogContainer.name = "Dialog Container";
  2567. dialogContainer.width = options.pickerWidth;
  2568. if (options.savedColors) {
  2569. dialogContainer.height = containerSize;
  2570. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2571. dialogContainer.addRowDefinition(topRow, false);
  2572. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2573. }
  2574. else {
  2575. dialogContainer.height = options.pickerHeight;
  2576. dialogContainer.addRowDefinition(1.0, false);
  2577. }
  2578. advancedTexture.addControl(dialogContainer);
  2579. // Swatch drawer which contains all saved color buttons
  2580. if (options.savedColors) {
  2581. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2582. swatchDrawer.name = "Swatch Drawer";
  2583. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2584. swatchDrawer.background = buttonBackgroundColor;
  2585. swatchDrawer.width = options.pickerWidth;
  2586. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2587. if (initialRows == 0) {
  2588. var gutterCount = 0;
  2589. }
  2590. else {
  2591. var gutterCount = initialRows + 1;
  2592. }
  2593. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2594. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2595. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2596. if (i % 2 != 0) {
  2597. swatchDrawer.addRowDefinition(swatchSize, true);
  2598. }
  2599. else {
  2600. swatchDrawer.addRowDefinition(gutterSize, true);
  2601. }
  2602. }
  2603. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2604. if (i % 2 != 0) {
  2605. swatchDrawer.addColumnDefinition(swatchSize, true);
  2606. }
  2607. else {
  2608. swatchDrawer.addColumnDefinition(gutterSize, true);
  2609. }
  2610. }
  2611. dialogContainer.addControl(swatchDrawer, 1, 0);
  2612. }
  2613. // Picker container
  2614. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2615. pickerPanel.name = "Picker Panel";
  2616. pickerPanel.height = options.pickerHeight;
  2617. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2618. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2619. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2620. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2621. dialogContainer.addControl(pickerPanel, 0, 0);
  2622. // Picker container header
  2623. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2624. header.name = "Dialogue Header Bar";
  2625. header.background = "#cccccc";
  2626. header.thickness = 0;
  2627. pickerPanel.addControl(header, 0, 0);
  2628. // Header close button
  2629. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2630. closeButton.fontFamily = "BabylonJSglyphs";
  2631. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2632. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2633. closeButton.color = closeIconColor.toHexString();
  2634. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2635. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2636. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2637. closeButton.height = closeButton.width = options.headerHeight;
  2638. closeButton.background = header.background;
  2639. closeButton.thickness = 0;
  2640. closeButton.pointerDownAnimation = function () {
  2641. };
  2642. closeButton.pointerUpAnimation = function () {
  2643. closeButton.background = header.background;
  2644. };
  2645. closeButton.pointerEnterAnimation = function () {
  2646. closeButton.color = header.background;
  2647. closeButton.background = "red";
  2648. };
  2649. closeButton.pointerOutAnimation = function () {
  2650. closeButton.color = closeIconColor.toHexString();
  2651. closeButton.background = header.background;
  2652. };
  2653. closeButton.onPointerClickObservable.add(function () {
  2654. closePicker(currentSwatch.background);
  2655. });
  2656. pickerPanel.addControl(closeButton, 0, 0);
  2657. // Dialog container body
  2658. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2659. dialogBody.name = "Dialogue Body";
  2660. dialogBody.background = buttonBackgroundColor;
  2661. var dialogBodyCols = [0.4375, 0.5625];
  2662. dialogBody.addRowDefinition(1.0, false);
  2663. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2664. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2665. pickerPanel.addControl(dialogBody, 1, 0);
  2666. // Picker grid
  2667. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2668. pickerGrid.name = "Picker Grid";
  2669. pickerGrid.addRowDefinition(0.85, false);
  2670. pickerGrid.addRowDefinition(0.15, false);
  2671. dialogBody.addControl(pickerGrid, 0, 0);
  2672. // Picker control
  2673. picker = new ColorPicker();
  2674. picker.name = "GUI Color Picker";
  2675. if (options.pickerHeight < options.pickerWidth) {
  2676. picker.width = 0.89;
  2677. }
  2678. else {
  2679. picker.height = 0.89;
  2680. }
  2681. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2682. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2683. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2684. picker.onPointerDownObservable.add(function () {
  2685. activeField = picker.name;
  2686. lastVal = "";
  2687. editSwatches(false);
  2688. });
  2689. picker.onValueChangedObservable.add(function (value) {
  2690. if (activeField == picker.name) {
  2691. updateValues(value, picker.name);
  2692. }
  2693. });
  2694. pickerGrid.addControl(picker, 0, 0);
  2695. // Picker body right quarant
  2696. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2697. pickerBodyRight.name = "Dialogue Right Half";
  2698. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2699. var pickerBodyRightRows = [0.514, 0.486];
  2700. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2701. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2702. dialogBody.addControl(pickerBodyRight, 1, 1);
  2703. // Picker container swatches and buttons
  2704. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2705. pickerSwatchesButtons.name = "Swatches and Buttons";
  2706. var pickerButtonsCol = [0.417, 0.583];
  2707. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2708. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2709. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2710. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2711. // Picker Swatches quadrant
  2712. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2713. pickerSwatches.name = "New and Current Swatches";
  2714. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2715. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2716. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2717. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2718. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2719. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2720. // Active swatches
  2721. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2722. activeSwatches.name = "Active Swatches";
  2723. activeSwatches.width = 0.67;
  2724. activeSwatches.addRowDefinition(0.5, false);
  2725. activeSwatches.addRowDefinition(0.5, false);
  2726. pickerSwatches.addControl(activeSwatches, 2, 0);
  2727. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2728. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2729. if (options.pickerWidth > options.pickerHeight) {
  2730. var labelTextSize = labelHeight;
  2731. }
  2732. else {
  2733. var labelTextSize = labelWidth;
  2734. }
  2735. // New color swatch and previous color button
  2736. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2737. newText.text = "new";
  2738. newText.name = "New Color Label";
  2739. newText.color = buttonColor;
  2740. newText.fontSize = labelTextSize;
  2741. pickerSwatches.addControl(newText, 1, 0);
  2742. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2743. newSwatch.name = "New Color Swatch";
  2744. newSwatch.background = options.lastColor;
  2745. newSwatch.thickness = 0;
  2746. activeSwatches.addControl(newSwatch, 0, 0);
  2747. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2748. currentSwatch.background = options.lastColor;
  2749. currentSwatch.thickness = 0;
  2750. currentSwatch.onPointerClickObservable.add(function () {
  2751. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2752. updateValues(revertColor, currentSwatch.name);
  2753. editSwatches(false);
  2754. });
  2755. currentSwatch.pointerDownAnimation = function () { };
  2756. currentSwatch.pointerUpAnimation = function () { };
  2757. currentSwatch.pointerEnterAnimation = function () { };
  2758. currentSwatch.pointerOutAnimation = function () { };
  2759. activeSwatches.addControl(currentSwatch, 1, 0);
  2760. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2761. swatchOutline.name = "Swatch Outline";
  2762. swatchOutline.width = 0.67;
  2763. swatchOutline.thickness = 2;
  2764. swatchOutline.color = currentSwatchesOutlineColor;
  2765. swatchOutline.isHitTestVisible = false;
  2766. pickerSwatches.addControl(swatchOutline, 2, 0);
  2767. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2768. currentText.name = "Current Color Label";
  2769. currentText.text = "current";
  2770. currentText.color = buttonColor;
  2771. currentText.fontSize = labelTextSize;
  2772. pickerSwatches.addControl(currentText, 3, 0);
  2773. // Buttons grid
  2774. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2775. buttonGrid.name = "Button Grid";
  2776. buttonGrid.height = 0.8;
  2777. var buttonGridRows = 1 / 3;
  2778. buttonGrid.addRowDefinition(buttonGridRows, false);
  2779. buttonGrid.addRowDefinition(buttonGridRows, false);
  2780. buttonGrid.addRowDefinition(buttonGridRows, false);
  2781. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2782. // Determine pixel width and height for all buttons from overall panel dimensions
  2783. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2784. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2785. // Determine button type size
  2786. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2787. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2788. }
  2789. else {
  2790. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2791. }
  2792. // Panel Buttons
  2793. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2794. butOK.width = buttonWidth;
  2795. butOK.height = buttonHeight;
  2796. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2797. butOK.thickness = 2;
  2798. butOK.color = buttonColor;
  2799. butOK.fontSize = buttonFontSize;
  2800. butOK.background = buttonBackgroundColor;
  2801. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2802. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2803. butOK.pointerDownAnimation = function () {
  2804. butOK.background = buttonBackgroundClickColor;
  2805. };
  2806. butOK.pointerUpAnimation = function () {
  2807. butOK.background = buttonBackgroundHoverColor;
  2808. };
  2809. butOK.onPointerClickObservable.add(function () {
  2810. editSwatches(false);
  2811. closePicker(newSwatch.background);
  2812. });
  2813. buttonGrid.addControl(butOK, 0, 0);
  2814. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2815. butCancel.width = buttonWidth;
  2816. butCancel.height = buttonHeight;
  2817. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2818. butCancel.thickness = 2;
  2819. butCancel.color = buttonColor;
  2820. butCancel.fontSize = buttonFontSize;
  2821. butCancel.background = buttonBackgroundColor;
  2822. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2823. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2824. butCancel.pointerDownAnimation = function () {
  2825. butCancel.background = buttonBackgroundClickColor;
  2826. };
  2827. butCancel.pointerUpAnimation = function () {
  2828. butCancel.background = buttonBackgroundHoverColor;
  2829. };
  2830. butCancel.onPointerClickObservable.add(function () {
  2831. editSwatches(false);
  2832. closePicker(currentSwatch.background);
  2833. });
  2834. buttonGrid.addControl(butCancel, 1, 0);
  2835. if (options.savedColors) {
  2836. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2837. butSave.width = buttonWidth;
  2838. butSave.height = buttonHeight;
  2839. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2840. butSave.thickness = 2;
  2841. butSave.fontSize = buttonFontSize;
  2842. if (options.savedColors.length < options.swatchLimit) {
  2843. butSave.color = buttonColor;
  2844. butSave.background = buttonBackgroundColor;
  2845. }
  2846. else {
  2847. disableButton(butSave, true);
  2848. }
  2849. butSave.onPointerEnterObservable.add(function () {
  2850. if (options.savedColors) {
  2851. if (options.savedColors.length < options.swatchLimit) {
  2852. butSave.background = buttonBackgroundHoverColor;
  2853. }
  2854. }
  2855. });
  2856. butSave.onPointerOutObservable.add(function () {
  2857. if (options.savedColors) {
  2858. if (options.savedColors.length < options.swatchLimit) {
  2859. butSave.background = buttonBackgroundColor;
  2860. }
  2861. }
  2862. });
  2863. butSave.pointerDownAnimation = function () {
  2864. if (options.savedColors) {
  2865. if (options.savedColors.length < options.swatchLimit) {
  2866. butSave.background = buttonBackgroundClickColor;
  2867. }
  2868. }
  2869. };
  2870. butSave.pointerUpAnimation = function () {
  2871. if (options.savedColors) {
  2872. if (options.savedColors.length < options.swatchLimit) {
  2873. butSave.background = buttonBackgroundHoverColor;
  2874. }
  2875. }
  2876. };
  2877. butSave.onPointerClickObservable.add(function () {
  2878. if (options.savedColors) {
  2879. if (options.savedColors.length == 0) {
  2880. setEditButtonVisibility(true);
  2881. }
  2882. if (options.savedColors.length < options.swatchLimit) {
  2883. updateSwatches(newSwatch.background, butSave);
  2884. }
  2885. editSwatches(false);
  2886. }
  2887. });
  2888. if (options.savedColors.length > 0) {
  2889. setEditButtonVisibility(true);
  2890. }
  2891. buttonGrid.addControl(butSave, 2, 0);
  2892. }
  2893. // Picker color values input
  2894. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2895. pickerColorValues.name = "Dialog Lower Right";
  2896. pickerColorValues.addRowDefinition(0.02, false);
  2897. pickerColorValues.addRowDefinition(0.63, false);
  2898. pickerColorValues.addRowDefinition(0.21, false);
  2899. pickerColorValues.addRowDefinition(0.14, false);
  2900. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2901. // RGB values text boxes
  2902. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2903. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2904. rgbValuesQuadrant.name = "RGB Values";
  2905. rgbValuesQuadrant.width = 0.82;
  2906. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2907. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2908. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2909. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2910. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2911. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2912. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2913. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2914. for (var i = 0; i < inputFieldLabels.length; i++) {
  2915. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2916. labelText.text = inputFieldLabels[i];
  2917. labelText.color = buttonColor;
  2918. labelText.fontSize = buttonFontSize;
  2919. rgbValuesQuadrant.addControl(labelText, i, 0);
  2920. }
  2921. // Input fields for RGB values
  2922. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2923. rValInt.width = 0.83;
  2924. rValInt.height = 0.72;
  2925. rValInt.name = "rIntField";
  2926. rValInt.fontSize = buttonFontSize;
  2927. rValInt.text = (currentColor.r * 255).toString();
  2928. rValInt.color = inputTextColor;
  2929. rValInt.background = inputTextBackgroundColor;
  2930. rValInt.onFocusObservable.add(function () {
  2931. activeField = rValInt.name;
  2932. lastVal = rValInt.text;
  2933. editSwatches(false);
  2934. });
  2935. rValInt.onBlurObservable.add(function () {
  2936. if (rValInt.text == "") {
  2937. rValInt.text = "0";
  2938. }
  2939. updateInt(rValInt, "r");
  2940. if (activeField == rValInt.name) {
  2941. activeField = "";
  2942. }
  2943. });
  2944. rValInt.onTextChangedObservable.add(function () {
  2945. if (activeField == rValInt.name) {
  2946. updateInt(rValInt, "r");
  2947. }
  2948. });
  2949. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2950. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2951. gValInt.width = 0.83;
  2952. gValInt.height = 0.72;
  2953. gValInt.name = "gIntField";
  2954. gValInt.fontSize = buttonFontSize;
  2955. gValInt.text = (currentColor.g * 255).toString();
  2956. gValInt.color = inputTextColor;
  2957. gValInt.background = inputTextBackgroundColor;
  2958. gValInt.onFocusObservable.add(function () {
  2959. activeField = gValInt.name;
  2960. lastVal = gValInt.text;
  2961. editSwatches(false);
  2962. });
  2963. gValInt.onBlurObservable.add(function () {
  2964. if (gValInt.text == "") {
  2965. gValInt.text = "0";
  2966. }
  2967. updateInt(gValInt, "g");
  2968. if (activeField == gValInt.name) {
  2969. activeField = "";
  2970. }
  2971. });
  2972. gValInt.onTextChangedObservable.add(function () {
  2973. if (activeField == gValInt.name) {
  2974. updateInt(gValInt, "g");
  2975. }
  2976. });
  2977. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2978. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2979. bValInt.width = 0.83;
  2980. bValInt.height = 0.72;
  2981. bValInt.name = "bIntField";
  2982. bValInt.fontSize = buttonFontSize;
  2983. bValInt.text = (currentColor.b * 255).toString();
  2984. bValInt.color = inputTextColor;
  2985. bValInt.background = inputTextBackgroundColor;
  2986. bValInt.onFocusObservable.add(function () {
  2987. activeField = bValInt.name;
  2988. lastVal = bValInt.text;
  2989. editSwatches(false);
  2990. });
  2991. bValInt.onBlurObservable.add(function () {
  2992. if (bValInt.text == "") {
  2993. bValInt.text = "0";
  2994. }
  2995. updateInt(bValInt, "b");
  2996. if (activeField == bValInt.name) {
  2997. activeField = "";
  2998. }
  2999. });
  3000. bValInt.onTextChangedObservable.add(function () {
  3001. if (activeField == bValInt.name) {
  3002. updateInt(bValInt, "b");
  3003. }
  3004. });
  3005. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  3006. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3007. rValDec.width = 0.95;
  3008. rValDec.height = 0.72;
  3009. rValDec.name = "rDecField";
  3010. rValDec.fontSize = buttonFontSize;
  3011. rValDec.text = currentColor.r.toString();
  3012. rValDec.color = inputTextColor;
  3013. rValDec.background = inputTextBackgroundColor;
  3014. rValDec.onFocusObservable.add(function () {
  3015. activeField = rValDec.name;
  3016. lastVal = rValDec.text;
  3017. editSwatches(false);
  3018. });
  3019. rValDec.onBlurObservable.add(function () {
  3020. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3021. rValDec.text = "0";
  3022. updateFloat(rValDec, "r");
  3023. }
  3024. if (activeField == rValDec.name) {
  3025. activeField = "";
  3026. }
  3027. });
  3028. rValDec.onTextChangedObservable.add(function () {
  3029. if (activeField == rValDec.name) {
  3030. updateFloat(rValDec, "r");
  3031. }
  3032. });
  3033. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3034. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3035. gValDec.width = 0.95;
  3036. gValDec.height = 0.72;
  3037. gValDec.name = "gDecField";
  3038. gValDec.fontSize = buttonFontSize;
  3039. gValDec.text = currentColor.g.toString();
  3040. gValDec.color = inputTextColor;
  3041. gValDec.background = inputTextBackgroundColor;
  3042. gValDec.onFocusObservable.add(function () {
  3043. activeField = gValDec.name;
  3044. lastVal = gValDec.text;
  3045. editSwatches(false);
  3046. });
  3047. gValDec.onBlurObservable.add(function () {
  3048. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3049. gValDec.text = "0";
  3050. updateFloat(gValDec, "g");
  3051. }
  3052. if (activeField == gValDec.name) {
  3053. activeField = "";
  3054. }
  3055. });
  3056. gValDec.onTextChangedObservable.add(function () {
  3057. if (activeField == gValDec.name) {
  3058. updateFloat(gValDec, "g");
  3059. }
  3060. });
  3061. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3062. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3063. bValDec.width = 0.95;
  3064. bValDec.height = 0.72;
  3065. bValDec.name = "bDecField";
  3066. bValDec.fontSize = buttonFontSize;
  3067. bValDec.text = currentColor.b.toString();
  3068. bValDec.color = inputTextColor;
  3069. bValDec.background = inputTextBackgroundColor;
  3070. bValDec.onFocusObservable.add(function () {
  3071. activeField = bValDec.name;
  3072. lastVal = bValDec.text;
  3073. editSwatches(false);
  3074. });
  3075. bValDec.onBlurObservable.add(function () {
  3076. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3077. bValDec.text = "0";
  3078. updateFloat(bValDec, "b");
  3079. }
  3080. if (activeField == bValDec.name) {
  3081. activeField = "";
  3082. }
  3083. });
  3084. bValDec.onTextChangedObservable.add(function () {
  3085. if (activeField == bValDec.name) {
  3086. updateFloat(bValDec, "b");
  3087. }
  3088. });
  3089. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3090. // Hex value input
  3091. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3092. hexValueQuadrant.name = "Hex Value";
  3093. hexValueQuadrant.width = 0.82;
  3094. hexValueQuadrant.addRowDefinition(1.0, false);
  3095. hexValueQuadrant.addColumnDefinition(0.1, false);
  3096. hexValueQuadrant.addColumnDefinition(0.9, false);
  3097. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3098. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3099. labelText.text = "#";
  3100. labelText.color = buttonColor;
  3101. labelText.fontSize = buttonFontSize;
  3102. hexValueQuadrant.addControl(labelText, 0, 0);
  3103. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3104. hexVal.width = 0.96;
  3105. hexVal.height = 0.72;
  3106. hexVal.name = "hexField";
  3107. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3108. hexVal.fontSize = buttonFontSize;
  3109. var minusPound = options.lastColor.split("#");
  3110. hexVal.text = minusPound[1];
  3111. hexVal.color = inputTextColor;
  3112. hexVal.background = inputTextBackgroundColor;
  3113. hexVal.onFocusObservable.add(function () {
  3114. activeField = hexVal.name;
  3115. lastVal = hexVal.text;
  3116. editSwatches(false);
  3117. });
  3118. hexVal.onBlurObservable.add(function () {
  3119. if (hexVal.text.length == 3) {
  3120. var val = hexVal.text.split("");
  3121. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3122. }
  3123. if (hexVal.text == "") {
  3124. hexVal.text = "000000";
  3125. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3126. }
  3127. if (activeField == hexVal.name) {
  3128. activeField = "";
  3129. }
  3130. });
  3131. hexVal.onTextChangedObservable.add(function () {
  3132. var newHexValue = hexVal.text;
  3133. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3134. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3135. hexVal.text = lastVal;
  3136. }
  3137. else {
  3138. if (hexVal.text.length < 6) {
  3139. var leadingZero = 6 - hexVal.text.length;
  3140. for (var i = 0; i < leadingZero; i++) {
  3141. newHexValue = "0" + newHexValue;
  3142. }
  3143. }
  3144. if (hexVal.text.length == 3) {
  3145. var val = hexVal.text.split("");
  3146. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3147. }
  3148. newHexValue = "#" + newHexValue;
  3149. if (activeField == hexVal.name) {
  3150. lastVal = hexVal.text;
  3151. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3152. }
  3153. }
  3154. });
  3155. hexValueQuadrant.addControl(hexVal, 0, 1);
  3156. if (options.savedColors && options.savedColors.length > 0) {
  3157. updateSwatches("", butSave);
  3158. }
  3159. });
  3160. };
  3161. ColorPicker._Epsilon = 0.000001;
  3162. return ColorPicker;
  3163. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3164. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3165. /***/ }),
  3166. /***/ "./2D/controls/container.ts":
  3167. /*!**********************************!*\
  3168. !*** ./2D/controls/container.ts ***!
  3169. \**********************************/
  3170. /*! exports provided: Container */
  3171. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3172. "use strict";
  3173. __webpack_require__.r(__webpack_exports__);
  3174. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3175. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3176. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/perfCounter");
  3177. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3178. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3179. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3180. /**
  3181. * Root class for 2D containers
  3182. * @see http://doc.babylonjs.com/how_to/gui#containers
  3183. */
  3184. var Container = /** @class */ (function (_super) {
  3185. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3186. /**
  3187. * Creates a new Container
  3188. * @param name defines the name of the container
  3189. */
  3190. function Container(name) {
  3191. var _this = _super.call(this, name) || this;
  3192. _this.name = name;
  3193. /** @hidden */
  3194. _this._children = new Array();
  3195. /** @hidden */
  3196. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3197. /** @hidden */
  3198. _this._background = "";
  3199. /** @hidden */
  3200. _this._adaptWidthToChildren = false;
  3201. /** @hidden */
  3202. _this._adaptHeightToChildren = false;
  3203. /**
  3204. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3205. */
  3206. _this.logLayoutCycleErrors = false;
  3207. /**
  3208. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3209. */
  3210. _this.maxLayoutCycle = 3;
  3211. return _this;
  3212. }
  3213. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3214. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3215. get: function () {
  3216. return this._adaptHeightToChildren;
  3217. },
  3218. set: function (value) {
  3219. if (this._adaptHeightToChildren === value) {
  3220. return;
  3221. }
  3222. this._adaptHeightToChildren = value;
  3223. if (value) {
  3224. this.height = "100%";
  3225. }
  3226. this._markAsDirty();
  3227. },
  3228. enumerable: true,
  3229. configurable: true
  3230. });
  3231. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3232. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3233. get: function () {
  3234. return this._adaptWidthToChildren;
  3235. },
  3236. set: function (value) {
  3237. if (this._adaptWidthToChildren === value) {
  3238. return;
  3239. }
  3240. this._adaptWidthToChildren = value;
  3241. if (value) {
  3242. this.width = "100%";
  3243. }
  3244. this._markAsDirty();
  3245. },
  3246. enumerable: true,
  3247. configurable: true
  3248. });
  3249. Object.defineProperty(Container.prototype, "background", {
  3250. /** Gets or sets background color */
  3251. get: function () {
  3252. return this._background;
  3253. },
  3254. set: function (value) {
  3255. if (this._background === value) {
  3256. return;
  3257. }
  3258. this._background = value;
  3259. this._markAsDirty();
  3260. },
  3261. enumerable: true,
  3262. configurable: true
  3263. });
  3264. Object.defineProperty(Container.prototype, "children", {
  3265. /** Gets the list of children */
  3266. get: function () {
  3267. return this._children;
  3268. },
  3269. enumerable: true,
  3270. configurable: true
  3271. });
  3272. Container.prototype._getTypeName = function () {
  3273. return "Container";
  3274. };
  3275. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3276. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3277. var child = _a[_i];
  3278. child._markMatrixAsDirty();
  3279. }
  3280. };
  3281. /**
  3282. * Gets a child using its name
  3283. * @param name defines the child name to look for
  3284. * @returns the child control if found
  3285. */
  3286. Container.prototype.getChildByName = function (name) {
  3287. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3288. var child = _a[_i];
  3289. if (child.name === name) {
  3290. return child;
  3291. }
  3292. }
  3293. return null;
  3294. };
  3295. /**
  3296. * Gets a child using its type and its name
  3297. * @param name defines the child name to look for
  3298. * @param type defines the child type to look for
  3299. * @returns the child control if found
  3300. */
  3301. Container.prototype.getChildByType = function (name, type) {
  3302. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3303. var child = _a[_i];
  3304. if (child.typeName === type) {
  3305. return child;
  3306. }
  3307. }
  3308. return null;
  3309. };
  3310. /**
  3311. * Search for a specific control in children
  3312. * @param control defines the control to look for
  3313. * @returns true if the control is in child list
  3314. */
  3315. Container.prototype.containsControl = function (control) {
  3316. return this.children.indexOf(control) !== -1;
  3317. };
  3318. /**
  3319. * Adds a new control to the current container
  3320. * @param control defines the control to add
  3321. * @returns the current container
  3322. */
  3323. Container.prototype.addControl = function (control) {
  3324. if (!control) {
  3325. return this;
  3326. }
  3327. var index = this._children.indexOf(control);
  3328. if (index !== -1) {
  3329. return this;
  3330. }
  3331. control._link(this._host);
  3332. control._markAllAsDirty();
  3333. this._reOrderControl(control);
  3334. this._markAsDirty();
  3335. return this;
  3336. };
  3337. /**
  3338. * Removes all controls from the current container
  3339. * @returns the current container
  3340. */
  3341. Container.prototype.clearControls = function () {
  3342. var children = this.children.slice();
  3343. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3344. var child = children_1[_i];
  3345. this.removeControl(child);
  3346. }
  3347. return this;
  3348. };
  3349. /**
  3350. * Removes a control from the current container
  3351. * @param control defines the control to remove
  3352. * @returns the current container
  3353. */
  3354. Container.prototype.removeControl = function (control) {
  3355. var index = this._children.indexOf(control);
  3356. if (index !== -1) {
  3357. this._children.splice(index, 1);
  3358. control.parent = null;
  3359. }
  3360. control.linkWithMesh(null);
  3361. if (this._host) {
  3362. this._host._cleanControlAfterRemoval(control);
  3363. }
  3364. this._markAsDirty();
  3365. return this;
  3366. };
  3367. /** @hidden */
  3368. Container.prototype._reOrderControl = function (control) {
  3369. this.removeControl(control);
  3370. var wasAdded = false;
  3371. for (var index = 0; index < this._children.length; index++) {
  3372. if (this._children[index].zIndex > control.zIndex) {
  3373. this._children.splice(index, 0, control);
  3374. wasAdded = true;
  3375. break;
  3376. }
  3377. }
  3378. if (!wasAdded) {
  3379. this._children.push(control);
  3380. }
  3381. control.parent = this;
  3382. this._markAsDirty();
  3383. };
  3384. /** @hidden */
  3385. Container.prototype._offsetLeft = function (offset) {
  3386. _super.prototype._offsetLeft.call(this, offset);
  3387. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3388. var child = _a[_i];
  3389. child._offsetLeft(offset);
  3390. }
  3391. };
  3392. /** @hidden */
  3393. Container.prototype._offsetTop = function (offset) {
  3394. _super.prototype._offsetTop.call(this, offset);
  3395. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3396. var child = _a[_i];
  3397. child._offsetTop(offset);
  3398. }
  3399. };
  3400. /** @hidden */
  3401. Container.prototype._markAllAsDirty = function () {
  3402. _super.prototype._markAllAsDirty.call(this);
  3403. for (var index = 0; index < this._children.length; index++) {
  3404. this._children[index]._markAllAsDirty();
  3405. }
  3406. };
  3407. /** @hidden */
  3408. Container.prototype._localDraw = function (context) {
  3409. if (this._background) {
  3410. context.save();
  3411. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3412. context.shadowColor = this.shadowColor;
  3413. context.shadowBlur = this.shadowBlur;
  3414. context.shadowOffsetX = this.shadowOffsetX;
  3415. context.shadowOffsetY = this.shadowOffsetY;
  3416. }
  3417. context.fillStyle = this._background;
  3418. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3419. context.restore();
  3420. }
  3421. };
  3422. /** @hidden */
  3423. Container.prototype._link = function (host) {
  3424. _super.prototype._link.call(this, host);
  3425. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3426. var child = _a[_i];
  3427. child._link(host);
  3428. }
  3429. };
  3430. /** @hidden */
  3431. Container.prototype._beforeLayout = function () {
  3432. // Do nothing
  3433. };
  3434. /** @hidden */
  3435. Container.prototype._processMeasures = function (parentMeasure, context) {
  3436. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3437. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3438. this._evaluateClippingState(parentMeasure);
  3439. }
  3440. };
  3441. /** @hidden */
  3442. Container.prototype._layout = function (parentMeasure, context) {
  3443. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3444. return false;
  3445. }
  3446. this.host._numLayoutCalls++;
  3447. if (this._isDirty) {
  3448. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3449. }
  3450. var rebuildCount = 0;
  3451. context.save();
  3452. this._applyStates(context);
  3453. this._beforeLayout();
  3454. do {
  3455. var computedWidth = -1;
  3456. var computedHeight = -1;
  3457. this._rebuildLayout = false;
  3458. this._processMeasures(parentMeasure, context);
  3459. if (!this._isClipped) {
  3460. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3461. var child = _a[_i];
  3462. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3463. if (child._layout(this._measureForChildren, context)) {
  3464. if (this.adaptWidthToChildren && child._width.isPixel) {
  3465. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3466. }
  3467. if (this.adaptHeightToChildren && child._height.isPixel) {
  3468. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3469. }
  3470. }
  3471. }
  3472. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3473. if (this.width !== computedWidth + "px") {
  3474. this.width = computedWidth + "px";
  3475. this._rebuildLayout = true;
  3476. }
  3477. }
  3478. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3479. if (this.height !== computedHeight + "px") {
  3480. this.height = computedHeight + "px";
  3481. this._rebuildLayout = true;
  3482. }
  3483. }
  3484. this._postMeasure();
  3485. }
  3486. rebuildCount++;
  3487. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3488. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3489. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3490. }
  3491. context.restore();
  3492. if (this._isDirty) {
  3493. this.invalidateRect();
  3494. this._isDirty = false;
  3495. }
  3496. return true;
  3497. };
  3498. Container.prototype._postMeasure = function () {
  3499. // Do nothing by default
  3500. };
  3501. /** @hidden */
  3502. Container.prototype._draw = function (context, invalidatedRectangle) {
  3503. this._localDraw(context);
  3504. if (this.clipChildren) {
  3505. this._clipForChildren(context);
  3506. }
  3507. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3508. var child = _a[_i];
  3509. // Only redraw parts of the screen that are invalidated
  3510. if (invalidatedRectangle) {
  3511. if (!child._intersectsRect(invalidatedRectangle)) {
  3512. continue;
  3513. }
  3514. }
  3515. child._render(context, invalidatedRectangle);
  3516. }
  3517. };
  3518. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3519. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3520. if (!this.children) {
  3521. return;
  3522. }
  3523. for (var index = 0; index < this.children.length; index++) {
  3524. var item = this.children[index];
  3525. if (!predicate || predicate(item)) {
  3526. results.push(item);
  3527. }
  3528. if (!directDescendantsOnly) {
  3529. item.getDescendantsToRef(results, false, predicate);
  3530. }
  3531. }
  3532. };
  3533. /** @hidden */
  3534. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3535. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3536. return false;
  3537. }
  3538. if (!_super.prototype.contains.call(this, x, y)) {
  3539. return false;
  3540. }
  3541. // Checking backwards to pick closest first
  3542. for (var index = this._children.length - 1; index >= 0; index--) {
  3543. var child = this._children[index];
  3544. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3545. if (child.hoverCursor) {
  3546. this._host._changeCursor(child.hoverCursor);
  3547. }
  3548. return true;
  3549. }
  3550. }
  3551. if (!this.isHitTestVisible) {
  3552. return false;
  3553. }
  3554. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3555. };
  3556. /** @hidden */
  3557. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3558. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3559. this._measureForChildren.copyFrom(this._currentMeasure);
  3560. };
  3561. /** Releases associated resources */
  3562. Container.prototype.dispose = function () {
  3563. _super.prototype.dispose.call(this);
  3564. for (var index = this.children.length - 1; index >= 0; index--) {
  3565. this.children[index].dispose();
  3566. }
  3567. };
  3568. return Container;
  3569. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3570. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3571. /***/ }),
  3572. /***/ "./2D/controls/control.ts":
  3573. /*!********************************!*\
  3574. !*** ./2D/controls/control.ts ***!
  3575. \********************************/
  3576. /*! exports provided: Control */
  3577. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3578. "use strict";
  3579. __webpack_require__.r(__webpack_exports__);
  3580. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3581. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  3582. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3583. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3584. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3585. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3586. /**
  3587. * Root class used for all 2D controls
  3588. * @see http://doc.babylonjs.com/how_to/gui#controls
  3589. */
  3590. var Control = /** @class */ (function () {
  3591. // Functions
  3592. /**
  3593. * Creates a new control
  3594. * @param name defines the name of the control
  3595. */
  3596. function Control(
  3597. /** defines the name of the control */
  3598. name) {
  3599. this.name = name;
  3600. this._alpha = 1;
  3601. this._alphaSet = false;
  3602. this._zIndex = 0;
  3603. /** @hidden */
  3604. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3605. this._fontFamily = "Arial";
  3606. this._fontStyle = "";
  3607. this._fontWeight = "";
  3608. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3609. /** @hidden */
  3610. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3611. /** @hidden */
  3612. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3613. this._color = "";
  3614. this._style = null;
  3615. /** @hidden */
  3616. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3617. /** @hidden */
  3618. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3619. /** @hidden */
  3620. this._isDirty = true;
  3621. /** @hidden */
  3622. this._wasDirty = false;
  3623. /** @hidden */
  3624. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3625. /** @hidden */
  3626. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3627. /** @hidden */
  3628. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3629. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3630. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3631. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3632. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3633. /** @hidden */
  3634. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3635. /** @hidden */
  3636. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3637. this._scaleX = 1.0;
  3638. this._scaleY = 1.0;
  3639. this._rotation = 0;
  3640. this._transformCenterX = 0.5;
  3641. this._transformCenterY = 0.5;
  3642. /** @hidden */
  3643. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3644. /** @hidden */
  3645. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3646. /** @hidden */
  3647. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3648. this._isMatrixDirty = true;
  3649. this._isVisible = true;
  3650. this._isHighlighted = false;
  3651. this._fontSet = false;
  3652. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3653. this._downCount = 0;
  3654. this._enterCount = -1;
  3655. this._doNotRender = false;
  3656. this._downPointerIds = {};
  3657. this._isEnabled = true;
  3658. this._disabledColor = "#9a9a9a";
  3659. /** @hidden */
  3660. this._rebuildLayout = false;
  3661. /** @hidden */
  3662. this._customData = {};
  3663. /** @hidden */
  3664. this._isClipped = false;
  3665. /** @hidden */
  3666. this._automaticSize = false;
  3667. /**
  3668. * Gets or sets an object used to store user defined information for the node
  3669. */
  3670. this.metadata = null;
  3671. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3672. this.isHitTestVisible = true;
  3673. /** Gets or sets a boolean indicating if the control can block pointer events */
  3674. this.isPointerBlocker = false;
  3675. /** Gets or sets a boolean indicating if the control can be focusable */
  3676. this.isFocusInvisible = false;
  3677. /**
  3678. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3679. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  3680. */
  3681. this.clipChildren = true;
  3682. /**
  3683. * Gets or sets a boolean indicating that control content must be clipped
  3684. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  3685. */
  3686. this.clipContent = true;
  3687. /**
  3688. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3689. */
  3690. this.useBitmapCache = false;
  3691. this._shadowOffsetX = 0;
  3692. this._shadowOffsetY = 0;
  3693. this._shadowBlur = 0;
  3694. this._shadowColor = 'black';
  3695. /** Gets or sets the cursor to use when the control is hovered */
  3696. this.hoverCursor = "";
  3697. /** @hidden */
  3698. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3699. /** @hidden */
  3700. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3701. /**
  3702. * An event triggered when the pointer move over the control.
  3703. */
  3704. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3705. /**
  3706. * An event triggered when the pointer move out of the control.
  3707. */
  3708. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3709. /**
  3710. * An event triggered when the pointer taps the control
  3711. */
  3712. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3713. /**
  3714. * An event triggered when pointer up
  3715. */
  3716. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3717. /**
  3718. * An event triggered when a control is clicked on
  3719. */
  3720. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3721. /**
  3722. * An event triggered when pointer enters the control
  3723. */
  3724. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3725. /**
  3726. * An event triggered when the control is marked as dirty
  3727. */
  3728. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3729. /**
  3730. * An event triggered before drawing the control
  3731. */
  3732. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3733. /**
  3734. * An event triggered after the control was drawn
  3735. */
  3736. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3737. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3738. }
  3739. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3740. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3741. get: function () {
  3742. return this._shadowOffsetX;
  3743. },
  3744. set: function (value) {
  3745. if (this._shadowOffsetX === value) {
  3746. return;
  3747. }
  3748. this._shadowOffsetX = value;
  3749. this._markAsDirty();
  3750. },
  3751. enumerable: true,
  3752. configurable: true
  3753. });
  3754. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3755. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3756. get: function () {
  3757. return this._shadowOffsetY;
  3758. },
  3759. set: function (value) {
  3760. if (this._shadowOffsetY === value) {
  3761. return;
  3762. }
  3763. this._shadowOffsetY = value;
  3764. this._markAsDirty();
  3765. },
  3766. enumerable: true,
  3767. configurable: true
  3768. });
  3769. Object.defineProperty(Control.prototype, "shadowBlur", {
  3770. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3771. get: function () {
  3772. return this._shadowBlur;
  3773. },
  3774. set: function (value) {
  3775. if (this._shadowBlur === value) {
  3776. return;
  3777. }
  3778. this._shadowBlur = value;
  3779. this._markAsDirty();
  3780. },
  3781. enumerable: true,
  3782. configurable: true
  3783. });
  3784. Object.defineProperty(Control.prototype, "shadowColor", {
  3785. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3786. get: function () {
  3787. return this._shadowColor;
  3788. },
  3789. set: function (value) {
  3790. if (this._shadowColor === value) {
  3791. return;
  3792. }
  3793. this._shadowColor = value;
  3794. this._markAsDirty();
  3795. },
  3796. enumerable: true,
  3797. configurable: true
  3798. });
  3799. Object.defineProperty(Control.prototype, "typeName", {
  3800. // Properties
  3801. /** Gets the control type name */
  3802. get: function () {
  3803. return this._getTypeName();
  3804. },
  3805. enumerable: true,
  3806. configurable: true
  3807. });
  3808. /**
  3809. * Get the current class name of the control.
  3810. * @returns current class name
  3811. */
  3812. Control.prototype.getClassName = function () {
  3813. return this._getTypeName();
  3814. };
  3815. Object.defineProperty(Control.prototype, "host", {
  3816. /**
  3817. * Get the hosting AdvancedDynamicTexture
  3818. */
  3819. get: function () {
  3820. return this._host;
  3821. },
  3822. enumerable: true,
  3823. configurable: true
  3824. });
  3825. Object.defineProperty(Control.prototype, "fontOffset", {
  3826. /** Gets or set information about font offsets (used to render and align text) */
  3827. get: function () {
  3828. return this._fontOffset;
  3829. },
  3830. set: function (offset) {
  3831. this._fontOffset = offset;
  3832. },
  3833. enumerable: true,
  3834. configurable: true
  3835. });
  3836. Object.defineProperty(Control.prototype, "alpha", {
  3837. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3838. get: function () {
  3839. return this._alpha;
  3840. },
  3841. set: function (value) {
  3842. if (this._alpha === value) {
  3843. return;
  3844. }
  3845. this._alphaSet = true;
  3846. this._alpha = value;
  3847. this._markAsDirty();
  3848. },
  3849. enumerable: true,
  3850. configurable: true
  3851. });
  3852. Object.defineProperty(Control.prototype, "isHighlighted", {
  3853. /**
  3854. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3855. */
  3856. get: function () {
  3857. return this._isHighlighted;
  3858. },
  3859. set: function (value) {
  3860. if (this._isHighlighted === value) {
  3861. return;
  3862. }
  3863. this._isHighlighted = value;
  3864. this._markAsDirty();
  3865. },
  3866. enumerable: true,
  3867. configurable: true
  3868. });
  3869. Object.defineProperty(Control.prototype, "scaleX", {
  3870. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3871. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3872. */
  3873. get: function () {
  3874. return this._scaleX;
  3875. },
  3876. set: function (value) {
  3877. if (this._scaleX === value) {
  3878. return;
  3879. }
  3880. this._scaleX = value;
  3881. this._markAsDirty();
  3882. this._markMatrixAsDirty();
  3883. },
  3884. enumerable: true,
  3885. configurable: true
  3886. });
  3887. Object.defineProperty(Control.prototype, "scaleY", {
  3888. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3889. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3890. */
  3891. get: function () {
  3892. return this._scaleY;
  3893. },
  3894. set: function (value) {
  3895. if (this._scaleY === value) {
  3896. return;
  3897. }
  3898. this._scaleY = value;
  3899. this._markAsDirty();
  3900. this._markMatrixAsDirty();
  3901. },
  3902. enumerable: true,
  3903. configurable: true
  3904. });
  3905. Object.defineProperty(Control.prototype, "rotation", {
  3906. /** Gets or sets the rotation angle (0 by default)
  3907. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3908. */
  3909. get: function () {
  3910. return this._rotation;
  3911. },
  3912. set: function (value) {
  3913. if (this._rotation === value) {
  3914. return;
  3915. }
  3916. this._rotation = value;
  3917. this._markAsDirty();
  3918. this._markMatrixAsDirty();
  3919. },
  3920. enumerable: true,
  3921. configurable: true
  3922. });
  3923. Object.defineProperty(Control.prototype, "transformCenterY", {
  3924. /** Gets or sets the transformation center on Y axis (0 by default)
  3925. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3926. */
  3927. get: function () {
  3928. return this._transformCenterY;
  3929. },
  3930. set: function (value) {
  3931. if (this._transformCenterY === value) {
  3932. return;
  3933. }
  3934. this._transformCenterY = value;
  3935. this._markAsDirty();
  3936. this._markMatrixAsDirty();
  3937. },
  3938. enumerable: true,
  3939. configurable: true
  3940. });
  3941. Object.defineProperty(Control.prototype, "transformCenterX", {
  3942. /** Gets or sets the transformation center on X axis (0 by default)
  3943. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3944. */
  3945. get: function () {
  3946. return this._transformCenterX;
  3947. },
  3948. set: function (value) {
  3949. if (this._transformCenterX === value) {
  3950. return;
  3951. }
  3952. this._transformCenterX = value;
  3953. this._markAsDirty();
  3954. this._markMatrixAsDirty();
  3955. },
  3956. enumerable: true,
  3957. configurable: true
  3958. });
  3959. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3960. /**
  3961. * Gets or sets the horizontal alignment
  3962. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3963. */
  3964. get: function () {
  3965. return this._horizontalAlignment;
  3966. },
  3967. set: function (value) {
  3968. if (this._horizontalAlignment === value) {
  3969. return;
  3970. }
  3971. this._horizontalAlignment = value;
  3972. this._markAsDirty();
  3973. },
  3974. enumerable: true,
  3975. configurable: true
  3976. });
  3977. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3978. /**
  3979. * Gets or sets the vertical alignment
  3980. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3981. */
  3982. get: function () {
  3983. return this._verticalAlignment;
  3984. },
  3985. set: function (value) {
  3986. if (this._verticalAlignment === value) {
  3987. return;
  3988. }
  3989. this._verticalAlignment = value;
  3990. this._markAsDirty();
  3991. },
  3992. enumerable: true,
  3993. configurable: true
  3994. });
  3995. Object.defineProperty(Control.prototype, "width", {
  3996. /**
  3997. * Gets or sets control width
  3998. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3999. */
  4000. get: function () {
  4001. return this._width.toString(this._host);
  4002. },
  4003. set: function (value) {
  4004. if (this._width.toString(this._host) === value) {
  4005. return;
  4006. }
  4007. if (this._width.fromString(value)) {
  4008. this._markAsDirty();
  4009. }
  4010. },
  4011. enumerable: true,
  4012. configurable: true
  4013. });
  4014. Object.defineProperty(Control.prototype, "widthInPixels", {
  4015. /**
  4016. * Gets or sets the control width in pixel
  4017. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4018. */
  4019. get: function () {
  4020. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4021. },
  4022. set: function (value) {
  4023. if (isNaN(value)) {
  4024. return;
  4025. }
  4026. this.width = value + "px";
  4027. },
  4028. enumerable: true,
  4029. configurable: true
  4030. });
  4031. Object.defineProperty(Control.prototype, "height", {
  4032. /**
  4033. * Gets or sets control height
  4034. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4035. */
  4036. get: function () {
  4037. return this._height.toString(this._host);
  4038. },
  4039. set: function (value) {
  4040. if (this._height.toString(this._host) === value) {
  4041. return;
  4042. }
  4043. if (this._height.fromString(value)) {
  4044. this._markAsDirty();
  4045. }
  4046. },
  4047. enumerable: true,
  4048. configurable: true
  4049. });
  4050. Object.defineProperty(Control.prototype, "heightInPixels", {
  4051. /**
  4052. * Gets or sets control height in pixel
  4053. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4054. */
  4055. get: function () {
  4056. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4057. },
  4058. set: function (value) {
  4059. if (isNaN(value)) {
  4060. return;
  4061. }
  4062. this.height = value + "px";
  4063. },
  4064. enumerable: true,
  4065. configurable: true
  4066. });
  4067. Object.defineProperty(Control.prototype, "fontFamily", {
  4068. /** Gets or set font family */
  4069. get: function () {
  4070. if (!this._fontSet) {
  4071. return "";
  4072. }
  4073. return this._fontFamily;
  4074. },
  4075. set: function (value) {
  4076. if (this._fontFamily === value) {
  4077. return;
  4078. }
  4079. this._fontFamily = value;
  4080. this._resetFontCache();
  4081. },
  4082. enumerable: true,
  4083. configurable: true
  4084. });
  4085. Object.defineProperty(Control.prototype, "fontStyle", {
  4086. /** Gets or sets font style */
  4087. get: function () {
  4088. return this._fontStyle;
  4089. },
  4090. set: function (value) {
  4091. if (this._fontStyle === value) {
  4092. return;
  4093. }
  4094. this._fontStyle = value;
  4095. this._resetFontCache();
  4096. },
  4097. enumerable: true,
  4098. configurable: true
  4099. });
  4100. Object.defineProperty(Control.prototype, "fontWeight", {
  4101. /** Gets or sets font weight */
  4102. get: function () {
  4103. return this._fontWeight;
  4104. },
  4105. set: function (value) {
  4106. if (this._fontWeight === value) {
  4107. return;
  4108. }
  4109. this._fontWeight = value;
  4110. this._resetFontCache();
  4111. },
  4112. enumerable: true,
  4113. configurable: true
  4114. });
  4115. Object.defineProperty(Control.prototype, "style", {
  4116. /**
  4117. * Gets or sets style
  4118. * @see http://doc.babylonjs.com/how_to/gui#styles
  4119. */
  4120. get: function () {
  4121. return this._style;
  4122. },
  4123. set: function (value) {
  4124. var _this = this;
  4125. if (this._style) {
  4126. this._style.onChangedObservable.remove(this._styleObserver);
  4127. this._styleObserver = null;
  4128. }
  4129. this._style = value;
  4130. if (this._style) {
  4131. this._styleObserver = this._style.onChangedObservable.add(function () {
  4132. _this._markAsDirty();
  4133. _this._resetFontCache();
  4134. });
  4135. }
  4136. this._markAsDirty();
  4137. this._resetFontCache();
  4138. },
  4139. enumerable: true,
  4140. configurable: true
  4141. });
  4142. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4143. /** @hidden */
  4144. get: function () {
  4145. return this._fontSize.isPercentage;
  4146. },
  4147. enumerable: true,
  4148. configurable: true
  4149. });
  4150. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4151. /** Gets or sets font size in pixels */
  4152. get: function () {
  4153. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4154. if (fontSizeToUse.isPixel) {
  4155. return fontSizeToUse.getValue(this._host);
  4156. }
  4157. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4158. },
  4159. set: function (value) {
  4160. if (isNaN(value)) {
  4161. return;
  4162. }
  4163. this.fontSize = value + "px";
  4164. },
  4165. enumerable: true,
  4166. configurable: true
  4167. });
  4168. Object.defineProperty(Control.prototype, "fontSize", {
  4169. /** Gets or sets font size */
  4170. get: function () {
  4171. return this._fontSize.toString(this._host);
  4172. },
  4173. set: function (value) {
  4174. if (this._fontSize.toString(this._host) === value) {
  4175. return;
  4176. }
  4177. if (this._fontSize.fromString(value)) {
  4178. this._markAsDirty();
  4179. this._resetFontCache();
  4180. }
  4181. },
  4182. enumerable: true,
  4183. configurable: true
  4184. });
  4185. Object.defineProperty(Control.prototype, "color", {
  4186. /** Gets or sets foreground color */
  4187. get: function () {
  4188. return this._color;
  4189. },
  4190. set: function (value) {
  4191. if (this._color === value) {
  4192. return;
  4193. }
  4194. this._color = value;
  4195. this._markAsDirty();
  4196. },
  4197. enumerable: true,
  4198. configurable: true
  4199. });
  4200. Object.defineProperty(Control.prototype, "zIndex", {
  4201. /** Gets or sets z index which is used to reorder controls on the z axis */
  4202. get: function () {
  4203. return this._zIndex;
  4204. },
  4205. set: function (value) {
  4206. if (this.zIndex === value) {
  4207. return;
  4208. }
  4209. this._zIndex = value;
  4210. if (this.parent) {
  4211. this.parent._reOrderControl(this);
  4212. }
  4213. },
  4214. enumerable: true,
  4215. configurable: true
  4216. });
  4217. Object.defineProperty(Control.prototype, "notRenderable", {
  4218. /** Gets or sets a boolean indicating if the control can be rendered */
  4219. get: function () {
  4220. return this._doNotRender;
  4221. },
  4222. set: function (value) {
  4223. if (this._doNotRender === value) {
  4224. return;
  4225. }
  4226. this._doNotRender = value;
  4227. this._markAsDirty();
  4228. },
  4229. enumerable: true,
  4230. configurable: true
  4231. });
  4232. Object.defineProperty(Control.prototype, "isVisible", {
  4233. /** Gets or sets a boolean indicating if the control is visible */
  4234. get: function () {
  4235. return this._isVisible;
  4236. },
  4237. set: function (value) {
  4238. if (this._isVisible === value) {
  4239. return;
  4240. }
  4241. this._isVisible = value;
  4242. this._markAsDirty(true);
  4243. },
  4244. enumerable: true,
  4245. configurable: true
  4246. });
  4247. Object.defineProperty(Control.prototype, "isDirty", {
  4248. /** Gets a boolean indicating that the control needs to update its rendering */
  4249. get: function () {
  4250. return this._isDirty;
  4251. },
  4252. enumerable: true,
  4253. configurable: true
  4254. });
  4255. Object.defineProperty(Control.prototype, "linkedMesh", {
  4256. /**
  4257. * Gets the current linked mesh (or null if none)
  4258. */
  4259. get: function () {
  4260. return this._linkedMesh;
  4261. },
  4262. enumerable: true,
  4263. configurable: true
  4264. });
  4265. Object.defineProperty(Control.prototype, "paddingLeft", {
  4266. /**
  4267. * Gets or sets a value indicating the padding to use on the left of the control
  4268. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4269. */
  4270. get: function () {
  4271. return this._paddingLeft.toString(this._host);
  4272. },
  4273. set: function (value) {
  4274. if (this._paddingLeft.fromString(value)) {
  4275. this._markAsDirty();
  4276. }
  4277. },
  4278. enumerable: true,
  4279. configurable: true
  4280. });
  4281. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4282. /**
  4283. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4284. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4285. */
  4286. get: function () {
  4287. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4288. },
  4289. set: function (value) {
  4290. if (isNaN(value)) {
  4291. return;
  4292. }
  4293. this.paddingLeft = value + "px";
  4294. },
  4295. enumerable: true,
  4296. configurable: true
  4297. });
  4298. Object.defineProperty(Control.prototype, "paddingRight", {
  4299. /**
  4300. * Gets or sets a value indicating the padding to use on the right of the control
  4301. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4302. */
  4303. get: function () {
  4304. return this._paddingRight.toString(this._host);
  4305. },
  4306. set: function (value) {
  4307. if (this._paddingRight.fromString(value)) {
  4308. this._markAsDirty();
  4309. }
  4310. },
  4311. enumerable: true,
  4312. configurable: true
  4313. });
  4314. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4315. /**
  4316. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4317. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4318. */
  4319. get: function () {
  4320. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4321. },
  4322. set: function (value) {
  4323. if (isNaN(value)) {
  4324. return;
  4325. }
  4326. this.paddingRight = value + "px";
  4327. },
  4328. enumerable: true,
  4329. configurable: true
  4330. });
  4331. Object.defineProperty(Control.prototype, "paddingTop", {
  4332. /**
  4333. * Gets or sets a value indicating the padding to use on the top of the control
  4334. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4335. */
  4336. get: function () {
  4337. return this._paddingTop.toString(this._host);
  4338. },
  4339. set: function (value) {
  4340. if (this._paddingTop.fromString(value)) {
  4341. this._markAsDirty();
  4342. }
  4343. },
  4344. enumerable: true,
  4345. configurable: true
  4346. });
  4347. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4348. /**
  4349. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4350. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4351. */
  4352. get: function () {
  4353. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4354. },
  4355. set: function (value) {
  4356. if (isNaN(value)) {
  4357. return;
  4358. }
  4359. this.paddingTop = value + "px";
  4360. },
  4361. enumerable: true,
  4362. configurable: true
  4363. });
  4364. Object.defineProperty(Control.prototype, "paddingBottom", {
  4365. /**
  4366. * Gets or sets a value indicating the padding to use on the bottom of the control
  4367. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4368. */
  4369. get: function () {
  4370. return this._paddingBottom.toString(this._host);
  4371. },
  4372. set: function (value) {
  4373. if (this._paddingBottom.fromString(value)) {
  4374. this._markAsDirty();
  4375. }
  4376. },
  4377. enumerable: true,
  4378. configurable: true
  4379. });
  4380. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4381. /**
  4382. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4383. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4384. */
  4385. get: function () {
  4386. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4387. },
  4388. set: function (value) {
  4389. if (isNaN(value)) {
  4390. return;
  4391. }
  4392. this.paddingBottom = value + "px";
  4393. },
  4394. enumerable: true,
  4395. configurable: true
  4396. });
  4397. Object.defineProperty(Control.prototype, "left", {
  4398. /**
  4399. * Gets or sets a value indicating the left coordinate of the control
  4400. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4401. */
  4402. get: function () {
  4403. return this._left.toString(this._host);
  4404. },
  4405. set: function (value) {
  4406. if (this._left.fromString(value)) {
  4407. this._markAsDirty();
  4408. }
  4409. },
  4410. enumerable: true,
  4411. configurable: true
  4412. });
  4413. Object.defineProperty(Control.prototype, "leftInPixels", {
  4414. /**
  4415. * Gets or sets a value indicating the left coordinate in pixels of the control
  4416. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4417. */
  4418. get: function () {
  4419. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4420. },
  4421. set: function (value) {
  4422. if (isNaN(value)) {
  4423. return;
  4424. }
  4425. this.left = value + "px";
  4426. },
  4427. enumerable: true,
  4428. configurable: true
  4429. });
  4430. Object.defineProperty(Control.prototype, "top", {
  4431. /**
  4432. * Gets or sets a value indicating the top coordinate of the control
  4433. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4434. */
  4435. get: function () {
  4436. return this._top.toString(this._host);
  4437. },
  4438. set: function (value) {
  4439. if (this._top.fromString(value)) {
  4440. this._markAsDirty();
  4441. }
  4442. },
  4443. enumerable: true,
  4444. configurable: true
  4445. });
  4446. Object.defineProperty(Control.prototype, "topInPixels", {
  4447. /**
  4448. * Gets or sets a value indicating the top coordinate in pixels of the control
  4449. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4450. */
  4451. get: function () {
  4452. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4453. },
  4454. set: function (value) {
  4455. if (isNaN(value)) {
  4456. return;
  4457. }
  4458. this.top = value + "px";
  4459. },
  4460. enumerable: true,
  4461. configurable: true
  4462. });
  4463. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4464. /**
  4465. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4466. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4467. */
  4468. get: function () {
  4469. return this._linkOffsetX.toString(this._host);
  4470. },
  4471. set: function (value) {
  4472. if (this._linkOffsetX.fromString(value)) {
  4473. this._markAsDirty();
  4474. }
  4475. },
  4476. enumerable: true,
  4477. configurable: true
  4478. });
  4479. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4480. /**
  4481. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4482. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4483. */
  4484. get: function () {
  4485. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4486. },
  4487. set: function (value) {
  4488. if (isNaN(value)) {
  4489. return;
  4490. }
  4491. this.linkOffsetX = value + "px";
  4492. },
  4493. enumerable: true,
  4494. configurable: true
  4495. });
  4496. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4497. /**
  4498. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4499. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4500. */
  4501. get: function () {
  4502. return this._linkOffsetY.toString(this._host);
  4503. },
  4504. set: function (value) {
  4505. if (this._linkOffsetY.fromString(value)) {
  4506. this._markAsDirty();
  4507. }
  4508. },
  4509. enumerable: true,
  4510. configurable: true
  4511. });
  4512. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4513. /**
  4514. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4515. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4516. */
  4517. get: function () {
  4518. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4519. },
  4520. set: function (value) {
  4521. if (isNaN(value)) {
  4522. return;
  4523. }
  4524. this.linkOffsetY = value + "px";
  4525. },
  4526. enumerable: true,
  4527. configurable: true
  4528. });
  4529. Object.defineProperty(Control.prototype, "centerX", {
  4530. /** Gets the center coordinate on X axis */
  4531. get: function () {
  4532. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4533. },
  4534. enumerable: true,
  4535. configurable: true
  4536. });
  4537. Object.defineProperty(Control.prototype, "centerY", {
  4538. /** Gets the center coordinate on Y axis */
  4539. get: function () {
  4540. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4541. },
  4542. enumerable: true,
  4543. configurable: true
  4544. });
  4545. Object.defineProperty(Control.prototype, "isEnabled", {
  4546. /** Gets or sets if control is Enabled*/
  4547. get: function () {
  4548. return this._isEnabled;
  4549. },
  4550. set: function (value) {
  4551. if (this._isEnabled === value) {
  4552. return;
  4553. }
  4554. this._isEnabled = value;
  4555. this._markAsDirty();
  4556. },
  4557. enumerable: true,
  4558. configurable: true
  4559. });
  4560. Object.defineProperty(Control.prototype, "disabledColor", {
  4561. /** Gets or sets background color of control if it's disabled*/
  4562. get: function () {
  4563. return this._disabledColor;
  4564. },
  4565. set: function (value) {
  4566. if (this._disabledColor === value) {
  4567. return;
  4568. }
  4569. this._disabledColor = value;
  4570. this._markAsDirty();
  4571. },
  4572. enumerable: true,
  4573. configurable: true
  4574. });
  4575. /** @hidden */
  4576. Control.prototype._getTypeName = function () {
  4577. return "Control";
  4578. };
  4579. /**
  4580. * Gets the first ascendant in the hierarchy of the given type
  4581. * @param className defines the required type
  4582. * @returns the ascendant or null if not found
  4583. */
  4584. Control.prototype.getAscendantOfClass = function (className) {
  4585. if (!this.parent) {
  4586. return null;
  4587. }
  4588. if (this.parent.getClassName() === className) {
  4589. return this.parent;
  4590. }
  4591. return this.parent.getAscendantOfClass(className);
  4592. };
  4593. /** @hidden */
  4594. Control.prototype._resetFontCache = function () {
  4595. this._fontSet = true;
  4596. this._markAsDirty();
  4597. };
  4598. /**
  4599. * Determines if a container is an ascendant of the current control
  4600. * @param container defines the container to look for
  4601. * @returns true if the container is one of the ascendant of the control
  4602. */
  4603. Control.prototype.isAscendant = function (container) {
  4604. if (!this.parent) {
  4605. return false;
  4606. }
  4607. if (this.parent === container) {
  4608. return true;
  4609. }
  4610. return this.parent.isAscendant(container);
  4611. };
  4612. /**
  4613. * Gets coordinates in local control space
  4614. * @param globalCoordinates defines the coordinates to transform
  4615. * @returns the new coordinates in local space
  4616. */
  4617. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4618. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4619. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4620. return result;
  4621. };
  4622. /**
  4623. * Gets coordinates in local control space
  4624. * @param globalCoordinates defines the coordinates to transform
  4625. * @param result defines the target vector2 where to store the result
  4626. * @returns the current control
  4627. */
  4628. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4629. result.x = globalCoordinates.x - this._currentMeasure.left;
  4630. result.y = globalCoordinates.y - this._currentMeasure.top;
  4631. return this;
  4632. };
  4633. /**
  4634. * Gets coordinates in parent local control space
  4635. * @param globalCoordinates defines the coordinates to transform
  4636. * @returns the new coordinates in parent local space
  4637. */
  4638. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4639. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4640. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4641. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4642. return result;
  4643. };
  4644. /**
  4645. * Move the current control to a vector3 position projected onto the screen.
  4646. * @param position defines the target position
  4647. * @param scene defines the hosting scene
  4648. */
  4649. Control.prototype.moveToVector3 = function (position, scene) {
  4650. if (!this._host || this.parent !== this._host._rootContainer) {
  4651. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4652. return;
  4653. }
  4654. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4655. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4656. var globalViewport = this._host._getGlobalViewport(scene);
  4657. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4658. this._moveToProjectedPosition(projectedPosition);
  4659. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4660. this.notRenderable = true;
  4661. return;
  4662. }
  4663. this.notRenderable = false;
  4664. };
  4665. /**
  4666. * Will store all controls that have this control as ascendant in a given array
  4667. * @param results defines the array where to store the descendants
  4668. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  4669. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  4670. */
  4671. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4672. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4673. // Do nothing by default
  4674. };
  4675. /**
  4676. * Will return all controls that have this control as ascendant
  4677. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  4678. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  4679. * @return all child controls
  4680. */
  4681. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4682. var results = new Array();
  4683. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4684. return results;
  4685. };
  4686. /**
  4687. * Link current control with a target mesh
  4688. * @param mesh defines the mesh to link with
  4689. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4690. */
  4691. Control.prototype.linkWithMesh = function (mesh) {
  4692. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4693. if (mesh) {
  4694. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4695. }
  4696. return;
  4697. }
  4698. var index = this._host._linkedControls.indexOf(this);
  4699. if (index !== -1) {
  4700. this._linkedMesh = mesh;
  4701. if (!mesh) {
  4702. this._host._linkedControls.splice(index, 1);
  4703. }
  4704. return;
  4705. }
  4706. else if (!mesh) {
  4707. return;
  4708. }
  4709. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4710. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4711. this._linkedMesh = mesh;
  4712. this._host._linkedControls.push(this);
  4713. };
  4714. /** @hidden */
  4715. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4716. var oldLeft = this._left.getValue(this._host);
  4717. var oldTop = this._top.getValue(this._host);
  4718. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4719. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4720. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4721. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4722. newLeft = oldLeft;
  4723. }
  4724. if (Math.abs(newTop - oldTop) < 0.5) {
  4725. newTop = oldTop;
  4726. }
  4727. }
  4728. this.left = newLeft + "px";
  4729. this.top = newTop + "px";
  4730. this._left.ignoreAdaptiveScaling = true;
  4731. this._top.ignoreAdaptiveScaling = true;
  4732. this._markAsDirty();
  4733. };
  4734. /** @hidden */
  4735. Control.prototype._offsetLeft = function (offset) {
  4736. this._isDirty = true;
  4737. this._currentMeasure.left += offset;
  4738. };
  4739. /** @hidden */
  4740. Control.prototype._offsetTop = function (offset) {
  4741. this._isDirty = true;
  4742. this._currentMeasure.top += offset;
  4743. };
  4744. /** @hidden */
  4745. Control.prototype._markMatrixAsDirty = function () {
  4746. this._isMatrixDirty = true;
  4747. this._flagDescendantsAsMatrixDirty();
  4748. };
  4749. /** @hidden */
  4750. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4751. // No child
  4752. };
  4753. /** @hidden */
  4754. Control.prototype._intersectsRect = function (rect) {
  4755. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4756. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4757. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4758. return false;
  4759. }
  4760. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4761. return false;
  4762. }
  4763. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4764. return false;
  4765. }
  4766. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4767. return false;
  4768. }
  4769. return true;
  4770. };
  4771. /** @hidden */
  4772. Control.prototype.invalidateRect = function () {
  4773. this._transform();
  4774. if (this.host && this.host.useInvalidateRectOptimization) {
  4775. // Rotate by transform to get the measure transformed to global space
  4776. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4777. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4778. // the previous measure is used to properly clear a control that is scaled down
  4779. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4780. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4781. // Expand rect based on shadows
  4782. var shadowOffsetX = this.shadowOffsetX;
  4783. var shadowOffsetY = this.shadowOffsetY;
  4784. var shadowBlur = this.shadowBlur;
  4785. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4786. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4787. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4788. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4789. this.host.invalidateRect(Math.floor(this._tmpMeasureA.left + leftShadowOffset), Math.floor(this._tmpMeasureA.top + topShadowOffset), Math.ceil(this._tmpMeasureA.left + this._tmpMeasureA.width + rightShadowOffset), Math.ceil(this._tmpMeasureA.top + this._tmpMeasureA.height + bottomShadowOffset));
  4790. }
  4791. else {
  4792. this.host.invalidateRect(Math.floor(this._tmpMeasureA.left), Math.floor(this._tmpMeasureA.top), Math.ceil(this._tmpMeasureA.left + this._tmpMeasureA.width), Math.ceil(this._tmpMeasureA.top + this._tmpMeasureA.height));
  4793. }
  4794. }
  4795. };
  4796. /** @hidden */
  4797. Control.prototype._markAsDirty = function (force) {
  4798. if (force === void 0) { force = false; }
  4799. if (!this._isVisible && !force) {
  4800. return;
  4801. }
  4802. this._isDirty = true;
  4803. // Redraw only this rectangle
  4804. if (this._host) {
  4805. this._host.markAsDirty();
  4806. }
  4807. };
  4808. /** @hidden */
  4809. Control.prototype._markAllAsDirty = function () {
  4810. this._markAsDirty();
  4811. if (this._font) {
  4812. this._prepareFont();
  4813. }
  4814. };
  4815. /** @hidden */
  4816. Control.prototype._link = function (host) {
  4817. this._host = host;
  4818. if (this._host) {
  4819. this.uniqueId = this._host.getScene().getUniqueId();
  4820. }
  4821. };
  4822. /** @hidden */
  4823. Control.prototype._transform = function (context) {
  4824. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4825. return;
  4826. }
  4827. // postTranslate
  4828. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4829. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4830. if (context) {
  4831. context.translate(offsetX, offsetY);
  4832. // rotate
  4833. context.rotate(this._rotation);
  4834. // scale
  4835. context.scale(this._scaleX, this._scaleY);
  4836. // preTranslate
  4837. context.translate(-offsetX, -offsetY);
  4838. }
  4839. // Need to update matrices?
  4840. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4841. this._cachedOffsetX = offsetX;
  4842. this._cachedOffsetY = offsetY;
  4843. this._isMatrixDirty = false;
  4844. this._flagDescendantsAsMatrixDirty();
  4845. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4846. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4847. }
  4848. };
  4849. /** @hidden */
  4850. Control.prototype._renderHighlight = function (context) {
  4851. if (!this.isHighlighted) {
  4852. return;
  4853. }
  4854. context.save();
  4855. context.strokeStyle = "#4affff";
  4856. context.lineWidth = 2;
  4857. this._renderHighlightSpecific(context);
  4858. context.restore();
  4859. };
  4860. /** @hidden */
  4861. Control.prototype._renderHighlightSpecific = function (context) {
  4862. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4863. };
  4864. /** @hidden */
  4865. Control.prototype._applyStates = function (context) {
  4866. if (this._isFontSizeInPercentage) {
  4867. this._fontSet = true;
  4868. }
  4869. if (this._fontSet) {
  4870. this._prepareFont();
  4871. this._fontSet = false;
  4872. }
  4873. if (this._font) {
  4874. context.font = this._font;
  4875. }
  4876. if (this._color) {
  4877. context.fillStyle = this._color;
  4878. }
  4879. if (Control.AllowAlphaInheritance) {
  4880. context.globalAlpha *= this._alpha;
  4881. }
  4882. else if (this._alphaSet) {
  4883. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4884. }
  4885. };
  4886. /** @hidden */
  4887. Control.prototype._layout = function (parentMeasure, context) {
  4888. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4889. return false;
  4890. }
  4891. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4892. this.host._numLayoutCalls++;
  4893. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4894. context.save();
  4895. this._applyStates(context);
  4896. var rebuildCount = 0;
  4897. do {
  4898. this._rebuildLayout = false;
  4899. this._processMeasures(parentMeasure, context);
  4900. rebuildCount++;
  4901. } while (this._rebuildLayout && rebuildCount < 3);
  4902. if (rebuildCount >= 3) {
  4903. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4904. }
  4905. context.restore();
  4906. this.invalidateRect();
  4907. this._evaluateClippingState(parentMeasure);
  4908. }
  4909. this._wasDirty = this._isDirty;
  4910. this._isDirty = false;
  4911. return true;
  4912. };
  4913. /** @hidden */
  4914. Control.prototype._processMeasures = function (parentMeasure, context) {
  4915. this._currentMeasure.copyFrom(parentMeasure);
  4916. // Let children take some pre-measurement actions
  4917. this._preMeasure(parentMeasure, context);
  4918. this._measure();
  4919. this._computeAlignment(parentMeasure, context);
  4920. // Convert to int values
  4921. this._currentMeasure.left = this._currentMeasure.left | 0;
  4922. this._currentMeasure.top = this._currentMeasure.top | 0;
  4923. this._currentMeasure.width = this._currentMeasure.width | 0;
  4924. this._currentMeasure.height = this._currentMeasure.height | 0;
  4925. // Let children add more features
  4926. this._additionalProcessing(parentMeasure, context);
  4927. this._cachedParentMeasure.copyFrom(parentMeasure);
  4928. if (this.onDirtyObservable.hasObservers()) {
  4929. this.onDirtyObservable.notifyObservers(this);
  4930. }
  4931. };
  4932. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4933. if (this.parent && this.parent.clipChildren) {
  4934. // Early clip
  4935. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4936. this._isClipped = true;
  4937. return;
  4938. }
  4939. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4940. this._isClipped = true;
  4941. return;
  4942. }
  4943. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4944. this._isClipped = true;
  4945. return;
  4946. }
  4947. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4948. this._isClipped = true;
  4949. return;
  4950. }
  4951. }
  4952. this._isClipped = false;
  4953. };
  4954. /** @hidden */
  4955. Control.prototype._measure = function () {
  4956. // Width / Height
  4957. if (this._width.isPixel) {
  4958. this._currentMeasure.width = this._width.getValue(this._host);
  4959. }
  4960. else {
  4961. this._currentMeasure.width *= this._width.getValue(this._host);
  4962. }
  4963. if (this._height.isPixel) {
  4964. this._currentMeasure.height = this._height.getValue(this._host);
  4965. }
  4966. else {
  4967. this._currentMeasure.height *= this._height.getValue(this._host);
  4968. }
  4969. };
  4970. /** @hidden */
  4971. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4972. var width = this._currentMeasure.width;
  4973. var height = this._currentMeasure.height;
  4974. var parentWidth = parentMeasure.width;
  4975. var parentHeight = parentMeasure.height;
  4976. // Left / top
  4977. var x = 0;
  4978. var y = 0;
  4979. switch (this.horizontalAlignment) {
  4980. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4981. x = 0;
  4982. break;
  4983. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4984. x = parentWidth - width;
  4985. break;
  4986. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4987. x = (parentWidth - width) / 2;
  4988. break;
  4989. }
  4990. switch (this.verticalAlignment) {
  4991. case Control.VERTICAL_ALIGNMENT_TOP:
  4992. y = 0;
  4993. break;
  4994. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4995. y = parentHeight - height;
  4996. break;
  4997. case Control.VERTICAL_ALIGNMENT_CENTER:
  4998. y = (parentHeight - height) / 2;
  4999. break;
  5000. }
  5001. if (this._paddingLeft.isPixel) {
  5002. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  5003. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  5004. }
  5005. else {
  5006. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  5007. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  5008. }
  5009. if (this._paddingRight.isPixel) {
  5010. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  5011. }
  5012. else {
  5013. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  5014. }
  5015. if (this._paddingTop.isPixel) {
  5016. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  5017. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  5018. }
  5019. else {
  5020. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  5021. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  5022. }
  5023. if (this._paddingBottom.isPixel) {
  5024. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  5025. }
  5026. else {
  5027. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  5028. }
  5029. if (this._left.isPixel) {
  5030. this._currentMeasure.left += this._left.getValue(this._host);
  5031. }
  5032. else {
  5033. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  5034. }
  5035. if (this._top.isPixel) {
  5036. this._currentMeasure.top += this._top.getValue(this._host);
  5037. }
  5038. else {
  5039. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5040. }
  5041. this._currentMeasure.left += x;
  5042. this._currentMeasure.top += y;
  5043. };
  5044. /** @hidden */
  5045. Control.prototype._preMeasure = function (parentMeasure, context) {
  5046. // Do nothing
  5047. };
  5048. /** @hidden */
  5049. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5050. // Do nothing
  5051. };
  5052. /** @hidden */
  5053. Control.prototype._clipForChildren = function (context) {
  5054. // DO nothing
  5055. };
  5056. Control.prototype._clip = function (context, invalidatedRectangle) {
  5057. context.beginPath();
  5058. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5059. if (invalidatedRectangle) {
  5060. // Rotate the invalidated rect into the control's space
  5061. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5062. // Get the intersection of the rect in context space and the current context
  5063. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5064. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5065. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5066. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5067. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5068. Control._ClipMeasure.copyFrom(intersection);
  5069. }
  5070. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5071. var shadowOffsetX = this.shadowOffsetX;
  5072. var shadowOffsetY = this.shadowOffsetY;
  5073. var shadowBlur = this.shadowBlur;
  5074. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5075. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5076. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5077. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5078. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5079. }
  5080. else {
  5081. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5082. }
  5083. context.clip();
  5084. };
  5085. /** @hidden */
  5086. Control.prototype._render = function (context, invalidatedRectangle) {
  5087. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5088. this._isDirty = false;
  5089. return false;
  5090. }
  5091. this.host._numRenderCalls++;
  5092. context.save();
  5093. this._applyStates(context);
  5094. // Transform
  5095. this._transform(context);
  5096. // Clip
  5097. if (this.clipContent) {
  5098. this._clip(context, invalidatedRectangle);
  5099. }
  5100. if (this.onBeforeDrawObservable.hasObservers()) {
  5101. this.onBeforeDrawObservable.notifyObservers(this);
  5102. }
  5103. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5104. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5105. }
  5106. else {
  5107. this._draw(context, invalidatedRectangle);
  5108. }
  5109. if (this.useBitmapCache && this._wasDirty) {
  5110. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5111. }
  5112. this._renderHighlight(context);
  5113. if (this.onAfterDrawObservable.hasObservers()) {
  5114. this.onAfterDrawObservable.notifyObservers(this);
  5115. }
  5116. context.restore();
  5117. return true;
  5118. };
  5119. /** @hidden */
  5120. Control.prototype._draw = function (context, invalidatedRectangle) {
  5121. // Do nothing
  5122. };
  5123. /**
  5124. * Tests if a given coordinates belong to the current control
  5125. * @param x defines x coordinate to test
  5126. * @param y defines y coordinate to test
  5127. * @returns true if the coordinates are inside the control
  5128. */
  5129. Control.prototype.contains = function (x, y) {
  5130. // Invert transform
  5131. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5132. x = this._transformedPosition.x;
  5133. y = this._transformedPosition.y;
  5134. // Check
  5135. if (x < this._currentMeasure.left) {
  5136. return false;
  5137. }
  5138. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5139. return false;
  5140. }
  5141. if (y < this._currentMeasure.top) {
  5142. return false;
  5143. }
  5144. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5145. return false;
  5146. }
  5147. if (this.isPointerBlocker) {
  5148. this._host._shouldBlockPointer = true;
  5149. }
  5150. return true;
  5151. };
  5152. /** @hidden */
  5153. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5154. if (!this._isEnabled) {
  5155. return false;
  5156. }
  5157. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5158. return false;
  5159. }
  5160. if (!this.contains(x, y)) {
  5161. return false;
  5162. }
  5163. this._processObservables(type, x, y, pointerId, buttonIndex);
  5164. return true;
  5165. };
  5166. /** @hidden */
  5167. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5168. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5169. if (canNotify && this.parent != null) {
  5170. this.parent._onPointerMove(target, coordinates, pointerId);
  5171. }
  5172. };
  5173. /** @hidden */
  5174. Control.prototype._onPointerEnter = function (target) {
  5175. if (!this._isEnabled) {
  5176. return false;
  5177. }
  5178. if (this._enterCount > 0) {
  5179. return false;
  5180. }
  5181. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5182. this._enterCount = 0;
  5183. }
  5184. this._enterCount++;
  5185. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5186. if (canNotify && this.parent != null) {
  5187. this.parent._onPointerEnter(target);
  5188. }
  5189. return true;
  5190. };
  5191. /** @hidden */
  5192. Control.prototype._onPointerOut = function (target, force) {
  5193. if (force === void 0) { force = false; }
  5194. if (!force && (!this._isEnabled || target === this)) {
  5195. return;
  5196. }
  5197. this._enterCount = 0;
  5198. var canNotify = true;
  5199. if (!target.isAscendant(this)) {
  5200. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5201. }
  5202. if (canNotify && this.parent != null) {
  5203. this.parent._onPointerOut(target, force);
  5204. }
  5205. };
  5206. /** @hidden */
  5207. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5208. // Prevent pointerout to lose control context.
  5209. // Event redundancy is checked inside the function.
  5210. this._onPointerEnter(this);
  5211. if (this._downCount !== 0) {
  5212. return false;
  5213. }
  5214. this._downCount++;
  5215. this._downPointerIds[pointerId] = true;
  5216. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5217. if (canNotify && this.parent != null) {
  5218. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5219. }
  5220. return true;
  5221. };
  5222. /** @hidden */
  5223. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5224. if (!this._isEnabled) {
  5225. return;
  5226. }
  5227. this._downCount = 0;
  5228. delete this._downPointerIds[pointerId];
  5229. var canNotifyClick = notifyClick;
  5230. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5231. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5232. }
  5233. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5234. if (canNotify && this.parent != null) {
  5235. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5236. }
  5237. };
  5238. /** @hidden */
  5239. Control.prototype._forcePointerUp = function (pointerId) {
  5240. if (pointerId === void 0) { pointerId = null; }
  5241. if (pointerId !== null) {
  5242. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5243. }
  5244. else {
  5245. for (var key in this._downPointerIds) {
  5246. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5247. }
  5248. }
  5249. };
  5250. /** @hidden */
  5251. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5252. if (!this._isEnabled) {
  5253. return false;
  5254. }
  5255. this._dummyVector2.copyFromFloats(x, y);
  5256. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5257. this._onPointerMove(this, this._dummyVector2, pointerId);
  5258. var previousControlOver = this._host._lastControlOver[pointerId];
  5259. if (previousControlOver && previousControlOver !== this) {
  5260. previousControlOver._onPointerOut(this);
  5261. }
  5262. if (previousControlOver !== this) {
  5263. this._onPointerEnter(this);
  5264. }
  5265. this._host._lastControlOver[pointerId] = this;
  5266. return true;
  5267. }
  5268. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5269. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5270. this._host._registerLastControlDown(this, pointerId);
  5271. this._host._lastPickedControl = this;
  5272. return true;
  5273. }
  5274. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5275. if (this._host._lastControlDown[pointerId]) {
  5276. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5277. }
  5278. delete this._host._lastControlDown[pointerId];
  5279. return true;
  5280. }
  5281. return false;
  5282. };
  5283. Control.prototype._prepareFont = function () {
  5284. if (!this._font && !this._fontSet) {
  5285. return;
  5286. }
  5287. if (this._style) {
  5288. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5289. }
  5290. else {
  5291. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5292. }
  5293. this._fontOffset = Control._GetFontOffset(this._font);
  5294. };
  5295. /** Releases associated resources */
  5296. Control.prototype.dispose = function () {
  5297. this.onDirtyObservable.clear();
  5298. this.onBeforeDrawObservable.clear();
  5299. this.onAfterDrawObservable.clear();
  5300. this.onPointerDownObservable.clear();
  5301. this.onPointerEnterObservable.clear();
  5302. this.onPointerMoveObservable.clear();
  5303. this.onPointerOutObservable.clear();
  5304. this.onPointerUpObservable.clear();
  5305. this.onPointerClickObservable.clear();
  5306. if (this._styleObserver && this._style) {
  5307. this._style.onChangedObservable.remove(this._styleObserver);
  5308. this._styleObserver = null;
  5309. }
  5310. if (this.parent) {
  5311. this.parent.removeControl(this);
  5312. this.parent = null;
  5313. }
  5314. if (this._host) {
  5315. var index = this._host._linkedControls.indexOf(this);
  5316. if (index > -1) {
  5317. this.linkWithMesh(null);
  5318. }
  5319. }
  5320. };
  5321. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5322. /** HORIZONTAL_ALIGNMENT_LEFT */
  5323. get: function () {
  5324. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5325. },
  5326. enumerable: true,
  5327. configurable: true
  5328. });
  5329. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5330. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5331. get: function () {
  5332. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5333. },
  5334. enumerable: true,
  5335. configurable: true
  5336. });
  5337. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5338. /** HORIZONTAL_ALIGNMENT_CENTER */
  5339. get: function () {
  5340. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5341. },
  5342. enumerable: true,
  5343. configurable: true
  5344. });
  5345. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5346. /** VERTICAL_ALIGNMENT_TOP */
  5347. get: function () {
  5348. return Control._VERTICAL_ALIGNMENT_TOP;
  5349. },
  5350. enumerable: true,
  5351. configurable: true
  5352. });
  5353. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5354. /** VERTICAL_ALIGNMENT_BOTTOM */
  5355. get: function () {
  5356. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5357. },
  5358. enumerable: true,
  5359. configurable: true
  5360. });
  5361. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5362. /** VERTICAL_ALIGNMENT_CENTER */
  5363. get: function () {
  5364. return Control._VERTICAL_ALIGNMENT_CENTER;
  5365. },
  5366. enumerable: true,
  5367. configurable: true
  5368. });
  5369. /** @hidden */
  5370. Control._GetFontOffset = function (font) {
  5371. if (Control._FontHeightSizes[font]) {
  5372. return Control._FontHeightSizes[font];
  5373. }
  5374. var text = document.createElement("span");
  5375. text.innerHTML = "Hg";
  5376. text.style.font = font;
  5377. var block = document.createElement("div");
  5378. block.style.display = "inline-block";
  5379. block.style.width = "1px";
  5380. block.style.height = "0px";
  5381. block.style.verticalAlign = "bottom";
  5382. var div = document.createElement("div");
  5383. div.appendChild(text);
  5384. div.appendChild(block);
  5385. document.body.appendChild(div);
  5386. var fontAscent = 0;
  5387. var fontHeight = 0;
  5388. try {
  5389. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5390. block.style.verticalAlign = "baseline";
  5391. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5392. }
  5393. finally {
  5394. document.body.removeChild(div);
  5395. }
  5396. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5397. Control._FontHeightSizes[font] = result;
  5398. return result;
  5399. };
  5400. /** @hidden */
  5401. Control.drawEllipse = function (x, y, width, height, context) {
  5402. context.translate(x, y);
  5403. context.scale(width, height);
  5404. context.beginPath();
  5405. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5406. context.closePath();
  5407. context.scale(1 / width, 1 / height);
  5408. context.translate(-x, -y);
  5409. };
  5410. /**
  5411. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5412. */
  5413. Control.AllowAlphaInheritance = false;
  5414. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5415. // Statics
  5416. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5417. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5418. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5419. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5420. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5421. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5422. Control._FontHeightSizes = {};
  5423. /**
  5424. * Creates a stack panel that can be used to render headers
  5425. * @param control defines the control to associate with the header
  5426. * @param text defines the text of the header
  5427. * @param size defines the size of the header
  5428. * @param options defines options used to configure the header
  5429. * @returns a new StackPanel
  5430. * @ignore
  5431. * @hidden
  5432. */
  5433. Control.AddHeader = function () { };
  5434. return Control;
  5435. }());
  5436. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5437. /***/ }),
  5438. /***/ "./2D/controls/displayGrid.ts":
  5439. /*!************************************!*\
  5440. !*** ./2D/controls/displayGrid.ts ***!
  5441. \************************************/
  5442. /*! exports provided: DisplayGrid */
  5443. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5444. "use strict";
  5445. __webpack_require__.r(__webpack_exports__);
  5446. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5447. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5448. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5449. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5450. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5451. /** Class used to render a grid */
  5452. var DisplayGrid = /** @class */ (function (_super) {
  5453. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5454. /**
  5455. * Creates a new GridDisplayRectangle
  5456. * @param name defines the control name
  5457. */
  5458. function DisplayGrid(name) {
  5459. var _this = _super.call(this, name) || this;
  5460. _this.name = name;
  5461. _this._cellWidth = 20;
  5462. _this._cellHeight = 20;
  5463. _this._minorLineTickness = 1;
  5464. _this._minorLineColor = "DarkGray";
  5465. _this._majorLineTickness = 2;
  5466. _this._majorLineColor = "White";
  5467. _this._majorLineFrequency = 5;
  5468. _this._background = "Black";
  5469. _this._displayMajorLines = true;
  5470. _this._displayMinorLines = true;
  5471. return _this;
  5472. }
  5473. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5474. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5475. get: function () {
  5476. return this._displayMinorLines;
  5477. },
  5478. set: function (value) {
  5479. if (this._displayMinorLines === value) {
  5480. return;
  5481. }
  5482. this._displayMinorLines = value;
  5483. this._markAsDirty();
  5484. },
  5485. enumerable: true,
  5486. configurable: true
  5487. });
  5488. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5489. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5490. get: function () {
  5491. return this._displayMajorLines;
  5492. },
  5493. set: function (value) {
  5494. if (this._displayMajorLines === value) {
  5495. return;
  5496. }
  5497. this._displayMajorLines = value;
  5498. this._markAsDirty();
  5499. },
  5500. enumerable: true,
  5501. configurable: true
  5502. });
  5503. Object.defineProperty(DisplayGrid.prototype, "background", {
  5504. /** Gets or sets background color (Black by default) */
  5505. get: function () {
  5506. return this._background;
  5507. },
  5508. set: function (value) {
  5509. if (this._background === value) {
  5510. return;
  5511. }
  5512. this._background = value;
  5513. this._markAsDirty();
  5514. },
  5515. enumerable: true,
  5516. configurable: true
  5517. });
  5518. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5519. /** Gets or sets the width of each cell (20 by default) */
  5520. get: function () {
  5521. return this._cellWidth;
  5522. },
  5523. set: function (value) {
  5524. this._cellWidth = value;
  5525. this._markAsDirty();
  5526. },
  5527. enumerable: true,
  5528. configurable: true
  5529. });
  5530. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5531. /** Gets or sets the height of each cell (20 by default) */
  5532. get: function () {
  5533. return this._cellHeight;
  5534. },
  5535. set: function (value) {
  5536. this._cellHeight = value;
  5537. this._markAsDirty();
  5538. },
  5539. enumerable: true,
  5540. configurable: true
  5541. });
  5542. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5543. /** Gets or sets the tickness of minor lines (1 by default) */
  5544. get: function () {
  5545. return this._minorLineTickness;
  5546. },
  5547. set: function (value) {
  5548. this._minorLineTickness = value;
  5549. this._markAsDirty();
  5550. },
  5551. enumerable: true,
  5552. configurable: true
  5553. });
  5554. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5555. /** Gets or sets the color of minor lines (DarkGray by default) */
  5556. get: function () {
  5557. return this._minorLineColor;
  5558. },
  5559. set: function (value) {
  5560. this._minorLineColor = value;
  5561. this._markAsDirty();
  5562. },
  5563. enumerable: true,
  5564. configurable: true
  5565. });
  5566. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5567. /** Gets or sets the tickness of major lines (2 by default) */
  5568. get: function () {
  5569. return this._majorLineTickness;
  5570. },
  5571. set: function (value) {
  5572. this._majorLineTickness = value;
  5573. this._markAsDirty();
  5574. },
  5575. enumerable: true,
  5576. configurable: true
  5577. });
  5578. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5579. /** Gets or sets the color of major lines (White by default) */
  5580. get: function () {
  5581. return this._majorLineColor;
  5582. },
  5583. set: function (value) {
  5584. this._majorLineColor = value;
  5585. this._markAsDirty();
  5586. },
  5587. enumerable: true,
  5588. configurable: true
  5589. });
  5590. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5591. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5592. get: function () {
  5593. return this._majorLineFrequency;
  5594. },
  5595. set: function (value) {
  5596. this._majorLineFrequency = value;
  5597. this._markAsDirty();
  5598. },
  5599. enumerable: true,
  5600. configurable: true
  5601. });
  5602. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5603. context.save();
  5604. this._applyStates(context);
  5605. if (this._isEnabled) {
  5606. if (this._background) {
  5607. context.fillStyle = this._background;
  5608. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5609. }
  5610. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5611. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5612. // Minor lines
  5613. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5614. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5615. if (this._displayMinorLines) {
  5616. context.strokeStyle = this._minorLineColor;
  5617. context.lineWidth = this._minorLineTickness;
  5618. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5619. var cellX = left + x * this.cellWidth;
  5620. context.beginPath();
  5621. context.moveTo(cellX, this._currentMeasure.top);
  5622. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5623. context.stroke();
  5624. }
  5625. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5626. var cellY = top_1 + y * this.cellHeight;
  5627. context.beginPath();
  5628. context.moveTo(this._currentMeasure.left, cellY);
  5629. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5630. context.stroke();
  5631. }
  5632. }
  5633. // Major lines
  5634. if (this._displayMajorLines) {
  5635. context.strokeStyle = this._majorLineColor;
  5636. context.lineWidth = this._majorLineTickness;
  5637. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5638. var cellX = left + x * this.cellWidth;
  5639. context.beginPath();
  5640. context.moveTo(cellX, this._currentMeasure.top);
  5641. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5642. context.stroke();
  5643. }
  5644. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5645. var cellY = top_1 + y * this.cellHeight;
  5646. context.moveTo(this._currentMeasure.left, cellY);
  5647. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5648. context.closePath();
  5649. context.stroke();
  5650. }
  5651. }
  5652. }
  5653. context.restore();
  5654. };
  5655. DisplayGrid.prototype._getTypeName = function () {
  5656. return "DisplayGrid";
  5657. };
  5658. return DisplayGrid;
  5659. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5660. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5661. /***/ }),
  5662. /***/ "./2D/controls/ellipse.ts":
  5663. /*!********************************!*\
  5664. !*** ./2D/controls/ellipse.ts ***!
  5665. \********************************/
  5666. /*! exports provided: Ellipse */
  5667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5668. "use strict";
  5669. __webpack_require__.r(__webpack_exports__);
  5670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5671. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5672. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5673. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5674. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5675. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5676. /** Class used to create 2D ellipse containers */
  5677. var Ellipse = /** @class */ (function (_super) {
  5678. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5679. /**
  5680. * Creates a new Ellipse
  5681. * @param name defines the control name
  5682. */
  5683. function Ellipse(name) {
  5684. var _this = _super.call(this, name) || this;
  5685. _this.name = name;
  5686. _this._thickness = 1;
  5687. return _this;
  5688. }
  5689. Object.defineProperty(Ellipse.prototype, "thickness", {
  5690. /** Gets or sets border thickness */
  5691. get: function () {
  5692. return this._thickness;
  5693. },
  5694. set: function (value) {
  5695. if (this._thickness === value) {
  5696. return;
  5697. }
  5698. this._thickness = value;
  5699. this._markAsDirty();
  5700. },
  5701. enumerable: true,
  5702. configurable: true
  5703. });
  5704. Ellipse.prototype._getTypeName = function () {
  5705. return "Ellipse";
  5706. };
  5707. Ellipse.prototype._localDraw = function (context) {
  5708. context.save();
  5709. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5710. context.shadowColor = this.shadowColor;
  5711. context.shadowBlur = this.shadowBlur;
  5712. context.shadowOffsetX = this.shadowOffsetX;
  5713. context.shadowOffsetY = this.shadowOffsetY;
  5714. }
  5715. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2 - this._thickness / 2, this._currentMeasure.height / 2 - this._thickness / 2, context);
  5716. if (this._background) {
  5717. context.fillStyle = this._background;
  5718. context.fill();
  5719. }
  5720. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5721. context.shadowBlur = 0;
  5722. context.shadowOffsetX = 0;
  5723. context.shadowOffsetY = 0;
  5724. }
  5725. if (this._thickness) {
  5726. if (this.color) {
  5727. context.strokeStyle = this.color;
  5728. }
  5729. context.lineWidth = this._thickness;
  5730. context.stroke();
  5731. }
  5732. context.restore();
  5733. };
  5734. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5735. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5736. this._measureForChildren.width -= 2 * this._thickness;
  5737. this._measureForChildren.height -= 2 * this._thickness;
  5738. this._measureForChildren.left += this._thickness;
  5739. this._measureForChildren.top += this._thickness;
  5740. };
  5741. Ellipse.prototype._clipForChildren = function (context) {
  5742. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2, this._currentMeasure.height / 2, context);
  5743. context.clip();
  5744. };
  5745. return Ellipse;
  5746. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5747. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5748. /***/ }),
  5749. /***/ "./2D/controls/grid.ts":
  5750. /*!*****************************!*\
  5751. !*** ./2D/controls/grid.ts ***!
  5752. \*****************************/
  5753. /*! exports provided: Grid */
  5754. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5755. "use strict";
  5756. __webpack_require__.r(__webpack_exports__);
  5757. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5758. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5759. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5760. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5761. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5762. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  5763. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5764. /**
  5765. * Class used to create a 2D grid container
  5766. */
  5767. var Grid = /** @class */ (function (_super) {
  5768. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5769. /**
  5770. * Creates a new Grid
  5771. * @param name defines control name
  5772. */
  5773. function Grid(name) {
  5774. var _this = _super.call(this, name) || this;
  5775. _this.name = name;
  5776. _this._rowDefinitions = new Array();
  5777. _this._columnDefinitions = new Array();
  5778. _this._cells = {};
  5779. _this._childControls = new Array();
  5780. return _this;
  5781. }
  5782. Object.defineProperty(Grid.prototype, "columnCount", {
  5783. /**
  5784. * Gets the number of columns
  5785. */
  5786. get: function () {
  5787. return this._columnDefinitions.length;
  5788. },
  5789. enumerable: true,
  5790. configurable: true
  5791. });
  5792. Object.defineProperty(Grid.prototype, "rowCount", {
  5793. /**
  5794. * Gets the number of rows
  5795. */
  5796. get: function () {
  5797. return this._rowDefinitions.length;
  5798. },
  5799. enumerable: true,
  5800. configurable: true
  5801. });
  5802. Object.defineProperty(Grid.prototype, "children", {
  5803. /** Gets the list of children */
  5804. get: function () {
  5805. return this._childControls;
  5806. },
  5807. enumerable: true,
  5808. configurable: true
  5809. });
  5810. Object.defineProperty(Grid.prototype, "cells", {
  5811. /** Gets the list of cells (e.g. the containers) */
  5812. get: function () {
  5813. return this._cells;
  5814. },
  5815. enumerable: true,
  5816. configurable: true
  5817. });
  5818. /**
  5819. * Gets the definition of a specific row
  5820. * @param index defines the index of the row
  5821. * @returns the row definition
  5822. */
  5823. Grid.prototype.getRowDefinition = function (index) {
  5824. if (index < 0 || index >= this._rowDefinitions.length) {
  5825. return null;
  5826. }
  5827. return this._rowDefinitions[index];
  5828. };
  5829. /**
  5830. * Gets the definition of a specific column
  5831. * @param index defines the index of the column
  5832. * @returns the column definition
  5833. */
  5834. Grid.prototype.getColumnDefinition = function (index) {
  5835. if (index < 0 || index >= this._columnDefinitions.length) {
  5836. return null;
  5837. }
  5838. return this._columnDefinitions[index];
  5839. };
  5840. /**
  5841. * Adds a new row to the grid
  5842. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5843. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5844. * @returns the current grid
  5845. */
  5846. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5847. if (isPixel === void 0) { isPixel = false; }
  5848. this._rowDefinitions.push(new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](height, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE));
  5849. this._markAsDirty();
  5850. return this;
  5851. };
  5852. /**
  5853. * Adds a new column to the grid
  5854. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5855. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5856. * @returns the current grid
  5857. */
  5858. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5859. if (isPixel === void 0) { isPixel = false; }
  5860. this._columnDefinitions.push(new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](width, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE));
  5861. this._markAsDirty();
  5862. return this;
  5863. };
  5864. /**
  5865. * Update a row definition
  5866. * @param index defines the index of the row to update
  5867. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5868. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5869. * @returns the current grid
  5870. */
  5871. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5872. if (isPixel === void 0) { isPixel = false; }
  5873. if (index < 0 || index >= this._rowDefinitions.length) {
  5874. return this;
  5875. }
  5876. var current = this._rowDefinitions[index];
  5877. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5878. return this;
  5879. }
  5880. this._rowDefinitions[index] = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](height, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE);
  5881. this._markAsDirty();
  5882. return this;
  5883. };
  5884. /**
  5885. * Update a column definition
  5886. * @param index defines the index of the column to update
  5887. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5888. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5889. * @returns the current grid
  5890. */
  5891. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5892. if (isPixel === void 0) { isPixel = false; }
  5893. if (index < 0 || index >= this._columnDefinitions.length) {
  5894. return this;
  5895. }
  5896. var current = this._columnDefinitions[index];
  5897. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5898. return this;
  5899. }
  5900. this._columnDefinitions[index] = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](width, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE);
  5901. this._markAsDirty();
  5902. return this;
  5903. };
  5904. /**
  5905. * Gets the list of children stored in a specific cell
  5906. * @param row defines the row to check
  5907. * @param column defines the column to check
  5908. * @returns the list of controls
  5909. */
  5910. Grid.prototype.getChildrenAt = function (row, column) {
  5911. var cell = this._cells[row + ":" + column];
  5912. if (!cell) {
  5913. return null;
  5914. }
  5915. return cell.children;
  5916. };
  5917. /**
  5918. * Gets a string representing the child cell info (row x column)
  5919. * @param child defines the control to get info from
  5920. * @returns a string containing the child cell info (row x column)
  5921. */
  5922. Grid.prototype.getChildCellInfo = function (child) {
  5923. return child._tag;
  5924. };
  5925. Grid.prototype._removeCell = function (cell, key) {
  5926. if (!cell) {
  5927. return;
  5928. }
  5929. _super.prototype.removeControl.call(this, cell);
  5930. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5931. var control = _a[_i];
  5932. var childIndex = this._childControls.indexOf(control);
  5933. if (childIndex !== -1) {
  5934. this._childControls.splice(childIndex, 1);
  5935. }
  5936. }
  5937. delete this._cells[key];
  5938. };
  5939. Grid.prototype._offsetCell = function (previousKey, key) {
  5940. if (!this._cells[key]) {
  5941. return;
  5942. }
  5943. this._cells[previousKey] = this._cells[key];
  5944. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5945. var control = _a[_i];
  5946. control._tag = previousKey;
  5947. }
  5948. delete this._cells[key];
  5949. };
  5950. /**
  5951. * Remove a column definition at specified index
  5952. * @param index defines the index of the column to remove
  5953. * @returns the current grid
  5954. */
  5955. Grid.prototype.removeColumnDefinition = function (index) {
  5956. if (index < 0 || index >= this._columnDefinitions.length) {
  5957. return this;
  5958. }
  5959. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5960. var key = x + ":" + index;
  5961. var cell = this._cells[key];
  5962. this._removeCell(cell, key);
  5963. }
  5964. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5965. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5966. var previousKey = x + ":" + (y - 1);
  5967. var key = x + ":" + y;
  5968. this._offsetCell(previousKey, key);
  5969. }
  5970. }
  5971. this._columnDefinitions.splice(index, 1);
  5972. this._markAsDirty();
  5973. return this;
  5974. };
  5975. /**
  5976. * Remove a row definition at specified index
  5977. * @param index defines the index of the row to remove
  5978. * @returns the current grid
  5979. */
  5980. Grid.prototype.removeRowDefinition = function (index) {
  5981. if (index < 0 || index >= this._rowDefinitions.length) {
  5982. return this;
  5983. }
  5984. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5985. var key = index + ":" + y;
  5986. var cell = this._cells[key];
  5987. this._removeCell(cell, key);
  5988. }
  5989. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5990. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5991. var previousKey = x - 1 + ":" + y;
  5992. var key = x + ":" + y;
  5993. this._offsetCell(previousKey, key);
  5994. }
  5995. }
  5996. this._rowDefinitions.splice(index, 1);
  5997. this._markAsDirty();
  5998. return this;
  5999. };
  6000. /**
  6001. * Adds a new control to the current grid
  6002. * @param control defines the control to add
  6003. * @param row defines the row where to add the control (0 by default)
  6004. * @param column defines the column where to add the control (0 by default)
  6005. * @returns the current grid
  6006. */
  6007. Grid.prototype.addControl = function (control, row, column) {
  6008. if (row === void 0) { row = 0; }
  6009. if (column === void 0) { column = 0; }
  6010. if (this._rowDefinitions.length === 0) {
  6011. // Add default row definition
  6012. this.addRowDefinition(1, false);
  6013. }
  6014. if (this._columnDefinitions.length === 0) {
  6015. // Add default column definition
  6016. this.addColumnDefinition(1, false);
  6017. }
  6018. if (this._childControls.indexOf(control) !== -1) {
  6019. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].Warn("Control (Name:" + control.name + ", UniqueId:" + control.uniqueId + ") is already associated with this grid. You must remove it before reattaching it");
  6020. return this;
  6021. }
  6022. var x = Math.min(row, this._rowDefinitions.length - 1);
  6023. var y = Math.min(column, this._columnDefinitions.length - 1);
  6024. var key = x + ":" + y;
  6025. var goodContainer = this._cells[key];
  6026. if (!goodContainer) {
  6027. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6028. this._cells[key] = goodContainer;
  6029. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6030. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6031. _super.prototype.addControl.call(this, goodContainer);
  6032. }
  6033. goodContainer.addControl(control);
  6034. this._childControls.push(control);
  6035. control._tag = key;
  6036. control.parent = this;
  6037. this._markAsDirty();
  6038. return this;
  6039. };
  6040. /**
  6041. * Removes a control from the current container
  6042. * @param control defines the control to remove
  6043. * @returns the current container
  6044. */
  6045. Grid.prototype.removeControl = function (control) {
  6046. var index = this._childControls.indexOf(control);
  6047. if (index !== -1) {
  6048. this._childControls.splice(index, 1);
  6049. }
  6050. var cell = this._cells[control._tag];
  6051. if (cell) {
  6052. cell.removeControl(control);
  6053. control._tag = null;
  6054. }
  6055. this._markAsDirty();
  6056. return this;
  6057. };
  6058. Grid.prototype._getTypeName = function () {
  6059. return "Grid";
  6060. };
  6061. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6062. var widths = [];
  6063. var heights = [];
  6064. var lefts = [];
  6065. var tops = [];
  6066. var availableWidth = this._currentMeasure.width;
  6067. var globalWidthPercentage = 0;
  6068. var availableHeight = this._currentMeasure.height;
  6069. var globalHeightPercentage = 0;
  6070. // Heights
  6071. var index = 0;
  6072. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6073. var value = _a[_i];
  6074. if (value.isPixel) {
  6075. var height = value.getValue(this._host);
  6076. availableHeight -= height;
  6077. heights[index] = height;
  6078. }
  6079. else {
  6080. globalHeightPercentage += value.internalValue;
  6081. }
  6082. index++;
  6083. }
  6084. var top = 0;
  6085. index = 0;
  6086. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6087. var value = _c[_b];
  6088. tops.push(top);
  6089. if (!value.isPixel) {
  6090. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6091. top += height;
  6092. heights[index] = height;
  6093. }
  6094. else {
  6095. top += value.getValue(this._host);
  6096. }
  6097. index++;
  6098. }
  6099. // Widths
  6100. index = 0;
  6101. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6102. var value = _e[_d];
  6103. if (value.isPixel) {
  6104. var width = value.getValue(this._host);
  6105. availableWidth -= width;
  6106. widths[index] = width;
  6107. }
  6108. else {
  6109. globalWidthPercentage += value.internalValue;
  6110. }
  6111. index++;
  6112. }
  6113. var left = 0;
  6114. index = 0;
  6115. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6116. var value = _g[_f];
  6117. lefts.push(left);
  6118. if (!value.isPixel) {
  6119. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6120. left += width;
  6121. widths[index] = width;
  6122. }
  6123. else {
  6124. left += value.getValue(this._host);
  6125. }
  6126. index++;
  6127. }
  6128. definitionCallback(lefts, tops, widths, heights);
  6129. };
  6130. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6131. var _this = this;
  6132. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6133. // Setting child sizes
  6134. for (var key in _this._cells) {
  6135. if (!_this._cells.hasOwnProperty(key)) {
  6136. continue;
  6137. }
  6138. var split = key.split(":");
  6139. var x = parseInt(split[0]);
  6140. var y = parseInt(split[1]);
  6141. var cell = _this._cells[key];
  6142. cell.left = lefts[y] + "px";
  6143. cell.top = tops[x] + "px";
  6144. cell.width = widths[y] + "px";
  6145. cell.height = heights[x] + "px";
  6146. cell._left.ignoreAdaptiveScaling = true;
  6147. cell._top.ignoreAdaptiveScaling = true;
  6148. cell._width.ignoreAdaptiveScaling = true;
  6149. cell._height.ignoreAdaptiveScaling = true;
  6150. }
  6151. });
  6152. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6153. };
  6154. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6155. for (var key in this._cells) {
  6156. if (!this._cells.hasOwnProperty(key)) {
  6157. continue;
  6158. }
  6159. var child = this._cells[key];
  6160. child._markMatrixAsDirty();
  6161. }
  6162. };
  6163. Grid.prototype._renderHighlightSpecific = function (context) {
  6164. var _this = this;
  6165. _super.prototype._renderHighlightSpecific.call(this, context);
  6166. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6167. // Columns
  6168. for (var index = 0; index < lefts.length; index++) {
  6169. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6170. context.beginPath();
  6171. context.moveTo(left, _this._currentMeasure.top);
  6172. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6173. context.stroke();
  6174. }
  6175. // Rows
  6176. for (var index = 0; index < tops.length; index++) {
  6177. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6178. context.beginPath();
  6179. context.moveTo(_this._currentMeasure.left, top_1);
  6180. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6181. context.stroke();
  6182. }
  6183. });
  6184. context.restore();
  6185. };
  6186. /** Releases associated resources */
  6187. Grid.prototype.dispose = function () {
  6188. _super.prototype.dispose.call(this);
  6189. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6190. var control = _a[_i];
  6191. control.dispose();
  6192. }
  6193. this._childControls = [];
  6194. };
  6195. return Grid;
  6196. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6197. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6198. /***/ }),
  6199. /***/ "./2D/controls/image.ts":
  6200. /*!******************************!*\
  6201. !*** ./2D/controls/image.ts ***!
  6202. \******************************/
  6203. /*! exports provided: Image */
  6204. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6205. "use strict";
  6206. __webpack_require__.r(__webpack_exports__);
  6207. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6208. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6209. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6210. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6211. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6212. /**
  6213. * Class used to create 2D images
  6214. */
  6215. var Image = /** @class */ (function (_super) {
  6216. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6217. /**
  6218. * Creates a new Image
  6219. * @param name defines the control name
  6220. * @param url defines the image url
  6221. */
  6222. function Image(name, url) {
  6223. if (url === void 0) { url = null; }
  6224. var _this = _super.call(this, name) || this;
  6225. _this.name = name;
  6226. _this._workingCanvas = null;
  6227. _this._loaded = false;
  6228. _this._stretch = Image.STRETCH_FILL;
  6229. _this._autoScale = false;
  6230. _this._sourceLeft = 0;
  6231. _this._sourceTop = 0;
  6232. _this._sourceWidth = 0;
  6233. _this._sourceHeight = 0;
  6234. _this._cellWidth = 0;
  6235. _this._cellHeight = 0;
  6236. _this._cellId = -1;
  6237. _this._populateNinePatchSlicesFromImage = false;
  6238. /**
  6239. * Observable notified when the content is loaded
  6240. */
  6241. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6242. /**
  6243. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6244. */
  6245. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6246. _this.source = url;
  6247. return _this;
  6248. }
  6249. Object.defineProperty(Image.prototype, "isLoaded", {
  6250. /**
  6251. * Gets a boolean indicating that the content is loaded
  6252. */
  6253. get: function () {
  6254. return this._loaded;
  6255. },
  6256. enumerable: true,
  6257. configurable: true
  6258. });
  6259. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6260. /**
  6261. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6262. */
  6263. get: function () {
  6264. return this._populateNinePatchSlicesFromImage;
  6265. },
  6266. set: function (value) {
  6267. if (this._populateNinePatchSlicesFromImage === value) {
  6268. return;
  6269. }
  6270. this._populateNinePatchSlicesFromImage = value;
  6271. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6272. this._extractNinePatchSliceDataFromImage();
  6273. }
  6274. },
  6275. enumerable: true,
  6276. configurable: true
  6277. });
  6278. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6279. /**
  6280. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6281. * Beware using this as this will comsume more memory as the image has to be stored twice
  6282. */
  6283. get: function () {
  6284. return this._detectPointerOnOpaqueOnly;
  6285. },
  6286. set: function (value) {
  6287. if (this._detectPointerOnOpaqueOnly === value) {
  6288. return;
  6289. }
  6290. this._detectPointerOnOpaqueOnly = value;
  6291. },
  6292. enumerable: true,
  6293. configurable: true
  6294. });
  6295. Object.defineProperty(Image.prototype, "sliceLeft", {
  6296. /**
  6297. * Gets or sets the left value for slicing (9-patch)
  6298. */
  6299. get: function () {
  6300. return this._sliceLeft;
  6301. },
  6302. set: function (value) {
  6303. if (this._sliceLeft === value) {
  6304. return;
  6305. }
  6306. this._sliceLeft = value;
  6307. this._markAsDirty();
  6308. },
  6309. enumerable: true,
  6310. configurable: true
  6311. });
  6312. Object.defineProperty(Image.prototype, "sliceRight", {
  6313. /**
  6314. * Gets or sets the right value for slicing (9-patch)
  6315. */
  6316. get: function () {
  6317. return this._sliceRight;
  6318. },
  6319. set: function (value) {
  6320. if (this._sliceRight === value) {
  6321. return;
  6322. }
  6323. this._sliceRight = value;
  6324. this._markAsDirty();
  6325. },
  6326. enumerable: true,
  6327. configurable: true
  6328. });
  6329. Object.defineProperty(Image.prototype, "sliceTop", {
  6330. /**
  6331. * Gets or sets the top value for slicing (9-patch)
  6332. */
  6333. get: function () {
  6334. return this._sliceTop;
  6335. },
  6336. set: function (value) {
  6337. if (this._sliceTop === value) {
  6338. return;
  6339. }
  6340. this._sliceTop = value;
  6341. this._markAsDirty();
  6342. },
  6343. enumerable: true,
  6344. configurable: true
  6345. });
  6346. Object.defineProperty(Image.prototype, "sliceBottom", {
  6347. /**
  6348. * Gets or sets the bottom value for slicing (9-patch)
  6349. */
  6350. get: function () {
  6351. return this._sliceBottom;
  6352. },
  6353. set: function (value) {
  6354. if (this._sliceBottom === value) {
  6355. return;
  6356. }
  6357. this._sliceBottom = value;
  6358. this._markAsDirty();
  6359. },
  6360. enumerable: true,
  6361. configurable: true
  6362. });
  6363. Object.defineProperty(Image.prototype, "sourceLeft", {
  6364. /**
  6365. * Gets or sets the left coordinate in the source image
  6366. */
  6367. get: function () {
  6368. return this._sourceLeft;
  6369. },
  6370. set: function (value) {
  6371. if (this._sourceLeft === value) {
  6372. return;
  6373. }
  6374. this._sourceLeft = value;
  6375. this._markAsDirty();
  6376. },
  6377. enumerable: true,
  6378. configurable: true
  6379. });
  6380. Object.defineProperty(Image.prototype, "sourceTop", {
  6381. /**
  6382. * Gets or sets the top coordinate in the source image
  6383. */
  6384. get: function () {
  6385. return this._sourceTop;
  6386. },
  6387. set: function (value) {
  6388. if (this._sourceTop === value) {
  6389. return;
  6390. }
  6391. this._sourceTop = value;
  6392. this._markAsDirty();
  6393. },
  6394. enumerable: true,
  6395. configurable: true
  6396. });
  6397. Object.defineProperty(Image.prototype, "sourceWidth", {
  6398. /**
  6399. * Gets or sets the width to capture in the source image
  6400. */
  6401. get: function () {
  6402. return this._sourceWidth;
  6403. },
  6404. set: function (value) {
  6405. if (this._sourceWidth === value) {
  6406. return;
  6407. }
  6408. this._sourceWidth = value;
  6409. this._markAsDirty();
  6410. },
  6411. enumerable: true,
  6412. configurable: true
  6413. });
  6414. Object.defineProperty(Image.prototype, "sourceHeight", {
  6415. /**
  6416. * Gets or sets the height to capture in the source image
  6417. */
  6418. get: function () {
  6419. return this._sourceHeight;
  6420. },
  6421. set: function (value) {
  6422. if (this._sourceHeight === value) {
  6423. return;
  6424. }
  6425. this._sourceHeight = value;
  6426. this._markAsDirty();
  6427. },
  6428. enumerable: true,
  6429. configurable: true
  6430. });
  6431. Object.defineProperty(Image.prototype, "autoScale", {
  6432. /**
  6433. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6434. * @see http://doc.babylonjs.com/how_to/gui#image
  6435. */
  6436. get: function () {
  6437. return this._autoScale;
  6438. },
  6439. set: function (value) {
  6440. if (this._autoScale === value) {
  6441. return;
  6442. }
  6443. this._autoScale = value;
  6444. if (value && this._loaded) {
  6445. this.synchronizeSizeWithContent();
  6446. }
  6447. },
  6448. enumerable: true,
  6449. configurable: true
  6450. });
  6451. Object.defineProperty(Image.prototype, "stretch", {
  6452. /** Gets or sets the streching mode used by the image */
  6453. get: function () {
  6454. return this._stretch;
  6455. },
  6456. set: function (value) {
  6457. if (this._stretch === value) {
  6458. return;
  6459. }
  6460. this._stretch = value;
  6461. this._markAsDirty();
  6462. },
  6463. enumerable: true,
  6464. configurable: true
  6465. });
  6466. /** @hidden */
  6467. Image.prototype._rotate90 = function (n) {
  6468. var canvas = document.createElement('canvas');
  6469. var context = canvas.getContext('2d');
  6470. var width = this._domImage.width;
  6471. var height = this._domImage.height;
  6472. canvas.width = height;
  6473. canvas.height = width;
  6474. context.translate(canvas.width / 2, canvas.height / 2);
  6475. context.rotate(n * Math.PI / 2);
  6476. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  6477. var dataUrl = canvas.toDataURL("image/jpg");
  6478. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  6479. return rotatedImage;
  6480. };
  6481. Object.defineProperty(Image.prototype, "domImage", {
  6482. get: function () {
  6483. return this._domImage;
  6484. },
  6485. /**
  6486. * Gets or sets the internal DOM image used to render the control
  6487. */
  6488. set: function (value) {
  6489. var _this = this;
  6490. this._domImage = value;
  6491. this._loaded = false;
  6492. if (this._domImage.width) {
  6493. this._onImageLoaded();
  6494. }
  6495. else {
  6496. this._domImage.onload = function () {
  6497. _this._onImageLoaded();
  6498. };
  6499. }
  6500. },
  6501. enumerable: true,
  6502. configurable: true
  6503. });
  6504. Image.prototype._onImageLoaded = function () {
  6505. this._imageWidth = this._domImage.width;
  6506. this._imageHeight = this._domImage.height;
  6507. this._loaded = true;
  6508. if (this._populateNinePatchSlicesFromImage) {
  6509. this._extractNinePatchSliceDataFromImage();
  6510. }
  6511. if (this._autoScale) {
  6512. this.synchronizeSizeWithContent();
  6513. }
  6514. this.onImageLoadedObservable.notifyObservers(this);
  6515. this._markAsDirty();
  6516. };
  6517. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6518. if (!this._workingCanvas) {
  6519. this._workingCanvas = document.createElement('canvas');
  6520. }
  6521. var canvas = this._workingCanvas;
  6522. var context = canvas.getContext('2d');
  6523. var width = this._domImage.width;
  6524. var height = this._domImage.height;
  6525. canvas.width = width;
  6526. canvas.height = height;
  6527. context.drawImage(this._domImage, 0, 0, width, height);
  6528. var imageData = context.getImageData(0, 0, width, height);
  6529. // Left and right
  6530. this._sliceLeft = -1;
  6531. this._sliceRight = -1;
  6532. for (var x = 0; x < width; x++) {
  6533. var alpha = imageData.data[x * 4 + 3];
  6534. if (alpha > 127 && this._sliceLeft === -1) {
  6535. this._sliceLeft = x;
  6536. continue;
  6537. }
  6538. if (alpha < 127 && this._sliceLeft > -1) {
  6539. this._sliceRight = x;
  6540. break;
  6541. }
  6542. }
  6543. // top and bottom
  6544. this._sliceTop = -1;
  6545. this._sliceBottom = -1;
  6546. for (var y = 0; y < height; y++) {
  6547. var alpha = imageData.data[y * width * 4 + 3];
  6548. if (alpha > 127 && this._sliceTop === -1) {
  6549. this._sliceTop = y;
  6550. continue;
  6551. }
  6552. if (alpha < 127 && this._sliceTop > -1) {
  6553. this._sliceBottom = y;
  6554. break;
  6555. }
  6556. }
  6557. };
  6558. Object.defineProperty(Image.prototype, "source", {
  6559. /**
  6560. * Gets or sets image source url
  6561. */
  6562. set: function (value) {
  6563. var _this = this;
  6564. if (this._source === value) {
  6565. return;
  6566. }
  6567. this._loaded = false;
  6568. this._source = value;
  6569. if (value) {
  6570. value = this._svgCheck(value);
  6571. }
  6572. this._domImage = document.createElement("img");
  6573. this._domImage.onload = function () {
  6574. _this._onImageLoaded();
  6575. };
  6576. if (value) {
  6577. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6578. this._domImage.src = value;
  6579. }
  6580. },
  6581. enumerable: true,
  6582. configurable: true
  6583. });
  6584. /**
  6585. * Checks for svg document with icon id present
  6586. */
  6587. Image.prototype._svgCheck = function (value) {
  6588. var _this = this;
  6589. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6590. var svgsrc = value.split('#')[0];
  6591. var elemid = value.split('#')[1];
  6592. // check if object alr exist in document
  6593. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6594. if (svgExist) {
  6595. var svgDoc = svgExist.contentDocument;
  6596. // get viewbox width and height, get svg document width and height in px
  6597. if (svgDoc && svgDoc.documentElement) {
  6598. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6599. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6600. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6601. if (vb && docwidth && docheight) {
  6602. this._getSVGAttribs(svgExist, elemid);
  6603. return value;
  6604. }
  6605. }
  6606. // wait for object to load
  6607. svgExist.addEventListener("load", function () {
  6608. _this._getSVGAttribs(svgExist, elemid);
  6609. });
  6610. }
  6611. else {
  6612. // create document object
  6613. var svgImage = document.createElement("object");
  6614. svgImage.data = svgsrc;
  6615. svgImage.type = "image/svg+xml";
  6616. svgImage.width = "0%";
  6617. svgImage.height = "0%";
  6618. document.body.appendChild(svgImage);
  6619. // when the object has loaded, get the element attribs
  6620. svgImage.onload = function () {
  6621. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6622. if (svgobj) {
  6623. _this._getSVGAttribs(svgobj, elemid);
  6624. }
  6625. };
  6626. }
  6627. return svgsrc;
  6628. }
  6629. else {
  6630. return value;
  6631. }
  6632. };
  6633. /**
  6634. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6635. * given external svg file and icon id
  6636. */
  6637. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6638. var svgDoc = svgsrc.contentDocument;
  6639. // get viewbox width and height, get svg document width and height in px
  6640. if (svgDoc && svgDoc.documentElement) {
  6641. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6642. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6643. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6644. // get element bbox and matrix transform
  6645. var elem = svgDoc.getElementById(elemid);
  6646. if (vb && docwidth && docheight) {
  6647. var vb_width = Number(vb.split(" ")[2]);
  6648. var vb_height = Number(vb.split(" ")[3]);
  6649. var elem_bbox = elem.getBBox();
  6650. var elem_matrix_a = 1;
  6651. var elem_matrix_d = 1;
  6652. var elem_matrix_e = 0;
  6653. var elem_matrix_f = 0;
  6654. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6655. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6656. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6657. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6658. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6659. }
  6660. // compute source coordinates and dimensions
  6661. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6662. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6663. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6664. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6665. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6666. }
  6667. }
  6668. };
  6669. Object.defineProperty(Image.prototype, "cellWidth", {
  6670. /**
  6671. * Gets or sets the cell width to use when animation sheet is enabled
  6672. * @see http://doc.babylonjs.com/how_to/gui#image
  6673. */
  6674. get: function () {
  6675. return this._cellWidth;
  6676. },
  6677. set: function (value) {
  6678. if (this._cellWidth === value) {
  6679. return;
  6680. }
  6681. this._cellWidth = value;
  6682. this._markAsDirty();
  6683. },
  6684. enumerable: true,
  6685. configurable: true
  6686. });
  6687. Object.defineProperty(Image.prototype, "cellHeight", {
  6688. /**
  6689. * Gets or sets the cell height to use when animation sheet is enabled
  6690. * @see http://doc.babylonjs.com/how_to/gui#image
  6691. */
  6692. get: function () {
  6693. return this._cellHeight;
  6694. },
  6695. set: function (value) {
  6696. if (this._cellHeight === value) {
  6697. return;
  6698. }
  6699. this._cellHeight = value;
  6700. this._markAsDirty();
  6701. },
  6702. enumerable: true,
  6703. configurable: true
  6704. });
  6705. Object.defineProperty(Image.prototype, "cellId", {
  6706. /**
  6707. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6708. * @see http://doc.babylonjs.com/how_to/gui#image
  6709. */
  6710. get: function () {
  6711. return this._cellId;
  6712. },
  6713. set: function (value) {
  6714. if (this._cellId === value) {
  6715. return;
  6716. }
  6717. this._cellId = value;
  6718. this._markAsDirty();
  6719. },
  6720. enumerable: true,
  6721. configurable: true
  6722. });
  6723. /**
  6724. * Tests if a given coordinates belong to the current control
  6725. * @param x defines x coordinate to test
  6726. * @param y defines y coordinate to test
  6727. * @returns true if the coordinates are inside the control
  6728. */
  6729. Image.prototype.contains = function (x, y) {
  6730. if (!_super.prototype.contains.call(this, x, y)) {
  6731. return false;
  6732. }
  6733. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6734. return true;
  6735. }
  6736. var canvas = this._workingCanvas;
  6737. var context = canvas.getContext("2d");
  6738. var width = this._currentMeasure.width | 0;
  6739. var height = this._currentMeasure.height | 0;
  6740. var imageData = context.getImageData(0, 0, width, height).data;
  6741. x = (x - this._currentMeasure.left) | 0;
  6742. y = (y - this._currentMeasure.top) | 0;
  6743. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6744. return pickedPixel > 0;
  6745. };
  6746. Image.prototype._getTypeName = function () {
  6747. return "Image";
  6748. };
  6749. /** Force the control to synchronize with its content */
  6750. Image.prototype.synchronizeSizeWithContent = function () {
  6751. if (!this._loaded) {
  6752. return;
  6753. }
  6754. this.width = this._domImage.width + "px";
  6755. this.height = this._domImage.height + "px";
  6756. };
  6757. Image.prototype._processMeasures = function (parentMeasure, context) {
  6758. if (this._loaded) {
  6759. switch (this._stretch) {
  6760. case Image.STRETCH_NONE:
  6761. break;
  6762. case Image.STRETCH_FILL:
  6763. break;
  6764. case Image.STRETCH_UNIFORM:
  6765. break;
  6766. case Image.STRETCH_NINE_PATCH:
  6767. break;
  6768. case Image.STRETCH_EXTEND:
  6769. if (this._autoScale) {
  6770. this.synchronizeSizeWithContent();
  6771. }
  6772. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6773. this.parent.adaptWidthToChildren = true;
  6774. this.parent.adaptHeightToChildren = true;
  6775. }
  6776. break;
  6777. }
  6778. }
  6779. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6780. };
  6781. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6782. if (!this._detectPointerOnOpaqueOnly) {
  6783. return;
  6784. }
  6785. if (!this._workingCanvas) {
  6786. this._workingCanvas = document.createElement('canvas');
  6787. }
  6788. var canvas = this._workingCanvas;
  6789. var width = this._currentMeasure.width;
  6790. var height = this._currentMeasure.height;
  6791. var context = canvas.getContext("2d");
  6792. canvas.width = width;
  6793. canvas.height = height;
  6794. context.clearRect(0, 0, width, height);
  6795. };
  6796. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6797. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6798. if (!this._detectPointerOnOpaqueOnly) {
  6799. return;
  6800. }
  6801. var canvas = this._workingCanvas;
  6802. context = canvas.getContext("2d");
  6803. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6804. };
  6805. Image.prototype._draw = function (context) {
  6806. context.save();
  6807. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6808. context.shadowColor = this.shadowColor;
  6809. context.shadowBlur = this.shadowBlur;
  6810. context.shadowOffsetX = this.shadowOffsetX;
  6811. context.shadowOffsetY = this.shadowOffsetY;
  6812. }
  6813. var x, y, width, height;
  6814. if (this.cellId == -1) {
  6815. x = this._sourceLeft;
  6816. y = this._sourceTop;
  6817. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6818. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6819. }
  6820. else {
  6821. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6822. var column = (this.cellId / rowCount) >> 0;
  6823. var row = this.cellId % rowCount;
  6824. x = this.cellWidth * row;
  6825. y = this.cellHeight * column;
  6826. width = this.cellWidth;
  6827. height = this.cellHeight;
  6828. }
  6829. this._prepareWorkingCanvasForOpaqueDetection();
  6830. this._applyStates(context);
  6831. if (this._loaded) {
  6832. switch (this._stretch) {
  6833. case Image.STRETCH_NONE:
  6834. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6835. break;
  6836. case Image.STRETCH_FILL:
  6837. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6838. break;
  6839. case Image.STRETCH_UNIFORM:
  6840. var hRatio = this._currentMeasure.width / width;
  6841. var vRatio = this._currentMeasure.height / height;
  6842. var ratio = Math.min(hRatio, vRatio);
  6843. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6844. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6845. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6846. break;
  6847. case Image.STRETCH_EXTEND:
  6848. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6849. break;
  6850. case Image.STRETCH_NINE_PATCH:
  6851. this._renderNinePatch(context);
  6852. break;
  6853. }
  6854. }
  6855. context.restore();
  6856. };
  6857. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6858. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6859. };
  6860. Image.prototype._renderNinePatch = function (context) {
  6861. var height = this._imageHeight;
  6862. var leftWidth = this._sliceLeft;
  6863. var topHeight = this._sliceTop;
  6864. var bottomHeight = this._imageHeight - this._sliceBottom;
  6865. var rightWidth = this._imageWidth - this._sliceRight;
  6866. var left = 0;
  6867. var top = 0;
  6868. if (this._populateNinePatchSlicesFromImage) {
  6869. left = 1;
  6870. top = 1;
  6871. height -= 2;
  6872. leftWidth -= 1;
  6873. topHeight -= 1;
  6874. bottomHeight -= 1;
  6875. rightWidth -= 1;
  6876. }
  6877. var centerWidth = this._sliceRight - this._sliceLeft;
  6878. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft;
  6879. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6880. // Corners
  6881. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6882. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6883. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6884. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6885. // Center
  6886. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight);
  6887. // Borders
  6888. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6889. 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);
  6890. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6891. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6892. };
  6893. Image.prototype.dispose = function () {
  6894. _super.prototype.dispose.call(this);
  6895. this.onImageLoadedObservable.clear();
  6896. this.onSVGAttributesComputedObservable.clear();
  6897. };
  6898. // Static
  6899. /** STRETCH_NONE */
  6900. Image.STRETCH_NONE = 0;
  6901. /** STRETCH_FILL */
  6902. Image.STRETCH_FILL = 1;
  6903. /** STRETCH_UNIFORM */
  6904. Image.STRETCH_UNIFORM = 2;
  6905. /** STRETCH_EXTEND */
  6906. Image.STRETCH_EXTEND = 3;
  6907. /** NINE_PATCH */
  6908. Image.STRETCH_NINE_PATCH = 4;
  6909. return Image;
  6910. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6911. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  6912. /***/ }),
  6913. /***/ "./2D/controls/index.ts":
  6914. /*!******************************!*\
  6915. !*** ./2D/controls/index.ts ***!
  6916. \******************************/
  6917. /*! 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 */
  6918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6919. "use strict";
  6920. __webpack_require__.r(__webpack_exports__);
  6921. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6923. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6925. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6927. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6929. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6931. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6933. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6935. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6937. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6939. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6941. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6943. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6945. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6947. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6949. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6955. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6957. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6960. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6963. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6965. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6967. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6969. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6971. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6973. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6975. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  6976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__["ImageScrollBar"]; });
  6977. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_25__["name"]; });
  6979. /***/ }),
  6980. /***/ "./2D/controls/inputPassword.ts":
  6981. /*!**************************************!*\
  6982. !*** ./2D/controls/inputPassword.ts ***!
  6983. \**************************************/
  6984. /*! exports provided: InputPassword */
  6985. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6986. "use strict";
  6987. __webpack_require__.r(__webpack_exports__);
  6988. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6989. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6990. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6991. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  6992. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  6993. /**
  6994. * Class used to create a password control
  6995. */
  6996. var InputPassword = /** @class */ (function (_super) {
  6997. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  6998. function InputPassword() {
  6999. return _super !== null && _super.apply(this, arguments) || this;
  7000. }
  7001. InputPassword.prototype._beforeRenderText = function (text) {
  7002. var txt = "";
  7003. for (var i = 0; i < text.length; i++) {
  7004. txt += "\u2022";
  7005. }
  7006. return txt;
  7007. };
  7008. return InputPassword;
  7009. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  7010. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  7011. /***/ }),
  7012. /***/ "./2D/controls/inputText.ts":
  7013. /*!**********************************!*\
  7014. !*** ./2D/controls/inputText.ts ***!
  7015. \**********************************/
  7016. /*! exports provided: InputText */
  7017. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7018. "use strict";
  7019. __webpack_require__.r(__webpack_exports__);
  7020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  7021. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7022. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  7023. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  7024. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7025. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7026. /**
  7027. * Class used to create input text control
  7028. */
  7029. var InputText = /** @class */ (function (_super) {
  7030. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7031. /**
  7032. * Creates a new InputText
  7033. * @param name defines the control name
  7034. * @param text defines the text of the control
  7035. */
  7036. function InputText(name, text) {
  7037. if (text === void 0) { text = ""; }
  7038. var _this = _super.call(this, name) || this;
  7039. _this.name = name;
  7040. _this._text = "";
  7041. _this._placeholderText = "";
  7042. _this._background = "#222222";
  7043. _this._focusedBackground = "#000000";
  7044. _this._focusedColor = "white";
  7045. _this._placeholderColor = "gray";
  7046. _this._thickness = 1;
  7047. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7048. _this._autoStretchWidth = true;
  7049. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7050. _this._isFocused = false;
  7051. _this._blinkIsEven = false;
  7052. _this._cursorOffset = 0;
  7053. _this._deadKey = false;
  7054. _this._addKey = true;
  7055. _this._currentKey = "";
  7056. _this._isTextHighlightOn = false;
  7057. _this._textHighlightColor = "#d5e0ff";
  7058. _this._highligherOpacity = 0.4;
  7059. _this._highlightedText = "";
  7060. _this._startHighlightIndex = 0;
  7061. _this._endHighlightIndex = 0;
  7062. _this._cursorIndex = -1;
  7063. _this._onFocusSelectAll = false;
  7064. _this._isPointerDown = false;
  7065. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7066. _this.promptMessage = "Please enter text:";
  7067. /** Force disable prompt on mobile device */
  7068. _this.disableMobilePrompt = false;
  7069. /** Observable raised when the text changes */
  7070. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7071. /** Observable raised just before an entered character is to be added */
  7072. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7073. /** Observable raised when the control gets the focus */
  7074. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7075. /** Observable raised when the control loses the focus */
  7076. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7077. /**Observable raised when the text is highlighted */
  7078. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7079. /**Observable raised when copy event is triggered */
  7080. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7081. /** Observable raised when cut event is triggered */
  7082. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7083. /** Observable raised when paste event is triggered */
  7084. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7085. /** Observable raised when a key event was processed */
  7086. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7087. _this.text = text;
  7088. _this.isPointerBlocker = true;
  7089. return _this;
  7090. }
  7091. Object.defineProperty(InputText.prototype, "maxWidth", {
  7092. /** Gets or sets the maximum width allowed by the control */
  7093. get: function () {
  7094. return this._maxWidth.toString(this._host);
  7095. },
  7096. set: function (value) {
  7097. if (this._maxWidth.toString(this._host) === value) {
  7098. return;
  7099. }
  7100. if (this._maxWidth.fromString(value)) {
  7101. this._markAsDirty();
  7102. }
  7103. },
  7104. enumerable: true,
  7105. configurable: true
  7106. });
  7107. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7108. /** Gets the maximum width allowed by the control in pixels */
  7109. get: function () {
  7110. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7111. },
  7112. enumerable: true,
  7113. configurable: true
  7114. });
  7115. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7116. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7117. get: function () {
  7118. return this._highligherOpacity;
  7119. },
  7120. set: function (value) {
  7121. if (this._highligherOpacity === value) {
  7122. return;
  7123. }
  7124. this._highligherOpacity = value;
  7125. this._markAsDirty();
  7126. },
  7127. enumerable: true,
  7128. configurable: true
  7129. });
  7130. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7131. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7132. get: function () {
  7133. return this._onFocusSelectAll;
  7134. },
  7135. set: function (value) {
  7136. if (this._onFocusSelectAll === value) {
  7137. return;
  7138. }
  7139. this._onFocusSelectAll = value;
  7140. this._markAsDirty();
  7141. },
  7142. enumerable: true,
  7143. configurable: true
  7144. });
  7145. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7146. /** Gets or sets the text hightlight color */
  7147. get: function () {
  7148. return this._textHighlightColor;
  7149. },
  7150. set: function (value) {
  7151. if (this._textHighlightColor === value) {
  7152. return;
  7153. }
  7154. this._textHighlightColor = value;
  7155. this._markAsDirty();
  7156. },
  7157. enumerable: true,
  7158. configurable: true
  7159. });
  7160. Object.defineProperty(InputText.prototype, "margin", {
  7161. /** Gets or sets control margin */
  7162. get: function () {
  7163. return this._margin.toString(this._host);
  7164. },
  7165. set: function (value) {
  7166. if (this._margin.toString(this._host) === value) {
  7167. return;
  7168. }
  7169. if (this._margin.fromString(value)) {
  7170. this._markAsDirty();
  7171. }
  7172. },
  7173. enumerable: true,
  7174. configurable: true
  7175. });
  7176. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7177. /** Gets control margin in pixels */
  7178. get: function () {
  7179. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7180. },
  7181. enumerable: true,
  7182. configurable: true
  7183. });
  7184. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7185. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7186. get: function () {
  7187. return this._autoStretchWidth;
  7188. },
  7189. set: function (value) {
  7190. if (this._autoStretchWidth === value) {
  7191. return;
  7192. }
  7193. this._autoStretchWidth = value;
  7194. this._markAsDirty();
  7195. },
  7196. enumerable: true,
  7197. configurable: true
  7198. });
  7199. Object.defineProperty(InputText.prototype, "thickness", {
  7200. /** Gets or sets border thickness */
  7201. get: function () {
  7202. return this._thickness;
  7203. },
  7204. set: function (value) {
  7205. if (this._thickness === value) {
  7206. return;
  7207. }
  7208. this._thickness = value;
  7209. this._markAsDirty();
  7210. },
  7211. enumerable: true,
  7212. configurable: true
  7213. });
  7214. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7215. /** Gets or sets the background color when focused */
  7216. get: function () {
  7217. return this._focusedBackground;
  7218. },
  7219. set: function (value) {
  7220. if (this._focusedBackground === value) {
  7221. return;
  7222. }
  7223. this._focusedBackground = value;
  7224. this._markAsDirty();
  7225. },
  7226. enumerable: true,
  7227. configurable: true
  7228. });
  7229. Object.defineProperty(InputText.prototype, "focusedColor", {
  7230. /** Gets or sets the background color when focused */
  7231. get: function () {
  7232. return this._focusedColor;
  7233. },
  7234. set: function (value) {
  7235. if (this._focusedColor === value) {
  7236. return;
  7237. }
  7238. this._focusedColor = value;
  7239. this._markAsDirty();
  7240. },
  7241. enumerable: true,
  7242. configurable: true
  7243. });
  7244. Object.defineProperty(InputText.prototype, "background", {
  7245. /** Gets or sets the background color */
  7246. get: function () {
  7247. return this._background;
  7248. },
  7249. set: function (value) {
  7250. if (this._background === value) {
  7251. return;
  7252. }
  7253. this._background = value;
  7254. this._markAsDirty();
  7255. },
  7256. enumerable: true,
  7257. configurable: true
  7258. });
  7259. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7260. /** Gets or sets the placeholder color */
  7261. get: function () {
  7262. return this._placeholderColor;
  7263. },
  7264. set: function (value) {
  7265. if (this._placeholderColor === value) {
  7266. return;
  7267. }
  7268. this._placeholderColor = value;
  7269. this._markAsDirty();
  7270. },
  7271. enumerable: true,
  7272. configurable: true
  7273. });
  7274. Object.defineProperty(InputText.prototype, "placeholderText", {
  7275. /** Gets or sets the text displayed when the control is empty */
  7276. get: function () {
  7277. return this._placeholderText;
  7278. },
  7279. set: function (value) {
  7280. if (this._placeholderText === value) {
  7281. return;
  7282. }
  7283. this._placeholderText = value;
  7284. this._markAsDirty();
  7285. },
  7286. enumerable: true,
  7287. configurable: true
  7288. });
  7289. Object.defineProperty(InputText.prototype, "deadKey", {
  7290. /** Gets or sets the dead key flag */
  7291. get: function () {
  7292. return this._deadKey;
  7293. },
  7294. set: function (flag) {
  7295. this._deadKey = flag;
  7296. },
  7297. enumerable: true,
  7298. configurable: true
  7299. });
  7300. Object.defineProperty(InputText.prototype, "highlightedText", {
  7301. /** Gets or sets the highlight text */
  7302. get: function () {
  7303. return this._highlightedText;
  7304. },
  7305. set: function (text) {
  7306. if (this._highlightedText === text) {
  7307. return;
  7308. }
  7309. this._highlightedText = text;
  7310. this._markAsDirty();
  7311. },
  7312. enumerable: true,
  7313. configurable: true
  7314. });
  7315. Object.defineProperty(InputText.prototype, "addKey", {
  7316. /** Gets or sets if the current key should be added */
  7317. get: function () {
  7318. return this._addKey;
  7319. },
  7320. set: function (flag) {
  7321. this._addKey = flag;
  7322. },
  7323. enumerable: true,
  7324. configurable: true
  7325. });
  7326. Object.defineProperty(InputText.prototype, "currentKey", {
  7327. /** Gets or sets the value of the current key being entered */
  7328. get: function () {
  7329. return this._currentKey;
  7330. },
  7331. set: function (key) {
  7332. this._currentKey = key;
  7333. },
  7334. enumerable: true,
  7335. configurable: true
  7336. });
  7337. Object.defineProperty(InputText.prototype, "text", {
  7338. /** Gets or sets the text displayed in the control */
  7339. get: function () {
  7340. return this._text;
  7341. },
  7342. set: function (value) {
  7343. var valueAsString = value.toString(); // Forcing convertion
  7344. if (this._text === valueAsString) {
  7345. return;
  7346. }
  7347. this._text = valueAsString;
  7348. this._markAsDirty();
  7349. this.onTextChangedObservable.notifyObservers(this);
  7350. },
  7351. enumerable: true,
  7352. configurable: true
  7353. });
  7354. Object.defineProperty(InputText.prototype, "width", {
  7355. /** Gets or sets control width */
  7356. get: function () {
  7357. return this._width.toString(this._host);
  7358. },
  7359. set: function (value) {
  7360. if (this._width.toString(this._host) === value) {
  7361. return;
  7362. }
  7363. if (this._width.fromString(value)) {
  7364. this._markAsDirty();
  7365. }
  7366. this.autoStretchWidth = false;
  7367. },
  7368. enumerable: true,
  7369. configurable: true
  7370. });
  7371. /** @hidden */
  7372. InputText.prototype.onBlur = function () {
  7373. this._isFocused = false;
  7374. this._scrollLeft = null;
  7375. this._cursorOffset = 0;
  7376. clearTimeout(this._blinkTimeout);
  7377. this._markAsDirty();
  7378. this.onBlurObservable.notifyObservers(this);
  7379. this._host.unRegisterClipboardEvents();
  7380. if (this._onClipboardObserver) {
  7381. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7382. }
  7383. var scene = this._host.getScene();
  7384. if (this._onPointerDblTapObserver && scene) {
  7385. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7386. }
  7387. };
  7388. /** @hidden */
  7389. InputText.prototype.onFocus = function () {
  7390. var _this = this;
  7391. if (!this._isEnabled) {
  7392. return;
  7393. }
  7394. this._scrollLeft = null;
  7395. this._isFocused = true;
  7396. this._blinkIsEven = false;
  7397. this._cursorOffset = 0;
  7398. this._markAsDirty();
  7399. this.onFocusObservable.notifyObservers(this);
  7400. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7401. var value = prompt(this.promptMessage);
  7402. if (value !== null) {
  7403. this.text = value;
  7404. }
  7405. this._host.focusedControl = null;
  7406. return;
  7407. }
  7408. this._host.registerClipboardEvents();
  7409. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7410. // process clipboard event, can be configured.
  7411. switch (clipboardInfo.type) {
  7412. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7413. _this._onCopyText(clipboardInfo.event);
  7414. _this.onTextCopyObservable.notifyObservers(_this);
  7415. break;
  7416. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7417. _this._onCutText(clipboardInfo.event);
  7418. _this.onTextCutObservable.notifyObservers(_this);
  7419. break;
  7420. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7421. _this._onPasteText(clipboardInfo.event);
  7422. _this.onTextPasteObservable.notifyObservers(_this);
  7423. break;
  7424. default: return;
  7425. }
  7426. });
  7427. var scene = this._host.getScene();
  7428. if (scene) {
  7429. //register the pointer double tap event
  7430. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7431. if (!_this._isFocused) {
  7432. return;
  7433. }
  7434. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7435. _this._processDblClick(pointerInfo);
  7436. }
  7437. });
  7438. }
  7439. if (this._onFocusSelectAll) {
  7440. this._selectAllText();
  7441. }
  7442. };
  7443. InputText.prototype._getTypeName = function () {
  7444. return "InputText";
  7445. };
  7446. /**
  7447. * Function called to get the list of controls that should not steal the focus from this control
  7448. * @returns an array of controls
  7449. */
  7450. InputText.prototype.keepsFocusWith = function () {
  7451. if (!this._connectedVirtualKeyboard) {
  7452. return null;
  7453. }
  7454. return [this._connectedVirtualKeyboard];
  7455. };
  7456. /** @hidden */
  7457. InputText.prototype.processKey = function (keyCode, key, evt) {
  7458. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7459. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7460. return;
  7461. }
  7462. //select all
  7463. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7464. this._selectAllText();
  7465. evt.preventDefault();
  7466. return;
  7467. }
  7468. // Specific cases
  7469. switch (keyCode) {
  7470. case 32: //SPACE
  7471. key = " "; //ie11 key for space is "Spacebar"
  7472. break;
  7473. case 191: //SLASH
  7474. if (evt) {
  7475. evt.preventDefault();
  7476. }
  7477. break;
  7478. case 8: // BACKSPACE
  7479. if (this._text && this._text.length > 0) {
  7480. //delete the highlighted text
  7481. if (this._isTextHighlightOn) {
  7482. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7483. this._isTextHighlightOn = false;
  7484. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7485. this._blinkIsEven = false;
  7486. if (evt) {
  7487. evt.preventDefault();
  7488. }
  7489. return;
  7490. }
  7491. //delete single character
  7492. if (this._cursorOffset === 0) {
  7493. this.text = this._text.substr(0, this._text.length - 1);
  7494. }
  7495. else {
  7496. var deletePosition = this._text.length - this._cursorOffset;
  7497. if (deletePosition > 0) {
  7498. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7499. }
  7500. }
  7501. }
  7502. if (evt) {
  7503. evt.preventDefault();
  7504. }
  7505. return;
  7506. case 46: // DELETE
  7507. if (this._isTextHighlightOn) {
  7508. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7509. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7510. while (decrementor > 0 && this._cursorOffset > 0) {
  7511. this._cursorOffset--;
  7512. }
  7513. this._isTextHighlightOn = false;
  7514. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7515. if (evt) {
  7516. evt.preventDefault();
  7517. }
  7518. return;
  7519. }
  7520. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7521. var deletePosition = this._text.length - this._cursorOffset;
  7522. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7523. this._cursorOffset--;
  7524. }
  7525. if (evt) {
  7526. evt.preventDefault();
  7527. }
  7528. return;
  7529. case 13: // RETURN
  7530. this._host.focusedControl = null;
  7531. this._isTextHighlightOn = false;
  7532. return;
  7533. case 35: // END
  7534. this._cursorOffset = 0;
  7535. this._blinkIsEven = false;
  7536. this._isTextHighlightOn = false;
  7537. this._markAsDirty();
  7538. return;
  7539. case 36: // HOME
  7540. this._cursorOffset = this._text.length;
  7541. this._blinkIsEven = false;
  7542. this._isTextHighlightOn = false;
  7543. this._markAsDirty();
  7544. return;
  7545. case 37: // LEFT
  7546. this._cursorOffset++;
  7547. if (this._cursorOffset > this._text.length) {
  7548. this._cursorOffset = this._text.length;
  7549. }
  7550. if (evt && evt.shiftKey) {
  7551. // update the cursor
  7552. this._blinkIsEven = false;
  7553. // shift + ctrl/cmd + <-
  7554. if (evt.ctrlKey || evt.metaKey) {
  7555. if (!this._isTextHighlightOn) {
  7556. if (this._text.length === this._cursorOffset) {
  7557. return;
  7558. }
  7559. else {
  7560. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7561. }
  7562. }
  7563. this._startHighlightIndex = 0;
  7564. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7565. this._cursorOffset = this._text.length;
  7566. this._isTextHighlightOn = true;
  7567. this._markAsDirty();
  7568. return;
  7569. }
  7570. //store the starting point
  7571. if (!this._isTextHighlightOn) {
  7572. this._isTextHighlightOn = true;
  7573. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7574. }
  7575. //if text is already highlighted
  7576. else if (this._cursorIndex === -1) {
  7577. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7578. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7579. }
  7580. //set the highlight indexes
  7581. if (this._cursorIndex < this._cursorOffset) {
  7582. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7583. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7584. }
  7585. else if (this._cursorIndex > this._cursorOffset) {
  7586. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7587. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7588. }
  7589. else {
  7590. this._isTextHighlightOn = false;
  7591. }
  7592. this._markAsDirty();
  7593. return;
  7594. }
  7595. if (this._isTextHighlightOn) {
  7596. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7597. this._isTextHighlightOn = false;
  7598. }
  7599. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7600. this._cursorOffset = this.text.length;
  7601. evt.preventDefault();
  7602. }
  7603. this._blinkIsEven = false;
  7604. this._isTextHighlightOn = false;
  7605. this._cursorIndex = -1;
  7606. this._markAsDirty();
  7607. return;
  7608. case 39: // RIGHT
  7609. this._cursorOffset--;
  7610. if (this._cursorOffset < 0) {
  7611. this._cursorOffset = 0;
  7612. }
  7613. if (evt && evt.shiftKey) {
  7614. //update the cursor
  7615. this._blinkIsEven = false;
  7616. //shift + ctrl/cmd + ->
  7617. if (evt.ctrlKey || evt.metaKey) {
  7618. if (!this._isTextHighlightOn) {
  7619. if (this._cursorOffset === 0) {
  7620. return;
  7621. }
  7622. else {
  7623. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7624. }
  7625. }
  7626. this._endHighlightIndex = this._text.length;
  7627. this._isTextHighlightOn = true;
  7628. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7629. this._cursorOffset = 0;
  7630. this._markAsDirty();
  7631. return;
  7632. }
  7633. if (!this._isTextHighlightOn) {
  7634. this._isTextHighlightOn = true;
  7635. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7636. }
  7637. //if text is already highlighted
  7638. else if (this._cursorIndex === -1) {
  7639. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7640. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7641. }
  7642. //set the highlight indexes
  7643. if (this._cursorIndex < this._cursorOffset) {
  7644. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7645. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7646. }
  7647. else if (this._cursorIndex > this._cursorOffset) {
  7648. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7649. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7650. }
  7651. else {
  7652. this._isTextHighlightOn = false;
  7653. }
  7654. this._markAsDirty();
  7655. return;
  7656. }
  7657. if (this._isTextHighlightOn) {
  7658. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7659. this._isTextHighlightOn = false;
  7660. }
  7661. //ctr + ->
  7662. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7663. this._cursorOffset = 0;
  7664. evt.preventDefault();
  7665. }
  7666. this._blinkIsEven = false;
  7667. this._isTextHighlightOn = false;
  7668. this._cursorIndex = -1;
  7669. this._markAsDirty();
  7670. return;
  7671. case 222: // Dead
  7672. if (evt) {
  7673. evt.preventDefault();
  7674. }
  7675. this._cursorIndex = -1;
  7676. this.deadKey = true;
  7677. break;
  7678. }
  7679. // Printable characters
  7680. if (key &&
  7681. ((keyCode === -1) || // Direct access
  7682. (keyCode === 32) || // Space
  7683. (keyCode > 47 && keyCode < 64) || // Numbers
  7684. (keyCode > 64 && keyCode < 91) || // Letters
  7685. (keyCode > 159 && keyCode < 193) || // Special characters
  7686. (keyCode > 218 && keyCode < 223) || // Special characters
  7687. (keyCode > 95 && keyCode < 112))) { // Numpad
  7688. this._currentKey = key;
  7689. this.onBeforeKeyAddObservable.notifyObservers(this);
  7690. key = this._currentKey;
  7691. if (this._addKey) {
  7692. if (this._isTextHighlightOn) {
  7693. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7694. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7695. this._isTextHighlightOn = false;
  7696. this._blinkIsEven = false;
  7697. this._markAsDirty();
  7698. }
  7699. else if (this._cursorOffset === 0) {
  7700. this.text += key;
  7701. }
  7702. else {
  7703. var insertPosition = this._text.length - this._cursorOffset;
  7704. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7705. }
  7706. }
  7707. }
  7708. };
  7709. /** @hidden */
  7710. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7711. //update the cursor
  7712. this._blinkIsEven = false;
  7713. if (this._cursorIndex === -1) {
  7714. this._cursorIndex = offset;
  7715. }
  7716. else {
  7717. if (this._cursorIndex < this._cursorOffset) {
  7718. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7719. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7720. }
  7721. else if (this._cursorIndex > this._cursorOffset) {
  7722. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7723. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7724. }
  7725. else {
  7726. this._isTextHighlightOn = false;
  7727. this._markAsDirty();
  7728. return;
  7729. }
  7730. }
  7731. this._isTextHighlightOn = true;
  7732. this._markAsDirty();
  7733. };
  7734. /** @hidden */
  7735. InputText.prototype._processDblClick = function (evt) {
  7736. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7737. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7738. this._endHighlightIndex = this._startHighlightIndex;
  7739. var rWord = /\w+/g, moveLeft, moveRight;
  7740. do {
  7741. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7742. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7743. } while (moveLeft || moveRight);
  7744. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7745. this.onTextHighlightObservable.notifyObservers(this);
  7746. this._isTextHighlightOn = true;
  7747. this._clickedCoordinate = null;
  7748. this._blinkIsEven = true;
  7749. this._cursorIndex = -1;
  7750. this._markAsDirty();
  7751. };
  7752. /** @hidden */
  7753. InputText.prototype._selectAllText = function () {
  7754. this._blinkIsEven = true;
  7755. this._isTextHighlightOn = true;
  7756. this._startHighlightIndex = 0;
  7757. this._endHighlightIndex = this._text.length;
  7758. this._cursorOffset = this._text.length;
  7759. this._cursorIndex = -1;
  7760. this._markAsDirty();
  7761. };
  7762. /**
  7763. * Handles the keyboard event
  7764. * @param evt Defines the KeyboardEvent
  7765. */
  7766. InputText.prototype.processKeyboard = function (evt) {
  7767. // process pressed key
  7768. this.processKey(evt.keyCode, evt.key, evt);
  7769. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7770. };
  7771. /** @hidden */
  7772. InputText.prototype._onCopyText = function (ev) {
  7773. this._isTextHighlightOn = false;
  7774. //when write permission to clipbaord data is denied
  7775. try {
  7776. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7777. }
  7778. catch (_a) { } //pass
  7779. this._host.clipboardData = this._highlightedText;
  7780. };
  7781. /** @hidden */
  7782. InputText.prototype._onCutText = function (ev) {
  7783. if (!this._highlightedText) {
  7784. return;
  7785. }
  7786. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7787. this._isTextHighlightOn = false;
  7788. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7789. //when write permission to clipbaord data is denied
  7790. try {
  7791. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7792. }
  7793. catch (_a) { } //pass
  7794. this._host.clipboardData = this._highlightedText;
  7795. this._highlightedText = "";
  7796. };
  7797. /** @hidden */
  7798. InputText.prototype._onPasteText = function (ev) {
  7799. var data = "";
  7800. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7801. data = ev.clipboardData.getData("text/plain");
  7802. }
  7803. else {
  7804. //get the cached data; returns blank string by default
  7805. data = this._host.clipboardData;
  7806. }
  7807. var insertPosition = this._text.length - this._cursorOffset;
  7808. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7809. };
  7810. InputText.prototype._draw = function (context, invalidatedRectangle) {
  7811. var _this = this;
  7812. context.save();
  7813. this._applyStates(context);
  7814. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7815. context.shadowColor = this.shadowColor;
  7816. context.shadowBlur = this.shadowBlur;
  7817. context.shadowOffsetX = this.shadowOffsetX;
  7818. context.shadowOffsetY = this.shadowOffsetY;
  7819. }
  7820. // Background
  7821. if (this._isFocused) {
  7822. if (this._focusedBackground) {
  7823. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7824. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7825. }
  7826. }
  7827. else if (this._background) {
  7828. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7829. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7830. }
  7831. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7832. context.shadowBlur = 0;
  7833. context.shadowOffsetX = 0;
  7834. context.shadowOffsetY = 0;
  7835. }
  7836. if (!this._fontOffset) {
  7837. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7838. }
  7839. // Text
  7840. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7841. if (this.color) {
  7842. context.fillStyle = this.color;
  7843. }
  7844. var text = this._beforeRenderText(this._text);
  7845. if (!this._isFocused && !this._text && this._placeholderText) {
  7846. text = this._placeholderText;
  7847. if (this._placeholderColor) {
  7848. context.fillStyle = this._placeholderColor;
  7849. }
  7850. }
  7851. this._textWidth = context.measureText(text).width;
  7852. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7853. if (this._autoStretchWidth) {
  7854. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7855. }
  7856. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7857. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7858. context.save();
  7859. context.beginPath();
  7860. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7861. context.clip();
  7862. if (this._isFocused && this._textWidth > availableWidth) {
  7863. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7864. if (!this._scrollLeft) {
  7865. this._scrollLeft = textLeft;
  7866. }
  7867. }
  7868. else {
  7869. this._scrollLeft = clipTextLeft;
  7870. }
  7871. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7872. // Cursor
  7873. if (this._isFocused) {
  7874. // Need to move cursor
  7875. if (this._clickedCoordinate) {
  7876. var rightPosition = this._scrollLeft + this._textWidth;
  7877. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7878. var currentSize = 0;
  7879. this._cursorOffset = 0;
  7880. var previousDist = 0;
  7881. do {
  7882. if (this._cursorOffset) {
  7883. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7884. }
  7885. this._cursorOffset++;
  7886. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7887. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7888. // Find closest move
  7889. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7890. this._cursorOffset--;
  7891. }
  7892. this._blinkIsEven = false;
  7893. this._clickedCoordinate = null;
  7894. }
  7895. // Render cursor
  7896. if (!this._blinkIsEven) {
  7897. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7898. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7899. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7900. if (cursorLeft < clipTextLeft) {
  7901. this._scrollLeft += (clipTextLeft - cursorLeft);
  7902. cursorLeft = clipTextLeft;
  7903. this._markAsDirty();
  7904. }
  7905. else if (cursorLeft > clipTextLeft + availableWidth) {
  7906. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7907. cursorLeft = clipTextLeft + availableWidth;
  7908. this._markAsDirty();
  7909. }
  7910. if (!this._isTextHighlightOn) {
  7911. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7912. }
  7913. }
  7914. clearTimeout(this._blinkTimeout);
  7915. this._blinkTimeout = setTimeout(function () {
  7916. _this._blinkIsEven = !_this._blinkIsEven;
  7917. _this._markAsDirty();
  7918. }, 500);
  7919. //show the highlighted text
  7920. if (this._isTextHighlightOn) {
  7921. clearTimeout(this._blinkTimeout);
  7922. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7923. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7924. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7925. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7926. if (highlightCursorLeft < clipTextLeft) {
  7927. width = width - (clipTextLeft - highlightCursorLeft);
  7928. if (!width) {
  7929. // when using left arrow on text.length > availableWidth;
  7930. // assigns the width of the first letter after clipTextLeft
  7931. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7932. }
  7933. highlightCursorLeft = clipTextLeft;
  7934. }
  7935. //for transparancy
  7936. context.globalAlpha = this._highligherOpacity;
  7937. context.fillStyle = this._textHighlightColor;
  7938. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7939. context.globalAlpha = 1.0;
  7940. }
  7941. }
  7942. context.restore();
  7943. // Border
  7944. if (this._thickness) {
  7945. if (this._isFocused) {
  7946. if (this.focusedColor) {
  7947. context.strokeStyle = this.focusedColor;
  7948. }
  7949. }
  7950. else {
  7951. if (this.color) {
  7952. context.strokeStyle = this.color;
  7953. }
  7954. }
  7955. context.lineWidth = this._thickness;
  7956. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7957. }
  7958. context.restore();
  7959. };
  7960. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7961. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7962. return false;
  7963. }
  7964. this._clickedCoordinate = coordinates.x;
  7965. this._isTextHighlightOn = false;
  7966. this._highlightedText = "";
  7967. this._cursorIndex = -1;
  7968. this._isPointerDown = true;
  7969. this._host._capturingControl[pointerId] = this;
  7970. if (this._host.focusedControl === this) {
  7971. // Move cursor
  7972. clearTimeout(this._blinkTimeout);
  7973. this._markAsDirty();
  7974. return true;
  7975. }
  7976. if (!this._isEnabled) {
  7977. return false;
  7978. }
  7979. this._host.focusedControl = this;
  7980. return true;
  7981. };
  7982. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7983. if (this._host.focusedControl === this && this._isPointerDown) {
  7984. this._clickedCoordinate = coordinates.x;
  7985. this._markAsDirty();
  7986. this._updateValueFromCursorIndex(this._cursorOffset);
  7987. }
  7988. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7989. };
  7990. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7991. this._isPointerDown = false;
  7992. delete this._host._capturingControl[pointerId];
  7993. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7994. };
  7995. InputText.prototype._beforeRenderText = function (text) {
  7996. return text;
  7997. };
  7998. InputText.prototype.dispose = function () {
  7999. _super.prototype.dispose.call(this);
  8000. this.onBlurObservable.clear();
  8001. this.onFocusObservable.clear();
  8002. this.onTextChangedObservable.clear();
  8003. this.onTextCopyObservable.clear();
  8004. this.onTextCutObservable.clear();
  8005. this.onTextPasteObservable.clear();
  8006. this.onTextHighlightObservable.clear();
  8007. this.onKeyboardEventProcessedObservable.clear();
  8008. };
  8009. return InputText;
  8010. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8011. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  8012. /***/ }),
  8013. /***/ "./2D/controls/line.ts":
  8014. /*!*****************************!*\
  8015. !*** ./2D/controls/line.ts ***!
  8016. \*****************************/
  8017. /*! exports provided: Line */
  8018. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8019. "use strict";
  8020. __webpack_require__.r(__webpack_exports__);
  8021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  8022. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8023. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  8024. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  8025. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8026. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  8027. /** Class used to render 2D lines */
  8028. var Line = /** @class */ (function (_super) {
  8029. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8030. /**
  8031. * Creates a new Line
  8032. * @param name defines the control name
  8033. */
  8034. function Line(name) {
  8035. var _this = _super.call(this, name) || this;
  8036. _this.name = name;
  8037. _this._lineWidth = 1;
  8038. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8039. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8040. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8041. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8042. _this._dash = new Array();
  8043. _this._automaticSize = true;
  8044. _this.isHitTestVisible = false;
  8045. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8046. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8047. return _this;
  8048. }
  8049. Object.defineProperty(Line.prototype, "dash", {
  8050. /** Gets or sets the dash pattern */
  8051. get: function () {
  8052. return this._dash;
  8053. },
  8054. set: function (value) {
  8055. if (this._dash === value) {
  8056. return;
  8057. }
  8058. this._dash = value;
  8059. this._markAsDirty();
  8060. },
  8061. enumerable: true,
  8062. configurable: true
  8063. });
  8064. Object.defineProperty(Line.prototype, "connectedControl", {
  8065. /** Gets or sets the control connected with the line end */
  8066. get: function () {
  8067. return this._connectedControl;
  8068. },
  8069. set: function (value) {
  8070. var _this = this;
  8071. if (this._connectedControl === value) {
  8072. return;
  8073. }
  8074. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8075. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8076. this._connectedControlDirtyObserver = null;
  8077. }
  8078. if (value) {
  8079. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8080. }
  8081. this._connectedControl = value;
  8082. this._markAsDirty();
  8083. },
  8084. enumerable: true,
  8085. configurable: true
  8086. });
  8087. Object.defineProperty(Line.prototype, "x1", {
  8088. /** Gets or sets start coordinates on X axis */
  8089. get: function () {
  8090. return this._x1.toString(this._host);
  8091. },
  8092. set: function (value) {
  8093. if (this._x1.toString(this._host) === value) {
  8094. return;
  8095. }
  8096. if (this._x1.fromString(value)) {
  8097. this._markAsDirty();
  8098. }
  8099. },
  8100. enumerable: true,
  8101. configurable: true
  8102. });
  8103. Object.defineProperty(Line.prototype, "y1", {
  8104. /** Gets or sets start coordinates on Y axis */
  8105. get: function () {
  8106. return this._y1.toString(this._host);
  8107. },
  8108. set: function (value) {
  8109. if (this._y1.toString(this._host) === value) {
  8110. return;
  8111. }
  8112. if (this._y1.fromString(value)) {
  8113. this._markAsDirty();
  8114. }
  8115. },
  8116. enumerable: true,
  8117. configurable: true
  8118. });
  8119. Object.defineProperty(Line.prototype, "x2", {
  8120. /** Gets or sets end coordinates on X axis */
  8121. get: function () {
  8122. return this._x2.toString(this._host);
  8123. },
  8124. set: function (value) {
  8125. if (this._x2.toString(this._host) === value) {
  8126. return;
  8127. }
  8128. if (this._x2.fromString(value)) {
  8129. this._markAsDirty();
  8130. }
  8131. },
  8132. enumerable: true,
  8133. configurable: true
  8134. });
  8135. Object.defineProperty(Line.prototype, "y2", {
  8136. /** Gets or sets end coordinates on Y axis */
  8137. get: function () {
  8138. return this._y2.toString(this._host);
  8139. },
  8140. set: function (value) {
  8141. if (this._y2.toString(this._host) === value) {
  8142. return;
  8143. }
  8144. if (this._y2.fromString(value)) {
  8145. this._markAsDirty();
  8146. }
  8147. },
  8148. enumerable: true,
  8149. configurable: true
  8150. });
  8151. Object.defineProperty(Line.prototype, "lineWidth", {
  8152. /** Gets or sets line width */
  8153. get: function () {
  8154. return this._lineWidth;
  8155. },
  8156. set: function (value) {
  8157. if (this._lineWidth === value) {
  8158. return;
  8159. }
  8160. this._lineWidth = value;
  8161. this._markAsDirty();
  8162. },
  8163. enumerable: true,
  8164. configurable: true
  8165. });
  8166. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8167. /** Gets or sets horizontal alignment */
  8168. set: function (value) {
  8169. return;
  8170. },
  8171. enumerable: true,
  8172. configurable: true
  8173. });
  8174. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8175. /** Gets or sets vertical alignment */
  8176. set: function (value) {
  8177. return;
  8178. },
  8179. enumerable: true,
  8180. configurable: true
  8181. });
  8182. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8183. get: function () {
  8184. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8185. },
  8186. enumerable: true,
  8187. configurable: true
  8188. });
  8189. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8190. get: function () {
  8191. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8192. },
  8193. enumerable: true,
  8194. configurable: true
  8195. });
  8196. Line.prototype._getTypeName = function () {
  8197. return "Line";
  8198. };
  8199. Line.prototype._draw = function (context) {
  8200. context.save();
  8201. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8202. context.shadowColor = this.shadowColor;
  8203. context.shadowBlur = this.shadowBlur;
  8204. context.shadowOffsetX = this.shadowOffsetX;
  8205. context.shadowOffsetY = this.shadowOffsetY;
  8206. }
  8207. this._applyStates(context);
  8208. context.strokeStyle = this.color;
  8209. context.lineWidth = this._lineWidth;
  8210. context.setLineDash(this._dash);
  8211. context.beginPath();
  8212. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8213. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8214. context.stroke();
  8215. context.restore();
  8216. };
  8217. Line.prototype._measure = function () {
  8218. // Width / Height
  8219. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8220. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8221. };
  8222. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8223. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8224. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8225. };
  8226. /**
  8227. * Move one end of the line given 3D cartesian coordinates.
  8228. * @param position Targeted world position
  8229. * @param scene Scene
  8230. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8231. */
  8232. Line.prototype.moveToVector3 = function (position, scene, end) {
  8233. if (end === void 0) { end = false; }
  8234. if (!this._host || this.parent !== this._host._rootContainer) {
  8235. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8236. return;
  8237. }
  8238. var globalViewport = this._host._getGlobalViewport(scene);
  8239. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8240. this._moveToProjectedPosition(projectedPosition, end);
  8241. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8242. this.notRenderable = true;
  8243. return;
  8244. }
  8245. this.notRenderable = false;
  8246. };
  8247. /**
  8248. * Move one end of the line to a position in screen absolute space.
  8249. * @param projectedPosition Position in screen absolute space (X, Y)
  8250. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8251. */
  8252. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8253. if (end === void 0) { end = false; }
  8254. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8255. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8256. if (end) {
  8257. this.x2 = x;
  8258. this.y2 = y;
  8259. this._x2.ignoreAdaptiveScaling = true;
  8260. this._y2.ignoreAdaptiveScaling = true;
  8261. }
  8262. else {
  8263. this.x1 = x;
  8264. this.y1 = y;
  8265. this._x1.ignoreAdaptiveScaling = true;
  8266. this._y1.ignoreAdaptiveScaling = true;
  8267. }
  8268. };
  8269. return Line;
  8270. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8271. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8272. /***/ }),
  8273. /***/ "./2D/controls/multiLine.ts":
  8274. /*!**********************************!*\
  8275. !*** ./2D/controls/multiLine.ts ***!
  8276. \**********************************/
  8277. /*! exports provided: MultiLine */
  8278. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8279. "use strict";
  8280. __webpack_require__.r(__webpack_exports__);
  8281. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8282. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8283. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/perfCounter");
  8284. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8285. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8286. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8287. /**
  8288. * Class used to create multi line control
  8289. */
  8290. var MultiLine = /** @class */ (function (_super) {
  8291. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8292. /**
  8293. * Creates a new MultiLine
  8294. * @param name defines the control name
  8295. */
  8296. function MultiLine(name) {
  8297. var _this = _super.call(this, name) || this;
  8298. _this.name = name;
  8299. _this._lineWidth = 1;
  8300. /** Function called when a point is updated */
  8301. _this.onPointUpdate = function () {
  8302. _this._markAsDirty();
  8303. };
  8304. _this._automaticSize = true;
  8305. _this.isHitTestVisible = false;
  8306. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8307. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8308. _this._dash = [];
  8309. _this._points = [];
  8310. return _this;
  8311. }
  8312. Object.defineProperty(MultiLine.prototype, "dash", {
  8313. /** Gets or sets dash pattern */
  8314. get: function () {
  8315. return this._dash;
  8316. },
  8317. set: function (value) {
  8318. if (this._dash === value) {
  8319. return;
  8320. }
  8321. this._dash = value;
  8322. this._markAsDirty();
  8323. },
  8324. enumerable: true,
  8325. configurable: true
  8326. });
  8327. /**
  8328. * Gets point stored at specified index
  8329. * @param index defines the index to look for
  8330. * @returns the requested point if found
  8331. */
  8332. MultiLine.prototype.getAt = function (index) {
  8333. if (!this._points[index]) {
  8334. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8335. }
  8336. return this._points[index];
  8337. };
  8338. /**
  8339. * Adds new points to the point collection
  8340. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8341. * @returns the list of created MultiLinePoint
  8342. */
  8343. MultiLine.prototype.add = function () {
  8344. var _this = this;
  8345. var items = [];
  8346. for (var _i = 0; _i < arguments.length; _i++) {
  8347. items[_i] = arguments[_i];
  8348. }
  8349. return items.map(function (item) { return _this.push(item); });
  8350. };
  8351. /**
  8352. * Adds a new point to the point collection
  8353. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8354. * @returns the created MultiLinePoint
  8355. */
  8356. MultiLine.prototype.push = function (item) {
  8357. var point = this.getAt(this._points.length);
  8358. if (item == null) {
  8359. return point;
  8360. }
  8361. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8362. point.mesh = item;
  8363. }
  8364. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8365. point.control = item;
  8366. }
  8367. else if (item.x != null && item.y != null) {
  8368. point.x = item.x;
  8369. point.y = item.y;
  8370. }
  8371. return point;
  8372. };
  8373. /**
  8374. * Remove a specific value or point from the active point collection
  8375. * @param value defines the value or point to remove
  8376. */
  8377. MultiLine.prototype.remove = function (value) {
  8378. var index;
  8379. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8380. index = this._points.indexOf(value);
  8381. if (index === -1) {
  8382. return;
  8383. }
  8384. }
  8385. else {
  8386. index = value;
  8387. }
  8388. var point = this._points[index];
  8389. if (!point) {
  8390. return;
  8391. }
  8392. point.dispose();
  8393. this._points.splice(index, 1);
  8394. };
  8395. /**
  8396. * Resets this object to initial state (no point)
  8397. */
  8398. MultiLine.prototype.reset = function () {
  8399. while (this._points.length > 0) {
  8400. this.remove(this._points.length - 1);
  8401. }
  8402. };
  8403. /**
  8404. * Resets all links
  8405. */
  8406. MultiLine.prototype.resetLinks = function () {
  8407. this._points.forEach(function (point) {
  8408. if (point != null) {
  8409. point.resetLinks();
  8410. }
  8411. });
  8412. };
  8413. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8414. /** Gets or sets line width */
  8415. get: function () {
  8416. return this._lineWidth;
  8417. },
  8418. set: function (value) {
  8419. if (this._lineWidth === value) {
  8420. return;
  8421. }
  8422. this._lineWidth = value;
  8423. this._markAsDirty();
  8424. },
  8425. enumerable: true,
  8426. configurable: true
  8427. });
  8428. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8429. set: function (value) {
  8430. return;
  8431. },
  8432. enumerable: true,
  8433. configurable: true
  8434. });
  8435. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8436. set: function (value) {
  8437. return;
  8438. },
  8439. enumerable: true,
  8440. configurable: true
  8441. });
  8442. MultiLine.prototype._getTypeName = function () {
  8443. return "MultiLine";
  8444. };
  8445. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8446. context.save();
  8447. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8448. context.shadowColor = this.shadowColor;
  8449. context.shadowBlur = this.shadowBlur;
  8450. context.shadowOffsetX = this.shadowOffsetX;
  8451. context.shadowOffsetY = this.shadowOffsetY;
  8452. }
  8453. this._applyStates(context);
  8454. context.strokeStyle = this.color;
  8455. context.lineWidth = this._lineWidth;
  8456. context.setLineDash(this._dash);
  8457. context.beginPath();
  8458. var first = true; //first index is not necessarily 0
  8459. this._points.forEach(function (point) {
  8460. if (!point) {
  8461. return;
  8462. }
  8463. if (first) {
  8464. context.moveTo(point._point.x, point._point.y);
  8465. first = false;
  8466. }
  8467. else {
  8468. context.lineTo(point._point.x, point._point.y);
  8469. }
  8470. });
  8471. context.stroke();
  8472. context.restore();
  8473. };
  8474. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8475. var _this = this;
  8476. this._minX = null;
  8477. this._minY = null;
  8478. this._maxX = null;
  8479. this._maxY = null;
  8480. this._points.forEach(function (point, index) {
  8481. if (!point) {
  8482. return;
  8483. }
  8484. point.translate();
  8485. if (_this._minX == null || point._point.x < _this._minX) {
  8486. _this._minX = point._point.x;
  8487. }
  8488. if (_this._minY == null || point._point.y < _this._minY) {
  8489. _this._minY = point._point.y;
  8490. }
  8491. if (_this._maxX == null || point._point.x > _this._maxX) {
  8492. _this._maxX = point._point.x;
  8493. }
  8494. if (_this._maxY == null || point._point.y > _this._maxY) {
  8495. _this._maxY = point._point.y;
  8496. }
  8497. });
  8498. if (this._minX == null) {
  8499. this._minX = 0;
  8500. }
  8501. if (this._minY == null) {
  8502. this._minY = 0;
  8503. }
  8504. if (this._maxX == null) {
  8505. this._maxX = 0;
  8506. }
  8507. if (this._maxY == null) {
  8508. this._maxY = 0;
  8509. }
  8510. };
  8511. MultiLine.prototype._measure = function () {
  8512. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8513. return;
  8514. }
  8515. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8516. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8517. };
  8518. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8519. if (this._minX == null || this._minY == null) {
  8520. return;
  8521. }
  8522. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8523. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8524. };
  8525. MultiLine.prototype.dispose = function () {
  8526. this.reset();
  8527. _super.prototype.dispose.call(this);
  8528. };
  8529. return MultiLine;
  8530. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8531. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8532. /***/ }),
  8533. /***/ "./2D/controls/radioButton.ts":
  8534. /*!************************************!*\
  8535. !*** ./2D/controls/radioButton.ts ***!
  8536. \************************************/
  8537. /*! exports provided: RadioButton */
  8538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8539. "use strict";
  8540. __webpack_require__.r(__webpack_exports__);
  8541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8542. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8543. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  8544. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8545. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8546. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8547. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8548. /**
  8549. * Class used to create radio button controls
  8550. */
  8551. var RadioButton = /** @class */ (function (_super) {
  8552. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8553. /**
  8554. * Creates a new RadioButton
  8555. * @param name defines the control name
  8556. */
  8557. function RadioButton(name) {
  8558. var _this = _super.call(this, name) || this;
  8559. _this.name = name;
  8560. _this._isChecked = false;
  8561. _this._background = "black";
  8562. _this._checkSizeRatio = 0.8;
  8563. _this._thickness = 1;
  8564. /** Gets or sets group name */
  8565. _this.group = "";
  8566. /** Observable raised when isChecked is changed */
  8567. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8568. _this.isPointerBlocker = true;
  8569. return _this;
  8570. }
  8571. Object.defineProperty(RadioButton.prototype, "thickness", {
  8572. /** Gets or sets border thickness */
  8573. get: function () {
  8574. return this._thickness;
  8575. },
  8576. set: function (value) {
  8577. if (this._thickness === value) {
  8578. return;
  8579. }
  8580. this._thickness = value;
  8581. this._markAsDirty();
  8582. },
  8583. enumerable: true,
  8584. configurable: true
  8585. });
  8586. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8587. /** Gets or sets a value indicating the ratio between overall size and check size */
  8588. get: function () {
  8589. return this._checkSizeRatio;
  8590. },
  8591. set: function (value) {
  8592. value = Math.max(Math.min(1, value), 0);
  8593. if (this._checkSizeRatio === value) {
  8594. return;
  8595. }
  8596. this._checkSizeRatio = value;
  8597. this._markAsDirty();
  8598. },
  8599. enumerable: true,
  8600. configurable: true
  8601. });
  8602. Object.defineProperty(RadioButton.prototype, "background", {
  8603. /** Gets or sets background color */
  8604. get: function () {
  8605. return this._background;
  8606. },
  8607. set: function (value) {
  8608. if (this._background === value) {
  8609. return;
  8610. }
  8611. this._background = value;
  8612. this._markAsDirty();
  8613. },
  8614. enumerable: true,
  8615. configurable: true
  8616. });
  8617. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8618. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8619. get: function () {
  8620. return this._isChecked;
  8621. },
  8622. set: function (value) {
  8623. var _this = this;
  8624. if (this._isChecked === value) {
  8625. return;
  8626. }
  8627. this._isChecked = value;
  8628. this._markAsDirty();
  8629. this.onIsCheckedChangedObservable.notifyObservers(value);
  8630. if (this._isChecked && this._host) {
  8631. // Update all controls from same group
  8632. this._host.executeOnAllControls(function (control) {
  8633. if (control === _this) {
  8634. return;
  8635. }
  8636. if (control.group === undefined) {
  8637. return;
  8638. }
  8639. var childRadio = control;
  8640. if (childRadio.group === _this.group) {
  8641. childRadio.isChecked = false;
  8642. }
  8643. });
  8644. }
  8645. },
  8646. enumerable: true,
  8647. configurable: true
  8648. });
  8649. RadioButton.prototype._getTypeName = function () {
  8650. return "RadioButton";
  8651. };
  8652. RadioButton.prototype._draw = function (context) {
  8653. context.save();
  8654. this._applyStates(context);
  8655. var actualWidth = this._currentMeasure.width - this._thickness;
  8656. var actualHeight = this._currentMeasure.height - this._thickness;
  8657. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8658. context.shadowColor = this.shadowColor;
  8659. context.shadowBlur = this.shadowBlur;
  8660. context.shadowOffsetX = this.shadowOffsetX;
  8661. context.shadowOffsetY = this.shadowOffsetY;
  8662. }
  8663. // Outer
  8664. _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);
  8665. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8666. context.fill();
  8667. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8668. context.shadowBlur = 0;
  8669. context.shadowOffsetX = 0;
  8670. context.shadowOffsetY = 0;
  8671. }
  8672. context.strokeStyle = this.color;
  8673. context.lineWidth = this._thickness;
  8674. context.stroke();
  8675. // Inner
  8676. if (this._isChecked) {
  8677. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8678. var offsetWidth = actualWidth * this._checkSizeRatio;
  8679. var offseHeight = actualHeight * this._checkSizeRatio;
  8680. _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);
  8681. context.fill();
  8682. }
  8683. context.restore();
  8684. };
  8685. // Events
  8686. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8687. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8688. return false;
  8689. }
  8690. if (!this.isChecked) {
  8691. this.isChecked = true;
  8692. }
  8693. return true;
  8694. };
  8695. /**
  8696. * Utility function to easily create a radio button with a header
  8697. * @param title defines the label to use for the header
  8698. * @param group defines the group to use for the radio button
  8699. * @param isChecked defines the initial state of the radio button
  8700. * @param onValueChanged defines the callback to call when value changes
  8701. * @returns a StackPanel containing the radio button and a textBlock
  8702. */
  8703. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8704. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8705. panel.isVertical = false;
  8706. panel.height = "30px";
  8707. var radio = new RadioButton();
  8708. radio.width = "20px";
  8709. radio.height = "20px";
  8710. radio.isChecked = isChecked;
  8711. radio.color = "green";
  8712. radio.group = group;
  8713. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8714. panel.addControl(radio);
  8715. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8716. header.text = title;
  8717. header.width = "180px";
  8718. header.paddingLeft = "5px";
  8719. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8720. header.color = "white";
  8721. panel.addControl(header);
  8722. return panel;
  8723. };
  8724. return RadioButton;
  8725. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8726. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8727. /***/ }),
  8728. /***/ "./2D/controls/rectangle.ts":
  8729. /*!**********************************!*\
  8730. !*** ./2D/controls/rectangle.ts ***!
  8731. \**********************************/
  8732. /*! exports provided: Rectangle */
  8733. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8734. "use strict";
  8735. __webpack_require__.r(__webpack_exports__);
  8736. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8737. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8738. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8739. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  8740. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8741. /** Class used to create rectangle container */
  8742. var Rectangle = /** @class */ (function (_super) {
  8743. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8744. /**
  8745. * Creates a new Rectangle
  8746. * @param name defines the control name
  8747. */
  8748. function Rectangle(name) {
  8749. var _this = _super.call(this, name) || this;
  8750. _this.name = name;
  8751. _this._thickness = 1;
  8752. _this._cornerRadius = 0;
  8753. return _this;
  8754. }
  8755. Object.defineProperty(Rectangle.prototype, "thickness", {
  8756. /** Gets or sets border thickness */
  8757. get: function () {
  8758. return this._thickness;
  8759. },
  8760. set: function (value) {
  8761. if (this._thickness === value) {
  8762. return;
  8763. }
  8764. this._thickness = value;
  8765. this._markAsDirty();
  8766. },
  8767. enumerable: true,
  8768. configurable: true
  8769. });
  8770. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8771. /** Gets or sets the corner radius angle */
  8772. get: function () {
  8773. return this._cornerRadius;
  8774. },
  8775. set: function (value) {
  8776. if (value < 0) {
  8777. value = 0;
  8778. }
  8779. if (this._cornerRadius === value) {
  8780. return;
  8781. }
  8782. this._cornerRadius = value;
  8783. this._markAsDirty();
  8784. },
  8785. enumerable: true,
  8786. configurable: true
  8787. });
  8788. Rectangle.prototype._getTypeName = function () {
  8789. return "Rectangle";
  8790. };
  8791. Rectangle.prototype._localDraw = function (context) {
  8792. context.save();
  8793. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8794. context.shadowColor = this.shadowColor;
  8795. context.shadowBlur = this.shadowBlur;
  8796. context.shadowOffsetX = this.shadowOffsetX;
  8797. context.shadowOffsetY = this.shadowOffsetY;
  8798. }
  8799. if (this._background) {
  8800. context.fillStyle = this._background;
  8801. if (this._cornerRadius) {
  8802. this._drawRoundedRect(context, this._thickness / 2);
  8803. context.fill();
  8804. }
  8805. else {
  8806. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8807. }
  8808. }
  8809. if (this._thickness) {
  8810. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8811. context.shadowBlur = 0;
  8812. context.shadowOffsetX = 0;
  8813. context.shadowOffsetY = 0;
  8814. }
  8815. if (this.color) {
  8816. context.strokeStyle = this.color;
  8817. }
  8818. context.lineWidth = this._thickness;
  8819. if (this._cornerRadius) {
  8820. this._drawRoundedRect(context, this._thickness / 2);
  8821. context.stroke();
  8822. }
  8823. else {
  8824. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8825. }
  8826. }
  8827. context.restore();
  8828. };
  8829. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8830. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8831. this._measureForChildren.width -= 2 * this._thickness;
  8832. this._measureForChildren.height -= 2 * this._thickness;
  8833. this._measureForChildren.left += this._thickness;
  8834. this._measureForChildren.top += this._thickness;
  8835. };
  8836. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8837. if (offset === void 0) { offset = 0; }
  8838. var x = this._currentMeasure.left + offset;
  8839. var y = this._currentMeasure.top + offset;
  8840. var width = this._currentMeasure.width - offset * 2;
  8841. var height = this._currentMeasure.height - offset * 2;
  8842. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8843. context.beginPath();
  8844. context.moveTo(x + radius, y);
  8845. context.lineTo(x + width - radius, y);
  8846. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8847. context.lineTo(x + width, y + height - radius);
  8848. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8849. context.lineTo(x + radius, y + height);
  8850. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8851. context.lineTo(x, y + radius);
  8852. context.quadraticCurveTo(x, y, x + radius, y);
  8853. context.closePath();
  8854. };
  8855. Rectangle.prototype._clipForChildren = function (context) {
  8856. if (this._cornerRadius) {
  8857. this._drawRoundedRect(context, this._thickness);
  8858. context.clip();
  8859. }
  8860. };
  8861. return Rectangle;
  8862. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8863. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  8864. /***/ }),
  8865. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8866. /*!***************************************************!*\
  8867. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8868. \***************************************************/
  8869. /*! exports provided: ScrollViewer */
  8870. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8871. "use strict";
  8872. __webpack_require__.r(__webpack_exports__);
  8873. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8874. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8875. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/perfCounter");
  8876. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8877. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8878. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8879. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8880. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8881. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8882. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  8883. /**
  8884. * Class used to hold a viewer window and sliders in a grid
  8885. */
  8886. var ScrollViewer = /** @class */ (function (_super) {
  8887. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  8888. /**
  8889. * Creates a new ScrollViewer
  8890. * @param name of ScrollViewer
  8891. */
  8892. function ScrollViewer(name, isImageBased) {
  8893. var _this = _super.call(this, name) || this;
  8894. _this._barSize = 20;
  8895. _this._pointerIsOver = false;
  8896. _this._wheelPrecision = 0.05;
  8897. _this._thumbLength = 0.5;
  8898. _this._thumbHeight = 1;
  8899. _this._barImageHeight = 1;
  8900. _this._horizontalBarImageHeight = 1;
  8901. _this._verticalBarImageHeight = 1;
  8902. _this._forceHorizontalBar = false;
  8903. _this._forceVerticalBar = false;
  8904. _this._useImageBar = isImageBased ? isImageBased : false;
  8905. _this.onDirtyObservable.add(function () {
  8906. _this._horizontalBarSpace.color = _this.color;
  8907. _this._verticalBarSpace.color = _this.color;
  8908. _this._dragSpace.color = _this.color;
  8909. });
  8910. _this.onPointerEnterObservable.add(function () {
  8911. _this._pointerIsOver = true;
  8912. });
  8913. _this.onPointerOutObservable.add(function () {
  8914. _this._pointerIsOver = false;
  8915. });
  8916. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8917. if (_this._useImageBar) {
  8918. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__["ImageScrollBar"]();
  8919. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__["ImageScrollBar"]();
  8920. }
  8921. else {
  8922. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8923. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8924. }
  8925. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]("scrollViewer_window");
  8926. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8927. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8928. _this._grid.addColumnDefinition(1);
  8929. _this._grid.addColumnDefinition(0, true);
  8930. _this._grid.addRowDefinition(1);
  8931. _this._grid.addRowDefinition(0, true);
  8932. _super.prototype.addControl.call(_this, _this._grid);
  8933. _this._grid.addControl(_this._window, 0, 0);
  8934. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8935. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8936. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8937. _this._verticalBarSpace.thickness = 1;
  8938. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8939. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  8940. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8941. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8942. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8943. _this._horizontalBarSpace.thickness = 1;
  8944. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8945. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  8946. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8947. _this._dragSpace.thickness = 1;
  8948. _this._grid.addControl(_this._dragSpace, 1, 1);
  8949. // Colors
  8950. if (!_this._useImageBar) {
  8951. _this.barColor = "grey";
  8952. _this.barBackground = "transparent";
  8953. }
  8954. return _this;
  8955. }
  8956. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8957. /**
  8958. * Gets the horizontal scrollbar
  8959. */
  8960. get: function () {
  8961. return this._horizontalBar;
  8962. },
  8963. enumerable: true,
  8964. configurable: true
  8965. });
  8966. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8967. /**
  8968. * Gets the vertical scrollbar
  8969. */
  8970. get: function () {
  8971. return this._verticalBar;
  8972. },
  8973. enumerable: true,
  8974. configurable: true
  8975. });
  8976. /**
  8977. * Adds a new control to the current container
  8978. * @param control defines the control to add
  8979. * @returns the current container
  8980. */
  8981. ScrollViewer.prototype.addControl = function (control) {
  8982. if (!control) {
  8983. return this;
  8984. }
  8985. this._window.addControl(control);
  8986. return this;
  8987. };
  8988. /**
  8989. * Removes a control from the current container
  8990. * @param control defines the control to remove
  8991. * @returns the current container
  8992. */
  8993. ScrollViewer.prototype.removeControl = function (control) {
  8994. this._window.removeControl(control);
  8995. return this;
  8996. };
  8997. Object.defineProperty(ScrollViewer.prototype, "children", {
  8998. /** Gets the list of children */
  8999. get: function () {
  9000. return this._window.children;
  9001. },
  9002. enumerable: true,
  9003. configurable: true
  9004. });
  9005. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  9006. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9007. var child = _a[_i];
  9008. child._markMatrixAsDirty();
  9009. }
  9010. };
  9011. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  9012. /**
  9013. * Freezes or unfreezes the controls in the window.
  9014. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  9015. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  9016. */
  9017. get: function () {
  9018. return this._window.freezeControls;
  9019. },
  9020. set: function (value) {
  9021. this._window.freezeControls = value;
  9022. },
  9023. enumerable: true,
  9024. configurable: true
  9025. });
  9026. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  9027. /** Gets the bucket width */
  9028. get: function () {
  9029. return this._window.bucketWidth;
  9030. },
  9031. enumerable: true,
  9032. configurable: true
  9033. });
  9034. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9035. /** Gets the bucket height */
  9036. get: function () {
  9037. return this._window.bucketHeight;
  9038. },
  9039. enumerable: true,
  9040. configurable: true
  9041. });
  9042. /**
  9043. * Sets the bucket sizes.
  9044. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9045. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9046. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9047. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9048. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9049. * used), that's why it is not enabled by default.
  9050. * @param width width of the bucket
  9051. * @param height height of the bucket
  9052. */
  9053. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9054. this._window.setBucketSizes(width, height);
  9055. };
  9056. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9057. /**
  9058. * Forces the horizontal scroll bar to be displayed
  9059. */
  9060. get: function () {
  9061. return this._forceHorizontalBar;
  9062. },
  9063. set: function (value) {
  9064. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9065. this._horizontalBar.isVisible = value;
  9066. this._forceHorizontalBar = value;
  9067. },
  9068. enumerable: true,
  9069. configurable: true
  9070. });
  9071. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9072. /**
  9073. * Forces the vertical scroll bar to be displayed
  9074. */
  9075. get: function () {
  9076. return this._forceVerticalBar;
  9077. },
  9078. set: function (value) {
  9079. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9080. this._verticalBar.isVisible = value;
  9081. this._forceVerticalBar = value;
  9082. },
  9083. enumerable: true,
  9084. configurable: true
  9085. });
  9086. /** Reset the scroll viewer window to initial size */
  9087. ScrollViewer.prototype.resetWindow = function () {
  9088. this._window.width = "100%";
  9089. this._window.height = "100%";
  9090. };
  9091. ScrollViewer.prototype._getTypeName = function () {
  9092. return "ScrollViewer";
  9093. };
  9094. ScrollViewer.prototype._buildClientSizes = function () {
  9095. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize : 0) - 2 * this.thickness;
  9096. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize : 0) - 2 * this.thickness;
  9097. this._clientWidth = this._window.parentClientWidth;
  9098. this._clientHeight = this._window.parentClientHeight;
  9099. };
  9100. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  9101. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9102. this._buildClientSizes();
  9103. };
  9104. ScrollViewer.prototype._postMeasure = function () {
  9105. _super.prototype._postMeasure.call(this);
  9106. this._updateScroller();
  9107. };
  9108. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  9109. /**
  9110. * Gets or sets the mouse wheel precision
  9111. * from 0 to 1 with a default value of 0.05
  9112. * */
  9113. get: function () {
  9114. return this._wheelPrecision;
  9115. },
  9116. set: function (value) {
  9117. if (this._wheelPrecision === value) {
  9118. return;
  9119. }
  9120. if (value < 0) {
  9121. value = 0;
  9122. }
  9123. if (value > 1) {
  9124. value = 1;
  9125. }
  9126. this._wheelPrecision = value;
  9127. },
  9128. enumerable: true,
  9129. configurable: true
  9130. });
  9131. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  9132. /** Gets or sets the scroll bar container background color */
  9133. get: function () {
  9134. return this._horizontalBarSpace.background;
  9135. },
  9136. set: function (color) {
  9137. if (this._horizontalBarSpace.background === color) {
  9138. return;
  9139. }
  9140. this._horizontalBarSpace.background = color;
  9141. this._verticalBarSpace.background = color;
  9142. },
  9143. enumerable: true,
  9144. configurable: true
  9145. });
  9146. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9147. /** Gets or sets the bar color */
  9148. get: function () {
  9149. return this._barColor;
  9150. },
  9151. set: function (color) {
  9152. if (this._barColor === color) {
  9153. return;
  9154. }
  9155. this._barColor = color;
  9156. this._horizontalBar.color = color;
  9157. this._verticalBar.color = color;
  9158. },
  9159. enumerable: true,
  9160. configurable: true
  9161. });
  9162. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9163. /** Gets or sets the bar image */
  9164. get: function () {
  9165. return this._barImage;
  9166. },
  9167. set: function (value) {
  9168. if (this._barImage === value) {
  9169. return;
  9170. }
  9171. this._barImage = value;
  9172. var hb = this._horizontalBar;
  9173. var vb = this._verticalBar;
  9174. hb.thumbImage = value;
  9175. vb.thumbImage = value;
  9176. },
  9177. enumerable: true,
  9178. configurable: true
  9179. });
  9180. Object.defineProperty(ScrollViewer.prototype, "horizontalThumbImage", {
  9181. /** Gets or sets the horizontal bar image */
  9182. get: function () {
  9183. return this._horizontalBarImage;
  9184. },
  9185. set: function (value) {
  9186. if (this._horizontalBarImage === value) {
  9187. return;
  9188. }
  9189. this._horizontalBarImage = value;
  9190. var hb = this._horizontalBar;
  9191. hb.thumbImage = value;
  9192. },
  9193. enumerable: true,
  9194. configurable: true
  9195. });
  9196. Object.defineProperty(ScrollViewer.prototype, "verticalThumbImage", {
  9197. /** Gets or sets the vertical bar image */
  9198. get: function () {
  9199. return this._verticalBarImage;
  9200. },
  9201. set: function (value) {
  9202. if (this._verticalBarImage === value) {
  9203. return;
  9204. }
  9205. this._verticalBarImage = value;
  9206. var vb = this._verticalBar;
  9207. vb.thumbImage = value;
  9208. },
  9209. enumerable: true,
  9210. configurable: true
  9211. });
  9212. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9213. /** Gets or sets the size of the bar */
  9214. get: function () {
  9215. return this._barSize;
  9216. },
  9217. set: function (value) {
  9218. if (this._barSize === value) {
  9219. return;
  9220. }
  9221. this._barSize = value;
  9222. this._markAsDirty();
  9223. if (this._horizontalBar.isVisible) {
  9224. this._grid.setRowDefinition(1, this._barSize, true);
  9225. }
  9226. if (this._verticalBar.isVisible) {
  9227. this._grid.setColumnDefinition(1, this._barSize, true);
  9228. }
  9229. },
  9230. enumerable: true,
  9231. configurable: true
  9232. });
  9233. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9234. /** Gets or sets the length of the thumb */
  9235. get: function () {
  9236. return this._thumbLength;
  9237. },
  9238. set: function (value) {
  9239. if (this._thumbLength === value) {
  9240. return;
  9241. }
  9242. if (value <= 0) {
  9243. value = 0.1;
  9244. }
  9245. if (value > 1) {
  9246. value = 1;
  9247. }
  9248. this._thumbLength = value;
  9249. var hb = this._horizontalBar;
  9250. var vb = this._verticalBar;
  9251. hb.thumbLength = value;
  9252. vb.thumbLength = value;
  9253. this._markAsDirty();
  9254. },
  9255. enumerable: true,
  9256. configurable: true
  9257. });
  9258. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9259. /** Gets or sets the height of the thumb */
  9260. get: function () {
  9261. return this._thumbHeight;
  9262. },
  9263. set: function (value) {
  9264. if (this._thumbHeight === value) {
  9265. return;
  9266. }
  9267. if (value <= 0) {
  9268. value = 0.1;
  9269. }
  9270. if (value > 1) {
  9271. value = 1;
  9272. }
  9273. this._thumbHeight = value;
  9274. var hb = this._horizontalBar;
  9275. var vb = this._verticalBar;
  9276. hb.thumbHeight = value;
  9277. vb.thumbHeight = value;
  9278. this._markAsDirty();
  9279. },
  9280. enumerable: true,
  9281. configurable: true
  9282. });
  9283. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9284. /** Gets or sets the height of the bar image */
  9285. get: function () {
  9286. return this._barImageHeight;
  9287. },
  9288. set: function (value) {
  9289. if (this._barImageHeight === value) {
  9290. return;
  9291. }
  9292. if (value <= 0) {
  9293. value = 0.1;
  9294. }
  9295. if (value > 1) {
  9296. value = 1;
  9297. }
  9298. this._barImageHeight = value;
  9299. var hb = this._horizontalBar;
  9300. var vb = this._verticalBar;
  9301. hb.barImageHeight = value;
  9302. vb.barImageHeight = value;
  9303. this._markAsDirty();
  9304. },
  9305. enumerable: true,
  9306. configurable: true
  9307. });
  9308. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImageHeight", {
  9309. /** Gets or sets the height of the horizontal bar image */
  9310. get: function () {
  9311. return this._horizontalBarImageHeight;
  9312. },
  9313. set: function (value) {
  9314. if (this._horizontalBarImageHeight === value) {
  9315. return;
  9316. }
  9317. if (value <= 0) {
  9318. value = 0.1;
  9319. }
  9320. if (value > 1) {
  9321. value = 1;
  9322. }
  9323. this._horizontalBarImageHeight = value;
  9324. var hb = this._horizontalBar;
  9325. hb.barImageHeight = value;
  9326. this._markAsDirty();
  9327. },
  9328. enumerable: true,
  9329. configurable: true
  9330. });
  9331. Object.defineProperty(ScrollViewer.prototype, "verticalBarImageHeight", {
  9332. /** Gets or sets the height of the vertical bar image */
  9333. get: function () {
  9334. return this._verticalBarImageHeight;
  9335. },
  9336. set: function (value) {
  9337. if (this._verticalBarImageHeight === value) {
  9338. return;
  9339. }
  9340. if (value <= 0) {
  9341. value = 0.1;
  9342. }
  9343. if (value > 1) {
  9344. value = 1;
  9345. }
  9346. this._verticalBarImageHeight = value;
  9347. var vb = this._verticalBar;
  9348. vb.barImageHeight = value;
  9349. this._markAsDirty();
  9350. },
  9351. enumerable: true,
  9352. configurable: true
  9353. });
  9354. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9355. /** Gets or sets the bar background */
  9356. get: function () {
  9357. return this._barBackground;
  9358. },
  9359. set: function (color) {
  9360. if (this._barBackground === color) {
  9361. return;
  9362. }
  9363. this._barBackground = color;
  9364. var hb = this._horizontalBar;
  9365. var vb = this._verticalBar;
  9366. hb.background = color;
  9367. vb.background = color;
  9368. this._dragSpace.background = color;
  9369. },
  9370. enumerable: true,
  9371. configurable: true
  9372. });
  9373. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9374. /** Gets or sets the bar background image */
  9375. get: function () {
  9376. return this._barBackgroundImage;
  9377. },
  9378. set: function (value) {
  9379. if (this._barBackgroundImage === value) {
  9380. }
  9381. this._barBackgroundImage = value;
  9382. var hb = this._horizontalBar;
  9383. var vb = this._verticalBar;
  9384. hb.backgroundImage = value;
  9385. vb.backgroundImage = value;
  9386. },
  9387. enumerable: true,
  9388. configurable: true
  9389. });
  9390. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImage", {
  9391. /** Gets or sets the horizontal bar background image */
  9392. get: function () {
  9393. return this._horizontalBarBackgroundImage;
  9394. },
  9395. set: function (value) {
  9396. if (this._horizontalBarBackgroundImage === value) {
  9397. }
  9398. this._horizontalBarBackgroundImage = value;
  9399. var hb = this._horizontalBar;
  9400. hb.backgroundImage = value;
  9401. },
  9402. enumerable: true,
  9403. configurable: true
  9404. });
  9405. Object.defineProperty(ScrollViewer.prototype, "verticalBarImage", {
  9406. /** Gets or sets the vertical bar background image */
  9407. get: function () {
  9408. return this._verticalBarBackgroundImage;
  9409. },
  9410. set: function (value) {
  9411. if (this._verticalBarBackgroundImage === value) {
  9412. }
  9413. this._verticalBarBackgroundImage = value;
  9414. var vb = this._verticalBar;
  9415. vb.backgroundImage = value;
  9416. },
  9417. enumerable: true,
  9418. configurable: true
  9419. });
  9420. ScrollViewer.prototype._setWindowPosition = function () {
  9421. var ratio = this.host.idealRatio;
  9422. var windowContentsWidth = this._window._currentMeasure.width;
  9423. var windowContentsHeight = this._window._currentMeasure.height;
  9424. var _endLeft = this._clientWidth - windowContentsWidth;
  9425. var _endTop = this._clientHeight - windowContentsHeight;
  9426. var newLeft = (this._horizontalBar.value / ratio) * _endLeft + "px";
  9427. var newTop = (this._verticalBar.value / ratio) * _endTop + "px";
  9428. if (newLeft !== this._window.left) {
  9429. this._window.left = newLeft;
  9430. if (!this.freezeControls) {
  9431. this._rebuildLayout = true;
  9432. }
  9433. }
  9434. if (newTop !== this._window.top) {
  9435. this._window.top = newTop;
  9436. if (!this.freezeControls) {
  9437. this._rebuildLayout = true;
  9438. }
  9439. }
  9440. };
  9441. /** @hidden */
  9442. ScrollViewer.prototype._updateScroller = function () {
  9443. var windowContentsWidth = this._window._currentMeasure.width;
  9444. var windowContentsHeight = this._window._currentMeasure.height;
  9445. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  9446. this._grid.setRowDefinition(1, 0, true);
  9447. this._horizontalBar.isVisible = false;
  9448. this._horizontalBar.value = 0;
  9449. this._rebuildLayout = true;
  9450. }
  9451. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  9452. this._grid.setRowDefinition(1, this._barSize, true);
  9453. this._horizontalBar.isVisible = true;
  9454. this._rebuildLayout = true;
  9455. }
  9456. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  9457. this._grid.setColumnDefinition(1, 0, true);
  9458. this._verticalBar.isVisible = false;
  9459. this._verticalBar.value = 0;
  9460. this._rebuildLayout = true;
  9461. }
  9462. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  9463. this._grid.setColumnDefinition(1, this._barSize, true);
  9464. this._verticalBar.isVisible = true;
  9465. this._rebuildLayout = true;
  9466. }
  9467. this._buildClientSizes();
  9468. var ratio = this.host.idealRatio;
  9469. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientWidth / ratio) + "px";
  9470. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientHeight / ratio) + "px";
  9471. };
  9472. ScrollViewer.prototype._link = function (host) {
  9473. _super.prototype._link.call(this, host);
  9474. this._attachWheel();
  9475. };
  9476. /** @hidden */
  9477. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9478. var _this = this;
  9479. barControl.paddingLeft = 0;
  9480. barControl.width = "100%";
  9481. barControl.height = "100%";
  9482. barControl.barOffset = 0;
  9483. barControl.value = 0;
  9484. barControl.maximum = 1;
  9485. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9486. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9487. barControl.isVertical = isVertical;
  9488. barControl.rotation = rotation;
  9489. barControl.isVisible = false;
  9490. barContainer.addControl(barControl);
  9491. barControl.onValueChangedObservable.add(function (value) {
  9492. _this._setWindowPosition();
  9493. });
  9494. };
  9495. /** @hidden */
  9496. ScrollViewer.prototype._attachWheel = function () {
  9497. var _this = this;
  9498. if (!this._host || this._onPointerObserver) {
  9499. return;
  9500. }
  9501. var scene = this._host.getScene();
  9502. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  9503. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  9504. return;
  9505. }
  9506. if (_this._verticalBar.isVisible == true) {
  9507. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  9508. _this._verticalBar.value -= _this._wheelPrecision;
  9509. }
  9510. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9511. _this._verticalBar.value += _this._wheelPrecision;
  9512. }
  9513. }
  9514. if (_this._horizontalBar.isVisible == true) {
  9515. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9516. _this._horizontalBar.value += _this._wheelPrecision;
  9517. }
  9518. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  9519. _this._horizontalBar.value -= _this._wheelPrecision;
  9520. }
  9521. }
  9522. });
  9523. };
  9524. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9525. if (!this.isHighlighted) {
  9526. return;
  9527. }
  9528. _super.prototype._renderHighlightSpecific.call(this, context);
  9529. this._grid._renderHighlightSpecific(context);
  9530. context.restore();
  9531. };
  9532. /** Releases associated resources */
  9533. ScrollViewer.prototype.dispose = function () {
  9534. var scene = this._host.getScene();
  9535. if (scene && this._onPointerObserver) {
  9536. scene.onPointerObservable.remove(this._onPointerObserver);
  9537. this._onPointerObserver = null;
  9538. }
  9539. _super.prototype.dispose.call(this);
  9540. };
  9541. return ScrollViewer;
  9542. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  9543. babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9544. /***/ }),
  9545. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9546. /*!*********************************************************!*\
  9547. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9548. \*********************************************************/
  9549. /*! exports provided: _ScrollViewerWindow */
  9550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9551. "use strict";
  9552. __webpack_require__.r(__webpack_exports__);
  9553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9554. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9555. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9556. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9557. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9558. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9559. /**
  9560. * Class used to hold a the container for ScrollViewer
  9561. * @hidden
  9562. */
  9563. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9564. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9565. /**
  9566. * Creates a new ScrollViewerWindow
  9567. * @param name of ScrollViewerWindow
  9568. */
  9569. function _ScrollViewerWindow(name) {
  9570. var _this = _super.call(this, name) || this;
  9571. _this._freezeControls = false;
  9572. _this._bucketWidth = 0;
  9573. _this._bucketHeight = 0;
  9574. _this._buckets = {};
  9575. return _this;
  9576. }
  9577. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  9578. get: function () {
  9579. return this._freezeControls;
  9580. },
  9581. set: function (value) {
  9582. if (this._freezeControls === value) {
  9583. return;
  9584. }
  9585. // trigger a full normal layout calculation to be sure all children have their measures up to date
  9586. this._freezeControls = false;
  9587. var textureSize = this.host.getSize();
  9588. var renderWidth = textureSize.width;
  9589. var renderHeight = textureSize.height;
  9590. var context = this.host.getContext();
  9591. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  9592. this.host._numLayoutCalls = 0;
  9593. this.host._rootContainer._layout(measure, context);
  9594. // in freeze mode, prepare children measures accordingly
  9595. if (value) {
  9596. this._updateMeasures();
  9597. if (this._useBuckets()) {
  9598. this._makeBuckets();
  9599. }
  9600. }
  9601. this._freezeControls = value;
  9602. this.host.markAsDirty(); // redraw with the (new) current settings
  9603. },
  9604. enumerable: true,
  9605. configurable: true
  9606. });
  9607. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  9608. get: function () {
  9609. return this._bucketWidth;
  9610. },
  9611. enumerable: true,
  9612. configurable: true
  9613. });
  9614. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  9615. get: function () {
  9616. return this._bucketHeight;
  9617. },
  9618. enumerable: true,
  9619. configurable: true
  9620. });
  9621. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  9622. this._bucketWidth = width;
  9623. this._bucketHeight = height;
  9624. if (this._useBuckets()) {
  9625. if (this._freezeControls) {
  9626. this._makeBuckets();
  9627. }
  9628. }
  9629. else {
  9630. this._buckets = {};
  9631. }
  9632. };
  9633. _ScrollViewerWindow.prototype._useBuckets = function () {
  9634. return this._bucketWidth > 0 && this._bucketHeight > 0;
  9635. };
  9636. _ScrollViewerWindow.prototype._makeBuckets = function () {
  9637. this._buckets = {};
  9638. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  9639. this._dispatchInBuckets(this._children);
  9640. };
  9641. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  9642. for (var i = 0; i < children.length; ++i) {
  9643. var child = children[i];
  9644. 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);
  9645. while (bStartY <= bEndY) {
  9646. for (var x = bStartX; x <= bEndX; ++x) {
  9647. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9648. if (!lstc) {
  9649. lstc = [];
  9650. this._buckets[bucket] = lstc;
  9651. }
  9652. lstc.push(child);
  9653. }
  9654. bStartY++;
  9655. }
  9656. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9657. this._dispatchInBuckets(child._children);
  9658. }
  9659. }
  9660. };
  9661. // reset left and top measures for the window and all its children
  9662. _ScrollViewerWindow.prototype._updateMeasures = function () {
  9663. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9664. this._measureForChildren.left -= left;
  9665. this._measureForChildren.top -= top;
  9666. this._currentMeasure.left -= left;
  9667. this._currentMeasure.top -= top;
  9668. this._updateChildrenMeasures(this._children, left, top);
  9669. };
  9670. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  9671. for (var i = 0; i < children.length; ++i) {
  9672. var child = children[i];
  9673. child._currentMeasure.left -= left;
  9674. child._currentMeasure.top -= top;
  9675. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  9676. child._customData._origTop = child._currentMeasure.top;
  9677. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9678. this._updateChildrenMeasures(child._children, left, top);
  9679. }
  9680. }
  9681. };
  9682. _ScrollViewerWindow.prototype._getTypeName = function () {
  9683. return "ScrollViewerWindow";
  9684. };
  9685. /** @hidden */
  9686. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9687. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9688. this._parentMeasure = parentMeasure;
  9689. this._measureForChildren.left = this._currentMeasure.left;
  9690. this._measureForChildren.top = this._currentMeasure.top;
  9691. this._measureForChildren.width = parentMeasure.width;
  9692. this._measureForChildren.height = parentMeasure.height;
  9693. };
  9694. /** @hidden */
  9695. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  9696. if (this._freezeControls) {
  9697. this.invalidateRect(); // will trigger a redraw of the window
  9698. return false;
  9699. }
  9700. return _super.prototype._layout.call(this, parentMeasure, context);
  9701. };
  9702. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  9703. for (var i = 0; i < children.length; ++i) {
  9704. var child = children[i];
  9705. child._currentMeasure.left = child._customData._origLeft + left;
  9706. child._currentMeasure.top = child._customData._origTop + top;
  9707. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9708. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9709. this._scrollChildren(child._children, left, top);
  9710. }
  9711. }
  9712. };
  9713. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  9714. 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);
  9715. while (bStartY <= bEndY) {
  9716. for (var x = bStartX; x <= bEndX; ++x) {
  9717. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9718. if (lstc) {
  9719. for (var i = 0; i < lstc.length; ++i) {
  9720. var child = lstc[i];
  9721. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  9722. child._currentMeasure.top = child._customData._origTop + scrollTop;
  9723. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9724. }
  9725. }
  9726. }
  9727. bStartY++;
  9728. }
  9729. };
  9730. /** @hidden */
  9731. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  9732. if (!this._freezeControls) {
  9733. _super.prototype._draw.call(this, context, invalidatedRectangle);
  9734. return;
  9735. }
  9736. this._localDraw(context);
  9737. if (this.clipChildren) {
  9738. this._clipForChildren(context);
  9739. }
  9740. var left = this.leftInPixels, top = this.topInPixels;
  9741. if (this._useBuckets()) {
  9742. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  9743. this._scrollChildrenWithBuckets(left, top, left, top);
  9744. }
  9745. else {
  9746. this._scrollChildren(this._children, left, top);
  9747. }
  9748. this._oldLeft = left;
  9749. this._oldTop = top;
  9750. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9751. var child = _a[_i];
  9752. if (!child._intersectsRect(this._parentMeasure)) {
  9753. continue;
  9754. }
  9755. child._render(context, this._parentMeasure);
  9756. }
  9757. };
  9758. _ScrollViewerWindow.prototype._postMeasure = function () {
  9759. if (this._freezeControls) {
  9760. _super.prototype._postMeasure.call(this);
  9761. return;
  9762. }
  9763. var maxWidth = this.parentClientWidth;
  9764. var maxHeight = this.parentClientHeight;
  9765. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9766. var child = _a[_i];
  9767. if (!child.isVisible || child.notRenderable) {
  9768. continue;
  9769. }
  9770. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9771. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9772. }
  9773. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9774. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9775. }
  9776. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9777. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9778. }
  9779. if (this._currentMeasure.width !== maxWidth) {
  9780. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9781. this._currentMeasure.width = maxWidth;
  9782. this._rebuildLayout = true;
  9783. this._isDirty = true;
  9784. }
  9785. if (this._currentMeasure.height !== maxHeight) {
  9786. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9787. this._currentMeasure.height = maxHeight;
  9788. this._rebuildLayout = true;
  9789. this._isDirty = true;
  9790. }
  9791. _super.prototype._postMeasure.call(this);
  9792. };
  9793. return _ScrollViewerWindow;
  9794. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  9795. /***/ }),
  9796. /***/ "./2D/controls/selector.ts":
  9797. /*!*********************************!*\
  9798. !*** ./2D/controls/selector.ts ***!
  9799. \*********************************/
  9800. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9801. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9802. "use strict";
  9803. __webpack_require__.r(__webpack_exports__);
  9804. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9805. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9807. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9808. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9809. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9810. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9811. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9812. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9813. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9814. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9815. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9816. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9817. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9818. /** Class used to create a RadioGroup
  9819. * which contains groups of radio buttons
  9820. */
  9821. var SelectorGroup = /** @class */ (function () {
  9822. /**
  9823. * Creates a new SelectorGroup
  9824. * @param name of group, used as a group heading
  9825. */
  9826. function SelectorGroup(
  9827. /** name of SelectorGroup */
  9828. name) {
  9829. this.name = name;
  9830. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9831. this._selectors = new Array();
  9832. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9833. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9834. this._groupHeader = this._addGroupHeader(name);
  9835. }
  9836. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9837. /** Gets the groupPanel of the SelectorGroup */
  9838. get: function () {
  9839. return this._groupPanel;
  9840. },
  9841. enumerable: true,
  9842. configurable: true
  9843. });
  9844. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9845. /** Gets the selectors array */
  9846. get: function () {
  9847. return this._selectors;
  9848. },
  9849. enumerable: true,
  9850. configurable: true
  9851. });
  9852. Object.defineProperty(SelectorGroup.prototype, "header", {
  9853. /** Gets and sets the group header */
  9854. get: function () {
  9855. return this._groupHeader.text;
  9856. },
  9857. set: function (label) {
  9858. if (this._groupHeader.text === "label") {
  9859. return;
  9860. }
  9861. this._groupHeader.text = label;
  9862. },
  9863. enumerable: true,
  9864. configurable: true
  9865. });
  9866. /** @hidden */
  9867. SelectorGroup.prototype._addGroupHeader = function (text) {
  9868. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9869. groupHeading.width = 0.9;
  9870. groupHeading.height = "30px";
  9871. groupHeading.textWrapping = true;
  9872. groupHeading.color = "black";
  9873. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9874. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9875. groupHeading.left = "2px";
  9876. this._groupPanel.addControl(groupHeading);
  9877. return groupHeading;
  9878. };
  9879. /** @hidden*/
  9880. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9881. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9882. return;
  9883. }
  9884. return this._selectors[selectorNb];
  9885. };
  9886. /** Removes the selector at the given position
  9887. * @param selectorNb the position of the selector within the group
  9888. */
  9889. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9890. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9891. return;
  9892. }
  9893. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9894. this._selectors.splice(selectorNb, 1);
  9895. };
  9896. return SelectorGroup;
  9897. }());
  9898. /** Class used to create a CheckboxGroup
  9899. * which contains groups of checkbox buttons
  9900. */
  9901. var CheckboxGroup = /** @class */ (function (_super) {
  9902. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  9903. function CheckboxGroup() {
  9904. return _super !== null && _super.apply(this, arguments) || this;
  9905. }
  9906. /** Adds a checkbox as a control
  9907. * @param text is the label for the selector
  9908. * @param func is the function called when the Selector is checked
  9909. * @param checked is true when Selector is checked
  9910. */
  9911. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9912. if (func === void 0) { func = function (s) { }; }
  9913. if (checked === void 0) { checked = false; }
  9914. var checked = checked || false;
  9915. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9916. button.width = "20px";
  9917. button.height = "20px";
  9918. button.color = "#364249";
  9919. button.background = "#CCCCCC";
  9920. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9921. button.onIsCheckedChangedObservable.add(function (state) {
  9922. func(state);
  9923. });
  9924. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9925. _selector.height = "30px";
  9926. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9927. _selector.left = "4px";
  9928. this.groupPanel.addControl(_selector);
  9929. this.selectors.push(_selector);
  9930. button.isChecked = checked;
  9931. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9932. button.color = this.groupPanel.parent.parent.buttonColor;
  9933. button.background = this.groupPanel.parent.parent.buttonBackground;
  9934. }
  9935. };
  9936. /** @hidden */
  9937. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9938. this.selectors[selectorNb].children[1].text = label;
  9939. };
  9940. /** @hidden */
  9941. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9942. this.selectors[selectorNb].children[1].color = color;
  9943. };
  9944. /** @hidden */
  9945. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9946. this.selectors[selectorNb].children[0].color = color;
  9947. };
  9948. /** @hidden */
  9949. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9950. this.selectors[selectorNb].children[0].background = color;
  9951. };
  9952. return CheckboxGroup;
  9953. }(SelectorGroup));
  9954. /** Class used to create a RadioGroup
  9955. * which contains groups of radio buttons
  9956. */
  9957. var RadioGroup = /** @class */ (function (_super) {
  9958. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  9959. function RadioGroup() {
  9960. var _this = _super !== null && _super.apply(this, arguments) || this;
  9961. _this._selectNb = 0;
  9962. return _this;
  9963. }
  9964. /** Adds a radio button as a control
  9965. * @param label is the label for the selector
  9966. * @param func is the function called when the Selector is checked
  9967. * @param checked is true when Selector is checked
  9968. */
  9969. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9970. if (func === void 0) { func = function (n) { }; }
  9971. if (checked === void 0) { checked = false; }
  9972. var nb = this._selectNb++;
  9973. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9974. button.name = label;
  9975. button.width = "20px";
  9976. button.height = "20px";
  9977. button.color = "#364249";
  9978. button.background = "#CCCCCC";
  9979. button.group = this.name;
  9980. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9981. button.onIsCheckedChangedObservable.add(function (state) {
  9982. if (state) {
  9983. func(nb);
  9984. }
  9985. });
  9986. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9987. _selector.height = "30px";
  9988. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9989. _selector.left = "4px";
  9990. this.groupPanel.addControl(_selector);
  9991. this.selectors.push(_selector);
  9992. button.isChecked = checked;
  9993. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9994. button.color = this.groupPanel.parent.parent.buttonColor;
  9995. button.background = this.groupPanel.parent.parent.buttonBackground;
  9996. }
  9997. };
  9998. /** @hidden */
  9999. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10000. this.selectors[selectorNb].children[1].text = label;
  10001. };
  10002. /** @hidden */
  10003. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10004. this.selectors[selectorNb].children[1].color = color;
  10005. };
  10006. /** @hidden */
  10007. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10008. this.selectors[selectorNb].children[0].color = color;
  10009. };
  10010. /** @hidden */
  10011. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10012. this.selectors[selectorNb].children[0].background = color;
  10013. };
  10014. return RadioGroup;
  10015. }(SelectorGroup));
  10016. /** Class used to create a SliderGroup
  10017. * which contains groups of slider buttons
  10018. */
  10019. var SliderGroup = /** @class */ (function (_super) {
  10020. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  10021. function SliderGroup() {
  10022. return _super !== null && _super.apply(this, arguments) || this;
  10023. }
  10024. /**
  10025. * Adds a slider to the SelectorGroup
  10026. * @param label is the label for the SliderBar
  10027. * @param func is the function called when the Slider moves
  10028. * @param unit is a string describing the units used, eg degrees or metres
  10029. * @param min is the minimum value for the Slider
  10030. * @param max is the maximum value for the Slider
  10031. * @param value is the start value for the Slider between min and max
  10032. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  10033. */
  10034. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  10035. if (func === void 0) { func = function (v) { }; }
  10036. if (unit === void 0) { unit = "Units"; }
  10037. if (min === void 0) { min = 0; }
  10038. if (max === void 0) { max = 0; }
  10039. if (value === void 0) { value = 0; }
  10040. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  10041. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  10042. button.name = unit;
  10043. button.value = value;
  10044. button.minimum = min;
  10045. button.maximum = max;
  10046. button.width = 0.9;
  10047. button.height = "20px";
  10048. button.color = "#364249";
  10049. button.background = "#CCCCCC";
  10050. button.borderColor = "black";
  10051. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10052. button.left = "4px";
  10053. button.paddingBottom = "4px";
  10054. button.onValueChangedObservable.add(function (value) {
  10055. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  10056. func(value);
  10057. });
  10058. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  10059. _selector.height = "60px";
  10060. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10061. _selector.left = "4px";
  10062. _selector.children[0].name = label;
  10063. this.groupPanel.addControl(_selector);
  10064. this.selectors.push(_selector);
  10065. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10066. button.color = this.groupPanel.parent.parent.buttonColor;
  10067. button.background = this.groupPanel.parent.parent.buttonBackground;
  10068. }
  10069. };
  10070. /** @hidden */
  10071. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10072. this.selectors[selectorNb].children[0].name = label;
  10073. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  10074. };
  10075. /** @hidden */
  10076. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10077. this.selectors[selectorNb].children[0].color = color;
  10078. };
  10079. /** @hidden */
  10080. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10081. this.selectors[selectorNb].children[1].color = color;
  10082. };
  10083. /** @hidden */
  10084. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10085. this.selectors[selectorNb].children[1].background = color;
  10086. };
  10087. return SliderGroup;
  10088. }(SelectorGroup));
  10089. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  10090. * @see http://doc.babylonjs.com/how_to/selector
  10091. */
  10092. var SelectionPanel = /** @class */ (function (_super) {
  10093. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  10094. /**
  10095. * Creates a new SelectionPanel
  10096. * @param name of SelectionPanel
  10097. * @param groups is an array of SelectionGroups
  10098. */
  10099. function SelectionPanel(
  10100. /** name of SelectionPanel */
  10101. name,
  10102. /** an array of SelectionGroups */
  10103. groups) {
  10104. if (groups === void 0) { groups = []; }
  10105. var _this = _super.call(this, name) || this;
  10106. _this.name = name;
  10107. _this.groups = groups;
  10108. _this._buttonColor = "#364249";
  10109. _this._buttonBackground = "#CCCCCC";
  10110. _this._headerColor = "black";
  10111. _this._barColor = "white";
  10112. _this._barHeight = "2px";
  10113. _this._spacerHeight = "20px";
  10114. _this._bars = new Array();
  10115. _this._groups = groups;
  10116. _this.thickness = 2;
  10117. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10118. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10119. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10120. _this._panel.top = 5;
  10121. _this._panel.left = 5;
  10122. _this._panel.width = 0.95;
  10123. if (groups.length > 0) {
  10124. for (var i = 0; i < groups.length - 1; i++) {
  10125. _this._panel.addControl(groups[i].groupPanel);
  10126. _this._addSpacer();
  10127. }
  10128. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  10129. }
  10130. _this.addControl(_this._panel);
  10131. return _this;
  10132. }
  10133. SelectionPanel.prototype._getTypeName = function () {
  10134. return "SelectionPanel";
  10135. };
  10136. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  10137. /** Gets or sets the headerColor */
  10138. get: function () {
  10139. return this._headerColor;
  10140. },
  10141. set: function (color) {
  10142. if (this._headerColor === color) {
  10143. return;
  10144. }
  10145. this._headerColor = color;
  10146. this._setHeaderColor();
  10147. },
  10148. enumerable: true,
  10149. configurable: true
  10150. });
  10151. SelectionPanel.prototype._setHeaderColor = function () {
  10152. for (var i = 0; i < this._groups.length; i++) {
  10153. this._groups[i].groupPanel.children[0].color = this._headerColor;
  10154. }
  10155. };
  10156. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  10157. /** Gets or sets the button color */
  10158. get: function () {
  10159. return this._buttonColor;
  10160. },
  10161. set: function (color) {
  10162. if (this._buttonColor === color) {
  10163. return;
  10164. }
  10165. this._buttonColor = color;
  10166. this._setbuttonColor();
  10167. },
  10168. enumerable: true,
  10169. configurable: true
  10170. });
  10171. SelectionPanel.prototype._setbuttonColor = function () {
  10172. for (var i = 0; i < this._groups.length; i++) {
  10173. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10174. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  10175. }
  10176. }
  10177. };
  10178. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  10179. /** Gets or sets the label color */
  10180. get: function () {
  10181. return this._labelColor;
  10182. },
  10183. set: function (color) {
  10184. if (this._labelColor === color) {
  10185. return;
  10186. }
  10187. this._labelColor = color;
  10188. this._setLabelColor();
  10189. },
  10190. enumerable: true,
  10191. configurable: true
  10192. });
  10193. SelectionPanel.prototype._setLabelColor = function () {
  10194. for (var i = 0; i < this._groups.length; i++) {
  10195. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10196. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  10197. }
  10198. }
  10199. };
  10200. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  10201. /** Gets or sets the button background */
  10202. get: function () {
  10203. return this._buttonBackground;
  10204. },
  10205. set: function (color) {
  10206. if (this._buttonBackground === color) {
  10207. return;
  10208. }
  10209. this._buttonBackground = color;
  10210. this._setButtonBackground();
  10211. },
  10212. enumerable: true,
  10213. configurable: true
  10214. });
  10215. SelectionPanel.prototype._setButtonBackground = function () {
  10216. for (var i = 0; i < this._groups.length; i++) {
  10217. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10218. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  10219. }
  10220. }
  10221. };
  10222. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  10223. /** Gets or sets the color of separator bar */
  10224. get: function () {
  10225. return this._barColor;
  10226. },
  10227. set: function (color) {
  10228. if (this._barColor === color) {
  10229. return;
  10230. }
  10231. this._barColor = color;
  10232. this._setBarColor();
  10233. },
  10234. enumerable: true,
  10235. configurable: true
  10236. });
  10237. SelectionPanel.prototype._setBarColor = function () {
  10238. for (var i = 0; i < this._bars.length; i++) {
  10239. this._bars[i].children[0].background = this._barColor;
  10240. }
  10241. };
  10242. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  10243. /** Gets or sets the height of separator bar */
  10244. get: function () {
  10245. return this._barHeight;
  10246. },
  10247. set: function (value) {
  10248. if (this._barHeight === value) {
  10249. return;
  10250. }
  10251. this._barHeight = value;
  10252. this._setBarHeight();
  10253. },
  10254. enumerable: true,
  10255. configurable: true
  10256. });
  10257. SelectionPanel.prototype._setBarHeight = function () {
  10258. for (var i = 0; i < this._bars.length; i++) {
  10259. this._bars[i].children[0].height = this._barHeight;
  10260. }
  10261. };
  10262. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  10263. /** Gets or sets the height of spacers*/
  10264. get: function () {
  10265. return this._spacerHeight;
  10266. },
  10267. set: function (value) {
  10268. if (this._spacerHeight === value) {
  10269. return;
  10270. }
  10271. this._spacerHeight = value;
  10272. this._setSpacerHeight();
  10273. },
  10274. enumerable: true,
  10275. configurable: true
  10276. });
  10277. SelectionPanel.prototype._setSpacerHeight = function () {
  10278. for (var i = 0; i < this._bars.length; i++) {
  10279. this._bars[i].height = this._spacerHeight;
  10280. }
  10281. };
  10282. /** Adds a bar between groups */
  10283. SelectionPanel.prototype._addSpacer = function () {
  10284. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  10285. separator.width = 1;
  10286. separator.height = this._spacerHeight;
  10287. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10288. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  10289. bar.width = 1;
  10290. bar.height = this._barHeight;
  10291. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10292. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10293. bar.background = this._barColor;
  10294. bar.color = "transparent";
  10295. separator.addControl(bar);
  10296. this._panel.addControl(separator);
  10297. this._bars.push(separator);
  10298. };
  10299. /** Add a group to the selection panel
  10300. * @param group is the selector group to add
  10301. */
  10302. SelectionPanel.prototype.addGroup = function (group) {
  10303. if (this._groups.length > 0) {
  10304. this._addSpacer();
  10305. }
  10306. this._panel.addControl(group.groupPanel);
  10307. this._groups.push(group);
  10308. group.groupPanel.children[0].color = this._headerColor;
  10309. for (var j = 0; j < group.selectors.length; j++) {
  10310. group._setSelectorButtonColor(j, this._buttonColor);
  10311. group._setSelectorButtonBackground(j, this._buttonBackground);
  10312. }
  10313. };
  10314. /** Remove the group from the given position
  10315. * @param groupNb is the position of the group in the list
  10316. */
  10317. SelectionPanel.prototype.removeGroup = function (groupNb) {
  10318. if (groupNb < 0 || groupNb >= this._groups.length) {
  10319. return;
  10320. }
  10321. var group = this._groups[groupNb];
  10322. this._panel.removeControl(group.groupPanel);
  10323. this._groups.splice(groupNb, 1);
  10324. if (groupNb < this._bars.length) {
  10325. this._panel.removeControl(this._bars[groupNb]);
  10326. this._bars.splice(groupNb, 1);
  10327. }
  10328. };
  10329. /** Change a group header label
  10330. * @param label is the new group header label
  10331. * @param groupNb is the number of the group to relabel
  10332. * */
  10333. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  10334. if (groupNb < 0 || groupNb >= this._groups.length) {
  10335. return;
  10336. }
  10337. var group = this._groups[groupNb];
  10338. group.groupPanel.children[0].text = label;
  10339. };
  10340. /** Change selector label to the one given
  10341. * @param label is the new selector label
  10342. * @param groupNb is the number of the groupcontaining the selector
  10343. * @param selectorNb is the number of the selector within a group to relabel
  10344. * */
  10345. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  10346. if (groupNb < 0 || groupNb >= this._groups.length) {
  10347. return;
  10348. }
  10349. var group = this._groups[groupNb];
  10350. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10351. return;
  10352. }
  10353. group._setSelectorLabel(selectorNb, label);
  10354. };
  10355. /** For a given group position remove the selector at the given position
  10356. * @param groupNb is the number of the group to remove the selector from
  10357. * @param selectorNb is the number of the selector within the group
  10358. */
  10359. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  10360. if (groupNb < 0 || groupNb >= this._groups.length) {
  10361. return;
  10362. }
  10363. var group = this._groups[groupNb];
  10364. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10365. return;
  10366. }
  10367. group.removeSelector(selectorNb);
  10368. };
  10369. /** For a given group position of correct type add a checkbox button
  10370. * @param groupNb is the number of the group to remove the selector from
  10371. * @param label is the label for the selector
  10372. * @param func is the function called when the Selector is checked
  10373. * @param checked is true when Selector is checked
  10374. */
  10375. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  10376. if (func === void 0) { func = function () { }; }
  10377. if (checked === void 0) { checked = false; }
  10378. if (groupNb < 0 || groupNb >= this._groups.length) {
  10379. return;
  10380. }
  10381. var group = this._groups[groupNb];
  10382. group.addCheckbox(label, func, checked);
  10383. };
  10384. /** For a given group position of correct type add a radio button
  10385. * @param groupNb is the number of the group to remove the selector from
  10386. * @param label is the label for the selector
  10387. * @param func is the function called when the Selector is checked
  10388. * @param checked is true when Selector is checked
  10389. */
  10390. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  10391. if (func === void 0) { func = function () { }; }
  10392. if (checked === void 0) { checked = false; }
  10393. if (groupNb < 0 || groupNb >= this._groups.length) {
  10394. return;
  10395. }
  10396. var group = this._groups[groupNb];
  10397. group.addRadio(label, func, checked);
  10398. };
  10399. /**
  10400. * For a given slider group add a slider
  10401. * @param groupNb is the number of the group to add the slider to
  10402. * @param label is the label for the Slider
  10403. * @param func is the function called when the Slider moves
  10404. * @param unit is a string describing the units used, eg degrees or metres
  10405. * @param min is the minimum value for the Slider
  10406. * @param max is the maximum value for the Slider
  10407. * @param value is the start value for the Slider between min and max
  10408. * @param onVal is the function used to format the value displayed, eg radians to degrees
  10409. */
  10410. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  10411. if (func === void 0) { func = function () { }; }
  10412. if (unit === void 0) { unit = "Units"; }
  10413. if (min === void 0) { min = 0; }
  10414. if (max === void 0) { max = 0; }
  10415. if (value === void 0) { value = 0; }
  10416. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  10417. if (groupNb < 0 || groupNb >= this._groups.length) {
  10418. return;
  10419. }
  10420. var group = this._groups[groupNb];
  10421. group.addSlider(label, func, unit, min, max, value, onVal);
  10422. };
  10423. return SelectionPanel;
  10424. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10425. /***/ }),
  10426. /***/ "./2D/controls/sliders/baseSlider.ts":
  10427. /*!*******************************************!*\
  10428. !*** ./2D/controls/sliders/baseSlider.ts ***!
  10429. \*******************************************/
  10430. /*! exports provided: BaseSlider */
  10431. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10432. "use strict";
  10433. __webpack_require__.r(__webpack_exports__);
  10434. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  10435. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10436. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  10437. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10438. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10439. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10440. /**
  10441. * Class used to create slider controls
  10442. */
  10443. var BaseSlider = /** @class */ (function (_super) {
  10444. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  10445. /**
  10446. * Creates a new BaseSlider
  10447. * @param name defines the control name
  10448. */
  10449. function BaseSlider(name) {
  10450. var _this = _super.call(this, name) || this;
  10451. _this.name = name;
  10452. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10453. _this._minimum = 0;
  10454. _this._maximum = 100;
  10455. _this._value = 50;
  10456. _this._isVertical = false;
  10457. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10458. _this._isThumbClamped = false;
  10459. _this._displayThumb = true;
  10460. _this._step = 0;
  10461. _this._lastPointerDownID = -1;
  10462. // Shared rendering info
  10463. _this._effectiveBarOffset = 0;
  10464. /** Observable raised when the sldier value changes */
  10465. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10466. // Events
  10467. _this._pointerIsDown = false;
  10468. _this.isPointerBlocker = true;
  10469. return _this;
  10470. }
  10471. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10472. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10473. get: function () {
  10474. return this._displayThumb;
  10475. },
  10476. set: function (value) {
  10477. if (this._displayThumb === value) {
  10478. return;
  10479. }
  10480. this._displayThumb = value;
  10481. this._markAsDirty();
  10482. },
  10483. enumerable: true,
  10484. configurable: true
  10485. });
  10486. Object.defineProperty(BaseSlider.prototype, "step", {
  10487. /** Gets or sets a step to apply to values (0 by default) */
  10488. get: function () {
  10489. return this._step;
  10490. },
  10491. set: function (value) {
  10492. if (this._step === value) {
  10493. return;
  10494. }
  10495. this._step = value;
  10496. this._markAsDirty();
  10497. },
  10498. enumerable: true,
  10499. configurable: true
  10500. });
  10501. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10502. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10503. get: function () {
  10504. return this._barOffset.toString(this._host);
  10505. },
  10506. set: function (value) {
  10507. if (this._barOffset.toString(this._host) === value) {
  10508. return;
  10509. }
  10510. if (this._barOffset.fromString(value)) {
  10511. this._markAsDirty();
  10512. }
  10513. },
  10514. enumerable: true,
  10515. configurable: true
  10516. });
  10517. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10518. /** Gets main bar offset in pixels*/
  10519. get: function () {
  10520. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10521. },
  10522. enumerable: true,
  10523. configurable: true
  10524. });
  10525. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10526. /** Gets or sets thumb width */
  10527. get: function () {
  10528. return this._thumbWidth.toString(this._host);
  10529. },
  10530. set: function (value) {
  10531. if (this._thumbWidth.toString(this._host) === value) {
  10532. return;
  10533. }
  10534. if (this._thumbWidth.fromString(value)) {
  10535. this._markAsDirty();
  10536. }
  10537. },
  10538. enumerable: true,
  10539. configurable: true
  10540. });
  10541. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10542. /** Gets thumb width in pixels */
  10543. get: function () {
  10544. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10545. },
  10546. enumerable: true,
  10547. configurable: true
  10548. });
  10549. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10550. /** Gets or sets minimum value */
  10551. get: function () {
  10552. return this._minimum;
  10553. },
  10554. set: function (value) {
  10555. if (this._minimum === value) {
  10556. return;
  10557. }
  10558. this._minimum = value;
  10559. this._markAsDirty();
  10560. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10561. },
  10562. enumerable: true,
  10563. configurable: true
  10564. });
  10565. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10566. /** Gets or sets maximum value */
  10567. get: function () {
  10568. return this._maximum;
  10569. },
  10570. set: function (value) {
  10571. if (this._maximum === value) {
  10572. return;
  10573. }
  10574. this._maximum = value;
  10575. this._markAsDirty();
  10576. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10577. },
  10578. enumerable: true,
  10579. configurable: true
  10580. });
  10581. Object.defineProperty(BaseSlider.prototype, "value", {
  10582. /** Gets or sets current value */
  10583. get: function () {
  10584. return this._value;
  10585. },
  10586. set: function (value) {
  10587. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10588. if (this._value === value) {
  10589. return;
  10590. }
  10591. this._value = value;
  10592. this._markAsDirty();
  10593. this.onValueChangedObservable.notifyObservers(this._value);
  10594. },
  10595. enumerable: true,
  10596. configurable: true
  10597. });
  10598. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10599. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10600. get: function () {
  10601. return this._isVertical;
  10602. },
  10603. set: function (value) {
  10604. if (this._isVertical === value) {
  10605. return;
  10606. }
  10607. this._isVertical = value;
  10608. this._markAsDirty();
  10609. },
  10610. enumerable: true,
  10611. configurable: true
  10612. });
  10613. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10614. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10615. get: function () {
  10616. return this._isThumbClamped;
  10617. },
  10618. set: function (value) {
  10619. if (this._isThumbClamped === value) {
  10620. return;
  10621. }
  10622. this._isThumbClamped = value;
  10623. this._markAsDirty();
  10624. },
  10625. enumerable: true,
  10626. configurable: true
  10627. });
  10628. BaseSlider.prototype._getTypeName = function () {
  10629. return "BaseSlider";
  10630. };
  10631. BaseSlider.prototype._getThumbPosition = function () {
  10632. if (this.isVertical) {
  10633. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10634. }
  10635. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10636. };
  10637. BaseSlider.prototype._getThumbThickness = function (type) {
  10638. var thumbThickness = 0;
  10639. switch (type) {
  10640. case "circle":
  10641. if (this._thumbWidth.isPixel) {
  10642. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10643. }
  10644. else {
  10645. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10646. }
  10647. break;
  10648. case "rectangle":
  10649. if (this._thumbWidth.isPixel) {
  10650. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10651. }
  10652. else {
  10653. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10654. }
  10655. }
  10656. return thumbThickness;
  10657. };
  10658. BaseSlider.prototype._prepareRenderingData = function (type) {
  10659. // Main bar
  10660. this._effectiveBarOffset = 0;
  10661. this._renderLeft = this._currentMeasure.left;
  10662. this._renderTop = this._currentMeasure.top;
  10663. this._renderWidth = this._currentMeasure.width;
  10664. this._renderHeight = this._currentMeasure.height;
  10665. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10666. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10667. this._effectiveThumbThickness = this._getThumbThickness(type);
  10668. if (this.displayThumb) {
  10669. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10670. }
  10671. //throw error when height is less than width for vertical slider
  10672. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10673. console.error("Height should be greater than width");
  10674. return;
  10675. }
  10676. if (this._barOffset.isPixel) {
  10677. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10678. }
  10679. else {
  10680. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10681. }
  10682. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10683. if (this.isVertical) {
  10684. this._renderLeft += this._effectiveBarOffset;
  10685. if (!this.isThumbClamped && this.displayThumb) {
  10686. this._renderTop += (this._effectiveThumbThickness / 2);
  10687. }
  10688. this._renderHeight = this._backgroundBoxLength;
  10689. this._renderWidth = this._backgroundBoxThickness;
  10690. }
  10691. else {
  10692. this._renderTop += this._effectiveBarOffset;
  10693. if (!this.isThumbClamped && this.displayThumb) {
  10694. this._renderLeft += (this._effectiveThumbThickness / 2);
  10695. }
  10696. this._renderHeight = this._backgroundBoxThickness;
  10697. this._renderWidth = this._backgroundBoxLength;
  10698. }
  10699. };
  10700. /** @hidden */
  10701. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10702. if (this.rotation != 0) {
  10703. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10704. x = this._transformedPosition.x;
  10705. y = this._transformedPosition.y;
  10706. }
  10707. var value;
  10708. if (this._isVertical) {
  10709. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10710. }
  10711. else {
  10712. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10713. }
  10714. var mult = (1 / this._step) | 0;
  10715. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10716. };
  10717. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10718. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10719. return false;
  10720. }
  10721. this._pointerIsDown = true;
  10722. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10723. this._host._capturingControl[pointerId] = this;
  10724. this._lastPointerDownID = pointerId;
  10725. return true;
  10726. };
  10727. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10728. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10729. if (pointerId != this._lastPointerDownID) {
  10730. return;
  10731. }
  10732. if (this._pointerIsDown) {
  10733. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10734. }
  10735. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10736. };
  10737. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10738. this._pointerIsDown = false;
  10739. delete this._host._capturingControl[pointerId];
  10740. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10741. };
  10742. return BaseSlider;
  10743. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10744. /***/ }),
  10745. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10746. /*!*************************************************!*\
  10747. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10748. \*************************************************/
  10749. /*! exports provided: ImageBasedSlider */
  10750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10751. "use strict";
  10752. __webpack_require__.r(__webpack_exports__);
  10753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10754. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10755. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10756. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10757. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  10758. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10759. /**
  10760. * Class used to create slider controls based on images
  10761. */
  10762. var ImageBasedSlider = /** @class */ (function (_super) {
  10763. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  10764. /**
  10765. * Creates a new ImageBasedSlider
  10766. * @param name defines the control name
  10767. */
  10768. function ImageBasedSlider(name) {
  10769. var _this = _super.call(this, name) || this;
  10770. _this.name = name;
  10771. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10772. return _this;
  10773. }
  10774. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10775. get: function () {
  10776. return this._displayThumb && this.thumbImage != null;
  10777. },
  10778. set: function (value) {
  10779. if (this._displayThumb === value) {
  10780. return;
  10781. }
  10782. this._displayThumb = value;
  10783. this._markAsDirty();
  10784. },
  10785. enumerable: true,
  10786. configurable: true
  10787. });
  10788. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10789. /**
  10790. * Gets or sets the image used to render the background
  10791. */
  10792. get: function () {
  10793. return this._backgroundImage;
  10794. },
  10795. set: function (value) {
  10796. var _this = this;
  10797. if (this._backgroundImage === value) {
  10798. return;
  10799. }
  10800. this._backgroundImage = value;
  10801. if (value && !value.isLoaded) {
  10802. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10803. }
  10804. this._markAsDirty();
  10805. },
  10806. enumerable: true,
  10807. configurable: true
  10808. });
  10809. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10810. /**
  10811. * Gets or sets the image used to render the value bar
  10812. */
  10813. get: function () {
  10814. return this._valueBarImage;
  10815. },
  10816. set: function (value) {
  10817. var _this = this;
  10818. if (this._valueBarImage === value) {
  10819. return;
  10820. }
  10821. this._valueBarImage = value;
  10822. if (value && !value.isLoaded) {
  10823. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10824. }
  10825. this._markAsDirty();
  10826. },
  10827. enumerable: true,
  10828. configurable: true
  10829. });
  10830. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10831. /**
  10832. * Gets or sets the image used to render the thumb
  10833. */
  10834. get: function () {
  10835. return this._thumbImage;
  10836. },
  10837. set: function (value) {
  10838. var _this = this;
  10839. if (this._thumbImage === value) {
  10840. return;
  10841. }
  10842. this._thumbImage = value;
  10843. if (value && !value.isLoaded) {
  10844. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10845. }
  10846. this._markAsDirty();
  10847. },
  10848. enumerable: true,
  10849. configurable: true
  10850. });
  10851. ImageBasedSlider.prototype._getTypeName = function () {
  10852. return "ImageBasedSlider";
  10853. };
  10854. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  10855. context.save();
  10856. this._applyStates(context);
  10857. this._prepareRenderingData("rectangle");
  10858. var thumbPosition = this._getThumbPosition();
  10859. var left = this._renderLeft;
  10860. var top = this._renderTop;
  10861. var width = this._renderWidth;
  10862. var height = this._renderHeight;
  10863. // Background
  10864. if (this._backgroundImage) {
  10865. this._tempMeasure.copyFromFloats(left, top, width, height);
  10866. if (this.isThumbClamped && this.displayThumb) {
  10867. if (this.isVertical) {
  10868. this._tempMeasure.height += this._effectiveThumbThickness;
  10869. }
  10870. else {
  10871. this._tempMeasure.width += this._effectiveThumbThickness;
  10872. }
  10873. }
  10874. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10875. this._backgroundImage._draw(context);
  10876. }
  10877. // Bar
  10878. if (this._valueBarImage) {
  10879. if (this.isVertical) {
  10880. if (this.isThumbClamped && this.displayThumb) {
  10881. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10882. }
  10883. else {
  10884. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10885. }
  10886. }
  10887. else {
  10888. if (this.isThumbClamped && this.displayThumb) {
  10889. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10890. }
  10891. else {
  10892. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10893. }
  10894. }
  10895. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10896. this._valueBarImage._draw(context);
  10897. }
  10898. // Thumb
  10899. if (this.displayThumb) {
  10900. if (this.isVertical) {
  10901. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10902. }
  10903. else {
  10904. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10905. }
  10906. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10907. this._thumbImage._draw(context);
  10908. }
  10909. context.restore();
  10910. };
  10911. return ImageBasedSlider;
  10912. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10913. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  10914. /***/ }),
  10915. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  10916. /*!***********************************************!*\
  10917. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  10918. \***********************************************/
  10919. /*! exports provided: ImageScrollBar */
  10920. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10921. "use strict";
  10922. __webpack_require__.r(__webpack_exports__);
  10923. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  10924. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10925. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10926. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10927. /**
  10928. * Class used to create slider controls
  10929. */
  10930. var ImageScrollBar = /** @class */ (function (_super) {
  10931. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  10932. /**
  10933. * Creates a new ImageScrollBar
  10934. * @param name defines the control name
  10935. */
  10936. function ImageScrollBar(name) {
  10937. var _this = _super.call(this, name) || this;
  10938. _this.name = name;
  10939. _this._thumbLength = 0.5;
  10940. _this._thumbHeight = 1;
  10941. _this._barImageHeight = 1;
  10942. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10943. return _this;
  10944. }
  10945. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  10946. /**
  10947. * Gets or sets the image used to render the background for horizontal bar
  10948. */
  10949. get: function () {
  10950. return this._backgroundBaseImage;
  10951. },
  10952. set: function (value) {
  10953. var _this = this;
  10954. if (this._backgroundBaseImage === value) {
  10955. return;
  10956. }
  10957. this._backgroundBaseImage = value;
  10958. if (this.isVertical) {
  10959. if (value && !value.isLoaded) {
  10960. value.onImageLoadedObservable.addOnce(function () {
  10961. var rotatedValue = value._rotate90(1);
  10962. _this._backgroundImage = rotatedValue;
  10963. if (!rotatedValue.isLoaded) {
  10964. rotatedValue.onImageLoadedObservable.addOnce(function () {
  10965. _this._markAsDirty();
  10966. });
  10967. }
  10968. _this._markAsDirty();
  10969. });
  10970. }
  10971. this._backgroundImage = value._rotate90(1);
  10972. this._markAsDirty();
  10973. }
  10974. else {
  10975. this._backgroundImage = value;
  10976. if (value && !value.isLoaded) {
  10977. value.onImageLoadedObservable.addOnce(function () {
  10978. _this._markAsDirty();
  10979. });
  10980. }
  10981. this._markAsDirty();
  10982. }
  10983. },
  10984. enumerable: true,
  10985. configurable: true
  10986. });
  10987. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  10988. /**
  10989. * Gets or sets the image used to render the thumb
  10990. */
  10991. get: function () {
  10992. return this._thumbBaseImage;
  10993. },
  10994. set: function (value) {
  10995. var _this = this;
  10996. if (this._thumbBaseImage === value) {
  10997. return;
  10998. }
  10999. this._thumbBaseImage = value;
  11000. if (this.isVertical) {
  11001. if (value && !value.isLoaded) {
  11002. value.onImageLoadedObservable.addOnce(function () {
  11003. var rotatedValue = value._rotate90(-1);
  11004. _this._thumbImage = rotatedValue;
  11005. if (!rotatedValue.isLoaded) {
  11006. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11007. _this._markAsDirty();
  11008. });
  11009. }
  11010. _this._markAsDirty();
  11011. });
  11012. }
  11013. this._thumbImage = value._rotate90(-1);
  11014. this._markAsDirty();
  11015. }
  11016. else {
  11017. this._thumbImage = value;
  11018. if (value && !value.isLoaded) {
  11019. value.onImageLoadedObservable.addOnce(function () {
  11020. _this._markAsDirty();
  11021. });
  11022. }
  11023. this._markAsDirty();
  11024. }
  11025. },
  11026. enumerable: true,
  11027. configurable: true
  11028. });
  11029. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  11030. /**
  11031. * Gets or sets the length of the thumb
  11032. */
  11033. get: function () {
  11034. return this._thumbLength;
  11035. },
  11036. set: function (value) {
  11037. if (this._thumbLength === value) {
  11038. return;
  11039. }
  11040. this._thumbLength = value;
  11041. this._markAsDirty();
  11042. },
  11043. enumerable: true,
  11044. configurable: true
  11045. });
  11046. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  11047. /**
  11048. * Gets or sets the height of the thumb
  11049. */
  11050. get: function () {
  11051. return this._thumbHeight;
  11052. },
  11053. set: function (value) {
  11054. if (this._thumbLength === value) {
  11055. return;
  11056. }
  11057. this._thumbHeight = value;
  11058. this._markAsDirty();
  11059. },
  11060. enumerable: true,
  11061. configurable: true
  11062. });
  11063. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  11064. /**
  11065. * Gets or sets the height of the bar image
  11066. */
  11067. get: function () {
  11068. return this._barImageHeight;
  11069. },
  11070. set: function (value) {
  11071. if (this._barImageHeight === value) {
  11072. return;
  11073. }
  11074. this._barImageHeight = value;
  11075. this._markAsDirty();
  11076. },
  11077. enumerable: true,
  11078. configurable: true
  11079. });
  11080. ImageScrollBar.prototype._getTypeName = function () {
  11081. return "ImageScrollBar";
  11082. };
  11083. ImageScrollBar.prototype._getThumbThickness = function () {
  11084. var thumbThickness = 0;
  11085. if (this._thumbWidth.isPixel) {
  11086. thumbThickness = this._thumbWidth.getValue(this._host);
  11087. }
  11088. else {
  11089. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11090. }
  11091. return thumbThickness;
  11092. };
  11093. ImageScrollBar.prototype._draw = function (context) {
  11094. context.save();
  11095. this._applyStates(context);
  11096. this._prepareRenderingData("rectangle");
  11097. var thumbPosition = this._getThumbPosition();
  11098. var left = this._renderLeft;
  11099. var top = this._renderTop;
  11100. var width = this._renderWidth;
  11101. var height = this._renderHeight;
  11102. // Background
  11103. if (this._backgroundImage) {
  11104. this._tempMeasure.copyFromFloats(left, top, width, height);
  11105. if (this.isVertical) {
  11106. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  11107. this._tempMeasure.height += this._effectiveThumbThickness;
  11108. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11109. }
  11110. else {
  11111. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  11112. this._tempMeasure.width += this._effectiveThumbThickness;
  11113. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11114. }
  11115. this._backgroundImage._draw(context);
  11116. }
  11117. // Thumb
  11118. if (this.isVertical) {
  11119. 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);
  11120. }
  11121. else {
  11122. 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);
  11123. }
  11124. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11125. this._thumbImage._draw(context);
  11126. context.restore();
  11127. };
  11128. /** @hidden */
  11129. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11130. if (this.rotation != 0) {
  11131. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11132. x = this._transformedPosition.x;
  11133. y = this._transformedPosition.y;
  11134. }
  11135. if (this._first) {
  11136. this._first = false;
  11137. this._originX = x;
  11138. this._originY = y;
  11139. // Check if move is required
  11140. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11141. if (this.isVertical) {
  11142. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11143. }
  11144. else {
  11145. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11146. }
  11147. }
  11148. }
  11149. // Delta mode
  11150. var delta = 0;
  11151. if (this.isVertical) {
  11152. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11153. }
  11154. else {
  11155. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11156. }
  11157. this.value += delta * (this.maximum - this.minimum);
  11158. this._originX = x;
  11159. this._originY = y;
  11160. };
  11161. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11162. this._first = true;
  11163. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11164. };
  11165. return ImageScrollBar;
  11166. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11167. /***/ }),
  11168. /***/ "./2D/controls/sliders/scrollBar.ts":
  11169. /*!******************************************!*\
  11170. !*** ./2D/controls/sliders/scrollBar.ts ***!
  11171. \******************************************/
  11172. /*! exports provided: ScrollBar */
  11173. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11174. "use strict";
  11175. __webpack_require__.r(__webpack_exports__);
  11176. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  11177. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11178. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11179. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11180. /**
  11181. * Class used to create slider controls
  11182. */
  11183. var ScrollBar = /** @class */ (function (_super) {
  11184. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  11185. /**
  11186. * Creates a new Slider
  11187. * @param name defines the control name
  11188. */
  11189. function ScrollBar(name) {
  11190. var _this = _super.call(this, name) || this;
  11191. _this.name = name;
  11192. _this._background = "black";
  11193. _this._borderColor = "white";
  11194. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11195. return _this;
  11196. }
  11197. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  11198. /** Gets or sets border color */
  11199. get: function () {
  11200. return this._borderColor;
  11201. },
  11202. set: function (value) {
  11203. if (this._borderColor === value) {
  11204. return;
  11205. }
  11206. this._borderColor = value;
  11207. this._markAsDirty();
  11208. },
  11209. enumerable: true,
  11210. configurable: true
  11211. });
  11212. Object.defineProperty(ScrollBar.prototype, "background", {
  11213. /** Gets or sets background color */
  11214. get: function () {
  11215. return this._background;
  11216. },
  11217. set: function (value) {
  11218. if (this._background === value) {
  11219. return;
  11220. }
  11221. this._background = value;
  11222. this._markAsDirty();
  11223. },
  11224. enumerable: true,
  11225. configurable: true
  11226. });
  11227. ScrollBar.prototype._getTypeName = function () {
  11228. return "Scrollbar";
  11229. };
  11230. ScrollBar.prototype._getThumbThickness = function () {
  11231. var thumbThickness = 0;
  11232. if (this._thumbWidth.isPixel) {
  11233. thumbThickness = this._thumbWidth.getValue(this._host);
  11234. }
  11235. else {
  11236. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11237. }
  11238. return thumbThickness;
  11239. };
  11240. ScrollBar.prototype._draw = function (context) {
  11241. context.save();
  11242. this._applyStates(context);
  11243. this._prepareRenderingData("rectangle");
  11244. var left = this._renderLeft;
  11245. var thumbPosition = this._getThumbPosition();
  11246. context.fillStyle = this._background;
  11247. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  11248. // Value bar
  11249. context.fillStyle = this.color;
  11250. // Thumb
  11251. if (this.isVertical) {
  11252. this._tempMeasure.left = left - this._effectiveBarOffset;
  11253. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  11254. this._tempMeasure.width = this._currentMeasure.width;
  11255. this._tempMeasure.height = this._effectiveThumbThickness;
  11256. }
  11257. else {
  11258. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  11259. this._tempMeasure.top = this._currentMeasure.top;
  11260. this._tempMeasure.width = this._effectiveThumbThickness;
  11261. this._tempMeasure.height = this._currentMeasure.height;
  11262. }
  11263. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  11264. context.restore();
  11265. };
  11266. /** @hidden */
  11267. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11268. if (this.rotation != 0) {
  11269. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11270. x = this._transformedPosition.x;
  11271. y = this._transformedPosition.y;
  11272. }
  11273. if (this._first) {
  11274. this._first = false;
  11275. this._originX = x;
  11276. this._originY = y;
  11277. // Check if move is required
  11278. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11279. if (this.isVertical) {
  11280. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11281. }
  11282. else {
  11283. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11284. }
  11285. }
  11286. }
  11287. // Delta mode
  11288. var delta = 0;
  11289. if (this.isVertical) {
  11290. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11291. }
  11292. else {
  11293. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11294. }
  11295. this.value += delta * (this.maximum - this.minimum);
  11296. this._originX = x;
  11297. this._originY = y;
  11298. };
  11299. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11300. this._first = true;
  11301. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11302. };
  11303. return ScrollBar;
  11304. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11305. /***/ }),
  11306. /***/ "./2D/controls/sliders/slider.ts":
  11307. /*!***************************************!*\
  11308. !*** ./2D/controls/sliders/slider.ts ***!
  11309. \***************************************/
  11310. /*! exports provided: Slider */
  11311. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11312. "use strict";
  11313. __webpack_require__.r(__webpack_exports__);
  11314. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  11315. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11316. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11317. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  11318. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  11319. /**
  11320. * Class used to create slider controls
  11321. */
  11322. var Slider = /** @class */ (function (_super) {
  11323. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  11324. /**
  11325. * Creates a new Slider
  11326. * @param name defines the control name
  11327. */
  11328. function Slider(name) {
  11329. var _this = _super.call(this, name) || this;
  11330. _this.name = name;
  11331. _this._background = "black";
  11332. _this._borderColor = "white";
  11333. _this._isThumbCircle = false;
  11334. _this._displayValueBar = true;
  11335. return _this;
  11336. }
  11337. Object.defineProperty(Slider.prototype, "displayValueBar", {
  11338. /** Gets or sets a boolean indicating if the value bar must be rendered */
  11339. get: function () {
  11340. return this._displayValueBar;
  11341. },
  11342. set: function (value) {
  11343. if (this._displayValueBar === value) {
  11344. return;
  11345. }
  11346. this._displayValueBar = value;
  11347. this._markAsDirty();
  11348. },
  11349. enumerable: true,
  11350. configurable: true
  11351. });
  11352. Object.defineProperty(Slider.prototype, "borderColor", {
  11353. /** Gets or sets border color */
  11354. get: function () {
  11355. return this._borderColor;
  11356. },
  11357. set: function (value) {
  11358. if (this._borderColor === value) {
  11359. return;
  11360. }
  11361. this._borderColor = value;
  11362. this._markAsDirty();
  11363. },
  11364. enumerable: true,
  11365. configurable: true
  11366. });
  11367. Object.defineProperty(Slider.prototype, "background", {
  11368. /** Gets or sets background color */
  11369. get: function () {
  11370. return this._background;
  11371. },
  11372. set: function (value) {
  11373. if (this._background === value) {
  11374. return;
  11375. }
  11376. this._background = value;
  11377. this._markAsDirty();
  11378. },
  11379. enumerable: true,
  11380. configurable: true
  11381. });
  11382. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  11383. /** Gets or sets a boolean indicating if the thumb should be round or square */
  11384. get: function () {
  11385. return this._isThumbCircle;
  11386. },
  11387. set: function (value) {
  11388. if (this._isThumbCircle === value) {
  11389. return;
  11390. }
  11391. this._isThumbCircle = value;
  11392. this._markAsDirty();
  11393. },
  11394. enumerable: true,
  11395. configurable: true
  11396. });
  11397. Slider.prototype._getTypeName = function () {
  11398. return "Slider";
  11399. };
  11400. Slider.prototype._draw = function (context, invalidatedRectangle) {
  11401. context.save();
  11402. this._applyStates(context);
  11403. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  11404. var left = this._renderLeft;
  11405. var top = this._renderTop;
  11406. var width = this._renderWidth;
  11407. var height = this._renderHeight;
  11408. var radius = 0;
  11409. if (this.isThumbClamped && this.isThumbCircle) {
  11410. if (this.isVertical) {
  11411. top += (this._effectiveThumbThickness / 2);
  11412. }
  11413. else {
  11414. left += (this._effectiveThumbThickness / 2);
  11415. }
  11416. radius = this._backgroundBoxThickness / 2;
  11417. }
  11418. else {
  11419. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  11420. }
  11421. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11422. context.shadowColor = this.shadowColor;
  11423. context.shadowBlur = this.shadowBlur;
  11424. context.shadowOffsetX = this.shadowOffsetX;
  11425. context.shadowOffsetY = this.shadowOffsetY;
  11426. }
  11427. var thumbPosition = this._getThumbPosition();
  11428. context.fillStyle = this._background;
  11429. if (this.isVertical) {
  11430. if (this.isThumbClamped) {
  11431. if (this.isThumbCircle) {
  11432. context.beginPath();
  11433. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  11434. context.fill();
  11435. context.fillRect(left, top, width, height);
  11436. }
  11437. else {
  11438. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  11439. }
  11440. }
  11441. else {
  11442. context.fillRect(left, top, width, height);
  11443. }
  11444. }
  11445. else {
  11446. if (this.isThumbClamped) {
  11447. if (this.isThumbCircle) {
  11448. context.beginPath();
  11449. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11450. context.fill();
  11451. context.fillRect(left, top, width, height);
  11452. }
  11453. else {
  11454. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  11455. }
  11456. }
  11457. else {
  11458. context.fillRect(left, top, width, height);
  11459. }
  11460. }
  11461. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11462. context.shadowBlur = 0;
  11463. context.shadowOffsetX = 0;
  11464. context.shadowOffsetY = 0;
  11465. }
  11466. // Value bar
  11467. context.fillStyle = this.color;
  11468. if (this._displayValueBar) {
  11469. if (this.isVertical) {
  11470. if (this.isThumbClamped) {
  11471. if (this.isThumbCircle) {
  11472. context.beginPath();
  11473. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  11474. context.fill();
  11475. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11476. }
  11477. else {
  11478. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11479. }
  11480. }
  11481. else {
  11482. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11483. }
  11484. }
  11485. else {
  11486. if (this.isThumbClamped) {
  11487. if (this.isThumbCircle) {
  11488. context.beginPath();
  11489. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  11490. context.fill();
  11491. context.fillRect(left, top, thumbPosition, height);
  11492. }
  11493. else {
  11494. context.fillRect(left, top, thumbPosition, height);
  11495. }
  11496. }
  11497. else {
  11498. context.fillRect(left, top, thumbPosition, height);
  11499. }
  11500. }
  11501. }
  11502. // Thumb
  11503. if (this.displayThumb) {
  11504. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11505. context.shadowColor = this.shadowColor;
  11506. context.shadowBlur = this.shadowBlur;
  11507. context.shadowOffsetX = this.shadowOffsetX;
  11508. context.shadowOffsetY = this.shadowOffsetY;
  11509. }
  11510. if (this._isThumbCircle) {
  11511. context.beginPath();
  11512. if (this.isVertical) {
  11513. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11514. }
  11515. else {
  11516. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11517. }
  11518. context.fill();
  11519. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11520. context.shadowBlur = 0;
  11521. context.shadowOffsetX = 0;
  11522. context.shadowOffsetY = 0;
  11523. }
  11524. context.strokeStyle = this._borderColor;
  11525. context.stroke();
  11526. }
  11527. else {
  11528. if (this.isVertical) {
  11529. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11530. }
  11531. else {
  11532. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11533. }
  11534. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11535. context.shadowBlur = 0;
  11536. context.shadowOffsetX = 0;
  11537. context.shadowOffsetY = 0;
  11538. }
  11539. context.strokeStyle = this._borderColor;
  11540. if (this.isVertical) {
  11541. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11542. }
  11543. else {
  11544. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11545. }
  11546. }
  11547. }
  11548. context.restore();
  11549. };
  11550. return Slider;
  11551. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11552. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11553. /***/ }),
  11554. /***/ "./2D/controls/stackPanel.ts":
  11555. /*!***********************************!*\
  11556. !*** ./2D/controls/stackPanel.ts ***!
  11557. \***********************************/
  11558. /*! exports provided: StackPanel */
  11559. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11560. "use strict";
  11561. __webpack_require__.r(__webpack_exports__);
  11562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11563. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11564. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  11565. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11566. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11567. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11568. /**
  11569. * Class used to create a 2D stack panel container
  11570. */
  11571. var StackPanel = /** @class */ (function (_super) {
  11572. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11573. /**
  11574. * Creates a new StackPanel
  11575. * @param name defines control name
  11576. */
  11577. function StackPanel(name) {
  11578. var _this = _super.call(this, name) || this;
  11579. _this.name = name;
  11580. _this._isVertical = true;
  11581. _this._manualWidth = false;
  11582. _this._manualHeight = false;
  11583. _this._doNotTrackManualChanges = false;
  11584. /**
  11585. * Gets or sets a boolean indicating that layou warnings should be ignored
  11586. */
  11587. _this.ignoreLayoutWarnings = false;
  11588. return _this;
  11589. }
  11590. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11591. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11592. get: function () {
  11593. return this._isVertical;
  11594. },
  11595. set: function (value) {
  11596. if (this._isVertical === value) {
  11597. return;
  11598. }
  11599. this._isVertical = value;
  11600. this._markAsDirty();
  11601. },
  11602. enumerable: true,
  11603. configurable: true
  11604. });
  11605. Object.defineProperty(StackPanel.prototype, "width", {
  11606. get: function () {
  11607. return this._width.toString(this._host);
  11608. },
  11609. /**
  11610. * Gets or sets panel width.
  11611. * This value should not be set when in horizontal mode as it will be computed automatically
  11612. */
  11613. set: function (value) {
  11614. if (!this._doNotTrackManualChanges) {
  11615. this._manualWidth = true;
  11616. }
  11617. if (this._width.toString(this._host) === value) {
  11618. return;
  11619. }
  11620. if (this._width.fromString(value)) {
  11621. this._markAsDirty();
  11622. }
  11623. },
  11624. enumerable: true,
  11625. configurable: true
  11626. });
  11627. Object.defineProperty(StackPanel.prototype, "height", {
  11628. get: function () {
  11629. return this._height.toString(this._host);
  11630. },
  11631. /**
  11632. * Gets or sets panel height.
  11633. * This value should not be set when in vertical mode as it will be computed automatically
  11634. */
  11635. set: function (value) {
  11636. if (!this._doNotTrackManualChanges) {
  11637. this._manualHeight = true;
  11638. }
  11639. if (this._height.toString(this._host) === value) {
  11640. return;
  11641. }
  11642. if (this._height.fromString(value)) {
  11643. this._markAsDirty();
  11644. }
  11645. },
  11646. enumerable: true,
  11647. configurable: true
  11648. });
  11649. StackPanel.prototype._getTypeName = function () {
  11650. return "StackPanel";
  11651. };
  11652. /** @hidden */
  11653. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11654. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11655. var child = _a[_i];
  11656. if (this._isVertical) {
  11657. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11658. }
  11659. else {
  11660. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11661. }
  11662. }
  11663. _super.prototype._preMeasure.call(this, parentMeasure, context);
  11664. };
  11665. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  11666. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  11667. this._measureForChildren.copyFrom(parentMeasure);
  11668. this._measureForChildren.left = this._currentMeasure.left;
  11669. this._measureForChildren.top = this._currentMeasure.top;
  11670. if (!this.isVertical || this._manualWidth) {
  11671. this._measureForChildren.width = this._currentMeasure.width;
  11672. }
  11673. if (this.isVertical || this._manualHeight) {
  11674. this._measureForChildren.height = this._currentMeasure.height;
  11675. }
  11676. };
  11677. StackPanel.prototype._postMeasure = function () {
  11678. var stackWidth = 0;
  11679. var stackHeight = 0;
  11680. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11681. var child = _a[_i];
  11682. if (!child.isVisible || child.notRenderable) {
  11683. continue;
  11684. }
  11685. if (this._isVertical) {
  11686. if (child.top !== stackHeight + "px") {
  11687. child.top = stackHeight + "px";
  11688. this._rebuildLayout = true;
  11689. child._top.ignoreAdaptiveScaling = true;
  11690. }
  11691. if (child._height.isPercentage && !child._automaticSize) {
  11692. if (!this.ignoreLayoutWarnings) {
  11693. 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");
  11694. }
  11695. }
  11696. else {
  11697. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  11698. }
  11699. }
  11700. else {
  11701. if (child.left !== stackWidth + "px") {
  11702. child.left = stackWidth + "px";
  11703. this._rebuildLayout = true;
  11704. child._left.ignoreAdaptiveScaling = true;
  11705. }
  11706. if (child._width.isPercentage && !child._automaticSize) {
  11707. if (!this.ignoreLayoutWarnings) {
  11708. 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");
  11709. }
  11710. }
  11711. else {
  11712. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  11713. }
  11714. }
  11715. }
  11716. this._doNotTrackManualChanges = true;
  11717. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  11718. // User can now define their own height and width for stack panel.
  11719. var panelWidthChanged = false;
  11720. var panelHeightChanged = false;
  11721. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  11722. var previousHeight = this.height;
  11723. this.height = stackHeight + "px";
  11724. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  11725. }
  11726. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  11727. var previousWidth = this.width;
  11728. this.width = stackWidth + "px";
  11729. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  11730. }
  11731. if (panelHeightChanged) {
  11732. this._height.ignoreAdaptiveScaling = true;
  11733. }
  11734. if (panelWidthChanged) {
  11735. this._width.ignoreAdaptiveScaling = true;
  11736. }
  11737. this._doNotTrackManualChanges = false;
  11738. if (panelWidthChanged || panelHeightChanged) {
  11739. this._rebuildLayout = true;
  11740. }
  11741. _super.prototype._postMeasure.call(this);
  11742. };
  11743. return StackPanel;
  11744. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  11745. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  11746. /***/ }),
  11747. /***/ "./2D/controls/statics.ts":
  11748. /*!********************************!*\
  11749. !*** ./2D/controls/statics.ts ***!
  11750. \********************************/
  11751. /*! exports provided: name */
  11752. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11753. "use strict";
  11754. __webpack_require__.r(__webpack_exports__);
  11755. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  11756. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11757. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11758. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  11759. /**
  11760. * Forcing an export so that this code will execute
  11761. * @hidden
  11762. */
  11763. var name = "Statics";
  11764. /**
  11765. * Creates a stack panel that can be used to render headers
  11766. * @param control defines the control to associate with the header
  11767. * @param text defines the text of the header
  11768. * @param size defines the size of the header
  11769. * @param options defines options used to configure the header
  11770. * @returns a new StackPanel
  11771. */
  11772. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  11773. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  11774. var isHorizontal = options ? options.isHorizontal : true;
  11775. var controlFirst = options ? options.controlFirst : true;
  11776. panel.isVertical = !isHorizontal;
  11777. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  11778. header.text = text;
  11779. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11780. if (isHorizontal) {
  11781. header.width = size;
  11782. }
  11783. else {
  11784. header.height = size;
  11785. }
  11786. if (controlFirst) {
  11787. panel.addControl(control);
  11788. panel.addControl(header);
  11789. header.paddingLeft = "5px";
  11790. }
  11791. else {
  11792. panel.addControl(header);
  11793. panel.addControl(control);
  11794. header.paddingRight = "5px";
  11795. }
  11796. header.shadowBlur = control.shadowBlur;
  11797. header.shadowColor = control.shadowColor;
  11798. header.shadowOffsetX = control.shadowOffsetX;
  11799. header.shadowOffsetY = control.shadowOffsetY;
  11800. return panel;
  11801. };
  11802. /***/ }),
  11803. /***/ "./2D/controls/textBlock.ts":
  11804. /*!**********************************!*\
  11805. !*** ./2D/controls/textBlock.ts ***!
  11806. \**********************************/
  11807. /*! exports provided: TextWrapping, TextBlock */
  11808. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11809. "use strict";
  11810. __webpack_require__.r(__webpack_exports__);
  11811. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  11812. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  11813. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11814. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  11815. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11816. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  11817. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11818. /**
  11819. * Enum that determines the text-wrapping mode to use.
  11820. */
  11821. var TextWrapping;
  11822. (function (TextWrapping) {
  11823. /**
  11824. * Clip the text when it's larger than Control.width; this is the default mode.
  11825. */
  11826. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  11827. /**
  11828. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  11829. */
  11830. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  11831. /**
  11832. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  11833. */
  11834. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  11835. })(TextWrapping || (TextWrapping = {}));
  11836. /**
  11837. * Class used to create text block control
  11838. */
  11839. var TextBlock = /** @class */ (function (_super) {
  11840. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  11841. /**
  11842. * Creates a new TextBlock object
  11843. * @param name defines the name of the control
  11844. * @param text defines the text to display (emptry string by default)
  11845. */
  11846. function TextBlock(
  11847. /**
  11848. * Defines the name of the control
  11849. */
  11850. name, text) {
  11851. if (text === void 0) { text = ""; }
  11852. var _this = _super.call(this, name) || this;
  11853. _this.name = name;
  11854. _this._text = "";
  11855. _this._textWrapping = TextWrapping.Clip;
  11856. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  11857. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  11858. _this._resizeToFit = false;
  11859. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  11860. _this._outlineWidth = 0;
  11861. _this._outlineColor = "white";
  11862. /**
  11863. * An event triggered after the text is changed
  11864. */
  11865. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11866. /**
  11867. * An event triggered after the text was broken up into lines
  11868. */
  11869. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11870. _this.text = text;
  11871. return _this;
  11872. }
  11873. Object.defineProperty(TextBlock.prototype, "lines", {
  11874. /**
  11875. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  11876. */
  11877. get: function () {
  11878. return this._lines;
  11879. },
  11880. enumerable: true,
  11881. configurable: true
  11882. });
  11883. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  11884. /**
  11885. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11886. */
  11887. get: function () {
  11888. return this._resizeToFit;
  11889. },
  11890. /**
  11891. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11892. */
  11893. set: function (value) {
  11894. if (this._resizeToFit === value) {
  11895. return;
  11896. }
  11897. this._resizeToFit = value;
  11898. if (this._resizeToFit) {
  11899. this._width.ignoreAdaptiveScaling = true;
  11900. this._height.ignoreAdaptiveScaling = true;
  11901. }
  11902. this._markAsDirty();
  11903. },
  11904. enumerable: true,
  11905. configurable: true
  11906. });
  11907. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  11908. /**
  11909. * Gets or sets a boolean indicating if text must be wrapped
  11910. */
  11911. get: function () {
  11912. return this._textWrapping;
  11913. },
  11914. /**
  11915. * Gets or sets a boolean indicating if text must be wrapped
  11916. */
  11917. set: function (value) {
  11918. if (this._textWrapping === value) {
  11919. return;
  11920. }
  11921. this._textWrapping = +value;
  11922. this._markAsDirty();
  11923. },
  11924. enumerable: true,
  11925. configurable: true
  11926. });
  11927. Object.defineProperty(TextBlock.prototype, "text", {
  11928. /**
  11929. * Gets or sets text to display
  11930. */
  11931. get: function () {
  11932. return this._text;
  11933. },
  11934. /**
  11935. * Gets or sets text to display
  11936. */
  11937. set: function (value) {
  11938. if (this._text === value) {
  11939. return;
  11940. }
  11941. this._text = value;
  11942. this._markAsDirty();
  11943. this.onTextChangedObservable.notifyObservers(this);
  11944. },
  11945. enumerable: true,
  11946. configurable: true
  11947. });
  11948. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  11949. /**
  11950. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11951. */
  11952. get: function () {
  11953. return this._textHorizontalAlignment;
  11954. },
  11955. /**
  11956. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11957. */
  11958. set: function (value) {
  11959. if (this._textHorizontalAlignment === value) {
  11960. return;
  11961. }
  11962. this._textHorizontalAlignment = value;
  11963. this._markAsDirty();
  11964. },
  11965. enumerable: true,
  11966. configurable: true
  11967. });
  11968. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  11969. /**
  11970. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11971. */
  11972. get: function () {
  11973. return this._textVerticalAlignment;
  11974. },
  11975. /**
  11976. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11977. */
  11978. set: function (value) {
  11979. if (this._textVerticalAlignment === value) {
  11980. return;
  11981. }
  11982. this._textVerticalAlignment = value;
  11983. this._markAsDirty();
  11984. },
  11985. enumerable: true,
  11986. configurable: true
  11987. });
  11988. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  11989. /**
  11990. * Gets or sets line spacing value
  11991. */
  11992. get: function () {
  11993. return this._lineSpacing.toString(this._host);
  11994. },
  11995. /**
  11996. * Gets or sets line spacing value
  11997. */
  11998. set: function (value) {
  11999. if (this._lineSpacing.fromString(value)) {
  12000. this._markAsDirty();
  12001. }
  12002. },
  12003. enumerable: true,
  12004. configurable: true
  12005. });
  12006. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  12007. /**
  12008. * Gets or sets outlineWidth of the text to display
  12009. */
  12010. get: function () {
  12011. return this._outlineWidth;
  12012. },
  12013. /**
  12014. * Gets or sets outlineWidth of the text to display
  12015. */
  12016. set: function (value) {
  12017. if (this._outlineWidth === value) {
  12018. return;
  12019. }
  12020. this._outlineWidth = value;
  12021. this._markAsDirty();
  12022. },
  12023. enumerable: true,
  12024. configurable: true
  12025. });
  12026. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  12027. /**
  12028. * Gets or sets outlineColor of the text to display
  12029. */
  12030. get: function () {
  12031. return this._outlineColor;
  12032. },
  12033. /**
  12034. * Gets or sets outlineColor of the text to display
  12035. */
  12036. set: function (value) {
  12037. if (this._outlineColor === value) {
  12038. return;
  12039. }
  12040. this._outlineColor = value;
  12041. this._markAsDirty();
  12042. },
  12043. enumerable: true,
  12044. configurable: true
  12045. });
  12046. TextBlock.prototype._getTypeName = function () {
  12047. return "TextBlock";
  12048. };
  12049. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  12050. if (!this._fontOffset) {
  12051. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  12052. }
  12053. _super.prototype._processMeasures.call(this, parentMeasure, context);
  12054. // Prepare lines
  12055. this._lines = this._breakLines(this._currentMeasure.width, context);
  12056. this.onLinesReadyObservable.notifyObservers(this);
  12057. var maxLineWidth = 0;
  12058. for (var i = 0; i < this._lines.length; i++) {
  12059. var line = this._lines[i];
  12060. if (line.width > maxLineWidth) {
  12061. maxLineWidth = line.width;
  12062. }
  12063. }
  12064. if (this._resizeToFit) {
  12065. if (this._textWrapping === TextWrapping.Clip) {
  12066. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  12067. if (newWidth !== this._width.internalValue) {
  12068. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12069. this._rebuildLayout = true;
  12070. }
  12071. }
  12072. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  12073. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12074. var lineSpacing = 0;
  12075. if (this._lineSpacing.isPixel) {
  12076. lineSpacing = this._lineSpacing.getValue(this._host);
  12077. }
  12078. else {
  12079. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12080. }
  12081. newHeight += (this._lines.length - 1) * lineSpacing;
  12082. }
  12083. if (newHeight !== this._height.internalValue) {
  12084. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12085. this._rebuildLayout = true;
  12086. }
  12087. }
  12088. };
  12089. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  12090. var width = this._currentMeasure.width;
  12091. var x = 0;
  12092. switch (this._textHorizontalAlignment) {
  12093. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  12094. x = 0;
  12095. break;
  12096. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  12097. x = width - textWidth;
  12098. break;
  12099. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  12100. x = (width - textWidth) / 2;
  12101. break;
  12102. }
  12103. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12104. context.shadowColor = this.shadowColor;
  12105. context.shadowBlur = this.shadowBlur;
  12106. context.shadowOffsetX = this.shadowOffsetX;
  12107. context.shadowOffsetY = this.shadowOffsetY;
  12108. }
  12109. if (this.outlineWidth) {
  12110. context.strokeText(text, this._currentMeasure.left + x, y);
  12111. }
  12112. context.fillText(text, this._currentMeasure.left + x, y);
  12113. };
  12114. /** @hidden */
  12115. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  12116. context.save();
  12117. this._applyStates(context);
  12118. // Render lines
  12119. this._renderLines(context);
  12120. context.restore();
  12121. };
  12122. TextBlock.prototype._applyStates = function (context) {
  12123. _super.prototype._applyStates.call(this, context);
  12124. if (this.outlineWidth) {
  12125. context.lineWidth = this.outlineWidth;
  12126. context.strokeStyle = this.outlineColor;
  12127. }
  12128. };
  12129. TextBlock.prototype._breakLines = function (refWidth, context) {
  12130. var lines = [];
  12131. var _lines = this.text.split("\n");
  12132. if (this._textWrapping === TextWrapping.Ellipsis) {
  12133. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  12134. var _line = _lines_1[_i];
  12135. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  12136. }
  12137. }
  12138. else if (this._textWrapping === TextWrapping.WordWrap) {
  12139. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  12140. var _line = _lines_2[_a];
  12141. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  12142. }
  12143. }
  12144. else {
  12145. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  12146. var _line = _lines_3[_b];
  12147. lines.push(this._parseLine(_line, context));
  12148. }
  12149. }
  12150. return lines;
  12151. };
  12152. TextBlock.prototype._parseLine = function (line, context) {
  12153. if (line === void 0) { line = ''; }
  12154. return { text: line, width: context.measureText(line).width };
  12155. };
  12156. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  12157. if (line === void 0) { line = ''; }
  12158. var lineWidth = context.measureText(line).width;
  12159. if (lineWidth > width) {
  12160. line += '…';
  12161. }
  12162. while (line.length > 2 && lineWidth > width) {
  12163. line = line.slice(0, -2) + '…';
  12164. lineWidth = context.measureText(line).width;
  12165. }
  12166. return { text: line, width: lineWidth };
  12167. };
  12168. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  12169. if (line === void 0) { line = ''; }
  12170. var lines = [];
  12171. var words = line.split(' ');
  12172. var lineWidth = 0;
  12173. for (var n = 0; n < words.length; n++) {
  12174. var testLine = n > 0 ? line + " " + words[n] : words[0];
  12175. var metrics = context.measureText(testLine);
  12176. var testWidth = metrics.width;
  12177. if (testWidth > width && n > 0) {
  12178. lines.push({ text: line, width: lineWidth });
  12179. line = words[n];
  12180. lineWidth = context.measureText(line).width;
  12181. }
  12182. else {
  12183. lineWidth = testWidth;
  12184. line = testLine;
  12185. }
  12186. }
  12187. lines.push({ text: line, width: lineWidth });
  12188. return lines;
  12189. };
  12190. TextBlock.prototype._renderLines = function (context) {
  12191. var height = this._currentMeasure.height;
  12192. var rootY = 0;
  12193. switch (this._textVerticalAlignment) {
  12194. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  12195. rootY = this._fontOffset.ascent;
  12196. break;
  12197. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  12198. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  12199. break;
  12200. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  12201. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  12202. break;
  12203. }
  12204. rootY += this._currentMeasure.top;
  12205. for (var i = 0; i < this._lines.length; i++) {
  12206. var line = this._lines[i];
  12207. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  12208. if (this._lineSpacing.isPixel) {
  12209. rootY += this._lineSpacing.getValue(this._host);
  12210. }
  12211. else {
  12212. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12213. }
  12214. }
  12215. this._drawText(line.text, line.width, rootY, context);
  12216. rootY += this._fontOffset.height;
  12217. }
  12218. };
  12219. /**
  12220. * Given a width constraint applied on the text block, find the expected height
  12221. * @returns expected height
  12222. */
  12223. TextBlock.prototype.computeExpectedHeight = function () {
  12224. if (this.text && this.widthInPixels) {
  12225. var context_1 = document.createElement('canvas').getContext('2d');
  12226. if (context_1) {
  12227. this._applyStates(context_1);
  12228. if (!this._fontOffset) {
  12229. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  12230. }
  12231. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  12232. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  12233. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12234. var lineSpacing = 0;
  12235. if (this._lineSpacing.isPixel) {
  12236. lineSpacing = this._lineSpacing.getValue(this._host);
  12237. }
  12238. else {
  12239. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12240. }
  12241. newHeight += (lines.length - 1) * lineSpacing;
  12242. }
  12243. return newHeight;
  12244. }
  12245. }
  12246. return 0;
  12247. };
  12248. TextBlock.prototype.dispose = function () {
  12249. _super.prototype.dispose.call(this);
  12250. this.onTextChangedObservable.clear();
  12251. };
  12252. return TextBlock;
  12253. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  12254. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  12255. /***/ }),
  12256. /***/ "./2D/controls/virtualKeyboard.ts":
  12257. /*!****************************************!*\
  12258. !*** ./2D/controls/virtualKeyboard.ts ***!
  12259. \****************************************/
  12260. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  12261. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12262. "use strict";
  12263. __webpack_require__.r(__webpack_exports__);
  12264. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  12265. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  12266. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12267. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12268. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12269. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12270. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  12271. /**
  12272. * Class used to store key control properties
  12273. */
  12274. var KeyPropertySet = /** @class */ (function () {
  12275. function KeyPropertySet() {
  12276. }
  12277. return KeyPropertySet;
  12278. }());
  12279. /**
  12280. * Class used to create virtual keyboard
  12281. */
  12282. var VirtualKeyboard = /** @class */ (function (_super) {
  12283. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  12284. function VirtualKeyboard() {
  12285. var _this = _super !== null && _super.apply(this, arguments) || this;
  12286. /** Observable raised when a key is pressed */
  12287. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12288. /** Gets or sets default key button width */
  12289. _this.defaultButtonWidth = "40px";
  12290. /** Gets or sets default key button height */
  12291. _this.defaultButtonHeight = "40px";
  12292. /** Gets or sets default key button left padding */
  12293. _this.defaultButtonPaddingLeft = "2px";
  12294. /** Gets or sets default key button right padding */
  12295. _this.defaultButtonPaddingRight = "2px";
  12296. /** Gets or sets default key button top padding */
  12297. _this.defaultButtonPaddingTop = "2px";
  12298. /** Gets or sets default key button bottom padding */
  12299. _this.defaultButtonPaddingBottom = "2px";
  12300. /** Gets or sets default key button foreground color */
  12301. _this.defaultButtonColor = "#DDD";
  12302. /** Gets or sets default key button background color */
  12303. _this.defaultButtonBackground = "#070707";
  12304. /** Gets or sets shift button foreground color */
  12305. _this.shiftButtonColor = "#7799FF";
  12306. /** Gets or sets shift button thickness*/
  12307. _this.selectedShiftThickness = 1;
  12308. /** Gets shift key state */
  12309. _this.shiftState = 0;
  12310. _this._currentlyConnectedInputText = null;
  12311. _this._connectedInputTexts = [];
  12312. _this._onKeyPressObserver = null;
  12313. return _this;
  12314. }
  12315. VirtualKeyboard.prototype._getTypeName = function () {
  12316. return "VirtualKeyboard";
  12317. };
  12318. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  12319. var _this = this;
  12320. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  12321. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  12322. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  12323. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  12324. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  12325. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  12326. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  12327. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  12328. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  12329. button.thickness = 0;
  12330. button.isFocusInvisible = true;
  12331. button.shadowColor = this.shadowColor;
  12332. button.shadowBlur = this.shadowBlur;
  12333. button.shadowOffsetX = this.shadowOffsetX;
  12334. button.shadowOffsetY = this.shadowOffsetY;
  12335. button.onPointerUpObservable.add(function () {
  12336. _this.onKeyPressObservable.notifyObservers(key);
  12337. });
  12338. return button;
  12339. };
  12340. /**
  12341. * Adds a new row of keys
  12342. * @param keys defines the list of keys to add
  12343. * @param propertySets defines the associated property sets
  12344. */
  12345. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  12346. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  12347. panel.isVertical = false;
  12348. panel.isFocusInvisible = true;
  12349. var maxKey = null;
  12350. for (var i = 0; i < keys.length; i++) {
  12351. var properties = null;
  12352. if (propertySets && propertySets.length === keys.length) {
  12353. properties = propertySets[i];
  12354. }
  12355. var key = this._createKey(keys[i], properties);
  12356. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  12357. maxKey = key;
  12358. }
  12359. panel.addControl(key);
  12360. }
  12361. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  12362. this.addControl(panel);
  12363. };
  12364. /**
  12365. * Set the shift key to a specific state
  12366. * @param shiftState defines the new shift state
  12367. */
  12368. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  12369. if (!this.children) {
  12370. return;
  12371. }
  12372. for (var i = 0; i < this.children.length; i++) {
  12373. var row = this.children[i];
  12374. if (!row || !row.children) {
  12375. continue;
  12376. }
  12377. var rowContainer = row;
  12378. for (var j = 0; j < rowContainer.children.length; j++) {
  12379. var button = rowContainer.children[j];
  12380. if (!button || !button.children[0]) {
  12381. continue;
  12382. }
  12383. var button_tblock = button.children[0];
  12384. if (button_tblock.text === "\u21E7") {
  12385. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  12386. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  12387. }
  12388. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  12389. }
  12390. }
  12391. };
  12392. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  12393. /** Gets the input text control currently attached to the keyboard */
  12394. get: function () {
  12395. return this._currentlyConnectedInputText;
  12396. },
  12397. enumerable: true,
  12398. configurable: true
  12399. });
  12400. /**
  12401. * Connects the keyboard with an input text control
  12402. *
  12403. * @param input defines the target control
  12404. */
  12405. VirtualKeyboard.prototype.connect = function (input) {
  12406. var _this = this;
  12407. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  12408. if (inputTextAlreadyConnected) {
  12409. return;
  12410. }
  12411. if (this._onKeyPressObserver === null) {
  12412. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  12413. if (!_this._currentlyConnectedInputText) {
  12414. return;
  12415. }
  12416. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  12417. switch (key) {
  12418. case "\u21E7":
  12419. _this.shiftState++;
  12420. if (_this.shiftState > 2) {
  12421. _this.shiftState = 0;
  12422. }
  12423. _this.applyShiftState(_this.shiftState);
  12424. return;
  12425. case "\u2190":
  12426. _this._currentlyConnectedInputText.processKey(8);
  12427. return;
  12428. case "\u21B5":
  12429. _this._currentlyConnectedInputText.processKey(13);
  12430. return;
  12431. }
  12432. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  12433. if (_this.shiftState === 1) {
  12434. _this.shiftState = 0;
  12435. _this.applyShiftState(_this.shiftState);
  12436. }
  12437. });
  12438. }
  12439. this.isVisible = false;
  12440. this._currentlyConnectedInputText = input;
  12441. input._connectedVirtualKeyboard = this;
  12442. // Events hooking
  12443. var onFocusObserver = input.onFocusObservable.add(function () {
  12444. _this._currentlyConnectedInputText = input;
  12445. input._connectedVirtualKeyboard = _this;
  12446. _this.isVisible = true;
  12447. });
  12448. var onBlurObserver = input.onBlurObservable.add(function () {
  12449. input._connectedVirtualKeyboard = null;
  12450. _this._currentlyConnectedInputText = null;
  12451. _this.isVisible = false;
  12452. });
  12453. this._connectedInputTexts.push({
  12454. input: input,
  12455. onBlurObserver: onBlurObserver,
  12456. onFocusObserver: onFocusObserver
  12457. });
  12458. };
  12459. /**
  12460. * Disconnects the keyboard from connected InputText controls
  12461. *
  12462. * @param input optionally defines a target control, otherwise all are disconnected
  12463. */
  12464. VirtualKeyboard.prototype.disconnect = function (input) {
  12465. var _this = this;
  12466. if (input) {
  12467. // .find not available on IE
  12468. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  12469. if (filtered.length === 1) {
  12470. this._removeConnectedInputObservables(filtered[0]);
  12471. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  12472. if (this._currentlyConnectedInputText === input) {
  12473. this._currentlyConnectedInputText = null;
  12474. }
  12475. }
  12476. }
  12477. else {
  12478. this._connectedInputTexts.forEach(function (connectedInputText) {
  12479. _this._removeConnectedInputObservables(connectedInputText);
  12480. });
  12481. this._connectedInputTexts = [];
  12482. }
  12483. if (this._connectedInputTexts.length === 0) {
  12484. this._currentlyConnectedInputText = null;
  12485. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  12486. this._onKeyPressObserver = null;
  12487. }
  12488. };
  12489. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  12490. connectedInputText.input._connectedVirtualKeyboard = null;
  12491. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  12492. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  12493. };
  12494. /**
  12495. * Release all resources
  12496. */
  12497. VirtualKeyboard.prototype.dispose = function () {
  12498. _super.prototype.dispose.call(this);
  12499. this.disconnect();
  12500. };
  12501. // Statics
  12502. /**
  12503. * Creates a new keyboard using a default layout
  12504. *
  12505. * @param name defines control name
  12506. * @returns a new VirtualKeyboard
  12507. */
  12508. VirtualKeyboard.CreateDefaultLayout = function (name) {
  12509. var returnValue = new VirtualKeyboard(name);
  12510. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  12511. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  12512. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  12513. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  12514. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  12515. return returnValue;
  12516. };
  12517. return VirtualKeyboard;
  12518. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  12519. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  12520. /***/ }),
  12521. /***/ "./2D/index.ts":
  12522. /*!*********************!*\
  12523. !*** ./2D/index.ts ***!
  12524. \*********************/
  12525. /*! 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 */
  12526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12527. "use strict";
  12528. __webpack_require__.r(__webpack_exports__);
  12529. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  12530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  12531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  12532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  12533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  12534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  12535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  12536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  12537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  12538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  12539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  12540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  12541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  12542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  12543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  12544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  12545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  12546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  12547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  12548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  12549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  12550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  12551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  12552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  12553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  12554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  12555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  12556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  12557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  12558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  12559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  12560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  12561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  12562. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  12564. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  12565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  12566. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  12567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  12568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  12569. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  12570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  12571. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  12572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  12573. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  12574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  12575. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  12577. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  12578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  12579. /***/ }),
  12580. /***/ "./2D/math2D.ts":
  12581. /*!**********************!*\
  12582. !*** ./2D/math2D.ts ***!
  12583. \**********************/
  12584. /*! exports provided: Vector2WithInfo, Matrix2D */
  12585. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12586. "use strict";
  12587. __webpack_require__.r(__webpack_exports__);
  12588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  12589. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  12590. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12591. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12592. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12593. /**
  12594. * Class used to transport Vector2 information for pointer events
  12595. */
  12596. var Vector2WithInfo = /** @class */ (function (_super) {
  12597. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  12598. /**
  12599. * Creates a new Vector2WithInfo
  12600. * @param source defines the vector2 data to transport
  12601. * @param buttonIndex defines the current mouse button index
  12602. */
  12603. function Vector2WithInfo(source,
  12604. /** defines the current mouse button index */
  12605. buttonIndex) {
  12606. if (buttonIndex === void 0) { buttonIndex = 0; }
  12607. var _this = _super.call(this, source.x, source.y) || this;
  12608. _this.buttonIndex = buttonIndex;
  12609. return _this;
  12610. }
  12611. return Vector2WithInfo;
  12612. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  12613. /** Class used to provide 2D matrix features */
  12614. var Matrix2D = /** @class */ (function () {
  12615. /**
  12616. * Creates a new matrix
  12617. * @param m00 defines value for (0, 0)
  12618. * @param m01 defines value for (0, 1)
  12619. * @param m10 defines value for (1, 0)
  12620. * @param m11 defines value for (1, 1)
  12621. * @param m20 defines value for (2, 0)
  12622. * @param m21 defines value for (2, 1)
  12623. */
  12624. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  12625. /** Gets the internal array of 6 floats used to store matrix data */
  12626. this.m = new Float32Array(6);
  12627. this.fromValues(m00, m01, m10, m11, m20, m21);
  12628. }
  12629. /**
  12630. * Fills the matrix from direct values
  12631. * @param m00 defines value for (0, 0)
  12632. * @param m01 defines value for (0, 1)
  12633. * @param m10 defines value for (1, 0)
  12634. * @param m11 defines value for (1, 1)
  12635. * @param m20 defines value for (2, 0)
  12636. * @param m21 defines value for (2, 1)
  12637. * @returns the current modified matrix
  12638. */
  12639. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  12640. this.m[0] = m00;
  12641. this.m[1] = m01;
  12642. this.m[2] = m10;
  12643. this.m[3] = m11;
  12644. this.m[4] = m20;
  12645. this.m[5] = m21;
  12646. return this;
  12647. };
  12648. /**
  12649. * Gets matrix determinant
  12650. * @returns the determinant
  12651. */
  12652. Matrix2D.prototype.determinant = function () {
  12653. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  12654. };
  12655. /**
  12656. * Inverses the matrix and stores it in a target matrix
  12657. * @param result defines the target matrix
  12658. * @returns the current matrix
  12659. */
  12660. Matrix2D.prototype.invertToRef = function (result) {
  12661. var l0 = this.m[0];
  12662. var l1 = this.m[1];
  12663. var l2 = this.m[2];
  12664. var l3 = this.m[3];
  12665. var l4 = this.m[4];
  12666. var l5 = this.m[5];
  12667. var det = this.determinant();
  12668. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  12669. result.m[0] = 0;
  12670. result.m[1] = 0;
  12671. result.m[2] = 0;
  12672. result.m[3] = 0;
  12673. result.m[4] = 0;
  12674. result.m[5] = 0;
  12675. return this;
  12676. }
  12677. var detDiv = 1 / det;
  12678. var det4 = l2 * l5 - l3 * l4;
  12679. var det5 = l1 * l4 - l0 * l5;
  12680. result.m[0] = l3 * detDiv;
  12681. result.m[1] = -l1 * detDiv;
  12682. result.m[2] = -l2 * detDiv;
  12683. result.m[3] = l0 * detDiv;
  12684. result.m[4] = det4 * detDiv;
  12685. result.m[5] = det5 * detDiv;
  12686. return this;
  12687. };
  12688. /**
  12689. * Multiplies the current matrix with another one
  12690. * @param other defines the second operand
  12691. * @param result defines the target matrix
  12692. * @returns the current matrix
  12693. */
  12694. Matrix2D.prototype.multiplyToRef = function (other, result) {
  12695. var l0 = this.m[0];
  12696. var l1 = this.m[1];
  12697. var l2 = this.m[2];
  12698. var l3 = this.m[3];
  12699. var l4 = this.m[4];
  12700. var l5 = this.m[5];
  12701. var r0 = other.m[0];
  12702. var r1 = other.m[1];
  12703. var r2 = other.m[2];
  12704. var r3 = other.m[3];
  12705. var r4 = other.m[4];
  12706. var r5 = other.m[5];
  12707. result.m[0] = l0 * r0 + l1 * r2;
  12708. result.m[1] = l0 * r1 + l1 * r3;
  12709. result.m[2] = l2 * r0 + l3 * r2;
  12710. result.m[3] = l2 * r1 + l3 * r3;
  12711. result.m[4] = l4 * r0 + l5 * r2 + r4;
  12712. result.m[5] = l4 * r1 + l5 * r3 + r5;
  12713. return this;
  12714. };
  12715. /**
  12716. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  12717. * @param x defines the x coordinate to transform
  12718. * @param y defines the x coordinate to transform
  12719. * @param result defines the target vector2
  12720. * @returns the current matrix
  12721. */
  12722. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  12723. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  12724. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  12725. return this;
  12726. };
  12727. // Statics
  12728. /**
  12729. * Creates an identity matrix
  12730. * @returns a new matrix
  12731. */
  12732. Matrix2D.Identity = function () {
  12733. return new Matrix2D(1, 0, 0, 1, 0, 0);
  12734. };
  12735. /**
  12736. * Creates a translation matrix and stores it in a target matrix
  12737. * @param x defines the x coordinate of the translation
  12738. * @param y defines the y coordinate of the translation
  12739. * @param result defines the target matrix
  12740. */
  12741. Matrix2D.TranslationToRef = function (x, y, result) {
  12742. result.fromValues(1, 0, 0, 1, x, y);
  12743. };
  12744. /**
  12745. * Creates a scaling matrix and stores it in a target matrix
  12746. * @param x defines the x coordinate of the scaling
  12747. * @param y defines the y coordinate of the scaling
  12748. * @param result defines the target matrix
  12749. */
  12750. Matrix2D.ScalingToRef = function (x, y, result) {
  12751. result.fromValues(x, 0, 0, y, 0, 0);
  12752. };
  12753. /**
  12754. * Creates a rotation matrix and stores it in a target matrix
  12755. * @param angle defines the rotation angle
  12756. * @param result defines the target matrix
  12757. */
  12758. Matrix2D.RotationToRef = function (angle, result) {
  12759. var s = Math.sin(angle);
  12760. var c = Math.cos(angle);
  12761. result.fromValues(c, s, -s, c, 0, 0);
  12762. };
  12763. /**
  12764. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  12765. * @param tx defines the x coordinate of the translation
  12766. * @param ty defines the y coordinate of the translation
  12767. * @param angle defines the rotation angle
  12768. * @param scaleX defines the x coordinate of the scaling
  12769. * @param scaleY defines the y coordinate of the scaling
  12770. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  12771. * @param result defines the target matrix
  12772. */
  12773. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  12774. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  12775. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  12776. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  12777. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  12778. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  12779. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  12780. if (parentMatrix) {
  12781. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  12782. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  12783. }
  12784. else {
  12785. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  12786. }
  12787. };
  12788. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  12789. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  12790. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  12791. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  12792. Matrix2D._TempCompose0 = Matrix2D.Identity();
  12793. Matrix2D._TempCompose1 = Matrix2D.Identity();
  12794. Matrix2D._TempCompose2 = Matrix2D.Identity();
  12795. return Matrix2D;
  12796. }());
  12797. /***/ }),
  12798. /***/ "./2D/measure.ts":
  12799. /*!***********************!*\
  12800. !*** ./2D/measure.ts ***!
  12801. \***********************/
  12802. /*! exports provided: Measure */
  12803. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12804. "use strict";
  12805. __webpack_require__.r(__webpack_exports__);
  12806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  12807. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12808. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12809. var tmpRect = [
  12810. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12811. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12812. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12813. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12814. ];
  12815. var tmpRect2 = [
  12816. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12817. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12818. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12819. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12820. ];
  12821. var tmpV1 = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12822. var tmpV2 = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12823. /**
  12824. * Class used to store 2D control sizes
  12825. */
  12826. var Measure = /** @class */ (function () {
  12827. /**
  12828. * Creates a new measure
  12829. * @param left defines left coordinate
  12830. * @param top defines top coordinate
  12831. * @param width defines width dimension
  12832. * @param height defines height dimension
  12833. */
  12834. function Measure(
  12835. /** defines left coordinate */
  12836. left,
  12837. /** defines top coordinate */
  12838. top,
  12839. /** defines width dimension */
  12840. width,
  12841. /** defines height dimension */
  12842. height) {
  12843. this.left = left;
  12844. this.top = top;
  12845. this.width = width;
  12846. this.height = height;
  12847. }
  12848. /**
  12849. * Copy from another measure
  12850. * @param other defines the other measure to copy from
  12851. */
  12852. Measure.prototype.copyFrom = function (other) {
  12853. this.left = other.left;
  12854. this.top = other.top;
  12855. this.width = other.width;
  12856. this.height = other.height;
  12857. };
  12858. /**
  12859. * Copy from a group of 4 floats
  12860. * @param left defines left coordinate
  12861. * @param top defines top coordinate
  12862. * @param width defines width dimension
  12863. * @param height defines height dimension
  12864. */
  12865. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  12866. this.left = left;
  12867. this.top = top;
  12868. this.width = width;
  12869. this.height = height;
  12870. };
  12871. /**
  12872. * Computes the axis aligned bounding box measure for two given measures
  12873. * @param a Input measure
  12874. * @param b Input measure
  12875. * @param result the resulting bounding measure
  12876. */
  12877. Measure.CombineToRef = function (a, b, result) {
  12878. var left = Math.min(a.left, b.left);
  12879. var top = Math.min(a.top, b.top);
  12880. var right = Math.max(a.left + a.width, b.left + b.width);
  12881. var bottom = Math.max(a.top + a.height, b.top + b.height);
  12882. result.left = left;
  12883. result.top = top;
  12884. result.width = right - left;
  12885. result.height = bottom - top;
  12886. };
  12887. /**
  12888. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  12889. * @param transform the matrix to transform the measure before computing the AABB
  12890. * @param result the resulting AABB
  12891. */
  12892. Measure.prototype.transformToRef = function (transform, result) {
  12893. tmpRect[0].copyFromFloats(this.left, this.top);
  12894. tmpRect[1].copyFromFloats(this.left + this.width, this.top);
  12895. tmpRect[2].copyFromFloats(this.left + this.width, this.top + this.height);
  12896. tmpRect[3].copyFromFloats(this.left, this.top + this.height);
  12897. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  12898. tmpV2.copyFromFloats(0, 0);
  12899. for (var i = 0; i < 4; i++) {
  12900. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  12901. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  12902. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  12903. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  12904. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  12905. }
  12906. result.left = tmpV1.x;
  12907. result.top = tmpV1.y;
  12908. result.width = tmpV2.x - tmpV1.x;
  12909. result.height = tmpV2.y - tmpV1.y;
  12910. };
  12911. /**
  12912. * Check equality between this measure and another one
  12913. * @param other defines the other measures
  12914. * @returns true if both measures are equals
  12915. */
  12916. Measure.prototype.isEqualsTo = function (other) {
  12917. if (this.left !== other.left) {
  12918. return false;
  12919. }
  12920. if (this.top !== other.top) {
  12921. return false;
  12922. }
  12923. if (this.width !== other.width) {
  12924. return false;
  12925. }
  12926. if (this.height !== other.height) {
  12927. return false;
  12928. }
  12929. return true;
  12930. };
  12931. /**
  12932. * Creates an empty measure
  12933. * @returns a new measure
  12934. */
  12935. Measure.Empty = function () {
  12936. return new Measure(0, 0, 0, 0);
  12937. };
  12938. return Measure;
  12939. }());
  12940. /***/ }),
  12941. /***/ "./2D/multiLinePoint.ts":
  12942. /*!******************************!*\
  12943. !*** ./2D/multiLinePoint.ts ***!
  12944. \******************************/
  12945. /*! exports provided: MultiLinePoint */
  12946. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12947. "use strict";
  12948. __webpack_require__.r(__webpack_exports__);
  12949. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  12950. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12951. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12952. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12953. /**
  12954. * Class used to store a point for a MultiLine object.
  12955. * The point can be pure 2D coordinates, a mesh or a control
  12956. */
  12957. var MultiLinePoint = /** @class */ (function () {
  12958. /**
  12959. * Creates a new MultiLinePoint
  12960. * @param multiLine defines the source MultiLine object
  12961. */
  12962. function MultiLinePoint(multiLine) {
  12963. this._multiLine = multiLine;
  12964. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12965. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12966. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12967. }
  12968. Object.defineProperty(MultiLinePoint.prototype, "x", {
  12969. /** Gets or sets x coordinate */
  12970. get: function () {
  12971. return this._x.toString(this._multiLine._host);
  12972. },
  12973. set: function (value) {
  12974. if (this._x.toString(this._multiLine._host) === value) {
  12975. return;
  12976. }
  12977. if (this._x.fromString(value)) {
  12978. this._multiLine._markAsDirty();
  12979. }
  12980. },
  12981. enumerable: true,
  12982. configurable: true
  12983. });
  12984. Object.defineProperty(MultiLinePoint.prototype, "y", {
  12985. /** Gets or sets y coordinate */
  12986. get: function () {
  12987. return this._y.toString(this._multiLine._host);
  12988. },
  12989. set: function (value) {
  12990. if (this._y.toString(this._multiLine._host) === value) {
  12991. return;
  12992. }
  12993. if (this._y.fromString(value)) {
  12994. this._multiLine._markAsDirty();
  12995. }
  12996. },
  12997. enumerable: true,
  12998. configurable: true
  12999. });
  13000. Object.defineProperty(MultiLinePoint.prototype, "control", {
  13001. /** Gets or sets the control associated with this point */
  13002. get: function () {
  13003. return this._control;
  13004. },
  13005. set: function (value) {
  13006. if (this._control === value) {
  13007. return;
  13008. }
  13009. if (this._control && this._controlObserver) {
  13010. this._control.onDirtyObservable.remove(this._controlObserver);
  13011. this._controlObserver = null;
  13012. }
  13013. this._control = value;
  13014. if (this._control) {
  13015. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  13016. }
  13017. this._multiLine._markAsDirty();
  13018. },
  13019. enumerable: true,
  13020. configurable: true
  13021. });
  13022. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  13023. /** Gets or sets the mesh associated with this point */
  13024. get: function () {
  13025. return this._mesh;
  13026. },
  13027. set: function (value) {
  13028. if (this._mesh === value) {
  13029. return;
  13030. }
  13031. if (this._mesh && this._meshObserver) {
  13032. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  13033. }
  13034. this._mesh = value;
  13035. if (this._mesh) {
  13036. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  13037. }
  13038. this._multiLine._markAsDirty();
  13039. },
  13040. enumerable: true,
  13041. configurable: true
  13042. });
  13043. /** Resets links */
  13044. MultiLinePoint.prototype.resetLinks = function () {
  13045. this.control = null;
  13046. this.mesh = null;
  13047. };
  13048. /**
  13049. * Gets a translation vector
  13050. * @returns the translation vector
  13051. */
  13052. MultiLinePoint.prototype.translate = function () {
  13053. this._point = this._translatePoint();
  13054. return this._point;
  13055. };
  13056. MultiLinePoint.prototype._translatePoint = function () {
  13057. if (this._mesh != null) {
  13058. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  13059. }
  13060. else if (this._control != null) {
  13061. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  13062. }
  13063. else {
  13064. var host = this._multiLine._host;
  13065. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  13066. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  13067. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  13068. }
  13069. };
  13070. /** Release associated resources */
  13071. MultiLinePoint.prototype.dispose = function () {
  13072. this.resetLinks();
  13073. };
  13074. return MultiLinePoint;
  13075. }());
  13076. /***/ }),
  13077. /***/ "./2D/style.ts":
  13078. /*!*********************!*\
  13079. !*** ./2D/style.ts ***!
  13080. \*********************/
  13081. /*! exports provided: Style */
  13082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13083. "use strict";
  13084. __webpack_require__.r(__webpack_exports__);
  13085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  13086. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  13087. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13088. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13089. /**
  13090. * Define a style used by control to automatically setup properties based on a template.
  13091. * Only support font related properties so far
  13092. */
  13093. var Style = /** @class */ (function () {
  13094. /**
  13095. * Creates a new style object
  13096. * @param host defines the AdvancedDynamicTexture which hosts this style
  13097. */
  13098. function Style(host) {
  13099. this._fontFamily = "Arial";
  13100. this._fontStyle = "";
  13101. this._fontWeight = "";
  13102. /** @hidden */
  13103. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  13104. /**
  13105. * Observable raised when the style values are changed
  13106. */
  13107. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13108. this._host = host;
  13109. }
  13110. Object.defineProperty(Style.prototype, "fontSize", {
  13111. /**
  13112. * Gets or sets the font size
  13113. */
  13114. get: function () {
  13115. return this._fontSize.toString(this._host);
  13116. },
  13117. set: function (value) {
  13118. if (this._fontSize.toString(this._host) === value) {
  13119. return;
  13120. }
  13121. if (this._fontSize.fromString(value)) {
  13122. this.onChangedObservable.notifyObservers(this);
  13123. }
  13124. },
  13125. enumerable: true,
  13126. configurable: true
  13127. });
  13128. Object.defineProperty(Style.prototype, "fontFamily", {
  13129. /**
  13130. * Gets or sets the font family
  13131. */
  13132. get: function () {
  13133. return this._fontFamily;
  13134. },
  13135. set: function (value) {
  13136. if (this._fontFamily === value) {
  13137. return;
  13138. }
  13139. this._fontFamily = value;
  13140. this.onChangedObservable.notifyObservers(this);
  13141. },
  13142. enumerable: true,
  13143. configurable: true
  13144. });
  13145. Object.defineProperty(Style.prototype, "fontStyle", {
  13146. /**
  13147. * Gets or sets the font style
  13148. */
  13149. get: function () {
  13150. return this._fontStyle;
  13151. },
  13152. set: function (value) {
  13153. if (this._fontStyle === value) {
  13154. return;
  13155. }
  13156. this._fontStyle = value;
  13157. this.onChangedObservable.notifyObservers(this);
  13158. },
  13159. enumerable: true,
  13160. configurable: true
  13161. });
  13162. Object.defineProperty(Style.prototype, "fontWeight", {
  13163. /** Gets or sets font weight */
  13164. get: function () {
  13165. return this._fontWeight;
  13166. },
  13167. set: function (value) {
  13168. if (this._fontWeight === value) {
  13169. return;
  13170. }
  13171. this._fontWeight = value;
  13172. this.onChangedObservable.notifyObservers(this);
  13173. },
  13174. enumerable: true,
  13175. configurable: true
  13176. });
  13177. /** Dispose all associated resources */
  13178. Style.prototype.dispose = function () {
  13179. this.onChangedObservable.clear();
  13180. };
  13181. return Style;
  13182. }());
  13183. /***/ }),
  13184. /***/ "./2D/valueAndUnit.ts":
  13185. /*!****************************!*\
  13186. !*** ./2D/valueAndUnit.ts ***!
  13187. \****************************/
  13188. /*! exports provided: ValueAndUnit */
  13189. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13190. "use strict";
  13191. __webpack_require__.r(__webpack_exports__);
  13192. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  13193. /**
  13194. * Class used to specific a value and its associated unit
  13195. */
  13196. var ValueAndUnit = /** @class */ (function () {
  13197. /**
  13198. * Creates a new ValueAndUnit
  13199. * @param value defines the value to store
  13200. * @param unit defines the unit to store
  13201. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  13202. */
  13203. function ValueAndUnit(value,
  13204. /** defines the unit to store */
  13205. unit,
  13206. /** defines a boolean indicating if the value can be negative */
  13207. negativeValueAllowed) {
  13208. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13209. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  13210. this.unit = unit;
  13211. this.negativeValueAllowed = negativeValueAllowed;
  13212. this._value = 1;
  13213. /**
  13214. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  13215. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  13216. */
  13217. this.ignoreAdaptiveScaling = false;
  13218. this._value = value;
  13219. this._originalUnit = unit;
  13220. }
  13221. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  13222. /** Gets a boolean indicating if the value is a percentage */
  13223. get: function () {
  13224. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  13225. },
  13226. enumerable: true,
  13227. configurable: true
  13228. });
  13229. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  13230. /** Gets a boolean indicating if the value is store as pixel */
  13231. get: function () {
  13232. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  13233. },
  13234. enumerable: true,
  13235. configurable: true
  13236. });
  13237. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  13238. /** Gets direct internal value */
  13239. get: function () {
  13240. return this._value;
  13241. },
  13242. enumerable: true,
  13243. configurable: true
  13244. });
  13245. /**
  13246. * Gets value as pixel
  13247. * @param host defines the root host
  13248. * @param refValue defines the reference value for percentages
  13249. * @returns the value as pixel
  13250. */
  13251. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  13252. if (this.isPixel) {
  13253. return this.getValue(host);
  13254. }
  13255. return this.getValue(host) * refValue;
  13256. };
  13257. /**
  13258. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  13259. * @param value defines the value to store
  13260. * @param unit defines the unit to store
  13261. * @returns the current ValueAndUnit
  13262. */
  13263. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  13264. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13265. this._value = value;
  13266. this.unit = unit;
  13267. return this;
  13268. };
  13269. /**
  13270. * Gets the value accordingly to its unit
  13271. * @param host defines the root host
  13272. * @returns the value
  13273. */
  13274. ValueAndUnit.prototype.getValue = function (host) {
  13275. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  13276. var width = 0;
  13277. var height = 0;
  13278. if (host.idealWidth) {
  13279. width = (this._value * host.getSize().width) / host.idealWidth;
  13280. }
  13281. if (host.idealHeight) {
  13282. height = (this._value * host.getSize().height) / host.idealHeight;
  13283. }
  13284. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  13285. return window.innerWidth < window.innerHeight ? width : height;
  13286. }
  13287. if (host.idealWidth) { // horizontal
  13288. return width;
  13289. }
  13290. if (host.idealHeight) { // vertical
  13291. return height;
  13292. }
  13293. }
  13294. return this._value;
  13295. };
  13296. /**
  13297. * Gets a string representation of the value
  13298. * @param host defines the root host
  13299. * @param decimals defines an optional number of decimals to display
  13300. * @returns a string
  13301. */
  13302. ValueAndUnit.prototype.toString = function (host, decimals) {
  13303. switch (this.unit) {
  13304. case ValueAndUnit.UNITMODE_PERCENTAGE:
  13305. var percentage = this.getValue(host) * 100;
  13306. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  13307. case ValueAndUnit.UNITMODE_PIXEL:
  13308. var pixels = this.getValue(host);
  13309. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  13310. }
  13311. return this.unit.toString();
  13312. };
  13313. /**
  13314. * Store a value parsed from a string
  13315. * @param source defines the source string
  13316. * @returns true if the value was successfully parsed
  13317. */
  13318. ValueAndUnit.prototype.fromString = function (source) {
  13319. var match = ValueAndUnit._Regex.exec(source.toString());
  13320. if (!match || match.length === 0) {
  13321. return false;
  13322. }
  13323. var sourceValue = parseFloat(match[1]);
  13324. var sourceUnit = this._originalUnit;
  13325. if (!this.negativeValueAllowed) {
  13326. if (sourceValue < 0) {
  13327. sourceValue = 0;
  13328. }
  13329. }
  13330. if (match.length === 4) {
  13331. switch (match[3]) {
  13332. case "px":
  13333. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  13334. break;
  13335. case "%":
  13336. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  13337. sourceValue /= 100.0;
  13338. break;
  13339. }
  13340. }
  13341. if (sourceValue === this._value && sourceUnit === this.unit) {
  13342. return false;
  13343. }
  13344. this._value = sourceValue;
  13345. this.unit = sourceUnit;
  13346. return true;
  13347. };
  13348. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  13349. /** UNITMODE_PERCENTAGE */
  13350. get: function () {
  13351. return ValueAndUnit._UNITMODE_PERCENTAGE;
  13352. },
  13353. enumerable: true,
  13354. configurable: true
  13355. });
  13356. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  13357. /** UNITMODE_PIXEL */
  13358. get: function () {
  13359. return ValueAndUnit._UNITMODE_PIXEL;
  13360. },
  13361. enumerable: true,
  13362. configurable: true
  13363. });
  13364. // Static
  13365. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  13366. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  13367. ValueAndUnit._UNITMODE_PIXEL = 1;
  13368. return ValueAndUnit;
  13369. }());
  13370. /***/ }),
  13371. /***/ "./2D/xmlLoader.ts":
  13372. /*!*************************!*\
  13373. !*** ./2D/xmlLoader.ts ***!
  13374. \*************************/
  13375. /*! exports provided: XmlLoader */
  13376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13377. "use strict";
  13378. __webpack_require__.r(__webpack_exports__);
  13379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  13380. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  13381. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  13382. /**
  13383. * Class used to load GUI via XML.
  13384. */
  13385. var XmlLoader = /** @class */ (function () {
  13386. /**
  13387. * Create a new xml loader
  13388. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  13389. */
  13390. function XmlLoader(parentClass) {
  13391. if (parentClass === void 0) { parentClass = null; }
  13392. this._nodes = {};
  13393. this._nodeTypes = {
  13394. element: 1,
  13395. attribute: 2,
  13396. text: 3
  13397. };
  13398. this._isLoaded = false;
  13399. this._objectAttributes = {
  13400. "textHorizontalAlignment": 1,
  13401. "textVerticalAlignment": 2,
  13402. "horizontalAlignment": 3,
  13403. "verticalAlignment": 4,
  13404. "stretch": 5,
  13405. };
  13406. if (parentClass) {
  13407. this._parentClass = parentClass;
  13408. }
  13409. }
  13410. XmlLoader.prototype._getChainElement = function (attributeValue) {
  13411. var element = window;
  13412. if (this._parentClass) {
  13413. element = this._parentClass;
  13414. }
  13415. var value = attributeValue;
  13416. value = value.split(".");
  13417. for (var i = 0; i < value.length; i++) {
  13418. element = element[value[i]];
  13419. }
  13420. return element;
  13421. };
  13422. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  13423. var attribute = attributeName.split(".");
  13424. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  13425. return className[attribute[1]];
  13426. };
  13427. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  13428. if (linkParent === void 0) { linkParent = true; }
  13429. try {
  13430. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  13431. var guiNode = new className();
  13432. if (parent && linkParent) {
  13433. parent.addControl(guiNode);
  13434. }
  13435. for (var i = 0; i < node.attributes.length; i++) {
  13436. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  13437. continue;
  13438. }
  13439. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  13440. var element = this._getChainElement(node.attributes[i].value);
  13441. guiNode[node.attributes[i].name].add(element);
  13442. continue;
  13443. }
  13444. else if (node.attributes[i].name == "linkWithMesh") {
  13445. if (this._parentClass) {
  13446. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  13447. }
  13448. else {
  13449. guiNode.linkWithMesh(window[node.attributes[i].value]);
  13450. }
  13451. }
  13452. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  13453. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  13454. guiNode[node.attributes[i].name] = element;
  13455. }
  13456. else if (!this._objectAttributes[node.attributes[i].name]) {
  13457. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  13458. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  13459. }
  13460. else {
  13461. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  13462. }
  13463. }
  13464. else {
  13465. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  13466. }
  13467. }
  13468. if (!node.attributes.getNamedItem("id")) {
  13469. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  13470. return guiNode;
  13471. }
  13472. var id = node.attributes.getNamedItem("id").value;
  13473. if (id.startsWith("{{") && id.endsWith("}}")) {
  13474. id = this._getChainElement(id.substring(2, id.length - 2));
  13475. }
  13476. if (!this._nodes[id]) {
  13477. this._nodes[id] = guiNode;
  13478. }
  13479. else {
  13480. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  13481. }
  13482. return guiNode;
  13483. }
  13484. catch (e) {
  13485. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  13486. }
  13487. };
  13488. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  13489. var width;
  13490. var height;
  13491. var columns;
  13492. var rows = node.children;
  13493. var cells;
  13494. var isPixel = false;
  13495. var cellNode;
  13496. var rowNumber = -1;
  13497. var columnNumber = -1;
  13498. var totalColumnsNumber = 0;
  13499. for (var i = 0; i < rows.length; i++) {
  13500. if (rows[i].nodeType != this._nodeTypes.element) {
  13501. continue;
  13502. }
  13503. if (rows[i].nodeName != "Row") {
  13504. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  13505. }
  13506. rowNumber += 1;
  13507. columns = rows[i].children;
  13508. if (!rows[i].attributes.getNamedItem("height")) {
  13509. throw "XmlLoader Exception : Height must be defined for grid rows";
  13510. }
  13511. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  13512. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  13513. guiNode.addRowDefinition(height, isPixel);
  13514. for (var j = 0; j < columns.length; j++) {
  13515. if (columns[j].nodeType != this._nodeTypes.element) {
  13516. continue;
  13517. }
  13518. if (columns[j].nodeName != "Column") {
  13519. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  13520. }
  13521. columnNumber += 1;
  13522. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  13523. 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.";
  13524. }
  13525. if (rowNumber == 0) {
  13526. if (!columns[j].attributes.getNamedItem("width")) {
  13527. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  13528. }
  13529. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  13530. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  13531. guiNode.addColumnDefinition(width, isPixel);
  13532. }
  13533. cells = columns[j].children;
  13534. for (var k = 0; k < cells.length; k++) {
  13535. if (cells[k].nodeType != this._nodeTypes.element) {
  13536. continue;
  13537. }
  13538. cellNode = this._createGuiElement(cells[k], guiNode, false);
  13539. guiNode.addControl(cellNode, rowNumber, columnNumber);
  13540. if (cells[k].firstChild) {
  13541. this._parseXml(cells[k].firstChild, cellNode);
  13542. }
  13543. }
  13544. }
  13545. if (rowNumber == 0) {
  13546. totalColumnsNumber = columnNumber;
  13547. }
  13548. columnNumber = -1;
  13549. }
  13550. if (node.nextSibling) {
  13551. this._parseXml(node.nextSibling, parent);
  13552. }
  13553. };
  13554. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  13555. if (node.firstChild) {
  13556. this._parseXml(node.firstChild, guiNode);
  13557. }
  13558. if (node.nextSibling) {
  13559. this._parseXml(node.nextSibling, parent);
  13560. }
  13561. };
  13562. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  13563. if (this._parentClass) {
  13564. this._parentClass[variable] = source[iterator];
  13565. }
  13566. else {
  13567. window[variable] = source[iterator];
  13568. }
  13569. if (node.firstChild) {
  13570. this._parseXml(node.firstChild, guiNode, true);
  13571. }
  13572. };
  13573. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  13574. var dataSource = node.attributes.getNamedItem("dataSource").value;
  13575. if (!dataSource.includes(" in ")) {
  13576. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  13577. }
  13578. else {
  13579. var isArray = true;
  13580. var splittedSource = dataSource.split(" in ");
  13581. if (splittedSource.length < 2) {
  13582. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  13583. }
  13584. var source = splittedSource[1];
  13585. if (source.startsWith("{") && source.endsWith("}")) {
  13586. isArray = false;
  13587. }
  13588. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  13589. source = source.substring(1, source.length - 1);
  13590. }
  13591. if (this._parentClass) {
  13592. source = this._parentClass[source];
  13593. }
  13594. else {
  13595. source = window[source];
  13596. }
  13597. if (isArray) {
  13598. for (var i = 0; i < source.length; i++) {
  13599. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13600. }
  13601. }
  13602. else {
  13603. for (var i in source) {
  13604. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13605. }
  13606. }
  13607. if (node.nextSibling) {
  13608. this._parseXml(node.nextSibling, parent);
  13609. }
  13610. }
  13611. };
  13612. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  13613. if (generated === void 0) { generated = false; }
  13614. if (node.nodeType != this._nodeTypes.element) {
  13615. if (node.nextSibling) {
  13616. this._parseXml(node.nextSibling, parent, generated);
  13617. }
  13618. return;
  13619. }
  13620. if (generated) {
  13621. node.setAttribute("id", parent.id + (parent._children.length + 1));
  13622. }
  13623. var guiNode = this._createGuiElement(node, parent);
  13624. if (node.nodeName == "Grid") {
  13625. this._parseGrid(node, guiNode, parent);
  13626. }
  13627. else if (!node.attributes.getNamedItem("dataSource")) {
  13628. this._parseElement(node, guiNode, parent);
  13629. }
  13630. else {
  13631. this._parseElementsFromSource(node, guiNode, parent);
  13632. }
  13633. };
  13634. /**
  13635. * Gets if the loading has finished.
  13636. * @returns whether the loading has finished or not
  13637. */
  13638. XmlLoader.prototype.isLoaded = function () {
  13639. return this._isLoaded;
  13640. };
  13641. /**
  13642. * Gets a loaded node / control by id.
  13643. * @param id the Controls id set in the xml
  13644. * @returns element of type Control
  13645. */
  13646. XmlLoader.prototype.getNodeById = function (id) {
  13647. return this._nodes[id];
  13648. };
  13649. /**
  13650. * Gets all loaded nodes / controls
  13651. * @returns Array of controls
  13652. */
  13653. XmlLoader.prototype.getNodes = function () {
  13654. return this._nodes;
  13655. };
  13656. /**
  13657. * Initiates the xml layout loading
  13658. * @param xmlFile defines the xml layout to load
  13659. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  13660. * @param callback defines the callback called on layout load.
  13661. */
  13662. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  13663. var xhttp = new XMLHttpRequest();
  13664. xhttp.onreadystatechange = function () {
  13665. if (xhttp.readyState == 4 && xhttp.status == 200) {
  13666. if (!xhttp.responseXML) {
  13667. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  13668. }
  13669. var xmlDoc = xhttp.responseXML.documentElement;
  13670. this._parseXml(xmlDoc.firstChild, rootNode);
  13671. this._isLoaded = true;
  13672. if (callback) {
  13673. callback();
  13674. }
  13675. }
  13676. }.bind(this);
  13677. xhttp.open("GET", xmlFile, true);
  13678. xhttp.send();
  13679. };
  13680. return XmlLoader;
  13681. }());
  13682. /***/ }),
  13683. /***/ "./3D/controls/abstractButton3D.ts":
  13684. /*!*****************************************!*\
  13685. !*** ./3D/controls/abstractButton3D.ts ***!
  13686. \*****************************************/
  13687. /*! exports provided: AbstractButton3D */
  13688. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13689. "use strict";
  13690. __webpack_require__.r(__webpack_exports__);
  13691. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  13692. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13693. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  13694. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13695. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13696. /**
  13697. * Class used as a root to all buttons
  13698. */
  13699. var AbstractButton3D = /** @class */ (function (_super) {
  13700. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  13701. /**
  13702. * Creates a new button
  13703. * @param name defines the control name
  13704. */
  13705. function AbstractButton3D(name) {
  13706. return _super.call(this, name) || this;
  13707. }
  13708. AbstractButton3D.prototype._getTypeName = function () {
  13709. return "AbstractButton3D";
  13710. };
  13711. // Mesh association
  13712. AbstractButton3D.prototype._createNode = function (scene) {
  13713. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  13714. };
  13715. return AbstractButton3D;
  13716. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13717. /***/ }),
  13718. /***/ "./3D/controls/button3D.ts":
  13719. /*!*********************************!*\
  13720. !*** ./3D/controls/button3D.ts ***!
  13721. \*********************************/
  13722. /*! exports provided: Button3D */
  13723. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13724. "use strict";
  13725. __webpack_require__.r(__webpack_exports__);
  13726. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  13727. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13728. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  13729. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13730. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13731. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13732. /**
  13733. * Class used to create a button in 3D
  13734. */
  13735. var Button3D = /** @class */ (function (_super) {
  13736. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  13737. /**
  13738. * Creates a new button
  13739. * @param name defines the control name
  13740. */
  13741. function Button3D(name) {
  13742. var _this = _super.call(this, name) || this;
  13743. _this._contentResolution = 512;
  13744. _this._contentScaleRatio = 2;
  13745. // Default animations
  13746. _this.pointerEnterAnimation = function () {
  13747. if (!_this.mesh) {
  13748. return;
  13749. }
  13750. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  13751. };
  13752. _this.pointerOutAnimation = function () {
  13753. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13754. };
  13755. _this.pointerDownAnimation = function () {
  13756. if (!_this.mesh) {
  13757. return;
  13758. }
  13759. _this.mesh.scaling.scaleInPlace(0.95);
  13760. };
  13761. _this.pointerUpAnimation = function () {
  13762. if (!_this.mesh) {
  13763. return;
  13764. }
  13765. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13766. };
  13767. return _this;
  13768. }
  13769. Object.defineProperty(Button3D.prototype, "contentResolution", {
  13770. /**
  13771. * Gets or sets the texture resolution used to render content (512 by default)
  13772. */
  13773. get: function () {
  13774. return this._contentResolution;
  13775. },
  13776. set: function (value) {
  13777. if (this._contentResolution === value) {
  13778. return;
  13779. }
  13780. this._contentResolution = value;
  13781. this._resetContent();
  13782. },
  13783. enumerable: true,
  13784. configurable: true
  13785. });
  13786. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  13787. /**
  13788. * Gets or sets the texture scale ratio used to render content (2 by default)
  13789. */
  13790. get: function () {
  13791. return this._contentScaleRatio;
  13792. },
  13793. set: function (value) {
  13794. if (this._contentScaleRatio === value) {
  13795. return;
  13796. }
  13797. this._contentScaleRatio = value;
  13798. this._resetContent();
  13799. },
  13800. enumerable: true,
  13801. configurable: true
  13802. });
  13803. Button3D.prototype._disposeFacadeTexture = function () {
  13804. if (this._facadeTexture) {
  13805. this._facadeTexture.dispose();
  13806. this._facadeTexture = null;
  13807. }
  13808. };
  13809. Button3D.prototype._resetContent = function () {
  13810. this._disposeFacadeTexture();
  13811. this.content = this._content;
  13812. };
  13813. Object.defineProperty(Button3D.prototype, "content", {
  13814. /**
  13815. * Gets or sets the GUI 2D content used to display the button's facade
  13816. */
  13817. get: function () {
  13818. return this._content;
  13819. },
  13820. set: function (value) {
  13821. this._content = value;
  13822. if (!this._host || !this._host.utilityLayer) {
  13823. return;
  13824. }
  13825. if (!this._facadeTexture) {
  13826. this._facadeTexture = new _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__["AdvancedDynamicTexture"]("Facade", this._contentResolution, this._contentResolution, this._host.utilityLayer.utilityLayerScene, true, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  13827. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  13828. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  13829. this._facadeTexture.premulAlpha = true;
  13830. }
  13831. else {
  13832. this._facadeTexture.rootContainer.clearControls();
  13833. }
  13834. this._facadeTexture.addControl(value);
  13835. this._applyFacade(this._facadeTexture);
  13836. },
  13837. enumerable: true,
  13838. configurable: true
  13839. });
  13840. /**
  13841. * Apply the facade texture (created from the content property).
  13842. * This function can be overloaded by child classes
  13843. * @param facadeTexture defines the AdvancedDynamicTexture to use
  13844. */
  13845. Button3D.prototype._applyFacade = function (facadeTexture) {
  13846. this._currentMaterial.emissiveTexture = facadeTexture;
  13847. };
  13848. Button3D.prototype._getTypeName = function () {
  13849. return "Button3D";
  13850. };
  13851. // Mesh association
  13852. Button3D.prototype._createNode = function (scene) {
  13853. var faceUV = new Array(6);
  13854. for (var i = 0; i < 6; i++) {
  13855. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  13856. }
  13857. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  13858. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  13859. width: 1.0,
  13860. height: 1.0,
  13861. depth: 0.08,
  13862. faceUV: faceUV
  13863. }, scene);
  13864. return mesh;
  13865. };
  13866. Button3D.prototype._affectMaterial = function (mesh) {
  13867. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  13868. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13869. mesh.material = material;
  13870. this._currentMaterial = material;
  13871. this._resetContent();
  13872. };
  13873. /**
  13874. * Releases all associated resources
  13875. */
  13876. Button3D.prototype.dispose = function () {
  13877. _super.prototype.dispose.call(this);
  13878. this._disposeFacadeTexture();
  13879. if (this._currentMaterial) {
  13880. this._currentMaterial.dispose();
  13881. }
  13882. };
  13883. return Button3D;
  13884. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  13885. /***/ }),
  13886. /***/ "./3D/controls/container3D.ts":
  13887. /*!************************************!*\
  13888. !*** ./3D/controls/container3D.ts ***!
  13889. \************************************/
  13890. /*! exports provided: Container3D */
  13891. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13892. "use strict";
  13893. __webpack_require__.r(__webpack_exports__);
  13894. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  13895. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13896. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  13897. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13898. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13899. /**
  13900. * Class used to create containers for controls
  13901. */
  13902. var Container3D = /** @class */ (function (_super) {
  13903. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  13904. /**
  13905. * Creates a new container
  13906. * @param name defines the container name
  13907. */
  13908. function Container3D(name) {
  13909. var _this = _super.call(this, name) || this;
  13910. _this._blockLayout = false;
  13911. /**
  13912. * Gets the list of child controls
  13913. */
  13914. _this._children = new Array();
  13915. return _this;
  13916. }
  13917. Object.defineProperty(Container3D.prototype, "children", {
  13918. /**
  13919. * Gets the list of child controls
  13920. */
  13921. get: function () {
  13922. return this._children;
  13923. },
  13924. enumerable: true,
  13925. configurable: true
  13926. });
  13927. Object.defineProperty(Container3D.prototype, "blockLayout", {
  13928. /**
  13929. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  13930. * This is helpful to optimize layout operation when adding multiple children in a row
  13931. */
  13932. get: function () {
  13933. return this._blockLayout;
  13934. },
  13935. set: function (value) {
  13936. if (this._blockLayout === value) {
  13937. return;
  13938. }
  13939. this._blockLayout = value;
  13940. if (!this._blockLayout) {
  13941. this._arrangeChildren();
  13942. }
  13943. },
  13944. enumerable: true,
  13945. configurable: true
  13946. });
  13947. /**
  13948. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  13949. * @returns the current container
  13950. */
  13951. Container3D.prototype.updateLayout = function () {
  13952. this._arrangeChildren();
  13953. return this;
  13954. };
  13955. /**
  13956. * Gets a boolean indicating if the given control is in the children of this control
  13957. * @param control defines the control to check
  13958. * @returns true if the control is in the child list
  13959. */
  13960. Container3D.prototype.containsControl = function (control) {
  13961. return this._children.indexOf(control) !== -1;
  13962. };
  13963. /**
  13964. * Adds a control to the children of this control
  13965. * @param control defines the control to add
  13966. * @returns the current container
  13967. */
  13968. Container3D.prototype.addControl = function (control) {
  13969. var index = this._children.indexOf(control);
  13970. if (index !== -1) {
  13971. return this;
  13972. }
  13973. control.parent = this;
  13974. control._host = this._host;
  13975. this._children.push(control);
  13976. if (this._host.utilityLayer) {
  13977. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  13978. if (control.node) {
  13979. control.node.parent = this.node;
  13980. }
  13981. if (!this.blockLayout) {
  13982. this._arrangeChildren();
  13983. }
  13984. }
  13985. return this;
  13986. };
  13987. /**
  13988. * This function will be called everytime a new control is added
  13989. */
  13990. Container3D.prototype._arrangeChildren = function () {
  13991. };
  13992. Container3D.prototype._createNode = function (scene) {
  13993. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  13994. };
  13995. /**
  13996. * Removes a control from the children of this control
  13997. * @param control defines the control to remove
  13998. * @returns the current container
  13999. */
  14000. Container3D.prototype.removeControl = function (control) {
  14001. var index = this._children.indexOf(control);
  14002. if (index !== -1) {
  14003. this._children.splice(index, 1);
  14004. control.parent = null;
  14005. control._disposeNode();
  14006. }
  14007. return this;
  14008. };
  14009. Container3D.prototype._getTypeName = function () {
  14010. return "Container3D";
  14011. };
  14012. /**
  14013. * Releases all associated resources
  14014. */
  14015. Container3D.prototype.dispose = function () {
  14016. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14017. var control = _a[_i];
  14018. control.dispose();
  14019. }
  14020. this._children = [];
  14021. _super.prototype.dispose.call(this);
  14022. };
  14023. /** Control rotation will remain unchanged */
  14024. Container3D.UNSET_ORIENTATION = 0;
  14025. /** Control will rotate to make it look at sphere central axis */
  14026. Container3D.FACEORIGIN_ORIENTATION = 1;
  14027. /** Control will rotate to make it look back at sphere central axis */
  14028. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  14029. /** Control will rotate to look at z axis (0, 0, 1) */
  14030. Container3D.FACEFORWARD_ORIENTATION = 3;
  14031. /** Control will rotate to look at negative z axis (0, 0, -1) */
  14032. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  14033. return Container3D;
  14034. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14035. /***/ }),
  14036. /***/ "./3D/controls/control3D.ts":
  14037. /*!**********************************!*\
  14038. !*** ./3D/controls/control3D.ts ***!
  14039. \**********************************/
  14040. /*! exports provided: Control3D */
  14041. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14042. "use strict";
  14043. __webpack_require__.r(__webpack_exports__);
  14044. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  14045. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  14046. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14047. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14048. /**
  14049. * Class used as base class for controls
  14050. */
  14051. var Control3D = /** @class */ (function () {
  14052. /**
  14053. * Creates a new control
  14054. * @param name defines the control name
  14055. */
  14056. function Control3D(
  14057. /** Defines the control name */
  14058. name) {
  14059. this.name = name;
  14060. this._downCount = 0;
  14061. this._enterCount = -1;
  14062. this._downPointerIds = {};
  14063. this._isVisible = true;
  14064. /**
  14065. * An event triggered when the pointer move over the control
  14066. */
  14067. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14068. /**
  14069. * An event triggered when the pointer move out of the control
  14070. */
  14071. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14072. /**
  14073. * An event triggered when the pointer taps the control
  14074. */
  14075. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14076. /**
  14077. * An event triggered when pointer is up
  14078. */
  14079. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14080. /**
  14081. * An event triggered when a control is clicked on (with a mouse)
  14082. */
  14083. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14084. /**
  14085. * An event triggered when pointer enters the control
  14086. */
  14087. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14088. // Behaviors
  14089. this._behaviors = new Array();
  14090. }
  14091. Object.defineProperty(Control3D.prototype, "position", {
  14092. /** Gets or sets the control position in world space */
  14093. get: function () {
  14094. if (!this._node) {
  14095. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  14096. }
  14097. return this._node.position;
  14098. },
  14099. set: function (value) {
  14100. if (!this._node) {
  14101. return;
  14102. }
  14103. this._node.position = value;
  14104. },
  14105. enumerable: true,
  14106. configurable: true
  14107. });
  14108. Object.defineProperty(Control3D.prototype, "scaling", {
  14109. /** Gets or sets the control scaling in world space */
  14110. get: function () {
  14111. if (!this._node) {
  14112. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  14113. }
  14114. return this._node.scaling;
  14115. },
  14116. set: function (value) {
  14117. if (!this._node) {
  14118. return;
  14119. }
  14120. this._node.scaling = value;
  14121. },
  14122. enumerable: true,
  14123. configurable: true
  14124. });
  14125. Object.defineProperty(Control3D.prototype, "behaviors", {
  14126. /**
  14127. * Gets the list of attached behaviors
  14128. * @see http://doc.babylonjs.com/features/behaviour
  14129. */
  14130. get: function () {
  14131. return this._behaviors;
  14132. },
  14133. enumerable: true,
  14134. configurable: true
  14135. });
  14136. /**
  14137. * Attach a behavior to the control
  14138. * @see http://doc.babylonjs.com/features/behaviour
  14139. * @param behavior defines the behavior to attach
  14140. * @returns the current control
  14141. */
  14142. Control3D.prototype.addBehavior = function (behavior) {
  14143. var _this = this;
  14144. var index = this._behaviors.indexOf(behavior);
  14145. if (index !== -1) {
  14146. return this;
  14147. }
  14148. behavior.init();
  14149. var scene = this._host.scene;
  14150. if (scene.isLoading) {
  14151. // We defer the attach when the scene will be loaded
  14152. scene.onDataLoadedObservable.addOnce(function () {
  14153. behavior.attach(_this);
  14154. });
  14155. }
  14156. else {
  14157. behavior.attach(this);
  14158. }
  14159. this._behaviors.push(behavior);
  14160. return this;
  14161. };
  14162. /**
  14163. * Remove an attached behavior
  14164. * @see http://doc.babylonjs.com/features/behaviour
  14165. * @param behavior defines the behavior to attach
  14166. * @returns the current control
  14167. */
  14168. Control3D.prototype.removeBehavior = function (behavior) {
  14169. var index = this._behaviors.indexOf(behavior);
  14170. if (index === -1) {
  14171. return this;
  14172. }
  14173. this._behaviors[index].detach();
  14174. this._behaviors.splice(index, 1);
  14175. return this;
  14176. };
  14177. /**
  14178. * Gets an attached behavior by name
  14179. * @param name defines the name of the behavior to look for
  14180. * @see http://doc.babylonjs.com/features/behaviour
  14181. * @returns null if behavior was not found else the requested behavior
  14182. */
  14183. Control3D.prototype.getBehaviorByName = function (name) {
  14184. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14185. var behavior = _a[_i];
  14186. if (behavior.name === name) {
  14187. return behavior;
  14188. }
  14189. }
  14190. return null;
  14191. };
  14192. Object.defineProperty(Control3D.prototype, "isVisible", {
  14193. /** Gets or sets a boolean indicating if the control is visible */
  14194. get: function () {
  14195. return this._isVisible;
  14196. },
  14197. set: function (value) {
  14198. if (this._isVisible === value) {
  14199. return;
  14200. }
  14201. this._isVisible = value;
  14202. var mesh = this.mesh;
  14203. if (mesh) {
  14204. mesh.setEnabled(value);
  14205. }
  14206. },
  14207. enumerable: true,
  14208. configurable: true
  14209. });
  14210. Object.defineProperty(Control3D.prototype, "typeName", {
  14211. /**
  14212. * Gets a string representing the class name
  14213. */
  14214. get: function () {
  14215. return this._getTypeName();
  14216. },
  14217. enumerable: true,
  14218. configurable: true
  14219. });
  14220. /**
  14221. * Get the current class name of the control.
  14222. * @returns current class name
  14223. */
  14224. Control3D.prototype.getClassName = function () {
  14225. return this._getTypeName();
  14226. };
  14227. Control3D.prototype._getTypeName = function () {
  14228. return "Control3D";
  14229. };
  14230. Object.defineProperty(Control3D.prototype, "node", {
  14231. /**
  14232. * Gets the transform node used by this control
  14233. */
  14234. get: function () {
  14235. return this._node;
  14236. },
  14237. enumerable: true,
  14238. configurable: true
  14239. });
  14240. Object.defineProperty(Control3D.prototype, "mesh", {
  14241. /**
  14242. * Gets the mesh used to render this control
  14243. */
  14244. get: function () {
  14245. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  14246. return this._node;
  14247. }
  14248. return null;
  14249. },
  14250. enumerable: true,
  14251. configurable: true
  14252. });
  14253. /**
  14254. * Link the control as child of the given node
  14255. * @param node defines the node to link to. Use null to unlink the control
  14256. * @returns the current control
  14257. */
  14258. Control3D.prototype.linkToTransformNode = function (node) {
  14259. if (this._node) {
  14260. this._node.parent = node;
  14261. }
  14262. return this;
  14263. };
  14264. /** @hidden **/
  14265. Control3D.prototype._prepareNode = function (scene) {
  14266. if (!this._node) {
  14267. this._node = this._createNode(scene);
  14268. if (!this.node) {
  14269. return;
  14270. }
  14271. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  14272. this._node.position = this.position;
  14273. this._node.scaling = this.scaling;
  14274. var mesh = this.mesh;
  14275. if (mesh) {
  14276. mesh.isPickable = true;
  14277. this._affectMaterial(mesh);
  14278. }
  14279. }
  14280. };
  14281. /**
  14282. * Node creation.
  14283. * Can be overriden by children
  14284. * @param scene defines the scene where the node must be attached
  14285. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  14286. */
  14287. Control3D.prototype._createNode = function (scene) {
  14288. // Do nothing by default
  14289. return null;
  14290. };
  14291. /**
  14292. * Affect a material to the given mesh
  14293. * @param mesh defines the mesh which will represent the control
  14294. */
  14295. Control3D.prototype._affectMaterial = function (mesh) {
  14296. mesh.material = null;
  14297. };
  14298. // Pointers
  14299. /** @hidden */
  14300. Control3D.prototype._onPointerMove = function (target, coordinates) {
  14301. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  14302. };
  14303. /** @hidden */
  14304. Control3D.prototype._onPointerEnter = function (target) {
  14305. if (this._enterCount > 0) {
  14306. return false;
  14307. }
  14308. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  14309. this._enterCount = 0;
  14310. }
  14311. this._enterCount++;
  14312. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  14313. if (this.pointerEnterAnimation) {
  14314. this.pointerEnterAnimation();
  14315. }
  14316. return true;
  14317. };
  14318. /** @hidden */
  14319. Control3D.prototype._onPointerOut = function (target) {
  14320. this._enterCount = 0;
  14321. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  14322. if (this.pointerOutAnimation) {
  14323. this.pointerOutAnimation();
  14324. }
  14325. };
  14326. /** @hidden */
  14327. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  14328. if (this._downCount !== 0) {
  14329. this._downCount++;
  14330. return false;
  14331. }
  14332. this._downCount++;
  14333. this._downPointerIds[pointerId] = true;
  14334. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14335. if (this.pointerDownAnimation) {
  14336. this.pointerDownAnimation();
  14337. }
  14338. return true;
  14339. };
  14340. /** @hidden */
  14341. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  14342. this._downCount--;
  14343. delete this._downPointerIds[pointerId];
  14344. if (this._downCount < 0) {
  14345. // Handle if forcePointerUp was called prior to this
  14346. this._downCount = 0;
  14347. return;
  14348. }
  14349. if (this._downCount == 0) {
  14350. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  14351. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14352. }
  14353. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14354. if (this.pointerUpAnimation) {
  14355. this.pointerUpAnimation();
  14356. }
  14357. }
  14358. };
  14359. /** @hidden */
  14360. Control3D.prototype.forcePointerUp = function (pointerId) {
  14361. if (pointerId === void 0) { pointerId = null; }
  14362. if (pointerId !== null) {
  14363. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  14364. }
  14365. else {
  14366. for (var key in this._downPointerIds) {
  14367. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  14368. }
  14369. if (this._downCount > 0) {
  14370. this._downCount = 1;
  14371. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  14372. }
  14373. }
  14374. };
  14375. /** @hidden */
  14376. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  14377. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14378. this._onPointerMove(this, pickedPoint);
  14379. var previousControlOver = this._host._lastControlOver[pointerId];
  14380. if (previousControlOver && previousControlOver !== this) {
  14381. previousControlOver._onPointerOut(this);
  14382. }
  14383. if (previousControlOver !== this) {
  14384. this._onPointerEnter(this);
  14385. }
  14386. this._host._lastControlOver[pointerId] = this;
  14387. return true;
  14388. }
  14389. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  14390. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  14391. this._host._lastControlDown[pointerId] = this;
  14392. this._host._lastPickedControl = this;
  14393. return true;
  14394. }
  14395. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14396. if (this._host._lastControlDown[pointerId]) {
  14397. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  14398. }
  14399. delete this._host._lastControlDown[pointerId];
  14400. return true;
  14401. }
  14402. return false;
  14403. };
  14404. /** @hidden */
  14405. Control3D.prototype._disposeNode = function () {
  14406. if (this._node) {
  14407. this._node.dispose();
  14408. this._node = null;
  14409. }
  14410. };
  14411. /**
  14412. * Releases all associated resources
  14413. */
  14414. Control3D.prototype.dispose = function () {
  14415. this.onPointerDownObservable.clear();
  14416. this.onPointerEnterObservable.clear();
  14417. this.onPointerMoveObservable.clear();
  14418. this.onPointerOutObservable.clear();
  14419. this.onPointerUpObservable.clear();
  14420. this.onPointerClickObservable.clear();
  14421. this._disposeNode();
  14422. // Behaviors
  14423. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14424. var behavior = _a[_i];
  14425. behavior.detach();
  14426. }
  14427. };
  14428. return Control3D;
  14429. }());
  14430. /***/ }),
  14431. /***/ "./3D/controls/cylinderPanel.ts":
  14432. /*!**************************************!*\
  14433. !*** ./3D/controls/cylinderPanel.ts ***!
  14434. \**************************************/
  14435. /*! exports provided: CylinderPanel */
  14436. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14437. "use strict";
  14438. __webpack_require__.r(__webpack_exports__);
  14439. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  14440. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14441. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  14442. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14443. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14444. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14445. /**
  14446. * Class used to create a container panel deployed on the surface of a cylinder
  14447. */
  14448. var CylinderPanel = /** @class */ (function (_super) {
  14449. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  14450. function CylinderPanel() {
  14451. var _this = _super !== null && _super.apply(this, arguments) || this;
  14452. _this._radius = 5.0;
  14453. return _this;
  14454. }
  14455. Object.defineProperty(CylinderPanel.prototype, "radius", {
  14456. /**
  14457. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  14458. */
  14459. get: function () {
  14460. return this._radius;
  14461. },
  14462. set: function (value) {
  14463. var _this = this;
  14464. if (this._radius === value) {
  14465. return;
  14466. }
  14467. this._radius = value;
  14468. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14469. _this._arrangeChildren();
  14470. });
  14471. },
  14472. enumerable: true,
  14473. configurable: true
  14474. });
  14475. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  14476. var mesh = control.mesh;
  14477. if (!mesh) {
  14478. return;
  14479. }
  14480. var newPos = this._cylindricalMapping(nodePosition);
  14481. control.position = newPos;
  14482. switch (this.orientation) {
  14483. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14484. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  14485. break;
  14486. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14487. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  14488. break;
  14489. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14490. break;
  14491. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14492. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14493. break;
  14494. }
  14495. };
  14496. CylinderPanel.prototype._cylindricalMapping = function (source) {
  14497. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  14498. var yAngle = (source.x / this._radius);
  14499. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14500. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14501. };
  14502. return CylinderPanel;
  14503. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14504. /***/ }),
  14505. /***/ "./3D/controls/holographicButton.ts":
  14506. /*!******************************************!*\
  14507. !*** ./3D/controls/holographicButton.ts ***!
  14508. \******************************************/
  14509. /*! exports provided: HolographicButton */
  14510. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14511. "use strict";
  14512. __webpack_require__.r(__webpack_exports__);
  14513. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  14514. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14515. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14516. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  14517. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  14518. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14519. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  14520. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  14521. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  14522. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14523. /**
  14524. * Class used to create a holographic button in 3D
  14525. */
  14526. var HolographicButton = /** @class */ (function (_super) {
  14527. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  14528. /**
  14529. * Creates a new button
  14530. * @param name defines the control name
  14531. */
  14532. function HolographicButton(name, shareMaterials) {
  14533. if (shareMaterials === void 0) { shareMaterials = true; }
  14534. var _this = _super.call(this, name) || this;
  14535. _this._shareMaterials = true;
  14536. _this._shareMaterials = shareMaterials;
  14537. // Default animations
  14538. _this.pointerEnterAnimation = function () {
  14539. if (!_this.mesh) {
  14540. return;
  14541. }
  14542. _this._frontPlate.setEnabled(true);
  14543. };
  14544. _this.pointerOutAnimation = function () {
  14545. if (!_this.mesh) {
  14546. return;
  14547. }
  14548. _this._frontPlate.setEnabled(false);
  14549. };
  14550. return _this;
  14551. }
  14552. HolographicButton.prototype._disposeTooltip = function () {
  14553. this._tooltipFade = null;
  14554. if (this._tooltipTextBlock) {
  14555. this._tooltipTextBlock.dispose();
  14556. }
  14557. if (this._tooltipTexture) {
  14558. this._tooltipTexture.dispose();
  14559. }
  14560. if (this._tooltipMesh) {
  14561. this._tooltipMesh.dispose();
  14562. }
  14563. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  14564. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  14565. };
  14566. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  14567. get: function () {
  14568. return this._backPlate.renderingGroupId;
  14569. },
  14570. /**
  14571. * Rendering ground id of all the mesh in the button
  14572. */
  14573. set: function (id) {
  14574. this._backPlate.renderingGroupId = id;
  14575. this._textPlate.renderingGroupId = id;
  14576. this._frontPlate.renderingGroupId = id;
  14577. if (this._tooltipMesh) {
  14578. this._tooltipMesh.renderingGroupId = id;
  14579. }
  14580. },
  14581. enumerable: true,
  14582. configurable: true
  14583. });
  14584. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  14585. get: function () {
  14586. if (this._tooltipTextBlock) {
  14587. return this._tooltipTextBlock.text;
  14588. }
  14589. return null;
  14590. },
  14591. /**
  14592. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  14593. */
  14594. set: function (text) {
  14595. var _this = this;
  14596. if (!text) {
  14597. this._disposeTooltip();
  14598. return;
  14599. }
  14600. if (!this._tooltipFade) {
  14601. // Create tooltip with mesh and text
  14602. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  14603. var tooltipBackground = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1, sideOrientation: babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Mesh"].DOUBLESIDE }, this._backPlate._scene);
  14604. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  14605. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  14606. tooltipBackground.material = mat;
  14607. tooltipBackground.isPickable = false;
  14608. this._tooltipMesh.addChild(tooltipBackground);
  14609. tooltipBackground.position.z = 0.05;
  14610. this._tooltipMesh.scaling.y = 1 / 3;
  14611. this._tooltipMesh.position.y = 0.7;
  14612. this._tooltipMesh.position.z = -0.15;
  14613. this._tooltipMesh.isPickable = false;
  14614. this._tooltipMesh.parent = this._backPlate;
  14615. // Create text texture for the tooltip
  14616. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  14617. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14618. this._tooltipTextBlock.scaleY = 3;
  14619. this._tooltipTextBlock.color = "white";
  14620. this._tooltipTextBlock.fontSize = 130;
  14621. this._tooltipTexture.addControl(this._tooltipTextBlock);
  14622. // Add hover action to tooltip
  14623. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  14624. this._tooltipFade.delay = 500;
  14625. this._tooltipMesh.addBehavior(this._tooltipFade);
  14626. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  14627. if (_this._tooltipFade) {
  14628. _this._tooltipFade.fadeIn(true);
  14629. }
  14630. });
  14631. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  14632. if (_this._tooltipFade) {
  14633. _this._tooltipFade.fadeIn(false);
  14634. }
  14635. });
  14636. }
  14637. if (this._tooltipTextBlock) {
  14638. this._tooltipTextBlock.text = text;
  14639. }
  14640. },
  14641. enumerable: true,
  14642. configurable: true
  14643. });
  14644. Object.defineProperty(HolographicButton.prototype, "text", {
  14645. /**
  14646. * Gets or sets text for the button
  14647. */
  14648. get: function () {
  14649. return this._text;
  14650. },
  14651. set: function (value) {
  14652. if (this._text === value) {
  14653. return;
  14654. }
  14655. this._text = value;
  14656. this._rebuildContent();
  14657. },
  14658. enumerable: true,
  14659. configurable: true
  14660. });
  14661. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  14662. /**
  14663. * Gets or sets the image url for the button
  14664. */
  14665. get: function () {
  14666. return this._imageUrl;
  14667. },
  14668. set: function (value) {
  14669. if (this._imageUrl === value) {
  14670. return;
  14671. }
  14672. this._imageUrl = value;
  14673. this._rebuildContent();
  14674. },
  14675. enumerable: true,
  14676. configurable: true
  14677. });
  14678. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  14679. /**
  14680. * Gets the back material used by this button
  14681. */
  14682. get: function () {
  14683. return this._backMaterial;
  14684. },
  14685. enumerable: true,
  14686. configurable: true
  14687. });
  14688. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  14689. /**
  14690. * Gets the front material used by this button
  14691. */
  14692. get: function () {
  14693. return this._frontMaterial;
  14694. },
  14695. enumerable: true,
  14696. configurable: true
  14697. });
  14698. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  14699. /**
  14700. * Gets the plate material used by this button
  14701. */
  14702. get: function () {
  14703. return this._plateMaterial;
  14704. },
  14705. enumerable: true,
  14706. configurable: true
  14707. });
  14708. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  14709. /**
  14710. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  14711. */
  14712. get: function () {
  14713. return this._shareMaterials;
  14714. },
  14715. enumerable: true,
  14716. configurable: true
  14717. });
  14718. HolographicButton.prototype._getTypeName = function () {
  14719. return "HolographicButton";
  14720. };
  14721. HolographicButton.prototype._rebuildContent = function () {
  14722. this._disposeFacadeTexture();
  14723. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  14724. panel.isVertical = true;
  14725. if (this._imageUrl) {
  14726. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  14727. image.source = this._imageUrl;
  14728. image.paddingTop = "40px";
  14729. image.height = "180px";
  14730. image.width = "100px";
  14731. image.paddingBottom = "40px";
  14732. panel.addControl(image);
  14733. }
  14734. if (this._text) {
  14735. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14736. text.text = this._text;
  14737. text.color = "white";
  14738. text.height = "30px";
  14739. text.fontSize = 24;
  14740. panel.addControl(text);
  14741. }
  14742. if (this._frontPlate) {
  14743. this.content = panel;
  14744. }
  14745. };
  14746. // Mesh association
  14747. HolographicButton.prototype._createNode = function (scene) {
  14748. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  14749. width: 1.0,
  14750. height: 1.0,
  14751. depth: 0.08
  14752. }, scene);
  14753. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  14754. width: 1.0,
  14755. height: 1.0,
  14756. depth: 0.08
  14757. }, scene);
  14758. this._frontPlate.parent = this._backPlate;
  14759. this._frontPlate.position.z = -0.08;
  14760. this._frontPlate.isPickable = false;
  14761. this._frontPlate.setEnabled(false);
  14762. this._textPlate = _super.prototype._createNode.call(this, scene);
  14763. this._textPlate.parent = this._backPlate;
  14764. this._textPlate.position.z = -0.08;
  14765. this._textPlate.isPickable = false;
  14766. return this._backPlate;
  14767. };
  14768. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  14769. this._plateMaterial.emissiveTexture = facadeTexture;
  14770. this._plateMaterial.opacityTexture = facadeTexture;
  14771. };
  14772. HolographicButton.prototype._createBackMaterial = function (mesh) {
  14773. var _this = this;
  14774. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  14775. this._backMaterial.renderHoverLight = true;
  14776. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  14777. if (pickedPoint) {
  14778. _this._backMaterial.hoverPosition = pickedPoint;
  14779. _this._backMaterial.hoverColor.a = 1.0;
  14780. }
  14781. else {
  14782. _this._backMaterial.hoverColor.a = 0;
  14783. }
  14784. });
  14785. };
  14786. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  14787. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  14788. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  14789. this._frontMaterial.alpha = 0.5; // Additive
  14790. this._frontMaterial.renderBorders = true;
  14791. };
  14792. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  14793. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  14794. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  14795. };
  14796. HolographicButton.prototype._affectMaterial = function (mesh) {
  14797. // Back
  14798. if (this._shareMaterials) {
  14799. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  14800. this._createBackMaterial(mesh);
  14801. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  14802. }
  14803. else {
  14804. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  14805. }
  14806. // Front
  14807. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  14808. this._createFrontMaterial(mesh);
  14809. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  14810. }
  14811. else {
  14812. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  14813. }
  14814. }
  14815. else {
  14816. this._createBackMaterial(mesh);
  14817. this._createFrontMaterial(mesh);
  14818. }
  14819. this._createPlateMaterial(mesh);
  14820. this._backPlate.material = this._backMaterial;
  14821. this._frontPlate.material = this._frontMaterial;
  14822. this._textPlate.material = this._plateMaterial;
  14823. this._rebuildContent();
  14824. };
  14825. /**
  14826. * Releases all associated resources
  14827. */
  14828. HolographicButton.prototype.dispose = function () {
  14829. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  14830. this._disposeTooltip();
  14831. if (!this.shareMaterials) {
  14832. this._backMaterial.dispose();
  14833. this._frontMaterial.dispose();
  14834. this._plateMaterial.dispose();
  14835. if (this._pickedPointObserver) {
  14836. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  14837. this._pickedPointObserver = null;
  14838. }
  14839. }
  14840. };
  14841. return HolographicButton;
  14842. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14843. /***/ }),
  14844. /***/ "./3D/controls/index.ts":
  14845. /*!******************************!*\
  14846. !*** ./3D/controls/index.ts ***!
  14847. \******************************/
  14848. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  14849. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14850. "use strict";
  14851. __webpack_require__.r(__webpack_exports__);
  14852. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  14853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14854. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14856. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  14858. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  14860. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  14861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  14862. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  14863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  14864. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  14865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  14866. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  14867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  14868. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  14869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  14870. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  14871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  14872. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  14873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  14874. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  14876. /***/ }),
  14877. /***/ "./3D/controls/meshButton3D.ts":
  14878. /*!*************************************!*\
  14879. !*** ./3D/controls/meshButton3D.ts ***!
  14880. \*************************************/
  14881. /*! exports provided: MeshButton3D */
  14882. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14883. "use strict";
  14884. __webpack_require__.r(__webpack_exports__);
  14885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  14886. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14887. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14888. /**
  14889. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  14890. */
  14891. var MeshButton3D = /** @class */ (function (_super) {
  14892. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  14893. /**
  14894. * Creates a new 3D button based on a mesh
  14895. * @param mesh mesh to become a 3D button
  14896. * @param name defines the control name
  14897. */
  14898. function MeshButton3D(mesh, name) {
  14899. var _this = _super.call(this, name) || this;
  14900. _this._currentMesh = mesh;
  14901. /**
  14902. * Provides a default behavior on hover/out & up/down
  14903. * Override those function to create your own desired behavior specific to your mesh
  14904. */
  14905. _this.pointerEnterAnimation = function () {
  14906. if (!_this.mesh) {
  14907. return;
  14908. }
  14909. _this.mesh.scaling.scaleInPlace(1.1);
  14910. };
  14911. _this.pointerOutAnimation = function () {
  14912. if (!_this.mesh) {
  14913. return;
  14914. }
  14915. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  14916. };
  14917. _this.pointerDownAnimation = function () {
  14918. if (!_this.mesh) {
  14919. return;
  14920. }
  14921. _this.mesh.scaling.scaleInPlace(0.95);
  14922. };
  14923. _this.pointerUpAnimation = function () {
  14924. if (!_this.mesh) {
  14925. return;
  14926. }
  14927. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  14928. };
  14929. return _this;
  14930. }
  14931. MeshButton3D.prototype._getTypeName = function () {
  14932. return "MeshButton3D";
  14933. };
  14934. // Mesh association
  14935. MeshButton3D.prototype._createNode = function (scene) {
  14936. var _this = this;
  14937. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  14938. mesh.metadata = _this;
  14939. });
  14940. return this._currentMesh;
  14941. };
  14942. MeshButton3D.prototype._affectMaterial = function (mesh) {
  14943. };
  14944. return MeshButton3D;
  14945. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14946. /***/ }),
  14947. /***/ "./3D/controls/planePanel.ts":
  14948. /*!***********************************!*\
  14949. !*** ./3D/controls/planePanel.ts ***!
  14950. \***********************************/
  14951. /*! exports provided: PlanePanel */
  14952. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14953. "use strict";
  14954. __webpack_require__.r(__webpack_exports__);
  14955. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  14956. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14957. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  14958. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14959. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14960. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14961. /**
  14962. * Class used to create a container panel deployed on the surface of a plane
  14963. */
  14964. var PlanePanel = /** @class */ (function (_super) {
  14965. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  14966. function PlanePanel() {
  14967. return _super !== null && _super.apply(this, arguments) || this;
  14968. }
  14969. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  14970. var mesh = control.mesh;
  14971. if (!mesh) {
  14972. return;
  14973. }
  14974. control.position = nodePosition.clone();
  14975. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14976. target.copyFrom(nodePosition);
  14977. switch (this.orientation) {
  14978. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  14979. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  14980. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  14981. mesh.lookAt(target);
  14982. break;
  14983. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14984. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14985. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  14986. mesh.lookAt(target);
  14987. break;
  14988. }
  14989. };
  14990. return PlanePanel;
  14991. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  14992. /***/ }),
  14993. /***/ "./3D/controls/scatterPanel.ts":
  14994. /*!*************************************!*\
  14995. !*** ./3D/controls/scatterPanel.ts ***!
  14996. \*************************************/
  14997. /*! exports provided: ScatterPanel */
  14998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14999. "use strict";
  15000. __webpack_require__.r(__webpack_exports__);
  15001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  15002. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15003. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15004. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15005. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15006. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15007. /**
  15008. * Class used to create a container panel where items get randomized planar mapping
  15009. */
  15010. var ScatterPanel = /** @class */ (function (_super) {
  15011. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  15012. function ScatterPanel() {
  15013. var _this = _super !== null && _super.apply(this, arguments) || this;
  15014. _this._iteration = 100.0;
  15015. return _this;
  15016. }
  15017. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  15018. /**
  15019. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  15020. */
  15021. get: function () {
  15022. return this._iteration;
  15023. },
  15024. set: function (value) {
  15025. var _this = this;
  15026. if (this._iteration === value) {
  15027. return;
  15028. }
  15029. this._iteration = value;
  15030. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15031. _this._arrangeChildren();
  15032. });
  15033. },
  15034. enumerable: true,
  15035. configurable: true
  15036. });
  15037. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  15038. var mesh = control.mesh;
  15039. var newPos = this._scatterMapping(nodePosition);
  15040. if (!mesh) {
  15041. return;
  15042. }
  15043. switch (this.orientation) {
  15044. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15045. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15046. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15047. break;
  15048. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15049. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15050. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15051. break;
  15052. }
  15053. control.position = newPos;
  15054. };
  15055. ScatterPanel.prototype._scatterMapping = function (source) {
  15056. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  15057. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  15058. return source;
  15059. };
  15060. ScatterPanel.prototype._finalProcessing = function () {
  15061. var meshes = [];
  15062. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15063. var child = _a[_i];
  15064. if (!child.mesh) {
  15065. continue;
  15066. }
  15067. meshes.push(child.mesh);
  15068. }
  15069. for (var count = 0; count < this._iteration; count++) {
  15070. meshes.sort(function (a, b) {
  15071. var distance1 = a.position.lengthSquared();
  15072. var distance2 = b.position.lengthSquared();
  15073. if (distance1 < distance2) {
  15074. return 1;
  15075. }
  15076. else if (distance1 > distance2) {
  15077. return -1;
  15078. }
  15079. return 0;
  15080. });
  15081. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  15082. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  15083. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  15084. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15085. for (var i = 0; i < meshes.length - 1; i++) {
  15086. for (var j = i + 1; j < meshes.length; j++) {
  15087. if (i != j) {
  15088. meshes[j].position.subtractToRef(meshes[i].position, difference);
  15089. // Ignore Z axis
  15090. difference2D.x = difference.x;
  15091. difference2D.y = difference.y;
  15092. var combinedRadius = cellSize;
  15093. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  15094. var minSeparation = Math.min(distance, radiusPaddingSquared);
  15095. distance -= minSeparation;
  15096. if (distance < (Math.pow(combinedRadius, 2.0))) {
  15097. difference2D.normalize();
  15098. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  15099. meshes[j].position.addInPlace(difference);
  15100. meshes[i].position.subtractInPlace(difference);
  15101. }
  15102. }
  15103. }
  15104. }
  15105. }
  15106. };
  15107. return ScatterPanel;
  15108. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15109. /***/ }),
  15110. /***/ "./3D/controls/spherePanel.ts":
  15111. /*!************************************!*\
  15112. !*** ./3D/controls/spherePanel.ts ***!
  15113. \************************************/
  15114. /*! exports provided: SpherePanel */
  15115. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15116. "use strict";
  15117. __webpack_require__.r(__webpack_exports__);
  15118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  15119. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15120. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15121. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15122. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15123. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15124. /**
  15125. * Class used to create a container panel deployed on the surface of a sphere
  15126. */
  15127. var SpherePanel = /** @class */ (function (_super) {
  15128. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  15129. function SpherePanel() {
  15130. var _this = _super !== null && _super.apply(this, arguments) || this;
  15131. _this._radius = 5.0;
  15132. return _this;
  15133. }
  15134. Object.defineProperty(SpherePanel.prototype, "radius", {
  15135. /**
  15136. * Gets or sets the radius of the sphere where to project controls (5 by default)
  15137. */
  15138. get: function () {
  15139. return this._radius;
  15140. },
  15141. set: function (value) {
  15142. var _this = this;
  15143. if (this._radius === value) {
  15144. return;
  15145. }
  15146. this._radius = value;
  15147. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15148. _this._arrangeChildren();
  15149. });
  15150. },
  15151. enumerable: true,
  15152. configurable: true
  15153. });
  15154. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  15155. var mesh = control.mesh;
  15156. if (!mesh) {
  15157. return;
  15158. }
  15159. var newPos = this._sphericalMapping(nodePosition);
  15160. control.position = newPos;
  15161. switch (this.orientation) {
  15162. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15163. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  15164. break;
  15165. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15166. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  15167. break;
  15168. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15169. break;
  15170. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15171. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  15172. break;
  15173. }
  15174. };
  15175. SpherePanel.prototype._sphericalMapping = function (source) {
  15176. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  15177. var xAngle = (source.y / this._radius);
  15178. var yAngle = -(source.x / this._radius);
  15179. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15180. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15181. };
  15182. return SpherePanel;
  15183. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15184. /***/ }),
  15185. /***/ "./3D/controls/stackPanel3D.ts":
  15186. /*!*************************************!*\
  15187. !*** ./3D/controls/stackPanel3D.ts ***!
  15188. \*************************************/
  15189. /*! exports provided: StackPanel3D */
  15190. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15191. "use strict";
  15192. __webpack_require__.r(__webpack_exports__);
  15193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  15194. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15195. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15196. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15197. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15198. /**
  15199. * Class used to create a stack panel in 3D on XY plane
  15200. */
  15201. var StackPanel3D = /** @class */ (function (_super) {
  15202. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  15203. /**
  15204. * Creates new StackPanel
  15205. * @param isVertical
  15206. */
  15207. function StackPanel3D(isVertical) {
  15208. if (isVertical === void 0) { isVertical = false; }
  15209. var _this = _super.call(this) || this;
  15210. _this._isVertical = false;
  15211. /**
  15212. * Gets or sets the distance between elements
  15213. */
  15214. _this.margin = 0.1;
  15215. _this._isVertical = isVertical;
  15216. return _this;
  15217. }
  15218. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  15219. /**
  15220. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  15221. */
  15222. get: function () {
  15223. return this._isVertical;
  15224. },
  15225. set: function (value) {
  15226. var _this = this;
  15227. if (this._isVertical === value) {
  15228. return;
  15229. }
  15230. this._isVertical = value;
  15231. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15232. _this._arrangeChildren();
  15233. });
  15234. },
  15235. enumerable: true,
  15236. configurable: true
  15237. });
  15238. StackPanel3D.prototype._arrangeChildren = function () {
  15239. var width = 0;
  15240. var height = 0;
  15241. var controlCount = 0;
  15242. var extendSizes = [];
  15243. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15244. // Measure
  15245. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15246. var child = _a[_i];
  15247. if (!child.mesh) {
  15248. continue;
  15249. }
  15250. controlCount++;
  15251. child.mesh.computeWorldMatrix(true);
  15252. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15253. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  15254. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15255. extendSizes.push(extendSize);
  15256. if (this._isVertical) {
  15257. height += extendSize.y;
  15258. }
  15259. else {
  15260. width += extendSize.x;
  15261. }
  15262. }
  15263. if (this._isVertical) {
  15264. height += (controlCount - 1) * this.margin / 2;
  15265. }
  15266. else {
  15267. width += (controlCount - 1) * this.margin / 2;
  15268. }
  15269. // Arrange
  15270. var offset;
  15271. if (this._isVertical) {
  15272. offset = -height;
  15273. }
  15274. else {
  15275. offset = -width;
  15276. }
  15277. var index = 0;
  15278. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15279. var child = _c[_b];
  15280. if (!child.mesh) {
  15281. continue;
  15282. }
  15283. controlCount--;
  15284. var extendSize = extendSizes[index++];
  15285. if (this._isVertical) {
  15286. child.position.y = offset + extendSize.y;
  15287. child.position.x = 0;
  15288. offset += extendSize.y * 2;
  15289. }
  15290. else {
  15291. child.position.x = offset + extendSize.x;
  15292. child.position.y = 0;
  15293. offset += extendSize.x * 2;
  15294. }
  15295. offset += (controlCount > 0 ? this.margin : 0);
  15296. }
  15297. };
  15298. return StackPanel3D;
  15299. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15300. /***/ }),
  15301. /***/ "./3D/controls/volumeBasedPanel.ts":
  15302. /*!*****************************************!*\
  15303. !*** ./3D/controls/volumeBasedPanel.ts ***!
  15304. \*****************************************/
  15305. /*! exports provided: VolumeBasedPanel */
  15306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15307. "use strict";
  15308. __webpack_require__.r(__webpack_exports__);
  15309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  15310. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15311. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15312. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15313. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15314. /**
  15315. * Abstract class used to create a container panel deployed on the surface of a volume
  15316. */
  15317. var VolumeBasedPanel = /** @class */ (function (_super) {
  15318. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  15319. /**
  15320. * Creates new VolumeBasedPanel
  15321. */
  15322. function VolumeBasedPanel() {
  15323. var _this = _super.call(this) || this;
  15324. _this._columns = 10;
  15325. _this._rows = 0;
  15326. _this._rowThenColum = true;
  15327. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  15328. /**
  15329. * Gets or sets the distance between elements
  15330. */
  15331. _this.margin = 0;
  15332. return _this;
  15333. }
  15334. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  15335. /**
  15336. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  15337. * | Value | Type | Description |
  15338. * | ----- | ----------------------------------- | ----------- |
  15339. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  15340. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  15341. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  15342. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  15343. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  15344. */
  15345. get: function () {
  15346. return this._orientation;
  15347. },
  15348. set: function (value) {
  15349. var _this = this;
  15350. if (this._orientation === value) {
  15351. return;
  15352. }
  15353. this._orientation = value;
  15354. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15355. _this._arrangeChildren();
  15356. });
  15357. },
  15358. enumerable: true,
  15359. configurable: true
  15360. });
  15361. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  15362. /**
  15363. * Gets or sets the number of columns requested (10 by default).
  15364. * The panel will automatically compute the number of rows based on number of child controls.
  15365. */
  15366. get: function () {
  15367. return this._columns;
  15368. },
  15369. set: function (value) {
  15370. var _this = this;
  15371. if (this._columns === value) {
  15372. return;
  15373. }
  15374. this._columns = value;
  15375. this._rowThenColum = true;
  15376. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15377. _this._arrangeChildren();
  15378. });
  15379. },
  15380. enumerable: true,
  15381. configurable: true
  15382. });
  15383. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  15384. /**
  15385. * Gets or sets a the number of rows requested.
  15386. * The panel will automatically compute the number of columns based on number of child controls.
  15387. */
  15388. get: function () {
  15389. return this._rows;
  15390. },
  15391. set: function (value) {
  15392. var _this = this;
  15393. if (this._rows === value) {
  15394. return;
  15395. }
  15396. this._rows = value;
  15397. this._rowThenColum = false;
  15398. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15399. _this._arrangeChildren();
  15400. });
  15401. },
  15402. enumerable: true,
  15403. configurable: true
  15404. });
  15405. VolumeBasedPanel.prototype._arrangeChildren = function () {
  15406. this._cellWidth = 0;
  15407. this._cellHeight = 0;
  15408. var rows = 0;
  15409. var columns = 0;
  15410. var controlCount = 0;
  15411. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15412. // Measure
  15413. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15414. var child = _a[_i];
  15415. if (!child.mesh) {
  15416. continue;
  15417. }
  15418. controlCount++;
  15419. child.mesh.computeWorldMatrix(true);
  15420. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  15421. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  15422. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15423. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  15424. boundingBox.max.subtractToRef(boundingBox.min, diff);
  15425. diff.scaleInPlace(0.5);
  15426. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  15427. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  15428. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  15429. }
  15430. this._cellWidth += this.margin * 2;
  15431. this._cellHeight += this.margin * 2;
  15432. // Arrange
  15433. if (this._rowThenColum) {
  15434. columns = this._columns;
  15435. rows = Math.ceil(controlCount / this._columns);
  15436. }
  15437. else {
  15438. rows = this._rows;
  15439. columns = Math.ceil(controlCount / this._rows);
  15440. }
  15441. var startOffsetX = (columns * 0.5) * this._cellWidth;
  15442. var startOffsetY = (rows * 0.5) * this._cellHeight;
  15443. var nodeGrid = [];
  15444. var cellCounter = 0;
  15445. if (this._rowThenColum) {
  15446. for (var r = 0; r < rows; r++) {
  15447. for (var c = 0; c < columns; c++) {
  15448. 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));
  15449. cellCounter++;
  15450. if (cellCounter > controlCount) {
  15451. break;
  15452. }
  15453. }
  15454. }
  15455. }
  15456. else {
  15457. for (var c = 0; c < columns; c++) {
  15458. for (var r = 0; r < rows; r++) {
  15459. 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));
  15460. cellCounter++;
  15461. if (cellCounter > controlCount) {
  15462. break;
  15463. }
  15464. }
  15465. }
  15466. }
  15467. cellCounter = 0;
  15468. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15469. var child = _c[_b];
  15470. if (!child.mesh) {
  15471. continue;
  15472. }
  15473. this._mapGridNode(child, nodeGrid[cellCounter]);
  15474. cellCounter++;
  15475. }
  15476. this._finalProcessing();
  15477. };
  15478. /** Child classes can implement this function to provide additional processing */
  15479. VolumeBasedPanel.prototype._finalProcessing = function () {
  15480. };
  15481. return VolumeBasedPanel;
  15482. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15483. /***/ }),
  15484. /***/ "./3D/gui3DManager.ts":
  15485. /*!****************************!*\
  15486. !*** ./3D/gui3DManager.ts ***!
  15487. \****************************/
  15488. /*! exports provided: GUI3DManager */
  15489. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15490. "use strict";
  15491. __webpack_require__.r(__webpack_exports__);
  15492. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  15493. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  15494. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15495. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  15496. /**
  15497. * Class used to manage 3D user interface
  15498. * @see http://doc.babylonjs.com/how_to/gui3d
  15499. */
  15500. var GUI3DManager = /** @class */ (function () {
  15501. /**
  15502. * Creates a new GUI3DManager
  15503. * @param scene
  15504. */
  15505. function GUI3DManager(scene) {
  15506. var _this = this;
  15507. /** @hidden */
  15508. this._lastControlOver = {};
  15509. /** @hidden */
  15510. this._lastControlDown = {};
  15511. /**
  15512. * Observable raised when the point picked by the pointer events changed
  15513. */
  15514. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15515. // Shared resources
  15516. /** @hidden */
  15517. this._sharedMaterials = {};
  15518. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  15519. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  15520. _this._sceneDisposeObserver = null;
  15521. _this._utilityLayer = null;
  15522. _this.dispose();
  15523. });
  15524. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  15525. this._utilityLayer.onlyCheckPointerDownEvents = false;
  15526. this._utilityLayer.pickUtilitySceneFirst = false;
  15527. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  15528. return mesh && mesh.metadata && mesh.metadata._node;
  15529. };
  15530. // Root
  15531. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  15532. this._rootContainer._host = this;
  15533. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  15534. // Events
  15535. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  15536. _this._handlePointerOut(pointerId, true);
  15537. });
  15538. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  15539. _this._doPicking(pi);
  15540. });
  15541. // Scene
  15542. this._utilityLayer.utilityLayerScene.autoClear = false;
  15543. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  15544. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  15545. }
  15546. Object.defineProperty(GUI3DManager.prototype, "scene", {
  15547. /** Gets the hosting scene */
  15548. get: function () {
  15549. return this._scene;
  15550. },
  15551. enumerable: true,
  15552. configurable: true
  15553. });
  15554. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  15555. /** Gets associated utility layer */
  15556. get: function () {
  15557. return this._utilityLayer;
  15558. },
  15559. enumerable: true,
  15560. configurable: true
  15561. });
  15562. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  15563. var previousControlOver = this._lastControlOver[pointerId];
  15564. if (previousControlOver) {
  15565. previousControlOver._onPointerOut(previousControlOver);
  15566. delete this._lastControlOver[pointerId];
  15567. }
  15568. if (isPointerUp) {
  15569. if (this._lastControlDown[pointerId]) {
  15570. this._lastControlDown[pointerId].forcePointerUp();
  15571. delete this._lastControlDown[pointerId];
  15572. }
  15573. }
  15574. this.onPickedPointChangedObservable.notifyObservers(null);
  15575. };
  15576. GUI3DManager.prototype._doPicking = function (pi) {
  15577. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  15578. return false;
  15579. }
  15580. var pointerEvent = (pi.event);
  15581. var pointerId = pointerEvent.pointerId || 0;
  15582. var buttonIndex = pointerEvent.button;
  15583. var pickingInfo = pi.pickInfo;
  15584. if (!pickingInfo || !pickingInfo.hit) {
  15585. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  15586. return false;
  15587. }
  15588. var control = (pickingInfo.pickedMesh.metadata);
  15589. if (pickingInfo.pickedPoint) {
  15590. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  15591. }
  15592. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  15593. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15594. if (this._lastControlOver[pointerId]) {
  15595. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  15596. }
  15597. delete this._lastControlOver[pointerId];
  15598. }
  15599. }
  15600. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  15601. if (this._lastControlDown[pointerEvent.pointerId]) {
  15602. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  15603. delete this._lastControlDown[pointerEvent.pointerId];
  15604. }
  15605. if (pointerEvent.pointerType === "touch") {
  15606. this._handlePointerOut(pointerId, false);
  15607. }
  15608. }
  15609. return true;
  15610. };
  15611. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  15612. /**
  15613. * Gets the root container
  15614. */
  15615. get: function () {
  15616. return this._rootContainer;
  15617. },
  15618. enumerable: true,
  15619. configurable: true
  15620. });
  15621. /**
  15622. * Gets a boolean indicating if the given control is in the root child list
  15623. * @param control defines the control to check
  15624. * @returns true if the control is in the root child list
  15625. */
  15626. GUI3DManager.prototype.containsControl = function (control) {
  15627. return this._rootContainer.containsControl(control);
  15628. };
  15629. /**
  15630. * Adds a control to the root child list
  15631. * @param control defines the control to add
  15632. * @returns the current manager
  15633. */
  15634. GUI3DManager.prototype.addControl = function (control) {
  15635. this._rootContainer.addControl(control);
  15636. return this;
  15637. };
  15638. /**
  15639. * Removes a control from the root child list
  15640. * @param control defines the control to remove
  15641. * @returns the current container
  15642. */
  15643. GUI3DManager.prototype.removeControl = function (control) {
  15644. this._rootContainer.removeControl(control);
  15645. return this;
  15646. };
  15647. /**
  15648. * Releases all associated resources
  15649. */
  15650. GUI3DManager.prototype.dispose = function () {
  15651. this._rootContainer.dispose();
  15652. for (var materialName in this._sharedMaterials) {
  15653. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  15654. continue;
  15655. }
  15656. this._sharedMaterials[materialName].dispose();
  15657. }
  15658. this._sharedMaterials = {};
  15659. if (this._pointerOutObserver && this._utilityLayer) {
  15660. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  15661. this._pointerOutObserver = null;
  15662. }
  15663. this.onPickedPointChangedObservable.clear();
  15664. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  15665. if (utilityLayerScene) {
  15666. if (this._pointerObserver) {
  15667. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  15668. this._pointerObserver = null;
  15669. }
  15670. }
  15671. if (this._scene) {
  15672. if (this._sceneDisposeObserver) {
  15673. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  15674. this._sceneDisposeObserver = null;
  15675. }
  15676. }
  15677. if (this._utilityLayer) {
  15678. this._utilityLayer.dispose();
  15679. }
  15680. };
  15681. return GUI3DManager;
  15682. }());
  15683. /***/ }),
  15684. /***/ "./3D/index.ts":
  15685. /*!*********************!*\
  15686. !*** ./3D/index.ts ***!
  15687. \*********************/
  15688. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15689. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15690. "use strict";
  15691. __webpack_require__.r(__webpack_exports__);
  15692. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  15693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15705. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  15706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15708. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  15709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  15710. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  15711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  15712. /***/ }),
  15713. /***/ "./3D/materials/fluentMaterial.ts":
  15714. /*!****************************************!*\
  15715. !*** ./3D/materials/fluentMaterial.ts ***!
  15716. \****************************************/
  15717. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15718. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15719. "use strict";
  15720. __webpack_require__.r(__webpack_exports__);
  15721. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  15722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  15723. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15724. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  15725. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  15726. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  15727. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  15728. /** @hidden */
  15729. var FluentMaterialDefines = /** @class */ (function (_super) {
  15730. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  15731. function FluentMaterialDefines() {
  15732. var _this = _super.call(this) || this;
  15733. _this.INNERGLOW = false;
  15734. _this.BORDER = false;
  15735. _this.HOVERLIGHT = false;
  15736. _this.TEXTURE = false;
  15737. _this.rebuild();
  15738. return _this;
  15739. }
  15740. return FluentMaterialDefines;
  15741. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  15742. /**
  15743. * Class used to render controls with fluent desgin
  15744. */
  15745. var FluentMaterial = /** @class */ (function (_super) {
  15746. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  15747. /**
  15748. * Creates a new Fluent material
  15749. * @param name defines the name of the material
  15750. * @param scene defines the hosting scene
  15751. */
  15752. function FluentMaterial(name, scene) {
  15753. var _this = _super.call(this, name, scene) || this;
  15754. /**
  15755. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  15756. */
  15757. _this.innerGlowColorIntensity = 0.5;
  15758. /**
  15759. * Gets or sets the inner glow color (white by default)
  15760. */
  15761. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  15762. /**
  15763. * Gets or sets alpha value (default is 1.0)
  15764. */
  15765. _this.alpha = 1.0;
  15766. /**
  15767. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  15768. */
  15769. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  15770. /**
  15771. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  15772. */
  15773. _this.renderBorders = false;
  15774. /**
  15775. * Gets or sets border width (default is 0.5)
  15776. */
  15777. _this.borderWidth = 0.5;
  15778. /**
  15779. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  15780. */
  15781. _this.edgeSmoothingValue = 0.02;
  15782. /**
  15783. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  15784. */
  15785. _this.borderMinValue = 0.1;
  15786. /**
  15787. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  15788. */
  15789. _this.renderHoverLight = false;
  15790. /**
  15791. * Gets or sets the radius used to render the hover light (default is 1.0)
  15792. */
  15793. _this.hoverRadius = 1.0;
  15794. /**
  15795. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  15796. */
  15797. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  15798. /**
  15799. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  15800. */
  15801. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  15802. return _this;
  15803. }
  15804. FluentMaterial.prototype.needAlphaBlending = function () {
  15805. return this.alpha !== 1.0;
  15806. };
  15807. FluentMaterial.prototype.needAlphaTesting = function () {
  15808. return false;
  15809. };
  15810. FluentMaterial.prototype.getAlphaTestTexture = function () {
  15811. return null;
  15812. };
  15813. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  15814. if (this.isFrozen) {
  15815. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  15816. return true;
  15817. }
  15818. }
  15819. if (!subMesh._materialDefines) {
  15820. subMesh._materialDefines = new FluentMaterialDefines();
  15821. }
  15822. var scene = this.getScene();
  15823. var defines = subMesh._materialDefines;
  15824. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  15825. if (defines._renderId === scene.getRenderId()) {
  15826. return true;
  15827. }
  15828. }
  15829. if (defines._areTexturesDirty) {
  15830. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  15831. defines.BORDER = this.renderBorders;
  15832. defines.HOVERLIGHT = this.renderHoverLight;
  15833. if (this._albedoTexture) {
  15834. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  15835. return false;
  15836. }
  15837. else {
  15838. defines.TEXTURE = true;
  15839. }
  15840. }
  15841. else {
  15842. defines.TEXTURE = false;
  15843. }
  15844. }
  15845. var engine = scene.getEngine();
  15846. // Get correct effect
  15847. if (defines.isDirty) {
  15848. defines.markAsProcessed();
  15849. scene.resetCachedMaterial();
  15850. //Attributes
  15851. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  15852. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  15853. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  15854. var shaderName = "fluent";
  15855. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  15856. "hoverColor", "hoverPosition", "hoverRadius"
  15857. ];
  15858. var samplers = ["albedoSampler"];
  15859. var uniformBuffers = new Array();
  15860. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  15861. uniformsNames: uniforms,
  15862. uniformBuffersNames: uniformBuffers,
  15863. samplers: samplers,
  15864. defines: defines,
  15865. maxSimultaneousLights: 4
  15866. });
  15867. var join = defines.toString();
  15868. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  15869. attributes: attribs,
  15870. uniformsNames: uniforms,
  15871. uniformBuffersNames: uniformBuffers,
  15872. samplers: samplers,
  15873. defines: join,
  15874. fallbacks: null,
  15875. onCompiled: this.onCompiled,
  15876. onError: this.onError,
  15877. indexParameters: { maxSimultaneousLights: 4 }
  15878. }, engine));
  15879. }
  15880. if (!subMesh.effect || !subMesh.effect.isReady()) {
  15881. return false;
  15882. }
  15883. defines._renderId = scene.getRenderId();
  15884. subMesh.effect._wasPreviouslyReady = true;
  15885. return true;
  15886. };
  15887. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  15888. var scene = this.getScene();
  15889. var defines = subMesh._materialDefines;
  15890. if (!defines) {
  15891. return;
  15892. }
  15893. var effect = subMesh.effect;
  15894. if (!effect) {
  15895. return;
  15896. }
  15897. this._activeEffect = effect;
  15898. // Matrices
  15899. this.bindOnlyWorldMatrix(world);
  15900. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  15901. if (this._mustRebind(scene, effect)) {
  15902. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  15903. if (defines.INNERGLOW) {
  15904. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  15905. }
  15906. if (defines.BORDER) {
  15907. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  15908. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  15909. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  15910. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15911. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15912. }
  15913. if (defines.HOVERLIGHT) {
  15914. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  15915. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  15916. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  15917. }
  15918. if (defines.TEXTURE) {
  15919. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  15920. }
  15921. }
  15922. this._afterBind(mesh, this._activeEffect);
  15923. };
  15924. FluentMaterial.prototype.getActiveTextures = function () {
  15925. var activeTextures = _super.prototype.getActiveTextures.call(this);
  15926. return activeTextures;
  15927. };
  15928. FluentMaterial.prototype.hasTexture = function (texture) {
  15929. if (_super.prototype.hasTexture.call(this, texture)) {
  15930. return true;
  15931. }
  15932. return false;
  15933. };
  15934. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  15935. _super.prototype.dispose.call(this, forceDisposeEffect);
  15936. };
  15937. FluentMaterial.prototype.clone = function (name) {
  15938. var _this = this;
  15939. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  15940. };
  15941. FluentMaterial.prototype.serialize = function () {
  15942. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  15943. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  15944. return serializationObject;
  15945. };
  15946. FluentMaterial.prototype.getClassName = function () {
  15947. return "FluentMaterial";
  15948. };
  15949. // Statics
  15950. FluentMaterial.Parse = function (source, scene, rootUrl) {
  15951. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  15952. };
  15953. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15954. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15955. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15956. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  15957. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15958. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15959. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  15960. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15961. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15962. ], FluentMaterial.prototype, "alpha", void 0);
  15963. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15964. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15965. ], FluentMaterial.prototype, "albedoColor", void 0);
  15966. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15967. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15968. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15969. ], FluentMaterial.prototype, "renderBorders", void 0);
  15970. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15971. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15972. ], FluentMaterial.prototype, "borderWidth", void 0);
  15973. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15974. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15975. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  15976. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15977. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15978. ], FluentMaterial.prototype, "borderMinValue", void 0);
  15979. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15980. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15981. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15982. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  15983. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15984. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15985. ], FluentMaterial.prototype, "hoverRadius", void 0);
  15986. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15987. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  15988. ], FluentMaterial.prototype, "hoverColor", void 0);
  15989. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15990. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  15991. ], FluentMaterial.prototype, "hoverPosition", void 0);
  15992. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15993. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  15994. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  15995. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15996. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  15997. ], FluentMaterial.prototype, "albedoTexture", void 0);
  15998. return FluentMaterial;
  15999. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  16000. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  16001. /***/ }),
  16002. /***/ "./3D/materials/index.ts":
  16003. /*!*******************************!*\
  16004. !*** ./3D/materials/index.ts ***!
  16005. \*******************************/
  16006. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16007. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16008. "use strict";
  16009. __webpack_require__.r(__webpack_exports__);
  16010. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  16011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16013. /***/ }),
  16014. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  16015. /*!*************************************************!*\
  16016. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  16017. \*************************************************/
  16018. /*! exports provided: fluentPixelShader */
  16019. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16020. "use strict";
  16021. __webpack_require__.r(__webpack_exports__);
  16022. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  16023. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  16024. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16025. var name = 'fluentPixelShader';
  16026. 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}";
  16027. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16028. /** @hidden */
  16029. var fluentPixelShader = { name: name, shader: shader };
  16030. /***/ }),
  16031. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  16032. /*!***********************************************!*\
  16033. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  16034. \***********************************************/
  16035. /*! exports provided: fluentVertexShader */
  16036. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16037. "use strict";
  16038. __webpack_require__.r(__webpack_exports__);
  16039. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  16040. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  16041. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16042. var name = 'fluentVertexShader';
  16043. 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";
  16044. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16045. /** @hidden */
  16046. var fluentVertexShader = { name: name, shader: shader };
  16047. /***/ }),
  16048. /***/ "./3D/vector3WithInfo.ts":
  16049. /*!*******************************!*\
  16050. !*** ./3D/vector3WithInfo.ts ***!
  16051. \*******************************/
  16052. /*! exports provided: Vector3WithInfo */
  16053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16054. "use strict";
  16055. __webpack_require__.r(__webpack_exports__);
  16056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  16057. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16058. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  16059. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  16060. /**
  16061. * Class used to transport Vector3 information for pointer events
  16062. */
  16063. var Vector3WithInfo = /** @class */ (function (_super) {
  16064. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  16065. /**
  16066. * Creates a new Vector3WithInfo
  16067. * @param source defines the vector3 data to transport
  16068. * @param buttonIndex defines the current mouse button index
  16069. */
  16070. function Vector3WithInfo(source,
  16071. /** defines the current mouse button index */
  16072. buttonIndex) {
  16073. if (buttonIndex === void 0) { buttonIndex = 0; }
  16074. var _this = _super.call(this, source.x, source.y, source.z) || this;
  16075. _this.buttonIndex = buttonIndex;
  16076. return _this;
  16077. }
  16078. return Vector3WithInfo;
  16079. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  16080. /***/ }),
  16081. /***/ "./index.ts":
  16082. /*!******************!*\
  16083. !*** ./index.ts ***!
  16084. \******************/
  16085. /*! 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 */
  16086. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16087. "use strict";
  16088. __webpack_require__.r(__webpack_exports__);
  16089. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  16090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16131. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  16132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  16133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  16134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  16135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  16136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  16137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  16138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  16139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  16140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  16141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  16142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  16143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  16144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  16145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  16146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16148. /***/ }),
  16149. /***/ "./legacy/legacy.ts":
  16150. /*!**************************!*\
  16151. !*** ./legacy/legacy.ts ***!
  16152. \**************************/
  16153. /*! 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 */
  16154. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16155. "use strict";
  16156. __webpack_require__.r(__webpack_exports__);
  16157. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  16158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  16168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  16169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16215. /**
  16216. * Legacy support, defining window.BABYLON.GUI (global variable).
  16217. *
  16218. * This is the entry point for the UMD module.
  16219. * The entry point for a future ESM package should be index.ts
  16220. */
  16221. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  16222. if (typeof globalObject !== "undefined") {
  16223. globalObject.BABYLON = globalObject.BABYLON || {};
  16224. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  16225. }
  16226. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  16227. /***/ }),
  16228. /***/ "babylonjs/Misc/perfCounter":
  16229. /*!****************************************************************************************************!*\
  16230. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  16231. \****************************************************************************************************/
  16232. /*! no static exports found */
  16233. /***/ (function(module, exports) {
  16234. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__;
  16235. /***/ })
  16236. /******/ });
  16237. });
  16238. //# sourceMappingURL=babylon.gui.js.map